/* Tracktor Estética · estrutura. Cores só por variáveis de tokens.css. */
:root {
  --r-btn: 6px;
  --r-card: 10px;
  --topo: 60px;
  --painel: 368px;
  --fonte: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fonte-titulo: 'Archivo', 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fundo);
  color: var(--texto);
  font-family: var(--fonte);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
h1, h2, h3 { font-family: var(--fonte-titulo); font-weight: 300; text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
p { text-wrap: pretty; margin: 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: var(--r-btn); border: 1px solid var(--fio);
  background: var(--fundo); color: var(--texto);
  font-size: 13px; font-weight: 500; letter-spacing: -0.003em;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--superficie); border-color: var(--fio-forte); }
.btn:focus-visible, .seg:focus-visible, .aba:focus-visible, .pronta:focus-visible { outline: 2px solid var(--dourado); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--fundo); border-color: var(--fio); }
.btn.primario { background: var(--dourado); border-color: var(--dourado); color: var(--branco); font-weight: 600; }
.btn.primario:hover { background: var(--dourado-hover); border-color: var(--dourado-hover); }
.btn.grande { min-height: 50px; padding: 0 22px; font-size: 14px; }
.btn.so-icone { width: 44px; padding: 0; }
.btn.alternar[aria-pressed="true"] { border-color: var(--dourado); color: var(--dourado-texto); background: var(--dourado-claro); }

/* ---------- cabeçalho ---------- */
.topo {
  height: var(--topo); flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid var(--fio);
  background: var(--fundo);
}
.marca { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.marca-nome { font-family: var(--fonte-titulo); font-weight: 400; font-size: 19px; letter-spacing: -0.01em; white-space: nowrap; }
.marca-sub { font-size: 10px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--dourado-texto); white-space: nowrap; }
.topo-acoes { display: flex; align-items: center; gap: 8px; }
.selo { display: inline-flex; align-items: center; gap: 6px; color: var(--texto-2); font-size: 12px; }
.selo .ic { width: 14px; height: 14px; color: var(--dourado-texto); }
.selo-topo { margin-right: 8px; }
body:not(.com-foto) .selo-topo { display: none; }

/* ---------- área principal ---------- */
.principal { flex: 1; min-height: 0; position: relative; }

/* tela vazia */
.vazia { height: 100%; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 32px 16px; background: var(--superficie); }
.envio {
  width: min(600px, 100%);
  border: 1px solid var(--fio);
  border-radius: 14px;
  background: var(--fundo);
  box-shadow: var(--sombra);
  padding: 48px 40px 36px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 22px;
  transition: border-color .15s, background-color .15s;
  outline: 1px dashed transparent; outline-offset: -10px;
}
.envio.arrastando { outline-color: var(--dourado); background: var(--dourado-claro); }
.envio-icone { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--fio); color: var(--dourado-texto); background: var(--superficie); }
.envio-icone .ic { width: 28px; height: 28px; stroke-width: 1.2; }
.envio-titulo { font-size: clamp(24px, 3.4vw, 32px); line-height: 1.12; max-width: 17ch; font-weight: 300; }
.dicas { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.dicas li {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--texto-2);
  border: 1px solid var(--fio); border-radius: 999px; padding: 6px 12px; background: var(--fundo);
}
.dicas .ic { width: 15px; height: 15px; color: var(--dourado-texto); }
.envio-botoes { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.envio-arraste { color: var(--texto-3); font-size: 12.5px; margin-top: -8px; }
@media (pointer: coarse) { .envio-arraste { display: none; } }

/* ---------- trabalho ---------- */
.trabalho {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--painel);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "abas painel" "palco painel";
}
.abas {
  grid-area: abas;
  display: flex; justify-content: center; gap: 4px; padding: 10px 16px 0; overflow-x: auto; scrollbar-width: none;
}
.abas::-webkit-scrollbar { display: none; }
.abas.tem-mais { -webkit-mask-image: linear-gradient(to right, var(--noite) 80%, transparent); mask-image: linear-gradient(to right, var(--noite) 80%, transparent); }
.aba {
  flex: none; min-height: 44px; padding: 0 14px; border: 0; background: transparent; color: var(--texto-2);
  font-size: 13.5px; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent;
}
.aba:hover { color: var(--texto); }
.aba.ativo { color: var(--texto); border-bottom-color: var(--dourado); }
.palco { grid-area: palco; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 12px 24px 20px; position: relative; }
.moldura {
  position: relative; border-radius: 10px; overflow: hidden;
  background: var(--noite);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  width: 320px; height: 400px; flex-shrink: 0;
  box-shadow: var(--sombra);
}
.moldura canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#sobre { pointer-events: none; }
.regua { position: absolute; top: 0; bottom: 0; width: 44px; margin-left: -22px; left: 50%; cursor: ew-resize; outline: none; }
.regua::before { content: ''; position: absolute; left: 21.5px; top: 0; bottom: 0; width: 1px; background: var(--branco); box-shadow: 0 0 6px var(--noite-veu); }
.regua-alca {
  position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px;
  border-radius: 50%; background: var(--branco); box-shadow: 0 2px 10px var(--noite-veu);
}
.regua-alca::before, .regua-alca::after { content: ''; position: absolute; top: 50%; width: 0; height: 0; margin-top: -5px; border: 5px solid transparent; }
.regua-alca::before { left: 6px; border-right-color: var(--dourado); }
.regua-alca::after { right: 6px; border-left-color: var(--dourado); }
.regua:focus-visible .regua-alca { box-shadow: 0 0 0 3px var(--dourado); }
.etiqueta {
  position: absolute; top: 12px; font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  padding: 5px 9px; border-radius: 4px; background: var(--noite-vidro); color: var(--branco);
  pointer-events: none; transition: opacity .2s;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.etiqueta-antes { left: 12px; }
.etiqueta-depois, .etiqueta-3d { right: 12px; color: var(--malha); }
.chip-estado {
  position: absolute; left: 12px; bottom: 12px; font-size: 10.5px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px; background: var(--branco); color: var(--texto); pointer-events: none;
  box-shadow: 0 2px 8px var(--noite-veu);
}
.chip-estado::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--dourado); margin-right: 7px; vertical-align: 1px; }
.contador {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  font-size: 12.5px; color: var(--branco); white-space: nowrap; letter-spacing: .02em;
  padding: 7px 14px; border-radius: 999px; background: var(--noite-vidro);
  transition: opacity .4s;
}
.contador strong { color: var(--malha); font-family: var(--fonte-titulo); font-weight: 500; font-variant-numeric: tabular-nums; font-size: 14px; }
.pular { position: absolute; inset: 0; background: transparent; border: 0; cursor: pointer; color: transparent; }
.barra-palco { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; max-width: 100%; }
.barra-2d, .barra-3d { display: flex; align-items: center; gap: 8px; }
.segmento { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--fio); border-radius: 8px; background: var(--superficie); }
.seg { min-height: 38px; min-width: 58px; padding: 0 12px; border: 0; border-radius: 5px; background: transparent; color: var(--texto-2); font-size: 13px; font-weight: 500; cursor: pointer; }
.seg.ativo { background: var(--fundo); color: var(--texto); box-shadow: var(--sombra-botao); }
.segmento.pequeno .seg { min-width: 0; }
#btnSegurar { touch-action: none; -webkit-touch-callout: none; }
#btnSegurar.segurando { border-color: var(--dourado); color: var(--dourado-texto); background: var(--dourado-claro); }

/* ---------- painel ---------- */
.painel { grid-area: painel; min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--fio); background: var(--fundo); }
.conteudo { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px 20px; overscroll-behavior: contain; }
.painel-titulo { font-size: 22px; font-weight: 300; margin-bottom: 4px; }
.objetivo { width: 100%; margin: 14px 0 6px; color: var(--dourado-texto); border-color: var(--dourado); background: var(--fundo); }
.objetivo:hover { background: var(--dourado-claro); border-color: var(--dourado); }

.linha { padding: 12px 0 6px; border-bottom: 1px solid var(--fio); }
.linha:last-child { border-bottom: 0; }
.linha-topo { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.linha-nome { font-size: 14px; font-weight: 500; }
.linha-musculo { display: block; font-size: 10px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--texto-3); margin-top: 2px; }
.linha-valor { font-family: var(--fonte-titulo); font-weight: 400; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--texto); }
.linha-valor.zero { color: var(--texto-3); }
.linha-leitura { font-size: 12px; color: var(--dourado-texto); margin: -2px 0 4px; }
.linha-leitura:empty { display: none; }
.linha-leitura .ref { color: var(--texto-2); }
.linha-extremos { display: flex; justify-content: space-between; font-size: 11px; color: var(--texto-3); margin-top: -6px; padding-bottom: 2px; }

/* slider grande */
.faixa {
  -webkit-appearance: none; appearance: none; width: 100%; height: 36px; margin: 0; background: transparent; cursor: pointer; touch-action: pan-y;
  --a: 0%; --b: 0%;
}
.faixa:focus { outline: none; }
.faixa::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px;
  background: linear-gradient(to right, var(--fio) 0, var(--fio) var(--a), var(--dourado) var(--a), var(--dourado) var(--b), var(--fio) var(--b));
}
.faixa::-moz-range-track { height: 3px; border-radius: 2px; background: var(--fio); }
.faixa::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--dourado); }
.faixa.bipolar::-moz-range-progress { background: transparent; }
.faixa::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10.5px; border-radius: 50%;
  background: var(--branco); border: 1px solid var(--fio-forte); box-shadow: var(--sombra-alca);
  transition: transform .12s, border-color .12s;
}
.faixa::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--branco); border: 1px solid var(--fio-forte); box-shadow: var(--sombra-alca); }
.faixa:active::-webkit-slider-thumb { transform: scale(1.1); border-color: var(--dourado); }
.faixa:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--dourado); }

.prontas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 14px 0 8px; }
.pronta {
  min-height: 44px; padding: 4px; border: 1px solid var(--fio); border-radius: var(--r-btn);
  background: var(--fundo); color: var(--texto-2); font-size: 12px; font-weight: 500; cursor: pointer; line-height: 1.15;
  text-wrap: balance;
}
.pronta:hover { color: var(--texto); border-color: var(--fio-forte); }
.pronta.ativo { color: var(--dourado-texto); border-color: var(--dourado); background: var(--dourado-claro); }
.nota { color: var(--texto-3); font-size: 12px; padding: 12px 0 4px; }

/* medidas */
.bloco { padding: 18px 0; border-bottom: 1px solid var(--fio); }
.bloco:last-child { border-bottom: 0; }
.bloco-titulo { margin-bottom: 10px; display: flex; justify-content: space-between; gap: 8px; }
.bloco-titulo span { font-size: 10.5px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--texto-2); }
.bloco-titulo span:last-child { color: var(--texto-3); letter-spacing: .08em; }
.grande-num { font-family: var(--fonte-titulo); font-weight: 300; font-size: 34px; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.grande-num small { font-family: var(--fonte); font-size: 12px; color: var(--texto-2); font-weight: 500; margin-left: 6px; letter-spacing: 0; }
.grande-num small.pct { font-family: var(--fonte-titulo); font-size: 18px; font-weight: 300; margin-left: 1px; }
.tercos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.terco-rot { font-size: 11.5px; color: var(--texto-2); margin-top: 8px; }
.barra { position: relative; height: 4px; border-radius: 2px; background: var(--fio); margin-top: 10px; overflow: visible; }
.barra-cheia { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--dourado); }
.barra-ideal { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--texto); border-radius: 1px; }
.sub { font-size: 12px; color: var(--texto-2); margin-top: 10px; }

.em-breve { margin-top: 18px; border: 1px dashed var(--fio-forte); border-radius: var(--r-card); padding: 22px 18px; color: var(--texto-2); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; background: var(--superficie); }
.em-breve-tag { font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--dourado-texto); border: 1px solid var(--dourado); border-radius: 4px; padding: 3px 8px; }

/* resumo */
.resumo { flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--fio); background: var(--superficie); }
.resumo-texto { flex: 1; min-width: 0; }
.resumo-plano { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.resumo-faixa { font-size: 12px; color: var(--dourado-texto); font-variant-numeric: tabular-nums; }
.resumo-aviso { font-size: 11.5px; color: var(--texto-2); }
.resumo-texto p { text-wrap: balance; }

/* ---------- carregando, modal, toast ---------- */
.carregando { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--branco-veu); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.carregando-caixa { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-radius: var(--r-card); background: var(--fundo); border: 1px solid var(--fio); box-shadow: var(--sombra-forte); font-size: 14px; }
.giro { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--fio); border-top-color: var(--dourado); animation: giro .8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: var(--noite-veu); }
.modal-caixa { width: min(440px, 100%); background: var(--fundo); border: 1px solid var(--fio); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--sombra-forte); }
.modal-caixa h2 { font-size: 22px; font-weight: 300; }
.modal-caixa p { color: var(--texto-2); }
.modal-botoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70;
  width: max-content; max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 8px; background: var(--noite); color: var(--branco);
  font-size: 13.5px; box-shadow: var(--sombra-forte); text-wrap: pretty;
}

/* ---------- câmera ---------- */
.camera { position: fixed; inset: 0; z-index: 60; background: var(--noite); overflow: hidden; color: var(--branco); }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera video.espelho { transform: scaleX(-1); }
.camera-oval { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.camera-topo { position: absolute; left: 0; right: 0; top: 0; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.camera-titulo { font-family: var(--fonte-titulo); font-weight: 400; font-size: 18px; text-align: center; }
.camera-espaco { width: 48px; }
.camera-dica {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(132px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px); padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--noite-vidro); white-space: nowrap; text-align: center;
}
.camera-dica.ok { color: var(--malha); }
.camera-base { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 28px calc(24px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; }
.btn-redondo { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--branco-fio); background: var(--noite-vidro); color: var(--branco); cursor: pointer; }
.btn-redondo .ic { width: 22px; height: 22px; }
.disparo { width: 78px; height: 78px; border-radius: 50%; border: 3px solid var(--branco); background: transparent; padding: 5px; cursor: pointer; }
.disparo span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--branco); transition: transform .1s, background-color .1s; }
.disparo:active span { transform: scale(.9); background: var(--dourado); }

/* ---------- celular e tablet em pé ---------- */
@media (max-width: 859px), (max-aspect-ratio: 1/1) {
  :root { --topo: 52px; }
  .topo { padding: 0 8px 0 16px; gap: 8px; }
  .marca { gap: 8px; }
  .marca-nome { font-size: 16.5px; }
  .marca-sub { font-size: 9px; letter-spacing: .12em; }
  .selo-topo { display: none; }
  .btn-ic-texto span { display: none; }
  .btn-ic-texto { width: 44px; padding: 0; }
  .topo-acoes { gap: 2px; }
  .topo-acoes .btn { border-color: transparent; background: transparent; }
  .topo-acoes .btn.primario { color: var(--dourado-texto); }
  .trabalho {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 54% auto minmax(0, 1fr);
    grid-template-areas: "palco" "abas" "painel";
  }
  .abas { justify-content: flex-start; padding: 0 8px; border-bottom: 1px solid var(--fio); border-top: 1px solid var(--fio); background: var(--fundo); gap: 0; }
  .aba { padding: 0 11px; font-size: 13px; }
  .palco { padding: 10px 16px 8px; gap: 8px; background: var(--superficie); }
  .painel { border-left: 0; }
  .conteudo { padding: 4px 16px 16px; }
  .painel-titulo { display: none; }
  .barra-palco { gap: 6px; }
  .barra-palco .btn { min-height: 40px; padding: 0 10px; font-size: 12.5px; }
  .barra-3d { gap: 4px; }
  .texto-some span { display: none; }
  .texto-some { width: 44px; padding: 0 !important; }
  .seg { min-height: 34px; min-width: 38px; padding: 0 7px; font-size: 12.5px; }
  .barra-palco { gap: 4px; }
  .segmento { padding: 2px; }
  .resumo { padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); }
  .resumo-plano { font-size: 12.5px; }
  .resumo-aviso, .resumo-faixa { font-size: 11px; }
  .envio { padding: 32px 20px 26px; gap: 18px; }
  .linha { padding: 10px 0 4px; }
}
@media (max-width: 370px) {
  .marca-sub { display: none; }
}

/* aviso de dose acima do usual nos estudos */
.alerta { color: var(--perigo); }
