/* ════════════════════════════════════════════════════════════════════════
   THE MINER · tema
   Layout: console de operador — HUD fixo no topo, trilho de seções à esquerda,
   painéis com cantos de mira e uma chuva de código bem fraca ao fundo.
   Visual único e escuro (de propósito): verde fósforo + azul ciano.
   ════════════════════════════════════════════════════════════════════════ */
:root {
  color-scheme: dark;
  --abismo: #010704;
  --painel: #03110a;
  --painel-2: #061a10;
  --painel-3: #0a2618;
  --linha: rgba(34, 255, 136, 0.13);
  --linha-forte: rgba(34, 255, 136, 0.32);
  --fosforo: #22ff88;
  --fosforo-claro: #8dffbf;
  --fosforo-escuro: #0f6b3d;
  --ciano: #27d3ff;
  --ciano-claro: #9be9ff;
  --ciano-escuro: #0b3f57;
  --texto: #cdf7e0;
  --texto-2: #86b89c;
  --texto-3: #4d7a62;
  --alta: #3dffa2;
  --queda: #ff4f7b;
  --alerta: #ffc94d;
  --tinta: #010704;
  --fonte-display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --fonte-texto: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --fonte-dados: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  --raio: 3px;
  --t: 160ms;
  --hud-altura: 56px;
  --trilho-largura: 212px;
  --console-altura: 30px;
  --sombra: 0 10px 40px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--abismo);
  color: var(--texto);
  font: 400 14px/1.55 var(--fonte-texto);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--fosforo-escuro); color: #fff; }
a { color: var(--ciano); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--fonte-display); font-weight: 600; letter-spacing: 0.02em; margin: 0; text-wrap: balance; color: var(--fosforo-claro); }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; line-height: 1.2; }
h3 { font-size: 16px; line-height: 1.3; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--texto-2); }
p { margin: 0; }
code, .mono, .num { font-family: var(--fonte-dados); font-variant-numeric: tabular-nums; }
.num { letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ciano); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* rolagem fina, combinando com o tema */
* { scrollbar-width: thin; scrollbar-color: var(--fosforo-escuro) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--fosforo-escuro); border-radius: 8px; }

/* camadas de atmosfera: chuva de fundo + linhas de varredura */
#chuva-fundo { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: 0.16; }
body.app-ativo #chuva-fundo { opacity: 0.07; }
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, 0.16) 2px 3px);
  mix-blend-mode: multiply;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* ── tipografia utilitária ─────────────────────────────────────────── */
.rotulo {
  font-family: var(--fonte-display); font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.16em; color: var(--texto-2);
}
.rotulo::before { content: "// "; color: var(--fosforo-escuro); }
.fraco { color: var(--texto-2); }
.mais-fraco { color: var(--texto-3); }
.verde { color: var(--fosforo); }
.ciano { color: var(--ciano); }
.alta { color: var(--alta); }
.queda { color: var(--queda); }
.alerta { color: var(--alerta); }
.brilho { text-shadow: 0 0 12px rgba(34, 255, 136, 0.55); }
.grande { font-family: var(--fonte-dados); font-size: 28px; font-weight: 500; line-height: 1.1; color: #e9fff3; }
.pequeno { font-size: 12px; }
.texto-longo { max-width: 68ch; }
.texto-longo p + p { margin-top: 10px; }

/* ── painéis ───────────────────────────────────────────────────────── */
.painel {
  position: relative; background: linear-gradient(180deg, rgba(10, 38, 24, 0.55), rgba(3, 17, 10, 0.92));
  border: 1px solid var(--linha); border-radius: var(--raio); padding: 16px; min-width: 0;
  backdrop-filter: blur(2px);
}
.painel.mira::before, .painel.mira::after {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border-color: var(--fosforo); border-style: solid; opacity: 0.75;
}
.painel.mira::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.painel.mira::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }
.painel-cabeca { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.painel-cabeca h2, .painel-cabeca h3 { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fosforo-claro); }
.painel-cabeca h2 .icone, .painel-cabeca h3 .icone { width: 18px; height: 18px; color: var(--fosforo); filter: drop-shadow(0 0 6px rgba(34, 255, 136, 0.5)); }
.icone { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.grade { display: grid; gap: 14px; }
.linha-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.espaco { flex: 1; }
.vazio {
  border: 1px dashed var(--linha-forte); border-radius: var(--raio); padding: 22px; text-align: center;
  color: var(--texto-2); display: grid; gap: 8px; justify-items: center;
}
.vazio .icone { width: 28px; height: 28px; color: var(--fosforo-escuro); }

/* ── botões ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 14px;
  border: 1px solid var(--linha-forte); background: rgba(34, 255, 136, 0.04); color: var(--fosforo-claro);
  border-radius: var(--raio); cursor: pointer; font-family: var(--fonte-display); font-weight: 600; font-size: 13px;
  letter-spacing: 0.06em; text-transform: uppercase; transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t);
  white-space: nowrap;
}
.btn:hover { background: rgba(34, 255, 136, 0.12); border-color: var(--fosforo); box-shadow: 0 0 16px rgba(34, 255, 136, 0.18); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn .icone { width: 16px; height: 16px; }
.btn-primario { background: var(--fosforo); color: var(--tinta); border-color: var(--fosforo); }
.btn-primario:hover { background: var(--fosforo-claro); color: var(--tinta); }
.btn-ciano { border-color: rgba(39, 211, 255, 0.45); color: var(--ciano-claro); background: rgba(39, 211, 255, 0.05); }
.btn-ciano:hover { border-color: var(--ciano); background: rgba(39, 211, 255, 0.12); box-shadow: 0 0 16px rgba(39, 211, 255, 0.2); }
.btn-perigo { border-color: rgba(255, 79, 123, 0.55); color: #ffb3c6; background: rgba(255, 79, 123, 0.06); }
.btn-perigo:hover { border-color: var(--queda); background: rgba(255, 79, 123, 0.16); box-shadow: 0 0 18px rgba(255, 79, 123, 0.25); }
.btn-fantasma { border-color: transparent; background: transparent; color: var(--texto-2); }
.btn-fantasma:hover { color: var(--fosforo-claro); background: rgba(34, 255, 136, 0.06); box-shadow: none; }
.btn-mini { height: 26px; padding: 0 9px; font-size: 11px; }
.btn-icone { width: 34px; padding: 0; }
.btn-icone.btn-mini { width: 26px; }

/* ── formulários ───────────────────────────────────────────────────── */
.campo { display: grid; gap: 6px; min-width: 0; }
.campo > span { font-size: 12px; color: var(--texto-2); }
.entrada, select.entrada, textarea.entrada {
  height: 36px; padding: 0 12px; border-radius: var(--raio); border: 1px solid var(--linha-forte);
  background: rgba(1, 7, 4, 0.7); color: var(--texto); width: 100%; min-width: 0;
  font-family: var(--fonte-dados); font-size: 13px; transition: border-color var(--t), box-shadow var(--t);
}
textarea.entrada { height: auto; min-height: 90px; padding: 10px 12px; font-family: var(--fonte-texto); resize: vertical; }
.entrada:focus { outline: none; border-color: var(--fosforo); box-shadow: 0 0 0 3px rgba(34, 255, 136, 0.12); }
select.entrada { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--fosforo) 50%), linear-gradient(135deg, var(--fosforo) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(90deg, var(--fosforo) var(--p, 50%), var(--painel-3) var(--p, 50%)); border-radius: 4px; }
input[type="range"]::-moz-range-track { height: 4px; background: var(--painel-3); border-radius: 4px; }
input[type="range"]::-moz-range-progress { height: 4px; background: var(--fosforo); border-radius: 4px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 2px; background: var(--abismo); border: 2px solid var(--fosforo); box-shadow: 0 0 10px rgba(34, 255, 136, 0.5); transform: rotate(45deg); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 2px; background: var(--abismo); border: 2px solid var(--fosforo); transform: rotate(45deg); }

.chave { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.chave input { position: absolute; opacity: 0; pointer-events: none; }
.chave .trilha { width: 38px; height: 20px; border-radius: 20px; border: 1px solid var(--linha-forte); background: var(--painel-2); position: relative; transition: background var(--t), border-color var(--t); flex: none; }
.chave .trilha::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--texto-3); transition: transform var(--t), background var(--t); }
.chave input:checked + .trilha { background: rgba(34, 255, 136, 0.18); border-color: var(--fosforo); }
.chave input:checked + .trilha::after { transform: translateX(18px); background: var(--fosforo); box-shadow: 0 0 8px var(--fosforo); }
.chave input:focus-visible + .trilha { outline: 2px solid var(--ciano); outline-offset: 2px; }

/* ── selos ─────────────────────────────────────────────────────────── */
.selo {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 2px;
  font-family: var(--fonte-display); font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid var(--linha-forte); color: var(--texto-2); white-space: nowrap;
}
.selo::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.selo.sem-ponto::before { display: none; }
.selo.neutro { color: var(--texto-3); border-color: rgba(77, 122, 98, 0.4); }
.selo.observando { color: var(--ciano); border-color: rgba(39, 211, 255, 0.4); }
.selo.armando { color: var(--alerta); border-color: rgba(255, 201, 77, 0.45); }
.selo.gatilho { color: var(--tinta); background: var(--fosforo); border-color: var(--fosforo); box-shadow: 0 0 14px rgba(34, 255, 136, 0.45); }
.selo.gatilho::before { background: var(--tinta); }
.selo.long { color: var(--alta); border-color: rgba(61, 255, 162, 0.4); }
.selo.short { color: var(--queda); border-color: rgba(255, 79, 123, 0.45); }
.selo.real { color: #ffd1dc; background: rgba(255, 79, 123, 0.16); border-color: var(--queda); }
.selo.ok { color: var(--alta); border-color: rgba(61, 255, 162, 0.4); }
.selo.aviso { color: var(--alerta); border-color: rgba(255, 201, 77, 0.45); }
.selo.erro { color: var(--queda); border-color: rgba(255, 79, 123, 0.45); }
.selo.referencia { color: var(--ciano); border-color: rgba(39, 211, 255, 0.4); }
.selo.curso { color: var(--alerta); border-color: rgba(255, 201, 77, 0.45); }

/* ── tabelas ───────────────────────────────────────────────────────── */
.rolagem-x { overflow-x: auto; min-width: 0; }
.tabela { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabela th { text-align: left; font-family: var(--fonte-display); font-weight: 600; font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--texto-3); padding: 8px 10px; border-bottom: 1px solid var(--linha-forte); white-space: nowrap; }
.tabela td { padding: 9px 10px; border-bottom: 1px solid var(--linha); vertical-align: middle; }
.tabela td.num, .tabela th.num { text-align: right; }
.tabela tbody tr { transition: background var(--t); }
.tabela tbody tr.clicavel { cursor: pointer; }
.tabela tbody tr.clicavel:hover { background: rgba(34, 255, 136, 0.05); }

/* ── checklist de regras ───────────────────────────────────────────── */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checklist li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; align-items: start; padding: 6px 8px; border-radius: 2px; background: rgba(1, 7, 4, 0.45); border: 1px solid transparent; }
.checklist li .marca { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 2px; font-size: 12px; font-weight: 700; margin-top: 1px; }
.checklist li.ok .marca { background: rgba(61, 255, 162, 0.16); color: var(--alta); }
.checklist li.nao .marca { background: rgba(255, 79, 123, 0.12); color: var(--queda); }
.checklist li.gatilho { border-color: rgba(34, 255, 136, 0.18); }
.checklist li.aviso .marca { background: rgba(255, 201, 77, 0.14); color: var(--alerta); }
.checklist .regra-texto { font-weight: 500; color: var(--texto); }
.checklist .regra-detalhe { display: block; font-size: 12px; color: var(--texto-2); font-family: var(--fonte-dados); }

/* ── barras e medidores ────────────────────────────────────────────── */
.barra { height: 6px; background: var(--painel-3); border-radius: 6px; overflow: hidden; position: relative; }
.barra > i { position: absolute; inset: 0 auto 0 0; background: var(--fosforo); border-radius: 6px; box-shadow: 0 0 10px rgba(34, 255, 136, 0.6); transition: width 400ms; }
.barra.alerta > i { background: var(--alerta); box-shadow: 0 0 10px rgba(255, 201, 77, 0.5); }
.barra.perigo > i { background: var(--queda); box-shadow: 0 0 10px rgba(255, 79, 123, 0.5); }
.anel { --v: 0; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: radial-gradient(closest-side, var(--painel) 76%, transparent 78% 100%), conic-gradient(var(--cor-anel, var(--fosforo)) calc(var(--v) * 1%), var(--painel-3) 0); }
.anel span { font-family: var(--fonte-dados); font-size: 11px; color: var(--texto); }

/* trilho de posição: stop ── entrada ── alvo, com o preço atual */
.trilho-posicao { position: relative; height: 34px; margin: 6px 0 2px; }
.trilho-posicao .base { position: absolute; left: 0; right: 0; top: 15px; height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(255, 79, 123, 0.55), rgba(255, 79, 123, 0.12) var(--e, 33%), rgba(61, 255, 162, 0.12) var(--e, 33%), rgba(61, 255, 162, 0.6)); }
.trilho-posicao .marca { position: absolute; top: 9px; width: 2px; height: 16px; background: var(--texto-2); }
.trilho-posicao .agulha { position: absolute; top: 4px; width: 12px; height: 26px; margin-left: -6px; transition: left 500ms; }
.trilho-posicao .agulha::before { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 10px #fff; }
.trilho-posicao .agulha::after { content: ""; position: absolute; left: 1px; top: -2px; border: 5px solid transparent; border-top-color: #fff; }
.trilho-posicao .legenda { position: absolute; top: 24px; font-size: 10px; color: var(--texto-3); transform: translateX(-50%); white-space: nowrap; font-family: var(--fonte-dados); }

/* ── dica (tooltip) e termos do glossário ──────────────────────────── */
.termo { border-bottom: 1px dotted var(--ciano); color: inherit; cursor: help; }
.termo:hover { color: var(--ciano-claro); }
#dica {
  position: fixed; z-index: 90; max-width: min(360px, calc(100vw - 24px)); pointer-events: none;
  background: rgba(3, 17, 10, 0.97); border: 1px solid rgba(39, 211, 255, 0.45); border-radius: var(--raio);
  padding: 12px 14px; box-shadow: var(--sombra), 0 0 24px rgba(39, 211, 255, 0.12);
  opacity: 0; transform: translateY(4px); transition: opacity 120ms, transform 120ms; font-size: 13px;
}
#dica.visivel { opacity: 1; transform: none; }
#dica .dica-titulo { font-family: var(--fonte-display); font-weight: 600; color: var(--ciano-claro); letter-spacing: 0.04em; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
#dica .dica-titulo small { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--texto-3); }
#dica .dica-corpo { color: var(--texto); }
#dica .dica-exemplo { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--linha); color: var(--texto-2); font-size: 12px; }
#dica .dica-rodape { margin-top: 8px; font-size: 11px; color: var(--texto-3); }

/* modo aprendiz: marca os elementos que têm explicação */
body.aprendiz [data-ajuda] { position: relative; }
body.aprendiz [data-ajuda]::after {
  content: "?"; position: absolute; top: -7px; right: -7px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--ciano); color: var(--tinta); font: 700 10px/15px var(--fonte-display); text-align: center;
  box-shadow: 0 0 10px rgba(39, 211, 255, 0.6); pointer-events: none; z-index: 3;
}

/* ── modal ─────────────────────────────────────────────────────────── */
#camada-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 20px max(16px, env(safe-area-inset-left, 0px));
  background: rgba(0, 4, 2, 0.72); backdrop-filter: blur(3px); }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--painel); border: 1px solid var(--linha-forte); border-radius: var(--raio); padding: 20px; box-shadow: var(--sombra); }
.modal.largo { width: min(980px, 100%); }
.modal-cabeca { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-rodape { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ── avisos (toasts) ───────────────────────────────────────────────── */
#avisos { position: fixed; z-index: 85; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(var(--console-altura) + 14px + env(safe-area-inset-bottom, 0px));
  display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.aviso-item { pointer-events: auto; display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; align-items: start; padding: 12px 12px 12px 0;
  background: rgba(3, 17, 10, 0.97); border: 1px solid var(--linha-forte); border-radius: var(--raio); box-shadow: var(--sombra);
  animation: entra-aviso 240ms ease-out; }
.aviso-item .aviso-faixa { align-self: stretch; background: var(--ciano); border-radius: 0 2px 2px 0; }
.aviso-item.sucesso .aviso-faixa { background: var(--alta); box-shadow: 0 0 10px var(--alta); }
.aviso-item.aviso .aviso-faixa { background: var(--alerta); }
.aviso-item.erro .aviso-faixa { background: var(--queda); }
.aviso-item strong { font-family: var(--fonte-display); letter-spacing: 0.06em; display: block; color: var(--fosforo-claro); font-size: 13px; }
.aviso-item p { font-size: 13px; color: var(--texto); }
@keyframes entra-aviso { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── gaveta lateral (explicações) ──────────────────────────────────── */
#gaveta { position: fixed; z-index: 70; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: rgba(2, 12, 7, 0.98);
  border-left: 1px solid var(--linha-forte); box-shadow: var(--sombra); transform: translateX(100%); transition: transform 240ms ease;
  display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
#gaveta.aberta { transform: none; }
#gaveta .gaveta-cabeca { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--linha); }
#gaveta .gaveta-corpo { flex: 1; overflow: auto; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 24px 16px; display: grid; gap: 16px; align-content: start; }

/* ── markdown (aulas, glossário) ───────────────────────────────────── */
.md { max-width: 72ch; line-height: 1.7; }
.md h2 { font-size: 18px; margin: 24px 0 8px; }
.md h3 { font-size: 15px; margin: 18px 0 6px; color: var(--ciano-claro); }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md strong { color: #ecfff5; }
.md blockquote { margin: 0 0 12px; padding: 8px 14px; border-left: 2px solid var(--ciano); background: rgba(39, 211, 255, 0.05); color: var(--texto); }
.md table { border-collapse: collapse; margin: 0 0 14px; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--linha-forte); padding: 6px 8px; text-align: left; vertical-align: top; }
.md code { background: rgba(34, 255, 136, 0.08); padding: 1px 5px; border-radius: 2px; font-size: 0.92em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
