/* AI Coach — design system "Caderno": an editorial private-tutor identity.
   Deep forest green, warm ivory, muted gold and charcoal. Serif for the teacher's voice and headings,
   a humanist sans for the interface. System fonts only (no third-party requests). */

:root {
  color-scheme: light;
  /* brand */
  --forest: #153e32;
  --forest-600: #1f5546;
  --forest-900: #0e2a22;
  --moss: #3e6b58;
  --ivory: #f6f1e6;
  --paper: #fffdf7;
  --gold: #b38b2d;
  --charcoal: #1f2326;

  /* semantic, light */
  --bg: #f6f1e6;
  --surface: #fffdf7;
  --surface-2: #efe8d8;
  --surface-3: #e6dcc6;
  --line: #ddd3bc;
  --line-strong: #c4b79a;
  --text: #1f2326;
  --text-2: #3b423e;
  --muted: #5c645e;
  --primary-bg: #153e32;
  --primary-hover: #1f5546;
  --primary-fg: #f6f1e6;
  --accent: #b38b2d;
  --accent-text: #7a5a12;
  --accent-soft: #f1e6c4;
  --link: #1f5546;
  --ok: #1f6b4a;
  --ok-soft: #dcebe0;
  --warn: #84560a;
  --warn-soft: #f4e6c3;
  --bad: #a03a2b;
  --bad-soft: #f4dcd4;
  --focus: #b38b2d;
  --shadow-1: 0 1px 0 rgb(31 35 38 / .04);
  --shadow-2: 0 1px 2px rgb(31 35 38 / .06), 0 10px 24px -14px rgb(31 35 38 / .22);
  --shadow-3: 0 18px 50px -12px rgb(14 42 34 / .35);

  --radius-s: 4px;
  --radius: 8px;
  --radius-l: 12px;
  --nav-h: 62px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-family: var(--font);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c1a15; --surface: #12231c; --surface-2: #193026; --surface-3: #21392e;
    --line: #28423a; --line-strong: #3a5849; --text: #eee7d4; --text-2: #d3cbb6; --muted: #a2aa9d;
    --primary-bg: #cfae5a; --primary-hover: #dcbf74; --primary-fg: #10201a;
    --accent: #cfae5a; --accent-text: #dcbf74; --accent-soft: #2b3524; --link: #dcbf74;
    --ok: #7fcf9f; --ok-soft: #14301f; --warn: #e3b45c; --warn-soft: #332a12; --bad: #f0907c; --bad-soft: #3a1f19;
    --focus: #dcbf74; --shadow-1: none; --shadow-2: 0 1px 2px rgb(0 0 0 / .4), 0 12px 28px -14px rgb(0 0 0 / .65); --shadow-3: 0 18px 50px -12px rgb(0 0 0 / .75);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1a15; --surface: #12231c; --surface-2: #193026; --surface-3: #21392e;
  --line: #28423a; --line-strong: #3a5849; --text: #eee7d4; --text-2: #d3cbb6; --muted: #a2aa9d;
  --primary-bg: #cfae5a; --primary-hover: #dcbf74; --primary-fg: #10201a;
  --accent: #cfae5a; --accent-text: #dcbf74; --accent-soft: #2b3524; --link: #dcbf74;
  --ok: #7fcf9f; --ok-soft: #14301f; --warn: #e3b45c; --warn-soft: #332a12; --bad: #f0907c; --bad-soft: #3a1f19;
  --focus: #dcbf74; --shadow-1: none; --shadow-2: 0 1px 2px rgb(0 0 0 / .4), 0 12px 28px -14px rgb(0 0 0 / .65); --shadow-3: 0 18px 50px -12px rgb(0 0 0 / .75);
}

/* ---------- base ---------- */
* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.55; min-height: 100svh; overflow-x: hidden; }
h1, h2, h3, h4, p, ul, ol, figure, dl { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
p, li, h1, h2, h3 { overflow-wrap: anywhere; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; top: -80px; left: 12px; z-index: 100; padding: 12px 16px; border-radius: var(--radius-s); background: var(--primary-bg); color: var(--primary-fg); }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
::selection { background: color-mix(in srgb, var(--gold) 38%, transparent); }

.eyebrow { font-size: .7rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.t-display { font-family: var(--serif); font-weight: 600; letter-spacing: -.015em; line-height: 1.14; }
.t-title { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
.t-sub { color: var(--text-2); }
.t-small { font-size: .85rem; }
.t-muted { color: var(--muted); }
.rule { width: 36px; height: 2px; background: var(--gold); border: 0; margin: 0; }
.stack { display: grid; gap: 16px; }
.stack-s { display: grid; gap: 8px; }
.stack-l { display: grid; gap: 30px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1 1 0; }

/* ---------- icons ---------- */
.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.i-s { width: 16px; height: 16px; }
.i-l { width: 28px; height: 28px; }

/* ---------- buttons ---------- */
.btn {
  --h: 46px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--h); padding: 0 22px;
  border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--text);
  font-size: .95rem; font-weight: 600; letter-spacing: .01em; line-height: 1; text-decoration: none; cursor: pointer; user-select: none;
  transition: background-color .18s, color .18s, border-color .18s, box-shadow .18s, transform .18s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--primary { background: var(--primary-bg); color: var(--primary-fg); box-shadow: 0 1px 0 rgb(255 255 255 / .08) inset, 0 1px 2px rgb(14 42 34 / .35); }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 1px 0 rgb(255 255 255 / .1) inset, 0 8px 16px -8px rgb(14 42 34 / .55); }
.btn--primary:active:not(:disabled) { transform: translateY(0); box-shadow: inset 0 2px 3px rgb(0 0 0 / .25); }
.btn--secondary { border-color: var(--text-2); color: var(--text); background: transparent; }
.btn--secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn--ghost { padding: 0 12px; color: var(--link); }
.btn--ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn--accent { background: var(--gold); color: #1d1a0f; }
.btn--accent:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }
.btn--danger { border-color: color-mix(in srgb, var(--bad) 55%, transparent); color: var(--bad); }
.btn--danger:hover:not(:disabled) { background: var(--bad-soft); }
.btn--sm { --h: 36px; padding: 0 14px; font-size: .86rem; border-radius: var(--radius-s); }
.btn--block { width: 100%; }
.btn--icon { width: 44px; padding: 0; }
.btn--icon.btn--sm { width: 36px; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--primary-fg); border-top-color: transparent; animation: spin .7s linear infinite; }
.btn--secondary.is-loading::after, .btn--ghost.is-loading::after { border-color: var(--text); border-top-color: transparent; }
.link-btn { display: inline-flex; align-items: center; min-height: 40px; padding: 0; border: 0; background: none; color: var(--link); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: .82rem; font-weight: 650; color: var(--text-2); }
.hint { font-size: .8rem; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
.textarea { line-height: 1.55; resize: vertical; min-height: 96px; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .75; }
.input:hover, .textarea:hover, .select:hover { border-color: var(--moss); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--forest-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 38%, transparent); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.choice-grid { display: grid; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color .15s, background-color .15s; }
.choice:hover { border-color: var(--moss); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--forest-600); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--gold); }
.choice:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice .mark { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex: none; }
.choice:has(input:checked) .mark { border-color: var(--forest-600); background: var(--forest-600); box-shadow: inset 0 0 0 3px var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--text); font-size: .86rem; font-weight: 560; text-decoration: none; cursor: pointer; transition: background-color .15s, border-color .15s; }
.chip:hover { border-color: var(--moss); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-1); }
.panel--tint { background: var(--surface-2); border-color: transparent; }
.section { display: grid; gap: 14px; }
.section + .section { padding-top: 28px; border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; letter-spacing: -.005em; }
.rule-list > li { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rule-list > li:last-child { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: var(--radius-s); font-size: .72rem; font-weight: 700; letter-spacing: .03em; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--bad { background: var(--bad-soft); color: var(--bad); }
.badge--accent { background: var(--accent-soft); color: var(--accent-text); }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); }
.callout--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.callout--bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.callout--ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.callout .i { margin-top: 2px; color: var(--accent-text); }
.callout--warn .i { color: var(--warn); } .callout--bad .i { color: var(--bad); }

/* ---------- loading / empty ---------- */
.skeleton { position: relative; overflow: hidden; border-radius: var(--radius-s); background: var(--surface-3); min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent); animation: shimmer 1.5s infinite; }
.sk-title { height: 28px; width: 55%; } .sk-block { height: 120px; }
.empty { display: grid; justify-items: start; gap: 10px; padding: 8px 0; max-width: 46ch; }
.empty .i-l { color: var(--moss); }
.empty h3 { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }

/* ---------- shell ---------- */

.app { min-height: 100svh; }
.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; color: var(--text); text-decoration: none; }
.brand em { font-style: italic; font-weight: 500; }
.logo { width: 30px; height: 30px; flex: none; }
.topnav { display: none; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: 700 .88rem var(--serif); text-decoration: none; cursor: pointer; }
.avatar:hover { background: var(--surface-2); }
.main { display: block; }
.main:focus { outline: none; }
.page { width: 100%; max-width: 720px; margin: 0 auto; padding: 28px max(18px, env(safe-area-inset-right)) calc(var(--nav-h) + 36px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
.page--wide { max-width: 960px; }
.page--room { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-top: 4px; }
.page-head { display: grid; gap: 8px; margin-bottom: 4px; }
.page-head h1 { font-family: var(--serif); font-size: clamp(1.7rem, 6vw, 2.2rem); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.page-head p { color: var(--text-2); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 4px max(8px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab { position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 54px; padding: 4px 1px; color: var(--muted); font-size: .68rem; font-weight: 650; letter-spacing: .02em; text-decoration: none; transition: color .15s; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--forest-600); }
:root[data-theme="dark"] .tab[aria-current="page"] { color: var(--accent-text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tab[aria-current="page"] { color: var(--accent-text); } }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -5px; width: 24px; height: 2px; background: var(--gold); }
.tab .i { width: 22px; height: 22px; }
.tab .count { position: absolute; top: 3px; left: calc(50% + 7px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--gold); color: #1d1a0f; font-size: .64rem; font-weight: 800; display: grid; place-items: center; }

.toasts { position: fixed; z-index: 120; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: var(--radius); background: var(--forest-900); color: #f1ead8; box-shadow: var(--shadow-3); font-size: .9rem; border-left: 3px solid var(--gold); animation: rise .22s ease-out; pointer-events: auto; }
.toast--bad { border-left-color: #e08a74; }
.backdrop { position: fixed; inset: 0; z-index: 90; background: rgb(8 20 16 / .6); animation: fade .18s ease-out; }
.sheet { position: fixed; z-index: 100; left: 0; right: 0; bottom: 0; max-height: 88svh; overflow: auto; padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); border-radius: 12px 12px 0 0; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-3); animation: sheet .24s cubic-bezier(.2, .8, .2, 1); }
.sheet .grab { width: 40px; height: 3px; margin: 6px auto 16px; background: var(--line-strong); }
.sheet h2 { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; margin-bottom: 12px; }

/* ---------- landing + auth ---------- */
.landing { min-height: 100svh; }
.land-nav { display: flex; align-items: center; justify-content: space-between; max-width: 1080px; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) 22px 14px; }
.hero { background: var(--forest); color: #f1ead8; }
.hero .brand { color: #f6f1e6; }
.hero-inner { max-width: 1080px; margin: 0 auto; padding: 40px 22px 70px; display: grid; gap: 40px; }
.hero h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(2.2rem, 9vw, 3.7rem); line-height: 1.06; letter-spacing: -.025em; max-width: 15ch; }
.hero h1 em { font-style: italic; color: #e2c680; }
.hero p.lead { max-width: 46ch; color: #cfd8cf; font-size: 1.08rem; }
.hero .eyebrow { color: #e2c680; }
.hero .btn--primary { background: #e2c680; color: #15261f; }
.hero .btn--primary:hover:not(:disabled) { background: #edd596; }
.hero .btn--secondary { border-color: #6f8c7e; color: #f1ead8; }
.hero .btn--secondary:hover:not(:disabled) { background: rgb(255 255 255 / .07); }
.hero .rule { background: #e2c680; }
.hero-art { display: none; }
.hero .student .bubble { background: #274437; color: #f1ead8; }
.hero .teacher .bubble { color: #f1ead8; }
.hero .teacher .who { color: #a9bdb2; }
.hero .noted { color: #a9bdb2; }
.hero .noted .was { color: #f0a998; } .hero .noted .now { color: #a7dcb7; }
.auth-card { background: var(--paper); color: #1f2326; border-radius: var(--radius-l); padding: 26px; box-shadow: var(--shadow-3); display: grid; gap: 16px; border-top: 3px solid var(--gold); }
.auth-card .field > label { color: #3b423e; }
.auth-card .input { background: #fff; color: #1f2326; border-color: #c4b79a; }
.auth-card h2 { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.auth-card .msg--info { color: #3b423e; }
.auth-card .btn--primary { background: #153e32; color: #f6f1e6; }
.auth-card .link-btn { color: #1f5546; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid #ddd3bc; }
.auth-tabs button { min-height: 44px; border: 0; background: none; font-weight: 650; color: #5c645e; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.auth-tabs button[aria-pressed="true"] { color: #1f2326; border-bottom-color: var(--gold); }
.msg { font-size: .88rem; line-height: 1.5; }
.msg:empty { display: none; }
.msg--bad { color: var(--bad); }
.auth-card .msg--bad { color: #a03a2b; }
.msg--info { color: var(--text-2); }
.land-section { max-width: 1080px; margin: 0 auto; padding: 60px 22px 0; display: grid; gap: 22px; }
.land-section h2 { font-family: var(--serif); font-size: clamp(1.7rem, 6vw, 2.5rem); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; max-width: 22ch; }
.steps { display: grid; border-top: 1px solid var(--line-strong); }
.step { display: grid; grid-template-columns: 52px 1fr; gap: 4px 16px; padding: 24px 0; border-bottom: 1px solid var(--line); }
.step .n { font: italic 600 2rem var(--serif); color: var(--accent-text); grid-row: span 2; line-height: 1; }
.step h3 { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.step p { color: var(--text-2); }
.compare { display: grid; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.compare > div { padding: 22px; }
.compare > div + div { border-top: 1px solid var(--line); }
.ba { display: grid; gap: 8px; }
.ba .was { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.ba .now { color: var(--ok); font-weight: 650; }
.land-foot { max-width: 1080px; margin: 0 auto; padding: 52px 22px calc(40px + env(safe-area-inset-bottom)); color: var(--muted); font-size: .86rem; display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; }

/* ---------- the classroom ---------- */
.room { display: flex; flex-direction: column; min-height: calc(100svh - 56px); }
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0 14px; border-bottom: 1px solid var(--line); }
.room-head .who { display: grid; gap: 1px; }
.room-head strong { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
.room-head .status { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.room-head .status::before { content: ""; width: 6px; height: 6px; background: var(--gold); border-radius: 50%; flex: none; }
.thread { display: grid; gap: 22px; padding: 22px 0 26px; align-content: start; flex: 1; }
.day { justify-self: center; font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.msg-row { display: grid; gap: 6px; max-width: 94%; }
.msg-row.student { justify-self: end; justify-items: end; max-width: 86%; }
.bubble { white-space: pre-wrap; line-height: 1.65; }
.student .bubble { padding: 10px 14px; background: var(--surface-3); color: var(--text); border-radius: var(--radius) var(--radius) 2px var(--radius); font-size: .98rem; }
.teacher .bubble { position: relative; padding: 2px 0 2px 16px; font-family: var(--serif); font-size: 1.08rem; line-height: 1.7; color: var(--text); }
.teacher .bubble::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px; background: var(--gold); }
.teacher .who { font-size: .68rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding-left: 16px; }
.teacher .bubble strong { font-weight: 700; }
.noted { padding-left: 16px; font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.noted a { font-weight: 600; }
.noted .was { color: var(--bad); text-decoration: line-through; }
.noted .now { color: var(--ok); font-weight: 650; }
.voice-tag { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted); }
.tools { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 10px; }
.tool { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border: 0; border-radius: var(--radius-s); background: none; color: var(--muted); font-size: .8rem; font-weight: 600; cursor: pointer; }
.tool:hover { background: var(--surface-2); color: var(--text); }
.typing { display: inline-flex; gap: 5px; padding: 8px 0 8px 16px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); animation: bounce 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
.composer-wrap { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 12; padding: 6px 0 12px; background: var(--bg); box-shadow: 0 -12px 14px -12px var(--bg); }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 6px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-2); }
.composer:focus-within { border-color: var(--forest-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 36%, transparent); }
.composer textarea { flex: 1; min-height: 44px; max-height: 140px; padding: 11px 10px; border: 0; outline: none; background: transparent; resize: none; font-size: 16px; line-height: 1.4; }
.composer .btn { flex: none; }
.voice-panel { display: grid; justify-items: center; gap: 14px; padding: 22px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-2); text-align: center; }
.rec-btn { position: relative; width: 74px; height: 74px; border-radius: 50%; border: 0; background: var(--primary-bg); color: var(--primary-fg); display: grid; place-items: center; cursor: pointer; transition: transform .15s; }
.rec-btn:active { transform: scale(.96); }
.rec-btn.is-rec { background: #b3402e; color: #fff; }
.rec-btn.is-rec::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid #b3402e; opacity: .5; animation: pulse 1.4s infinite; }
.rec-btn .i { width: 28px; height: 28px; }
.wave { display: flex; align-items: center; gap: 3px; height: 28px; }
.wave i { width: 3px; background: var(--gold); height: 8px; transition: height .08s; }
.timer { font: 650 1.05rem var(--mono); letter-spacing: .04em; }
.gate { display: grid; gap: 14px; justify-items: start; padding: 22px; border: 1px solid var(--line-strong); border-left: 3px solid var(--gold); border-radius: var(--radius); background: var(--surface); }

/* ---------- mistakes ---------- */
.diff { display: grid; gap: 4px; }
.diff .was { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.diff .now { color: var(--ok); font-weight: 640; }
.count-pill { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: var(--radius-s); background: var(--bad-soft); color: var(--bad); font-size: .78rem; font-weight: 800; }
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.stat-strip > div { padding: 16px 4px; }
.stat-strip > div + div { border-left: 1px solid var(--line); padding-left: 16px; }
.stat-strip strong { display: block; font: 600 2rem/1.1 var(--serif); letter-spacing: -.02em; }
.stat-strip span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.group { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.group > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; cursor: pointer; list-style: none; font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary .i { color: var(--muted); transition: transform .2s; }
.group[open] > summary .i { transform: rotate(90deg); }
.group-body { border-top: 1px solid var(--line); }
.mistake { display: grid; gap: 10px; padding: 16px; }
.mistake + .mistake { border-top: 1px solid var(--line); }
.streak { display: inline-flex; gap: 4px; align-items: center; }
.streak i { width: 18px; height: 5px; background: var(--line-strong); }
.streak i.on { background: var(--ok); }
.practice-box { display: grid; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--surface-2); }
.verdict { display: grid; gap: 10px; padding: 16px 18px; border-radius: var(--radius); border: 1px solid; animation: rise .22s ease-out; }
.verdict--correct { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.verdict--almost { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.verdict--incorrect { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.verdict h3 { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; }
.verdict--correct h3 { color: var(--ok); } .verdict--almost h3 { color: var(--warn); } .verdict--incorrect h3 { color: var(--bad); }

/* ---------- progress / profile ---------- */
.ladder { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.ladder .rung { display: grid; gap: 6px; padding-top: 10px; border-top: 3px solid var(--line-strong); font: 600 1.05rem var(--serif); color: var(--muted); }
.ladder .rung.passed { border-top-color: var(--forest-600); color: var(--text); }
.ladder .rung.here { border-top-color: var(--gold); color: var(--text); }
.ladder .rung.here::after { content: "Aqui, por enquanto"; font: 700 .66rem var(--font); letter-spacing: .04em; color: var(--accent-text); }
.skill { display: grid; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.skill:last-child { border-bottom: 0; }
.bar { height: 6px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--forest-600); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.bar--none { background: repeating-linear-gradient(135deg, var(--surface-3) 0 6px, transparent 6px 12px); }
.metric-row { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.metric-row > div { padding: 16px 4px; border-bottom: 1px solid var(--line); }
.metric-row > div:nth-child(odd) { padding-right: 16px; }
.metric-row > div:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--line); }
.metric-row > div:nth-last-child(-n+2) { border-bottom: 0; }
.metric-row strong { display: block; font: 600 1.8rem/1.1 var(--serif); letter-spacing: -.02em; }
.metric-row span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.concept-list { display: flex; flex-wrap: wrap; gap: 8px; }
.concept { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); font-size: .88rem; }
.concept.solid { border-color: var(--ok); } .concept.weak { border-color: var(--bad); } .concept.practicing { border-color: var(--gold); }
.quote { padding: 16px 18px; border-left: 2px solid var(--gold); background: var(--surface); font-family: var(--serif); font-size: 1.05rem; line-height: 1.65; }
.kv { display: grid; border-top: 1px solid var(--line-strong); }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 620; text-align: right; }
.next-list > li { border-bottom: 1px solid var(--line); }
.next-list > li:last-child { border-bottom: 0; }
.next-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 14px 0; border: 0; background: none; text-align: left; cursor: pointer; color: var(--text); font-weight: 600; text-decoration: none; }
.next-link:hover { color: var(--link); }

/* ---------- admin / owner ---------- */
.student-card { display: grid; gap: 8px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.student-card:last-child { border-bottom: 0; }
.admin-form { display: grid; gap: 12px; align-items: end; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- motion ---------- */
.view-in { animation: viewin .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes viewin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes slide { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes pulse { 0% { transform: scale(.9); opacity: .6; } 100% { transform: scale(1.25); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 359px) {
  .page { padding-inline: 14px; }
  .tab { font-size: .64rem; }
  .stat-strip strong { font-size: 1.6rem; }
}
@media (min-width: 640px) {
  .hero-inner { padding-block: 60px 90px; }
  .compare { grid-template-columns: 1fr 1fr; }
  .compare > div + div { border-top: 0; border-left: 1px solid var(--line); }
  .admin-form { grid-template-columns: 1fr auto; }
  .admin-form.invite { grid-template-columns: 2fr 1fr auto; }
}
@media (min-width: 960px) {
  :root { --nav-h: 0px; }
  .tabbar { display: none; }
  .appbar { padding-inline: max(32px, calc((100vw - 1040px) / 2)); }
  .topnav { display: flex; align-items: center; gap: 4px; margin-right: auto; margin-left: 36px; }
  .topnav a { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; color: var(--text-2); font-weight: 600; font-size: .92rem; text-decoration: none; }
  .topnav a:hover { color: var(--text); }
  .topnav a[aria-current="page"] { color: var(--text); }
  .topnav a[aria-current="page"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -11px; height: 2px; background: var(--gold); }
  .topnav .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #1d1a0f; font-size: .68rem; font-weight: 800; display: grid; place-items: center; }
  .page { padding: 44px 32px 64px; }
  .page--room { padding-bottom: 0; padding-top: 4px; }
  .room { min-height: calc(100svh - 60px); }
  .composer-wrap { bottom: 0; }
  .toasts { bottom: 24px; }
  .hero-inner { grid-template-columns: 1.15fr .85fr; align-items: center; gap: 72px; }
  .hero-art { display: block; }
  .steps { grid-template-columns: repeat(3, 1fr); border-top: 0; gap: 32px; }
  .step { grid-template-columns: 1fr; border-bottom: 0; border-top: 1px solid var(--line-strong); padding: 22px 0 0; }
  .step .n { grid-row: auto; }
  .sheet { left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%); width: min(520px, 92vw); border-radius: 12px; animation: fade .2s; }
}

/* ---------- classroom additions: lesson stage, guidance, install, voice review, offline ---------- */
.stages { display: flex; gap: 2px; list-style: none; margin: 0; padding: 10px 0 0; overflow: hidden; }
.stages li { flex: 1 1 0; min-width: 0; display: grid; gap: 4px; font-size: .62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stages .dot { display: block; height: 3px; background: var(--line-strong); }
.stages .lbl { display: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stages .is-past .dot { background: var(--moss); }
.stages .is-now .dot { background: var(--gold); height: 4px; }
.stages .is-now .lbl { display: block; color: var(--accent-text); }
.guide, .install-card { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--line-strong); border-left: 3px solid var(--gold); border-radius: var(--radius); background: var(--surface); display: grid; gap: 10px; }
.guide-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: .9rem; color: var(--text-2); }
.guide .btn, .install-card .btn { justify-self: start; }
.install-card { grid-template-columns: auto 1fr; align-items: start; }
.install-card .i-l { color: var(--accent-text); margin-top: 2px; }
.install-card .row { flex-wrap: wrap; gap: 8px; }
.install-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.install-steps li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; font-size: .92rem; }
.install-steps .n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: var(--radius-s); background: var(--accent-soft); color: var(--accent-text); font-weight: 800; font-size: .8rem; }
.hear-note { display: grid; gap: 4px; justify-items: end; max-width: 100%; font-size: .78rem; color: var(--warn); text-align: right; }
.net-note { margin: 0 0 8px; padding: 8px 12px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); font-size: .82rem; }
.voice-panel .row { flex-wrap: wrap; justify-content: center; gap: 8px; }
.voice-panel audio { width: 100%; max-width: 360px; }
.voice-panel progress { width: 100%; max-width: 280px; height: 6px; accent-color: var(--gold); }
.gate { scroll-margin-bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
.tools .tool { padding: 0 8px; }
@media (min-width: 420px) { .stages .lbl { display: block; } .stages li:not(.is-now) .lbl { visibility: hidden; } }
.room-head .tool { flex: none; white-space: nowrap; }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
.composer-wrap .install-card { margin: 0 0 8px; padding: 12px 14px; box-shadow: var(--shadow-2); }
