:root {
  --bg: #fff9f3;
  --surface: #ffffff;
  --surface-2: #f0f8f3;
  --border: #d9e7de;
  --text: #18372f;
  --muted: #64766f;
  --accent: #2f7d5b;
  --accent-hover: #256749;
  --success: #4a936d;
  --warning: #9a641a;
  --error: #b94a4a;
  --blue: #6f8fdd;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  color: var(--text); line-height: 1.55;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(ellipse 75% 55% at 50% -10%, rgba(91, 183, 135, 0.20), transparent 60%),
    radial-gradient(ellipse 50% 35% at 85% 105%, rgba(246, 199, 112, 0.16), transparent 55%),
    var(--bg);
}
.hidden { display: none !important; }
a { color: var(--accent); }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 0.9rem; padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.82); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.wordmark { font-weight: 800; letter-spacing: 0.01em; text-decoration: none; color: var(--text); font-size: 1.05rem; }
.wordmark em { color: var(--accent); font-style: normal; }
.phase { font-size: 0.8rem; color: var(--muted); padding: 0.15rem 0.6rem; border-radius: 999px; background: var(--surface-2); }
.phase:empty { display: none; }
.topbar-right { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; border: none; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }

/* ---- buttons ---- */
button { font-family: inherit; font-size: 0.95rem; cursor: pointer; border: none; border-radius: 10px; padding: 0.6rem 1rem; transition: background .15s, box-shadow .15s, transform .15s, opacity .15s; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 6px 18px rgba(47,125,91,0.20); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary.nudge { animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 0%,100% { box-shadow: 0 6px 18px rgba(47,125,91,0.20);} 50% { box-shadow: 0 0 0 8px rgba(47,125,91,0.18);} }
.btn-secondary { background: #e7f1eb; color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #dcebe2; }
.btn-ghost { background: rgba(255,255,255,0.5); color: var(--muted); border: 1px solid var(--border); }
.btn-link { background: none; color: var(--muted); text-decoration: underline; padding: 0.4rem 0.5rem; font-size: 0.85rem; }
.btn-big { min-height: 56px; padding: 0.9rem 1.6rem; font-size: 1.1rem; border-radius: 14px; }

.err { margin: 0.75rem auto 0; width: min(760px, calc(100% - 2rem)); padding: 0.7rem 1rem; border-radius: 12px; background: #fdecec; color: var(--error); border: 1px solid #f3c5c5; font-size: 0.9rem; }

/* ---- views ---- */
.view { flex: 1; width: min(880px, 100%); margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.5rem) 1.25rem 3rem; }
.eyebrow { margin: 0 0 0.6rem; color: var(--accent); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.lead { color: var(--muted); font-size: clamp(1.05rem, 2.4vw, 1.2rem); max-width: 40rem; margin: 1rem auto 0; text-wrap: balance; }
.fine { color: var(--muted); font-size: 0.85rem; margin: 0.9rem 0 0; }

/* ---- coach avatar ---- */
.coach-avatar { position: relative; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid var(--border); box-shadow: 0 10px 30px rgba(24,55,47,0.08); transition: border-color .2s, box-shadow .2s; }
.coach-avatar .face { font-size: 2.4rem; line-height: 1; transition: transform .2s, opacity .2s; }
.coach-avatar .dots { position: absolute; bottom: -6px; display: none; gap: 3px; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 3px 6px; }
.coach-avatar .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); display: block; animation: blink 0.9s infinite; }
.coach-avatar .dots i:nth-child(2) { animation-delay: .18s; } .coach-avatar .dots i:nth-child(3) { animation-delay: .36s; }
.coach-avatar.idle .face { opacity: 0.7; }
.coach-avatar.listening { border-color: var(--success); box-shadow: 0 0 0 8px rgba(74,147,109,0.14); }
.coach-avatar.listening .face { transform: rotate(-7deg); }
.coach-avatar.speaking { border-color: var(--blue); box-shadow: 0 0 0 10px rgba(111,143,221,0.16); }
.coach-avatar.speaking .face { animation: bob 1.1s ease-in-out infinite; }
.coach-avatar.thinking .dots { display: flex; }
@keyframes bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-4px);} }
@keyframes blink { 0%,100% { opacity: .25;} 50% { opacity: 1;} }
.hero-avatar { margin: 0 auto 1.2rem; }

/* ---- landing ---- */
.hero { text-align: center; padding: clamp(1rem, 5vw, 3rem) 0 1rem; }
.hero h1 { margin: 0 auto; max-width: 18ch; font-size: clamp(2.2rem, 6.5vw, 3.6rem); line-height: 1.05; letter-spacing: -0.04em; text-wrap: balance; }
.hero .btn-big { margin-top: 1.8rem; }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 2.5rem 0 0; }
.how-step { background: rgba(255,255,255,0.75); border: 1px solid var(--border); border-radius: 18px; padding: 1.25rem; }
.how-n { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 0.9rem; }
.how-step h3 { margin: 0.8rem 0 0.4rem; font-size: 1.05rem; }
.how-step p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.cta2 { text-align: center; margin-top: 2.5rem; }

/* ---- session ---- */
.session { display: grid; grid-template-columns: 120px 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 640px) { .session { grid-template-columns: 1fr; } .coach-col { flex-direction: row; align-items: center; } }
.coach-col { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; position: sticky; top: 76px; }
.captions { font-size: 0.85rem; color: var(--muted); max-width: 100%; }
.cap { margin: 0.25rem 0; padding: 0.4rem 0.6rem; border-radius: 10px; background: rgba(255,255,255,0.7); border: 1px solid var(--border); }
.cap.user { color: var(--text); }
.cap.coach { color: #3d5aa8; }
.units { display: flex; flex-direction: column; gap: 0.75rem; }
.unit { background: rgba(255,255,255,0.8); border: 1px solid var(--border); border-radius: 16px; padding: 0.9rem 1.1rem; }
.unit.done { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.6rem; opacity: 0.9; padding: 0.65rem 1rem; }
.unit-check { color: var(--success); font-weight: 800; grid-row: span 2; }
.unit.done .unit-title { font-weight: 600; font-size: 0.9rem; }
.unit-summary { color: var(--muted); font-size: 0.88rem; }
.unit.current { border-width: 2px; border-color: var(--border); padding: 1.1rem 1.25rem; transition: border-color .2s, box-shadow .2s; }
.unit.current[data-mode="listening"] { border-color: var(--success); box-shadow: 0 0 0 6px rgba(74,147,109,0.10); }
.unit.current[data-mode="speaking"] { border-color: var(--blue); }
.unit-head { display: flex; align-items: center; gap: 0.6rem; }
.unit-head .unit-title { font-size: 1.15rem; font-weight: 700; }
.mic-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex: none; }
.unit.current[data-mode="listening"] .mic-dot { background: var(--success); box-shadow: 0 0 0 4px rgba(74,147,109,0.25); animation: blink 1.2s infinite; }
.compose { margin-top: 0.8rem; }
.compose-hint { color: var(--muted); font-size: 0.92rem; min-height: 1.4em; }
.compose-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.6rem; }
.typed { display: flex; gap: 0.5rem; margin-top: 0.7rem; }
.typed input { flex: 1; padding: 0.6rem 0.8rem; border-radius: 10px; border: 1px solid var(--border); font: inherit; }

/* ---- confirm card ---- */
.card { background: #fff; border: 2px solid var(--accent); border-radius: 18px; padding: 1.25rem; box-shadow: 0 16px 40px rgba(47,125,91,0.12); }
.card h3 { margin: 0 0 0.8rem; }
.card form { display: grid; gap: 0.8rem; }
.card label { display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.card input, .card textarea { font: inherit; font-size: 1rem; color: var(--text); padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 10px; resize: vertical; }
.card-note { margin: 0; color: var(--muted); font-size: 0.82rem; }

/* ---- focus ---- */
.focus { text-align: center; max-width: 620px; margin: 0 auto; }
.focus h2 { font-size: clamp(1.4rem, 4vw, 2rem); margin: 0 0 1.2rem; letter-spacing: -0.02em; text-wrap: balance; }
.focus-signage .sig { margin: 0 auto; max-width: 380px; }
.focus-coach { color: #3d5aa8; min-height: 1.5em; margin: 1rem 0 0; font-size: 0.95rem; }
.focus-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 1.4rem; }
.monitor-row { margin: 1.4rem auto 0; max-width: 520px; text-align: left; }
.monitor-offer, .monitor-live { display: flex; align-items: center; gap: 0.8rem; background: rgba(255,255,255,0.8); border: 1px solid var(--border); border-radius: 16px; padding: 0.8rem 1rem; }
.monitor-eye { font-size: 1.5rem; line-height: 1; }
.monitor-text { display: grid; gap: 0.15rem; flex: 1; font-size: 0.88rem; color: var(--muted); }
.monitor-text strong { color: var(--text); font-size: 0.95rem; }
.monitor-live { justify-content: center; font-size: 0.88rem; color: var(--muted); }
.monitor-live .monitor-text { flex: 0 1 auto; }
.monitor-live.hmm { border-color: var(--warning); }

/* ---- nudge overlay (shown on the focus page only after they come back) ---- */
.nudge-panel { margin-top: 1.2rem; padding: 1rem 1.1rem 1.2rem; background: rgba(255,255,255,0.9); border: 1px solid var(--warning); border-radius: 16px; }
.nudge-panel h3 { font-size: 1.25rem; margin: 0 0 0.4rem; letter-spacing: -0.02em; }
.distracted-seen { margin: 0 0 0.8rem; color: var(--muted); font-size: 0.92rem; }

/* ---- coach mood (drives the face in both the page and the PiP) ---- */
.coach-avatar.mood-sad { border-color: var(--warning); box-shadow: 0 0 0 8px rgba(191,138,60,0.12); }
.coach-avatar.mood-sad .face, .sig-avatar.mood-sad { animation: droop 2.4s ease-in-out infinite; }
.coach-avatar.mood-happy { border-color: var(--success); }
@keyframes droop { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(3px) rotate(-8deg); } }

/* ---- done ---- */
.done { text-align: center; max-width: 620px; margin: 0 auto; }
.done .coach-avatar { margin: 0 auto 1rem; }
.done h1 { margin: 0; font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -0.04em; }
.facts { text-align: left; margin: 1.6rem auto; max-width: 480px; background: rgba(255,255,255,0.8); border: 1px solid var(--border); border-radius: 16px; padding: 1rem 1.25rem; display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem; }
.facts div { display: contents; }
.facts dt { color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; align-self: baseline; }
.facts dd { margin: 0; }

/* ---- signage (shared by PiP window, focus view, fallback bar) ---- */
.pip-body {
  margin: 0; min-height: 100vh; padding: 0;
  background: #fff; color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.pip-body .sig {
  background: transparent; border: none; border-radius: 0; box-shadow: none;
  min-height: 100vh; padding: 8px 12px 12px; gap: 0.45rem; box-sizing: border-box;
  align-content: start;
}
.sig { width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 0.85rem 1rem; display: grid; gap: 0.4rem; text-align: center; box-shadow: 0 10px 30px rgba(24,55,47,0.08); }
.sig-head { display: flex; align-items: center; gap: 0.45rem; font-size: 0.78rem; color: var(--muted); }
.sig-avatar { font-size: 1.3rem; line-height: 1; transition: transform .2s; display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto; }
.sig-avatar.has-clip { font-size: 2rem; opacity: 1; }
.sig-avatar.has-clip.idle { opacity: 1; }
.sig-face { line-height: 1; }
.sig-lottie { width: 52px; height: 52px; pointer-events: none; }
.sig-lottie svg { display: block; width: 100%; height: 100%; }
.sig-avatar.speaking { animation: bob 1.1s ease-in-out infinite; }
.sig-avatar.listening { transform: rotate(-7deg); }
.sig-avatar.idle { opacity: 0.75; }
.sig-live { margin-left: auto; color: var(--success); font-size: 0.72rem; }
.sig-eye { font: inherit; font-size: 0.72rem; padding: 0.15rem 0.5rem; border-radius: 999px; border: 1px solid var(--border); background: #f3f8f5; color: var(--muted); cursor: pointer; animation: eyeblink 6s ease-in-out infinite; }
.sig-eye.hmm { border-color: var(--warning); color: var(--warning); animation: none; }
@keyframes eyeblink { 0%, 92%, 100% { opacity: 1; } 96% { opacity: 0.35; } }
.sig-timer { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sig-timer.paused { color: var(--warning); }
.sig-timer.ending { color: var(--error); }
.sig-task { font-size: 1.15rem; font-weight: 700; text-wrap: balance; line-height: 1.25; }
.sig-praise { font-size: 0.85rem; color: var(--accent); font-style: italic; }
.sig-nudge { font-size: 0.9rem; font-weight: 600; color: var(--warning); text-wrap: balance; }
.sig-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-top: 0.15rem; align-items: center; }
.sig-btn { font: inherit; font-size: 0.82rem; padding: 0.45rem 0.8rem; border-radius: 10px; border: 1px solid var(--border); background: #f3f8f5; color: var(--text); cursor: pointer; }
.sig-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.sig-btn[data-act="realign"] { width: auto; padding: 0.25rem 0.65rem; font-size: 0.72rem; transition: padding .35s ease, font-size .35s ease, width .35s ease; }
.sig-btn[data-act="realign"][data-heat="1"] { font-size: 0.72rem; padding: 0.25rem 0.65rem; }
.sig-btn[data-act="realign"][data-heat="2"] { font-size: 0.85rem; padding: 0.4rem 0.9rem; }
.sig-btn[data-act="realign"][data-heat="3"] { font-size: 0.98rem; padding: 0.55rem 1.1rem; width: 80%; }
.sig-btn[data-act="realign"][data-heat="4"] { font-size: 1.1rem; padding: 0.7rem 1.15rem; width: 100%; }
.signage-bar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(380px, calc(100% - 1.5rem)); z-index: 30; }

/* PiP is the card — face twice as large, task leads */
.pip-body .sig-avatar, .pip-body .sig-avatar.has-clip { width: 108px; height: 108px; font-size: 4rem; }
.pip-body .sig-lottie { width: 108px; height: 108px; }
.pip-body .sig-task { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.pip-body .sig-timer { font-size: 2.35rem; }

/* ---- debug ---- */
.debug { position: fixed; right: 10px; bottom: 10px; max-width: 360px; max-height: 45vh; overflow: auto; background: #111; color: #9fe6b8; font: 11px/1.4 ui-monospace, monospace; padding: 8px; border-radius: 8px; opacity: 0.9; z-index: 50; }
.debug pre { margin: 0; white-space: pre-wrap; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
