:root {
  color-scheme: dark;
  --bg: #0a0d0e;
  --phone: #0f1415;
  --surface: #161d1e;
  --surface-2: #1d2627;
  --line: #ffffff14;
  --line-strong: #ffffff26;
  --text: #e9eeec;
  --muted: #9aa69f;
  --faint: #8d9a93;
  --lime: #c3ee95;
  --lime-ink: #18260f;
  --lime-dim: #88b062;
  --them: #222b2c;
  --amber: #f1c46b;
  --red: #ff8f80;
  --radius: 18px;
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', var(--font);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  display: grid;
  place-items: center;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 10; background: var(--lime); color: var(--lime-ink); padding: 8px 12px; border-radius: 8px; }

/* ── Aparelho ─────────────────────────────────────────── */
.phone {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--phone);
  overflow: hidden;
}
@media (min-width: 560px) and (min-height: 640px) {
  body { background: radial-gradient(60% 50% at 50% 40%, #1d2e22 0%, transparent 70%), var(--bg); }
  .phone {
    width: 410px;
    height: min(880px, calc(100dvh - 40px));
    border-radius: 46px;
    border: 9px solid #1e2526;
    box-shadow: 0 0 0 1px #3a463d, 0 40px 120px #000c, inset 0 0 0 1px #ffffff0a;
  }
}

.statusbar {
  flex-shrink: 0;
  height: calc(42px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 26px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: 600 14px/1 var(--display);
  font-variant-numeric: tabular-nums;
  position: relative;
}
.island { position: absolute; left: 50%; top: calc(9px + env(safe-area-inset-top)); width: 96px; height: 26px; transform: translateX(-50%); background: #000; border-radius: 20px; }
.signal { display: flex; gap: 6px; align-items: center; color: var(--text); }
.signal svg { fill: currentColor; }
@media (max-width: 559px) { .island { display: none; } }

.contact {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 10px 18px;
  border-bottom: 1px solid var(--line);
}
.avatar { position: relative; width: 42px; height: 42px; flex-shrink: 0; }
.avatar span { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 15px; background: var(--lime); color: var(--lime-ink); font: 700 23px/1 var(--display); transform: rotate(-5deg); }
.avatar i { position: absolute; right: -2px; bottom: -2px; width: 13px; height: 13px; border-radius: 50%; background: #8fe06a; border: 3px solid var(--phone); }
.identity { flex: 1; min-width: 0; }
.identity h1 { margin: 0; font: 600 17px/1.2 var(--display); }
.identity p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon {
  width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 12px; background: transparent; color: #c2cdc7; cursor: pointer;
}
@media (hover: hover) { .icon:hover { background: #ffffff0d; color: var(--lime); } }
.icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#soundBtn .wave { display: none; }
#soundBtn[aria-pressed="true"] .wave { display: inline; }
#soundBtn[aria-pressed="true"] .mute { display: none; }
#soundBtn[aria-pressed="true"] { color: var(--lime); }

/* ── Prazo (tempo é público; progresso, não) ── */
.deadline { flex-shrink: 0; padding: 8px 18px 9px; border-bottom: 1px solid var(--line); background: #ffffff04; }
.deadline p { margin: 0 0 6px; display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.deadline strong { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.track { height: 3px; border-radius: 3px; background: #ffffff12; overflow: hidden; }
.fill { height: 100%; background: var(--lime-dim); transform-origin: left; transition: transform .6s ease, background-color .3s; }
.deadline[data-level="warning"] .fill { background: var(--amber); }
.deadline[data-level="warning"] strong { color: var(--amber); }
.deadline[data-level="critical"] .fill { background: var(--red); animation: pulse 1.2s ease-in-out infinite; }
.deadline[data-level="critical"] strong { color: var(--red); }
@keyframes pulse { 50% { opacity: .45; } }

/* ── Conversa ─────────────────────────────────────────── */
.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  padding: 0 14px 14px;
  scrollbar-width: thin;
  scrollbar-color: #33403a transparent;
}
.intro { text-align: center; padding: 26px 8px 14px; }
.eyebrow { margin: 0; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--lime-dim); }
.intro h2 { margin: 10px 0 8px; font: 600 clamp(30px, 9vw, 38px)/1.02 var(--display); letter-spacing: -.04em; }
.intro h2 em { font-style: normal; color: var(--lime); }
.intro p:last-child { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }

.msg { position: relative; max-width: 84%; margin: 6px 0; padding: 9px 12px 7px; border-radius: var(--radius); font-size: 15px; line-height: 1.45; }
.msg p { margin: 0; overflow-wrap: anywhere; }
.msg time { display: block; margin-top: 2px; text-align: right; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.msg.them { background: var(--them); border-bottom-left-radius: 6px; }
.msg.me { margin-left: auto; background: var(--lime); color: var(--lime-ink); border-bottom-right-radius: 6px; }
.msg.me time { color: #3f5a2e; }
.msg.them + .msg.them { margin-top: 2px; }
.msg.me + .msg.me { margin-top: 2px; }
.divider { margin: 18px auto; max-width: 92%; text-align: center; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.divider strong { display: inline-block; margin-bottom: 4px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text); font: 600 11.5px/1.5 var(--display); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.divider span { display: block; }
.enter { animation: enter .28s cubic-bezier(.2,.8,.3,1) both; }
.msg.me.enter { transform-origin: bottom right; }
.msg.them.enter { transform-origin: bottom left; }
@keyframes enter { from { opacity: 0; transform: translateY(8px) scale(.97); } }

.typing { display: inline-flex; gap: 4px; margin: 6px 0; padding: 13px 14px; border-radius: var(--radius); border-bottom-left-radius: 6px; background: var(--them); }
.typing[hidden] { display: none; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #93a199; animation: dot 1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { transform: none; opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ── Respostas ────────────────────────────────────────── */
.composer {
  flex-shrink: 0;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #0c1011;
  max-height: 52dvh;
  overflow-y: auto;
}
.composer-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 4px 8px; font-size: 13px; color: var(--muted); }
.hint { font-size: 11.5px; color: var(--faint); }
@media (hover: none) { .hint { display: none; } }
.choices { display: grid; gap: 7px; }
.choices:focus { outline: none; }
.choice {
  display: flex; align-items: flex-start; gap: 10px;
  width: 100%; min-height: 46px; padding: 10px 12px;
  text-align: left; font-size: 14px; line-height: 1.4;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px;
  cursor: pointer; transition: background-color .15s, border-color .15s, transform .15s;
}
@media (hover: hover) { .choice:hover:not(:disabled) { background: #1f2a22; border-color: var(--lime-dim); } }
.choice:active:not(:disabled) { transform: scale(.985); }
.choice:disabled { opacity: .45; cursor: progress; }
.choice kbd {
  flex-shrink: 0; display: grid; place-items: center; width: 22px; height: 22px; margin-top: -1px;
  border-radius: 7px; background: #ffffff0f; color: var(--lime); font: 600 12px/1 var(--display);
}
.choice-text { display: flex; flex-direction: column; gap: 2px; }
.choice small { font-size: 12.5px; color: var(--muted); }
.choice.level strong { font-weight: 600; color: var(--lime); }
.choice.cta { justify-content: center; background: var(--lime); color: var(--lime-ink); border-color: transparent; font-weight: 700; }
@media (hover: hover) { .choice.cta:hover:not(:disabled) { background: #d2f5ad; } }

/* ── Diálogos ─────────────────────────────────────────── */
dialog {
  width: min(420px, calc(100vw - 24px));
  max-height: min(86dvh, 720px);
  padding: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  overflow-y: auto;
}
dialog::backdrop { background: #000000b8; backdrop-filter: blur(3px); }
dialog[open] { animation: enter .22s ease both; }
dialog h2 { margin: 0 32px 6px 0; font: 600 25px/1.15 var(--display); letter-spacing: -.02em; }
.dialog-lede { margin: 0 0 16px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.dialog-close { position: absolute; top: 14px; right: 14px; margin: 0; }
.dialog-close button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: #ffffff0d; cursor: pointer; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin: 0; }
.primary, .secondary { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; cursor: pointer; font-weight: 600; }
.primary { background: var(--lime); color: var(--lime-ink); }
.primary:hover { background: #d2f5ad; }
.secondary { background: var(--surface-2); }
.secondary:hover { background: #283334; }

.score-form { margin: 0 0 18px; padding: 14px; border-radius: 16px; background: #c3ee950f; border: 1px solid #c3ee9533; }
.score-form label { display: block; margin-bottom: 8px; font-size: 13.5px; font-weight: 600; }
.field { display: flex; gap: 8px; }
.field input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--phone); color: var(--text); font: inherit; font-size: 16px; }
.field input:focus { border-color: var(--lime-dim); }
.notice { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.notice strong { color: var(--amber); font-weight: 600; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 13px; background: var(--phone); }
.tabs button { min-height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 14px; }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--lime); }
.ranking-status { min-height: 1.4em; margin: 12px 0 4px; font-size: 13.5px; color: var(--muted); }
.ranking-list { list-style: none; margin: 0; padding: 0; }
.ranking-list li { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.ranking-list li.mine { background: #c3ee9514; border-radius: 10px; }
.ranking-list .pos { font: 600 14px/1 var(--display); color: var(--faint); text-align: center; }
.ranking-list li:nth-child(-n+3) .pos { color: var(--lime); }
.ranking-list strong { overflow-wrap: anywhere; font-weight: 600; font-size: 14.5px; }
.ranking-list .score { text-align: right; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ranking-list .score small { display: block; font-size: 11.5px; color: var(--faint); }

.noscript { position: fixed; inset: auto 16px 16px; padding: 14px; border-radius: 14px; background: var(--surface); }

@media (max-height: 700px) {
  .intro { padding: 14px 8px 6px; }
  .intro h2 { font-size: 28px; margin: 6px 0; }
  .intro p:last-child { display: none; }
  .choice { padding: 8px 10px; font-size: 13.5px; min-height: 44px; }
  .composer-head { padding-bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .msg, .choice, .divider strong { border: 1px solid CanvasText; }
}
