:root {
  --bg: #f5f6fb; --card: #ffffff; --ink: #141a33; --muted: #5a6385; --line: #e2e6f1;
  --brand: #4f46e5; --brand-ink: #ffffff; --good: #15803d; --bad: #dc2626; --warn: #b45309;
  --c-S: #2563eb; --c-V: #dc2626; --c-O: #15803d; --c-IO: #0f766e; --c-C: #9333ea; --c-A: #c2410c; --c-M: #be185d; --c-X: #475569;
  --shadow: 0 1px 2px rgba(20, 26, 51, .06), 0 6px 20px rgba(20, 26, 51, .06);
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1120; --card: #161b31; --ink: #eef0fb; --muted: #9aa3c7; --line: #262d4d;
    --brand: #8b93ff; --brand-ink: #0d1120; --good: #4ade80; --bad: #f87171; --warn: #fbbf24;
    --c-S: #60a5fa; --c-V: #f87171; --c-O: #4ade80; --c-IO: #2dd4bf; --c-C: #c084fc; --c-A: #fb923c; --c-M: #f472b6; --c-X: #94a3b8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); margin: .2em 0 .3em; letter-spacing: -.02em; line-height: 1.15; }
h2 { font-size: 1.25rem; margin: 1.6em 0 .5em; letter-spacing: -.01em; }
h2 small { display: block; font-size: .85rem; font-weight: 400; color: var(--muted); }
h3 { font-size: 1.05rem; margin: 0 0 .5em; }
p { margin: .4em 0; }
a { color: var(--brand); }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 60ch; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; padding: 0 10px 18px; letter-spacing: -.02em; }
.brand i { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, var(--c-S), var(--c-C)); display: grid; place-items: center; color: #fff; font-style: normal; font-size: 1rem; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--ink); text-decoration: none; font-weight: 600; }
.nav a span:first-child { font-size: 1.2rem; width: 1.5rem; text-align: center; }
.nav a:hover { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.nav a.on { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
main { padding: 26px clamp(16px, 4vw, 48px) 80px; max-width: 1000px; width: 100%; margin: 0 auto; outline: none; }
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.top .brand-m { display: none; font-weight: 800; }
.gear { position: fixed; top: 12px; right: 14px; z-index: 25; }
.icon-btn { margin-left: auto; border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 42px; height: 42px; border-radius: 12px; cursor: pointer; font-size: 1.1rem; }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); z-index: 30; }
  .side .brand { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-between; }
  .nav a { flex-direction: column; gap: 0; font-size: .68rem; padding: 6px 4px; flex: 1; text-align: center; }
  .top .brand-m { display: block; }
  main { padding-bottom: 100px; }
}

/* ---------- generic ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); margin: 14px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.grid .card { margin: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }
.gap { gap: 10px; }
.btn { font: inherit; font-weight: 650; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 10px 16px; border-radius: 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.big { padding: 14px 26px; font-size: 1.1rem; border-radius: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input { font: inherit; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-height: 44px; }
.input.grow { flex: 1; min-width: 180px; }
textarea.input { width: 100%; min-height: 110px; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.segctl { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.segctl button { font: inherit; font-weight: 600; font-size: .9rem; border: 0; background: transparent; color: var(--muted); padding: 9px 14px; cursor: pointer; min-height: 40px; }
.segctl button.on { background: var(--brand); color: var(--brand-ink); }

/* ---------- role colors ---------- */
.r-S { --rc: var(--c-S); } .r-V { --rc: var(--c-V); } .r-O { --rc: var(--c-O); } .r-IO { --rc: var(--c-IO); }
.r-C { --rc: var(--c-C); } .r-A { --rc: var(--c-A); } .r-M { --rc: var(--c-M); } .r-X { --rc: var(--c-X); } .r-N { --rc: var(--muted); }
.sentence { font-size: clamp(1.3rem, 3.4vw, 2rem); line-height: 1; margin: 0; font-weight: 500; padding: .2em 0; }
.seg { display: inline-flex; flex-direction: column; align-items: center; margin: .28em .08em; padding: .12em .38em .02em; border-radius: .42em;
  background: color-mix(in srgb, var(--rc) 15%, transparent); font: inherit; color: inherit; border: 0; transition: transform .15s, outline-color .15s; line-height: 1.25; }
.seg .tag { font-size: .5em; text-transform: uppercase; font-weight: 800; letter-spacing: .08em; color: var(--rc); line-height: 1.6; }
.seg[data-i], button.seg { cursor: pointer; }
.seg[data-i]:hover, button.seg:hover { transform: translateY(-2px); }
.seg.sel, .seg.active { outline: 3px solid var(--rc); outline-offset: 1px; transform: translateY(-2px); }
.r-S .w { text-decoration: underline solid var(--rc) 2px; text-underline-offset: .12em; }
.r-V .w { font-weight: 800; }
.r-O .w { text-decoration: underline dotted var(--rc) 3px; text-underline-offset: .12em; }
.r-IO .w { text-decoration: underline dashed var(--rc) 2px; text-underline-offset: .12em; }
.r-C .w { text-decoration: underline wavy var(--rc) 2px; text-underline-offset: .12em; }
.r-A .w { font-style: italic; }
.r-M .w { text-decoration: underline double var(--rc) 2px; text-underline-offset: .12em; }
.r-X .w { font-weight: 700; font-style: italic; letter-spacing: .02em; }
.mode-color .tag, .mode-neutral .tag { display: none; }
.mode-plain .seg { background: none; padding-left: .12em; padding-right: .12em; }
.mode-plain .w { text-decoration: none !important; font-weight: inherit !important; font-style: normal !important; }
.mode-plain .tag { visibility: hidden; }
.seg.neutral { --rc: var(--muted); background: color-mix(in srgb, var(--muted) 14%, transparent); }
.seg.ok { --rc: var(--good); background: color-mix(in srgb, var(--good) 28%, transparent); outline: 3px solid var(--good); }
.seg.no { --rc: var(--bad); background: color-mix(in srgb, var(--bad) 28%, transparent); outline: 3px solid var(--bad); }
.chip { display: inline-grid; place-items: center; min-width: 2.1em; padding: .15em .55em; border-radius: 999px; font-weight: 800; font-size: .8rem; color: var(--rc); background: color-mix(in srgb, var(--rc) 16%, transparent); border: 1.5px solid var(--rc); }
.chip.big { font-size: 1rem; min-width: 2.6em; }
.formula { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.formula .plus { color: var(--muted); font-weight: 700; }
.formula .lbl { font-size: .8rem; color: var(--muted); margin-right: 4px; font-weight: 600; }
.formula.mini .chip { font-size: .7rem; padding: .05em .45em; }

/* ---------- home ---------- */
.tasks { display: grid; gap: 10px; margin-top: 10px; }
.task { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); text-decoration: none; color: var(--ink); }
.task:hover { border-color: var(--brand); }
.task .check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; }
.task.done .check { background: var(--good); border-color: var(--good); }
.task b { display: block; } .task small { color: var(--muted); } .task .count { margin-left: auto; font-weight: 800; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat b { display: block; font-size: 1.5rem; letter-spacing: -.02em; line-height: 1.2; }
.stat span { font-size: .8rem; color: var(--muted); }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.key { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.key small { display: block; color: var(--muted); }
.steps { counter-reset: s; display: grid; gap: 8px; padding: 0; list-style: none; margin: 8px 0 0; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: baseline; }
.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; font-size: .85rem; }

/* ---------- learn ---------- */
.sent-card { display: block; text-decoration: none; color: var(--ink); position: relative; }
.sent-card:hover { border-color: var(--brand); }
.sent-card .plain { font-weight: 600; font-size: 1.05rem; }
.sent-card .seen { position: absolute; top: 10px; right: 12px; font-size: .75rem; color: var(--good); font-weight: 700; }
.stage { padding: 14px 22px 18px; }
.ladder { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; }
.ladder .lbl { font-weight: 700; color: var(--muted); font-size: .9rem; }
.detail .here { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--rc, var(--brand)) 10%, transparent); }
.qchain { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.qchain li { display: grid; grid-template-columns: 1fr auto 1.6fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 12px; background: color-mix(in srgb, var(--rc) 10%, transparent); border-left: 5px solid var(--rc); }
.qchain .q { color: var(--muted); font-size: .9rem; }
.qchain .t { font-weight: 700; }
@media (max-width: 560px) { .qchain li { grid-template-columns: 1fr auto; } .qchain .arrow { display: none; } .qchain .t { grid-column: 1 / -1; order: 3; } }

/* ---------- spot / shadow ---------- */
.bigq { font-size: clamp(1.3rem, 3.2vw, 1.9rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.25; margin: 6px 0 12px; }
.bigq.small { font-size: 1.1rem; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; margin: 4px; border-radius: 12px; background: color-mix(in srgb, var(--rc) 14%, transparent); border: 1.5px solid var(--rc); }
.pill b { color: var(--rc); } .pill em { font-style: normal; font-weight: 700; } .pill small { color: var(--muted); }
.fb { margin-top: 12px; padding: 12px 14px; border-radius: 12px; }
.fb.good { background: color-mix(in srgb, var(--good) 14%, transparent); }
.fb.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chips .seg, .answer .seg { font-size: 1.15rem; }
.answer { min-height: 3.4em; padding: 8px 12px; border: 2px dashed var(--line); border-radius: 14px; }
.diff { font-size: 1.25rem; line-height: 1.8; }
.diff .ok { color: var(--good); font-weight: 650; } .diff .miss { color: var(--bad); text-decoration: underline wavy; font-weight: 650; }
.diff .extra { color: var(--muted); text-decoration: line-through; }
.mic { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); font-size: 2rem; cursor: pointer; box-shadow: 0 6px 24px color-mix(in srgb, var(--brand) 45%, transparent); }
.mic.live { background: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 55%, transparent); } 100% { box-shadow: 0 0 0 26px transparent; } }
.score { font-size: 2.4rem; font-weight: 800; letter-spacing: -.03em; }

/* ---------- speak ---------- */
.lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 10px 0; }
.lane { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); opacity: .7; transition: .25s; }
.lane.now { opacity: 1; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.lane .num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: .8rem; margin-right: 8px; }
.lane small { display: block; color: var(--muted); margin: 2px 0 4px; } .lane em { font-style: normal; font-size: .85rem; color: var(--brand); font-weight: 600; }
.timer { font-size: 2.6rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s linear; }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.live { min-height: 5.5em; padding: 12px 14px; margin: 12px 0; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); font-size: 1.05rem; }
.countdown { display: grid; place-items: center; min-height: 52vh; font-size: clamp(5rem, 22vw, 9rem); font-weight: 800; color: var(--brand); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.tile b { display: block; font-size: 1.7rem; letter-spacing: -.02em; line-height: 1.2; }
.tile span { font-size: .8rem; color: var(--muted); } .tile em { display: block; font-style: normal; font-size: .85rem; margin-top: 2px; font-weight: 600; }
mark.conn { background: color-mix(in srgb, var(--good) 26%, transparent); color: inherit; border-radius: 5px; padding: 0 3px; }
mark.fill { background: color-mix(in srgb, var(--bad) 26%, transparent); color: inherit; border-radius: 5px; padding: 0 3px; }
.notes { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.notes li { padding: 10px 12px; border-radius: 12px; border-left: 5px solid; }
.notes li.good { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, transparent); }
.notes li.fix { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.transcript { font-size: 1.1rem; line-height: 1.8; }

/* ---------- toolkit ---------- */
.phrase { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.phrase:first-of-type { border-top: 0; }
.phrase button { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--brand); cursor: pointer; font-size: 1rem; }
.phrase b { display: block; } .phrase small { color: var(--muted); }
.swap { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; text-align: center; }
.swap .a { text-decoration: line-through; color: var(--bad); font-weight: 700; } .swap .b { color: var(--good); font-weight: 700; }

/* ---------- my text ---------- */
.editor { margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; background: var(--bg); }
.role-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.role-pick .chip { font: inherit; font-size: .8rem; font-weight: 800; cursor: pointer; padding: .35em .8em; min-height: 36px; }
.role-pick .chip.cur { background: var(--rc); color: var(--brand-ink); }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: .85rem; }
.cwrap { position: relative; }
.del { position: absolute; top: 8px; right: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem; width: 36px; height: 36px; border-radius: 10px; z-index: 2; }
.del:hover { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.cwrap .sent-card { height: 100%; padding-right: 44px; }
.cta { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.cta:hover { border-color: var(--brand); }
.cta b { display: block; } .cta small { color: var(--muted); }
.cta-ic { font-size: 1.6rem; } .cta-go { margin-left: auto; font-weight: 800; color: var(--brand); font-size: 1.3rem; }
@media (max-width: 820px) { .nav a { font-size: .6rem; padding: 6px 2px; } .nav a span:first-child { font-size: 1.1rem; width: auto; } }

dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--card); color: var(--ink); padding: 20px 22px; max-width: 420px; width: calc(100% - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog label { display: grid; gap: 4px; margin: 12px 0; font-weight: 600; font-size: .9rem; }
dialog select { font: inherit; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 50; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
