/* Somattery Practice — shared styles for learner and parent pages. */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1d2433;
  --muted: #5d6475;
  --line: #e2ded4;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --good: #1f7a4d;
  --good-bg: #e6f4ec;
  --bad: #a23a2a;
  --bad-bg: #fbeae6;
  --hint-bg: #fff6dc;
  --amber: #e0891c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 6px 20px rgba(20, 24, 40, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171f;
    --surface: #1d212c;
    --ink: #e8eaf0;
    --muted: #a3a9b8;
    --line: #2e3442;
    --accent: #7d9cff;
    --accent-ink: #0d1020;
    --good: #6fd29c;
    --good-bg: #17301f;
    --bad: #ff9a85;
    --bad-bg: #3a1d18;
    --hint-bg: #352d14;
    --amber: #f2a541;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .4rem 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

input, select, button, textarea { font: inherit; }
input, select, textarea {
  width: 100%;
  padding: .65rem .8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
}
label { display: block; margin: .6rem 0; font-weight: 600; font-size: .95rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
input[type=checkbox] { width: auto; }

button {
  cursor: pointer;
  padding: .65rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); padding: .4rem 0; text-decoration: underline; }
button.quiet { color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }

.alert { background: var(--bad-bg); color: var(--bad); padding: .6rem .8rem; border-radius: 10px; }
.ok-msg { background: var(--good-bg); color: var(--good); padding: .6rem .8rem; border-radius: 10px; }

/* Login */
.login { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.login h1 { font-size: 1.8rem; }
.login button { width: 100%; margin-top: .6rem; }
.langs { text-align: center; margin-top: 1rem; }

/* Learner app */
.top {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font-weight: 700; }
.hud { display: flex; align-items: center; gap: .6rem; flex: 1; flex-wrap: wrap; justify-content: flex-end; }
.hud-level { display: flex; align-items: center; gap: .5rem; min-width: 160px; }
.hud-level .bar { width: 90px; }
.chip {
  display: inline-block; padding: .15rem .6rem; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); font-size: .85rem; white-space: nowrap;
}
.chip.small { font-size: .75rem; margin-left: .4rem; }
.chip.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.app, .goals { max-width: 720px; margin: 1.25rem auto; padding: 0 16px; }
.eyebrow { font-size: .85rem; color: var(--muted); text-transform: none; margin-bottom: .5rem; }
.statement { font-size: 1.2rem; font-weight: 500; }
.statement.small { font-size: 1rem; }
.gloss { font-size: .9rem; color: var(--muted); font-style: italic; }
.lead { font-size: 1.1rem; }
.big { font-size: 1.3rem; font-weight: 600; }
.good { color: var(--good); }

.answer { display: flex; gap: .6rem; margin: 1rem 0 .4rem; }
.answer input { flex: 1; font-size: 1.15rem; }
.actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: .8rem; }

.steps { margin: 1rem 0; padding: 1rem; border: 1px dashed var(--line); border-radius: var(--radius); }
.step { display: grid; grid-template-columns: 1fr 9rem 1.5rem; gap: .6rem; align-items: center; font-weight: 500; }
.step input { margin: 0; }
.step .mark { font-weight: 700; text-align: center; }
.step.is-ok .mark { color: var(--good); }
.step.is-ok input { border-color: var(--good); }
.step.is-wrong .mark { color: var(--bad); }
.step.is-wrong input { border-color: var(--bad); }
.step.is-round .mark { color: var(--amber); }
.step.is-round input { border-color: var(--amber); }
.steps button { margin-top: .4rem; }

.choices { display: grid; gap: .5rem; margin: 1rem 0; }

.feedback p { padding: .55rem .8rem; border-radius: 10px; margin: .5rem 0; }
.feedback.good .fb-msg { background: var(--good-bg); color: var(--good); }
.feedback.bad .fb-msg { background: var(--bad-bg); color: var(--bad); }
.fb-mis { background: var(--bg); border: 1px solid var(--line); }
.fb-hint { background: var(--hint-bg); }

.worked { background: var(--bg); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; }
.solution { padding-left: 1.3rem; }
.solution li { margin: .35rem 0; }

.bar { height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.goals h2 { margin-top: .5rem; }
.goal { margin: .6rem 0; }
.goal.reached { border-color: var(--good); }
.goal-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.goal-row { margin: .4rem 0; font-size: .9rem; color: var(--muted); }
.goal-row .bar { margin-top: .25rem; }
.goal-reached { color: var(--good); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  max-width: calc(100% - 32px); background: var(--ink); color: var(--bg);
  padding: .7rem 1rem; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600;
}

/* Parent dashboard */
.wrap { max-width: 960px; margin: 1.25rem auto; padding: 0 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.stack > * + * { margin-top: 1rem; }
.kpis { display: flex; gap: 1rem; flex-wrap: wrap; }
.kpi { flex: 1; min-width: 120px; background: var(--bg); border-radius: 10px; padding: .6rem .8rem; }
.kpi strong { display: block; font-size: 1.4rem; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .45rem .3rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.inline { display: inline; }
.checkbox { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.checkbox input { width: auto; }
.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: var(--surface); }
.tabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

@media (max-width: 640px) {
  .top { display: grid; grid-template-columns: 1fr auto; row-gap: .5rem; }
  .hud { grid-row: 2; grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 520px) {
  .step { grid-template-columns: 1fr 6.5rem 1.2rem; font-size: .9rem; }
  .answer { flex-direction: column; }
}

/* Visuals: share-out blocks and bar charts */
.viz { margin: 1rem 0; padding: 1rem; background: var(--bg); border-radius: var(--radius); }
.viz svg { display: block; width: 100%; max-width: 460px; height: auto; }
.viz .blk { fill: var(--accent); transition: transform .7s cubic-bezier(.3,.7,.3,1), fill .3s; }
.viz .blk.moved { fill: var(--amber); }
.viz .ghost { fill: none; stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 4 3; opacity: 0; transition: opacity .4s; }
.viz .ghost.on { opacity: .7; }
.viz .bar-r { fill: var(--accent); }
.viz .bar-r.hi { fill: var(--amber); }
.viz .bar-r.faded { fill: color-mix(in srgb, var(--accent) 30%, var(--bg)); }
.viz .chart-title { fill: var(--ink); font-weight: 700; font-size: 15px; }
.viz-multi { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .5rem; }
.viz-multi .viz { margin: .5rem 0; }
.viz .bar-r.below { fill: color-mix(in srgb, var(--accent) 45%, var(--bg)); }
.viz .axis { stroke: var(--line); stroke-width: 2; }
.viz .mean-line { stroke: var(--amber); stroke-width: 2.5; stroke-dasharray: 7 5; }
.viz .mean { transition: opacity .4s; }
.viz .mean-text { fill: var(--amber); font-weight: 700; font-size: 14px; }
.viz .val { fill: var(--ink); font-size: 13px; font-weight: 600; }
.viz .val.in { fill: #ffffff; }
.viz .cap { fill: var(--muted); font-size: 12px; }
.viz figcaption, .viz .small { font-size: .85rem; margin: .4rem 0 0; }
@media (prefers-reduced-motion: reduce) { .viz .blk, .viz .mean { transition: none; } }

/* Progress strip above each exercise */
.progress { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center;
  padding: .6rem .8rem; margin: -.25rem 0 .9rem; background: var(--bg); border-radius: 10px; font-size: .85rem; }
.pg-item { display: flex; align-items: center; gap: .45rem; }
.pg-item.grow { flex: 1; min-width: 160px; }
.pg-item.grow .bar { flex: 1; }
.pg-label { color: var(--muted); }
.pg-val { font-weight: 600; }
.dots { display: inline-flex; gap: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--accent); }
.dot.on { background: var(--good); border-color: var(--good); }
.stars { color: var(--amber); letter-spacing: 1px; font-size: 1rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .5rem; }
.chip.new { background: var(--amber); color: #1d2433; border-color: var(--amber); font-weight: 600; }
.daily-done { background: var(--good-bg); color: var(--good); padding: .7rem .9rem; border-radius: 10px; margin: .6rem 0; }
.daily-done p { margin: .2rem 0 0; }

/* ---------- v0.3 ---------- */

/* Topic title above every card */
.chapter { margin: 0 0 .8rem; }
.chapter-label { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.chapter-title { font-size: 1.6rem; margin: .1rem 0 0; }

/* Level badge + star row */
.hud-level { min-width: 0; }
.level-badge { font-weight: 700; white-space: nowrap; display: inline-block; }
.level-badge.level-pop { animation: levelPop .9s ease; color: var(--amber); }
@keyframes levelPop { 0% { transform: scale(1); } 40% { transform: scale(1.5); } 100% { transform: scale(1); } }
.star-row { display: inline-flex; gap: 3px; }
.star-slot { font-size: 1.2rem; line-height: 1; color: transparent; -webkit-text-stroke: 1.4px var(--amber); transition: color .3s; }
.star-slot.on { color: var(--amber); }
.star-slot.pop { animation: starPop .5s ease; }
@keyframes starPop { 0% { transform: scale(.4); } 60% { transform: scale(1.5); } 100% { transform: scale(1); } }
.star-row.merge .star-slot { animation: starMerge .6s ease forwards; }
@keyframes starMerge { to { transform: translateX(-60px) scale(.2); opacity: 0; } }
.flying-star { position: fixed; z-index: 50; width: 40px; height: 40px; font-size: 40px; line-height: 40px; text-align: center;
  color: var(--amber); text-shadow: 0 2px 8px rgba(0,0,0,.25); pointer-events: none;
  transition: transform .85s cubic-bezier(.5,-0.3,.4,1.2); }

/* "Correct!" confirmation */
.correct-banner { display: flex; align-items: center; gap: .8rem; margin: .4rem 0 .2rem; }
.correct-banner .check { width: 56px; height: 56px; border-radius: 50%; background: var(--good); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700;
  animation: checkIn .5s cubic-bezier(.3,1.6,.5,1); }
.correct-word { font-size: 1.7rem; font-weight: 800; color: var(--good); animation: fadeUp .5s ease .1s both; }
@keyframes checkIn { from { transform: scale(0) rotate(-45deg); } to { transform: scale(1) rotate(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Difficulty as signal bars */
.diff-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 20px; }
.diff-bar { width: 6px; border-radius: 2px; background: var(--line); }
.diff-bar.on { background: var(--accent); }

/* Tools: calculator and rounding help */
.tools { display: flex; gap: .5rem; flex-wrap: wrap; margin: .2rem 0 .6rem; }
.tool { font-size: .9rem; padding: .4rem .8rem; border-radius: 999px; }
.tool.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.calc { flex: 0 1 300px; max-width: 300px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin-bottom: .8rem; }
.calc-display { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .7rem;
  text-align: right; font-variant-numeric: tabular-nums; }
.calc-expr { font-size: .95rem; color: var(--muted); min-height: 1.3rem; line-height: 1.35;
  white-space: normal; word-break: normal; overflow-wrap: break-word; }
.calc-result { font-size: 1.5rem; font-weight: 700; min-height: 2rem; overflow-wrap: anywhere; }
.calc-result.preview { color: var(--muted); font-weight: 500; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; margin-top: .5rem; }
.calc-key { padding: .55rem 0; font-size: 1.05rem; }
.calc-key.op { background: color-mix(in srgb, var(--accent) 15%, var(--surface)); font-weight: 700; }

/* Step info */
.step-label { display: flex; align-items: center; gap: .4rem; }
.info-btn { width: 22px; height: 22px; padding: 0; border-radius: 50%; font-size: .75rem; font-weight: 700; font-style: italic;
  font-family: Georgia, serif; flex: none; line-height: 20px; color: var(--accent); border-color: var(--accent); }
.step-info { margin: .1rem 0 .6rem; padding: .5rem .7rem; background: var(--hint-bg); border-radius: 8px; font-size: .9rem; }

/* Problem drawn: unknown value */
.viz .bar-r.unknown { fill: none; stroke: var(--amber); stroke-width: 2; stroke-dasharray: 5 4; }

/* Notices */
.notice { background: var(--hint-bg); padding: .6rem .8rem; border-radius: 10px; font-weight: 600; }
.feedback.warn .fb-msg { background: var(--hint-bg); color: var(--ink); border: 1px solid var(--amber); }
.actions.foot { border-top: 1px solid var(--line); padding-top: .6rem; margin-top: 1rem; }
.small { font-size: .9rem; }
.intro h2 { font-size: 1.3rem; }

/* Rewards */
.goal-empty { background: var(--hint-bg); padding: .6rem .8rem; border-radius: 10px; }
.goal-left { font-weight: 600; margin: .1rem 0 .4rem; }

/* Rounding cascade */
.rounding .rounding-title { font-weight: 700; margin-bottom: .2rem; }
.rounding-ex { margin: .8rem 0; }
.digits { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.digit { display: inline-flex; width: 1.4em; height: 1.6em; align-items: center; justify-content: center;
  border-radius: 6px; background: var(--surface); border: 1px solid var(--line); transition: all .4s; }
.digit.sep, .digit.int { border-color: transparent; background: none; width: auto; padding: 0 .1em; }
.rounding-ex .arrow, .rounding-ex .result, .rounding-ex .explain { opacity: 0; transition: opacity .4s; }
.rounding-ex .arrow { color: var(--amber); font-weight: 700; }
.rounding-ex .result { margin-left: .6rem; font-weight: 700; color: var(--good); }
.rounding-ex.s1 .digit[data-i="2"] { background: var(--amber); color: #1d2433; border-color: var(--amber); transform: translateY(-4px); }
.rounding-ex.s2 .arrow { opacity: 1; }
.rounding-ex.s2 .digit[data-i="1"] { outline: 3px solid var(--amber); }
.rounding-ex.s3 .digit[data-i="1"] { background: var(--good-bg); color: var(--good); font-weight: 700; }
.digit.bump { animation: starPop .5s ease; }
.rounding-ex.s4 .digit[data-i="2"], .rounding-ex.s4 .digit[data-i="3"] { opacity: .2; transform: translateY(6px); background: none; border-style: dashed; }
.rounding-ex.s4 .result, .rounding-ex.s4 .explain { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .star-slot.pop, .level-badge.level-pop, .correct-banner .check, .correct-word, .digit.bump { animation: none; }
  .flying-star, .digit { transition: none; }
}
@media (max-width: 520px) {
  .chapter-title { font-size: 1.3rem; }
  .star-slot { font-size: 1rem; }
}

/* v0.3.1: course plan */
.chapter { display: flex; justify-content: space-between; align-items: flex-end; gap: .8rem; flex-wrap: wrap; }
.plan-btn { white-space: nowrap; }
.plan h3.term { margin: 1.2rem 0 .4rem; font-size: .9rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.plan-units { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.unit { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; background: var(--surface); }
.unit.soon { opacity: .6; background: var(--bg); }
.unit.current { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.unit-head { display: flex; justify-content: space-between; gap: .6rem; align-items: center; flex-wrap: wrap; }
.unit-meta { display: inline-flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.unit-state { font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.unit-state.s-mastered { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.unit-state.s-in_progress { background: var(--hint-bg); }
.unit-bar { display: flex; align-items: center; gap: .5rem; margin-top: .45rem; }
.unit-bar .bar { flex: 1; }
.unit-node { margin: .25rem 0 0; color: var(--muted); }
.unit-contents { margin: .3rem 0 0; color: var(--muted); line-height: 1.4; }
.unit.soon .unit-contents { opacity: .85; }
.chip.small.accent { background: var(--accent); color: var(--accent-ink); }
#plan table { table-layout: fixed; }
#plan td:first-child { width: 55%; }
#plan td:nth-child(2) { width: 20%; }

/* Whiteboard next to the calculator (v0.3.2) */
.calc-wrap { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-start; margin-bottom: .8rem; }
.calc-wrap .calc { margin-bottom: 0; }
.board { flex: 1 1 240px; max-width: 360px; background: var(--bg); border: 1px dashed var(--line); border-radius: var(--radius); padding: .8rem; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }
.board-count { color: var(--muted); font-size: .85rem; }
.board-save { width: 100%; margin-bottom: .5rem; }
.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.board-empty { color: var(--muted); font-size: .9rem; }
.board-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: .35rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .3rem .4rem; }
.board-value { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; min-width: 3ch; padding: 0 .2rem; }
.board-label { min-width: 0; width: 100%; font-size: .85rem; padding: .25rem .4rem; }
.board-insert { padding: .3rem .55rem; font-size: .85rem; border-color: var(--accent); color: var(--accent); }
.board-remove { padding: .3rem .5rem; font-size: .85rem; color: var(--muted); }
.board-msg { margin: .4rem 0 0; font-size: .85rem; color: var(--muted); min-height: 0; }
.board-msg:empty { display: none; }
@media (max-width: 640px) { .calc-wrap .calc, .board { flex-basis: 100%; max-width: none; } }

/* Home menu, exams and hooks (v0.4) */
.chapter-tools { display: flex; gap: .4rem; flex-wrap: wrap; }
.home h3 { margin: 1.2rem 0 .5rem; font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; }
.subject { display: flex; flex-direction: column; gap: .35rem; padding: .8rem .9rem; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg); }
.subject .actions { margin-top: .2rem; align-items: center; }
.subject.soon { opacity: .6; border-style: dashed; }
.exam-card { padding: .8rem .9rem; border-radius: 12px; border: 1px solid var(--amber); background: var(--hint-bg); margin-bottom: .6rem; }
.exam-card.ask { border-color: var(--accent); background: var(--bg); }
.exam-card p { margin: .3rem 0; }
.exam-head { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; align-items: baseline; }
.exam-when { font-weight: 600; }
.exam-when.soon { color: var(--bad); }
.exam-line { display: grid; grid-template-columns: 1fr minmax(80px, 160px); gap: .6rem; align-items: center;
  padding: .45rem .7rem; border-radius: 10px; background: var(--hint-bg); font-size: .9rem; margin-bottom: .5rem; }
.exam-line.done { background: var(--good-bg); color: var(--good); }
.exam-done, .hook-unlocked { padding: .55rem .8rem; border-radius: 10px; background: var(--hint-bg); margin: .5rem 0; }
.exam-form label { display: flex; flex-direction: column; gap: .25rem; }
.exam-form fieldset.units { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .8rem; display: grid; gap: .2rem; }
.exam-form .unit-check { flex-direction: row; align-items: center; gap: .3rem; font-size: .95rem; }
.hook { border-top: 4px solid var(--amber); }
.hook-top { display: flex; justify-content: space-between; align-items: center; }
.hook-top .eyebrow { margin: 0; }
.hook-scene { white-space: pre-line; }
blockquote.hook-scene { margin: .4rem 0; padding: .6rem .9rem; border-left: 4px solid var(--amber); background: var(--bg); border-radius: 0 10px 10px 0; }
.hook-by { color: var(--muted); margin-bottom: 0; }
.hook-question { font-weight: 700; font-size: 1.1rem; }
.hook-choices { display: grid; gap: .45rem; }
.hook-choice { text-align: left; }
.hook-choice:disabled { opacity: 1; color: var(--muted); }
.hook-choice.picked { color: var(--ink); }
.hook-choice.picked { border-color: var(--accent); border-width: 2px; }
.hook-choice.right { background: var(--good-bg); color: var(--good); border-color: var(--good); opacity: 1; }
.hook-verdict { font-weight: 700; margin: .6rem 0 .2rem; }
.hook-verdict.good { color: var(--good); }
.hook-verdict.warn { color: var(--amber); }
.hook-explain { background: var(--bg); padding: .7rem .9rem; border-radius: 10px; }
.hook-video { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; margin: .5rem 0; }
.hook-video iframe, .hook-thumb { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.hook-thumb { padding: 0; border-radius: 0; background: #000; }
.hook-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: .75; }
.hook-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, .7);
  color: #fff; padding: .5rem 1rem; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.hook-image { max-width: 100%; max-height: 320px; border-radius: 12px; display: block; margin: .5rem 0; }
.where textarea { width: 100%; font: inherit; padding: .6rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
/* Parent: hooks */
.hook-row { border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; margin-bottom: .6rem; }
.hook-row.pending { border-color: var(--amber); }
.hook-row.rejected { opacity: .55; }
.hook-row p { margin: .25rem 0; }
.hook-row .meta { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.tag-grid { display: flex; flex-wrap: wrap; gap: .2rem .9rem; }
.tag-grid label { display: inline-flex; gap: .3rem; align-items: center; }
.alert-text { color: var(--bad); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .8rem .7rem; margin: 0; }
legend { padding: 0 .3rem; color: var(--muted); font-size: .9rem; }
.home-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.home-head h2 { margin: 0; }
.exam-card .unit-bar { display: grid; grid-template-columns: 1fr; gap: .3rem; margin: .4rem 0; }

/* ---------------------------------------------------------------- v0.5: admin, tickets, chat */
.top-links { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.wrap.wide { max-width: 1280px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.btn { display: inline-block; padding: .5rem .9rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); text-decoration: none; font-size: .95rem; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: .25rem; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; display: grid; }
.stat-n { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: .82rem; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.users { min-width: 920px; font-size: .9rem; }
table.users th, table.users td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.users th { font-size: .78rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.users .num { text-align: right; font-variant-numeric: tabular-nums; }
table.users tr.off td { opacity: .55; }
table.users tr.sel td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 80px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.spark-bar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }

/* Companion panel: chat with Somattery + suggestions (lavender, like the first Somattery chat) */
:root { --cp-bg: #f4f1fd; --cp-head: #e6e1fa; --cp-in: #ffffff; --cp-out: #c9bff0; --cp-out-ink: #1d1838; --cp-accent: #6f5cc4; --cp-w: 390px; }
@media (prefers-color-scheme: dark) {
  :root { --cp-bg: #1a1826; --cp-head: #25213a; --cp-in: #262338; --cp-out: #4b3f8f; --cp-out-ink: #f1eeff; --cp-accent: #a99bf0; }
}
.cp-launch {
  position: fixed; right: 16px; bottom: 16px; z-index: 40; width: 60px; height: 60px; padding: 0; border-radius: 50%;
  border: 3px solid var(--surface); background: var(--cp-head); box-shadow: 0 4px 16px rgba(20, 16, 50, .25); overflow: hidden;
  display: grid; place-items: center; font-size: 1.6rem;
}
.cp-launch img { width: 100%; height: 100%; object-fit: cover; }
body.cp-open .cp-launch { display: none; }
body:has(.cp-launch) main { padding-bottom: 84px; }
.cp {
  position: fixed; z-index: 50; background: var(--cp-bg); display: flex; flex-direction: column;
  inset: 0; border-left: 1px solid var(--line);
}
@media (min-width: 1100px) {
  .cp { inset: 0 0 0 auto; width: var(--cp-w); box-shadow: -6px 0 24px rgba(20, 16, 50, .08); }
  body.cp-open { padding-right: var(--cp-w); }
}
.cp-head { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; background: var(--cp-head); }
.cp-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.cp-title { flex: 1; display: grid; line-height: 1.2; min-width: 0; }
.cp-node { font-size: .78rem; color: var(--cp-accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-close { border: 0; background: none; font-size: 1.1rem; padding: .3rem .5rem; color: var(--muted); }
.cp-tabs { display: flex; gap: .3rem; padding: .4rem .6rem 0; background: var(--cp-head); }
.cp-tabs button { border: 0; border-radius: 10px 10px 0 0; background: transparent; padding: .45rem .8rem; font-size: .92rem; color: var(--muted); }
.cp-tabs button[aria-selected="true"] { background: var(--cp-bg); color: var(--ink); font-weight: 600; }
.cp-banner { margin: 0; padding: .5rem .8rem; background: var(--hint-bg); font-size: .85rem; border-bottom: 1px solid var(--line); }
.cp-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.cp-msgs { flex: 1; overflow-y: auto; padding: .8rem; display: flex; flex-direction: column; gap: .45rem; }
.cp-row { display: flex; align-items: flex-end; gap: .4rem; }
.cp-row.out { justify-content: flex-end; }
.cp-mini { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; }
.cp-bubble { max-width: 82%; padding: .5rem .75rem; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; line-height: 1.45; }
.cp-bubble.in { background: var(--cp-in); border-bottom-left-radius: 4px; box-shadow: 0 1px 1px rgba(0,0,0,.04); }
.cp-bubble.out { background: var(--cp-out); color: var(--cp-out-ink); border-bottom-right-radius: 4px; }
.cp-bubble.guarded { border: 1px dashed var(--cp-accent); }
.cp-divider { display: flex; align-items: center; gap: .5rem; color: var(--cp-accent); font-size: .75rem; margin: .4rem 0; }
.cp-divider::before, .cp-divider::after { content: ""; flex: 1; border-top: 1px solid currentColor; opacity: .35; }
.cp-day { align-self: center; font-size: .72rem; color: var(--muted); background: var(--cp-head); padding: .1rem .6rem; border-radius: 999px; margin: .3rem 0; }
.cp-older { align-self: center; font-size: .85rem; }
.cp-note { align-self: center; font-size: .85rem; color: var(--muted); text-align: center; margin: .3rem 0; }
.dots { letter-spacing: 2px; animation: cp-pulse 1.2s ease-in-out infinite; }
@keyframes cp-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .dots { animation: none; } }
.cp-form { display: flex; align-items: flex-end; gap: .4rem; padding: .6rem; border-top: 1px solid var(--line); background: var(--cp-head); }
.cp-form textarea { flex: 1; resize: none; min-height: 42px; max-height: 140px; border-radius: 20px; padding: .55rem .9rem; font: inherit; font-size: 16px; }
.cp-form.busy .cp-send { opacity: .5; }
.cp-send, .cp-end { width: 42px; height: 42px; padding: 0; border-radius: 50%; flex: none; }
.cp-send { background: var(--cp-accent); color: #fff; border-color: var(--cp-accent); }
.cp-end { color: var(--muted); }
.cp-fb { padding: .9rem; overflow-y: auto; display: grid; gap: .6rem; align-content: start; }
.cp-fb label { display: grid; gap: .25rem; font-size: .9rem; }
.cp-fb-list { display: grid; gap: .4rem; }
.cp-fb-item { display: grid; gap: .15rem; text-align: left; background: var(--surface); }

/* Tickets (parents) */
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.ticket-list { display: grid; gap: .5rem; }
.ticket-row { display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center; text-decoration: none; color: var(--ink); padding: .8rem 1rem; }
.ticket-row:hover { border-color: var(--accent); }
.tk-icon { font-size: 1.3rem; }
.tk-main { display: grid; gap: .15rem; min-width: 0; }
.tk-side { display: grid; justify-items: end; gap: .25rem; }
.st-open { background: #e8f0ff; } .st-planned { background: #fff3d6; } .st-in_progress { background: #e8e1ff; }
.st-done { background: var(--good-bg); color: var(--good); } .st-declined { opacity: .7; }
@media (prefers-color-scheme: dark) { .st-open { background: #1e2a44; } .st-planned { background: #3a3014; } .st-in_progress { background: #2b2450; } }
.comment { border-top: 1px solid var(--line); padding: .6rem 0; }
.comment.mine { background: color-mix(in srgb, var(--accent) 5%, transparent); }
details.orig summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
details > summary.btn { list-style: none; cursor: pointer; }
details > summary.btn::-webkit-details-marker { display: none; }
@media (max-width: 640px) { .ticket-row { grid-template-columns: auto 1fr; } .tk-side { grid-column: 2; justify-items: start; grid-auto-flow: column; } }

/* Parent: conversations */
.convo-day { margin-top: .8rem; }
.convo-day h4 { margin: .4rem 0; font-size: .85rem; color: var(--muted); }
.convo .cp-bubble { max-width: 90%; }
.import-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.import-row select { max-width: 260px; }
.cp-exam { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .5rem .8rem;
  background: #fdf1dc; border-bottom: 1px solid var(--line); font-size: .85rem; font-weight: 600; }
@media (prefers-color-scheme: dark) { .cp-exam { background: #3a2e14; } }
.skill-map { display: grid; gap: .15rem; margin: .3rem 0; }
.skill-map p { margin: 0; }
.skill-gap strong { color: var(--bad); } .skill-partial strong { color: var(--amber); } .skill-ok strong { color: var(--good); }
/* Costs */
.stat-link { text-decoration: none; color: inherit; } .stat-link:hover { border-color: var(--accent); }
.spark.tall { height: 140px; }
table.users tr.fam td { border-top: 2px solid var(--line); background: color-mix(in srgb, var(--accent) 4%, transparent); }
table.users tr.member td { font-size: .85rem; }
.share { display: inline-block; width: 60px; height: 6px; background: var(--line); border-radius: 3px; vertical-align: middle; overflow: hidden; }
.share span { display: block; height: 100%; background: var(--accent); }
