:root {
  --bg: #0e1220;
  --panel: #171d31;
  --panel-2: #1e2540;
  --ink: #e8ecf6;
  --muted: #98a2c0;
  --accent: #5b8cff;
  --accent-2: #00d1b2;
  --warn: #ffb454;
  --danger: #ff6b6b;
  --line: #2a3252;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1a2138, var(--bg));
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100%; }

.screen { display: none; min-height: 100vh; padding: 4vh 5vw; }
.screen.active { display: flex; align-items: center; justify-content: center; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
  max-width: 560px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.card.wide { max-width: 760px; }

h1 { margin: 0 0 6px; font-size: 2rem; letter-spacing: -.02em; }
h2 { margin: 0 0 4px; }
h3 { margin: 28px 0 4px; font-size: 1.05rem; }
.subtitle { color: var(--muted); margin: 0 0 24px; line-height: 1.5; }

.field { margin-bottom: 16px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
input, select {
  width: 100%; padding: 12px 14px; font-size: 1rem;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
}

.note {
  background: rgba(255,180,84,.08);
  border: 1px solid rgba(255,180,84,.3);
  color: #ffe0b8; border-radius: 12px;
  padding: 14px 16px; font-size: .82rem; line-height: 1.5; margin: 20px 0;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.demo-controls { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.demo-controls label { margin: 0; }
.demo-controls select { width: auto; flex: 1; min-width: 200px; }

button {
  font: inherit; cursor: pointer; border-radius: 10px; padding: 12px 20px;
  border: 1px solid transparent; font-weight: 600; transition: transform .05s, filter .15s;
}
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: white; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.ghost:hover { background: var(--panel-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* Calibração */
[data-screen="calib"] { position: relative; display: none; }
[data-screen="calib"].active { display: block; }
.calib-instructions {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  text-align: center; z-index: 5; max-width: 90vw;
  pointer-events: none; /* NUNCA rouba o toque dos pontos embaixo */
}
.calib-instructions p { text-wrap: balance; margin: 0 0 4px; max-width: 640px; }

/* O preview da câmera do WebGazer fica no canto superior esquerdo com prioridade
   máxima; aqui rebaixamos a camada dele para o ponto móvel ficar por cima. */
#webgazerVideoContainer { z-index: 3 !important; opacity: .92; }

/* Ponto que se move pela tela — o paciente segue só com os olhos, sem tocar. */
.calib-moving {
  position: fixed; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-2); border: 3px solid #fff;
  transform: translate(-50%, -50%); z-index: 20;
  box-shadow: 0 0 0 9px rgba(0,209,178,.22);
  transition: left .55s cubic-bezier(.4,0,.2,1), top .55s cubic-bezier(.4,0,.2,1);
}
.calib-moving::after {
  content: ""; position: absolute; inset: 10px; border-radius: 50%;
  background: #fff;
}
.calib-controls {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  z-index: 21; display: flex; gap: 12px;
}

/* Leitura */
[data-screen="reading"].active { flex-direction: column; align-items: center; justify-content: center; }
.reading-progress { position: fixed; top: 24px; right: 32px; color: var(--muted); }
.sentence-wrap { max-width: 900px; }
.sentence {
  font-size: 2.4rem; line-height: 2; letter-spacing: .01em; text-align: center;
}
.sentence .word { padding: 2px 6px; border-radius: 6px; }
.reading-actions { margin-top: 48px; }
.gaze-live {
  position: fixed; bottom: 16px; left: 16px; z-index: 8;
  background: rgba(0,209,178,.15); color: var(--accent-2);
  border: 1px solid rgba(0,209,178,.4); border-radius: 999px;
  padding: 6px 12px; font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* Resultados */
.score-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 18px 0; }
.score-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.score-card.highlight { border-color: var(--accent); background: linear-gradient(180deg, rgba(91,140,255,.14), var(--panel-2)); }
.score-label { font-size: .78rem; color: var(--muted); }
.score-value { font-size: 1.7rem; font-weight: 700; margin: 4px 0; }
.score-hint { font-size: .72rem; color: var(--muted); }

#scatter, #linechart { width: 100%; max-width: 640px; height: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; }

/* ponto de fixação central entre as frases */
.fixation {
  position: fixed; inset: 0; z-index: 4;
  display: flex; align-items: center; justify-content: center;
  font-size: 5rem; font-weight: 300; color: var(--ink);
}
[data-screen="instruction"].active { display: flex; align-items: center; justify-content: center; }
[data-screen="instruction"] p { line-height: 1.6; }

#word-map { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.wm-word { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 44px; }
.wm-chip { padding: 6px 10px; border-radius: 8px; font-weight: 600; color: #06122b; }
.wm-bar-track { width: 100%; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.wm-bar { height: 100%; background: var(--accent-2); }

.results-meta { margin-bottom: 8px; }

@media (max-width: 600px) {
  .sentence { font-size: 1.7rem; line-height: 1.9; }
  .card { padding: 22px; }
}

/* ============ LAUDO ============ */
[data-screen="laudo"].active { display: block; padding: 24px 5vw 60px; }
.laudo-actions { display: flex; gap: 12px; max-width: 800px; margin: 0 auto 20px; }
#laudo-content { max-width: 800px; margin: 0 auto; }
.laudo {
  background: #ffffff; color: #1a1f2e; border-radius: 12px;
  padding: 40px 44px; line-height: 1.55;
}
.laudo h1 { color: #1a1f2e; font-size: 1.6rem; margin: 0; }
.laudo h2 { color: #1a1f2e; font-size: 1.15rem; margin: 26px 0 10px; border-bottom: 2px solid #eef1f6; padding-bottom: 6px; }
.laudo-sub { color: #5b647d; margin: 4px 0 0; font-size: .9rem; }
.laudo-head { border-bottom: 3px solid #1a1f2e; padding-bottom: 14px; }
.laudo-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px 20px; margin: 18px 0; font-size: .9rem; color: #333b52; }
.laudo-resumo { display: flex; gap: 20px; align-items: center; border: 2px solid; border-radius: 10px; padding: 16px 20px; margin: 8px 0 4px; background: #fafbfd; }
.laudo-score { font-size: 3rem; font-weight: 800; line-height: 1; white-space: nowrap; }
.laudo-score span { font-size: 1rem; color: #8a93a8; font-weight: 600; }
.laudo-faixa { font-weight: 700; font-size: 1.05rem; margin-bottom: 4px; }
.laudo-resumo-txt p { margin: 0; color: #333b52; font-size: .92rem; }
.laudo-tab { width: 100%; border-collapse: collapse; font-size: .88rem; }
.laudo-tab td { padding: 8px 10px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
.laudo-tab td.v { font-weight: 700; white-space: nowrap; width: 130px; }
.laudo-tab td.h { color: #6b7288; font-size: .82rem; }
.laudo-frase { border-left: 3px solid #5b8cff; padding: 6px 0 6px 14px; margin: 14px 0; }
.laudo-frase-num { font-weight: 700; font-size: .82rem; color: #5b8cff; text-transform: uppercase; letter-spacing: .03em; }
.laudo-frase-txt { font-size: 1.05rem; margin: 4px 0 8px; color: #1a1f2e; }
.laudo-linha { font-size: .88rem; color: #333b52; margin: 3px 0; }
.laudo-linha span { font-weight: 700; color: #1a1f2e; }
.laudo-recs { margin: 6px 0; padding-left: 20px; }
.laudo-recs li { margin: 5px 0; color: #333b52; font-size: .9rem; }
.laudo-foot { margin-top: 26px; border-top: 1px solid #eef1f6; padding-top: 14px; font-size: .8rem; color: #6b7288; }
.laudo-assin { margin-top: 8px; color: #98a2c0; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .screen { display: none !important; }
  [data-screen="laudo"].active { display: block !important; padding: 0; }
  #laudo-content { max-width: none; }
  .laudo { border-radius: 0; padding: 0; }
}
