/* ------------------------------------------------------------------ tokens
   Palette: the original sage swatch, pushed brighter, plus one warm apricot accent.
   Type: Unbounded (display) · Golos Text (UI) · Alegreya (reading: transcripts, quiz words). */
:root {
  --frame: #E8EEE3;
  --bg: #F6F8F2;
  --surface: #FFFFFF;
  --surface-2: #F0F4EB;
  --line: #E0E7DA;
  --line-strong: #CCD7C5;
  --bubble: #DCEAC3;           /* olive-lime, from #D0D6C2 */
  --tint: #E4F0E3;             /* sage tint, from #C3CEC4 */
  --accent: #3F9E68;           /* fills, rings, bars */
  --accent-strong: #2F7E52;    /* buttons with white text (4.97:1) */
  --accent-soft: #D4ECDB;
  --accent-ink: #2C6B47;       /* accent text on light (5.9:1) */
  --on-accent: #FFFFFF;
  --warm: #F08C4B;             /* apricot: streaks, highlights, the one warm note */
  --warm-soft: #FDE7D5;
  --warm-ink: #A8501B;
  --text: #1E2D25;
  --text-2: #445A4D;
  --muted: #5F7065;
  --good: #2A7D4E;
  --good-bg: #DDF1E3;
  --bad: #B8433A;
  --bad-bg: #FBE4DF;
  --mark: #FFE2B5;
  --h0: #EBF0E6; --h1: #CBE8D3; --h2: #92CFA6; --h3: #57AE7C; --h4: #2F7E52;
  --shadow-sm: 0 1px 2px rgba(30, 45, 37, .06);
  --shadow: 0 1px 2px rgba(30, 45, 37, .05), 0 10px 28px -14px rgba(30, 60, 42, .22);
  --glow: 0 6px 18px -6px rgba(47, 126, 82, .55);

  --font-display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --font-ui: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-read: "Alegreya", Georgia, "Times New Roman", serif;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --pill: 999px;
  --sidebar-w: 276px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --frame: #0E1511; --bg: #131C17; --surface: #1A251F; --surface-2: #16201B;
    --line: #26332B; --line-strong: #35463B; --bubble: #2C3C24; --tint: #1E3026;
    --accent: #57BD84; --accent-strong: #6FD39A; --accent-soft: #1F3A2B; --accent-ink: #92E3B4; --on-accent: #0B1A11;
    --warm: #F5A66B; --warm-soft: #3A2617; --warm-ink: #F8BC8C;
    --text: #E4ECE6; --text-2: #B4C3B9; --muted: #8E9E94;
    --good: #7EDBA2; --good-bg: #1C3526; --bad: #F19A8D; --bad-bg: #3D2320; --mark: #5A4321;
    --h0: #25332B; --h1: #1F4430; --h2: #2E6E49; --h3: #47A06D; --h4: #6FD39A;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -14px rgba(0, 0, 0, .65);
    --glow: 0 6px 20px -6px rgba(111, 211, 154, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --frame: #0E1511; --bg: #131C17; --surface: #1A251F; --surface-2: #16201B;
  --line: #26332B; --line-strong: #35463B; --bubble: #2C3C24; --tint: #1E3026;
  --accent: #57BD84; --accent-strong: #6FD39A; --accent-soft: #1F3A2B; --accent-ink: #92E3B4; --on-accent: #0B1A11;
  --warm: #F5A66B; --warm-soft: #3A2617; --warm-ink: #F8BC8C;
  --text: #E4ECE6; --text-2: #B4C3B9; --muted: #8E9E94;
  --good: #7EDBA2; --good-bg: #1C3526; --bad: #F19A8D; --bad-bg: #3D2320; --mark: #5A4321;
  --h0: #25332B; --h1: #1F4430; --h2: #2E6E49; --h3: #47A06D; --h4: #6FD39A;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -14px rgba(0, 0, 0, .65);
  --glow: 0 6px 20px -6px rgba(111, 211, 154, .45);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--frame); color: var(--text);
  font: 400 15px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; flex: none; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--accent-soft); }
kbd {
  font: 500 12px/1 var(--font-ui); padding: 3px 7px; border-radius: 7px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  box-shadow: 0 1px 0 var(--line-strong);
}
code { font-size: .92em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }

/* ------------------------------------------------------------------ layout */
.app { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px 14px; min-height: 0;
}
.main {
  flex: 1; min-width: 0; margin: 10px 10px 10px 0; background: var(--bg);
  border-radius: var(--r-xl); display: flex; flex-direction: column; overflow: hidden;
  position: relative; box-shadow: 0 0 0 1px var(--line);
}

/* sidebar */
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; background: var(--accent-strong); color: var(--on-accent);
  display: grid; place-items: center; transition: transform .4s var(--ease);
}
.brand-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: inherit; text-decoration: none; border-radius: 999px; }
.brand-link:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 4px; }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.05); }
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font: 500 15px/1.1 var(--font-display); letter-spacing: -.01em; flex: 1; }

.new-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 16px;
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--pill);
  font-weight: 600; text-align: left; transition: border-color .2s, box-shadow .2s, transform .15s;
}
.new-btn svg { color: var(--accent-ink); transition: transform .3s var(--ease); }
.new-btn:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.new-btn:hover svg { transform: rotate(90deg); }
.new-btn:active { transform: scale(.98); }

.nav { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 8px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 14px; border-radius: var(--pill);
  color: var(--text-2); text-decoration: none; font-weight: 500; position: relative;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line), var(--shadow-sm); }
.nav-item.active svg { color: var(--accent-ink); }
.nav-count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.history { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line-strong); padding-top: 12px; }
.history-head { font-size: 13px; color: var(--muted); padding: 0 14px 6px; font-weight: 500; }
.history-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.history-list button {
  width: 100%; text-align: left; border: 0; background: none; padding: 8px 14px; border-radius: var(--r-md);
  display: block; color: var(--text-2); transition: background .15s;
}
.history-list button:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); }
.history-list button.active { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.h-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.h-date { display: block; font-size: 12px; color: var(--muted); }
.history-empty { padding: 4px 14px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.h-running .h-title::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--warm); margin-right: 7px; vertical-align: 1px; animation: pulse 1.4s ease-in-out infinite;
}

/* user chip */
.me-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; margin: 6px 0 4px;
  border-radius: var(--pill); background: var(--surface); box-shadow: 0 0 0 1px var(--line);
  text-decoration: none; color: var(--text); transition: box-shadow .2s, transform .15s;
}
.me-chip:hover { box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm); }
.me-chip.active { box-shadow: 0 0 0 1.5px var(--accent); }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.me-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-ring { width: 30px; height: 30px; transform: rotate(-90deg); }
.goal-ring circle { fill: none; stroke-width: 4; }
.gr-track { stroke: var(--h0); }
.gr-val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.goal-ring.complete .gr-val { stroke: var(--warm); }

.avatar {
  --size: 40px; width: var(--size); height: var(--size); border-radius: 50%; flex: none;
  display: grid; place-items: center; background: linear-gradient(140deg, var(--accent-soft), var(--bubble));
  color: var(--accent-ink); font: 500 calc(var(--size) * .38)/1 var(--font-display); letter-spacing: -.02em;
  user-select: none;
}
.avatar.sm { --size: 34px; }
.avatar.emoji { font: 400 calc(var(--size) * .55)/1 system-ui, "Apple Color Emoji", "Segoe UI Emoji", sans-serif; }

.sidebar-foot { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line-strong); padding-top: 8px; }
.foot-btn {
  display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 8px 14px;
  border-radius: var(--pill); color: var(--text-2); font-size: 14px; text-align: left;
}
.foot-btn:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); }
.foot-btn svg { width: 18px; height: 18px; }
.foot-btn kbd { width: 18px; text-align: center; padding: 3px 0; }
.if-dark { display: none; }
:root[data-theme="dark"] .if-dark { display: inline; }
:root[data-theme="dark"] .if-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .if-dark { display: inline; }
  :root:not([data-theme="light"]) .if-light { display: none; }
}

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 24px; min-height: 64px;
  border-bottom: 1px solid var(--line);
}
.topbar-title {
  margin: 0; font-size: 16px; font-weight: 600; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.lang-pick {
  display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 14px; border-radius: var(--pill);
  background: var(--surface); border: 1px solid var(--line);
}
.lang-label { font-size: 13px; color: var(--muted); }
.lang-pick select { border: 0; background: var(--surface-2); border-radius: var(--pill); padding: 5px 12px; font-weight: 500; cursor: pointer; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: none; display: grid; place-items: center;
  color: var(--text-2); transition: background .15s, color .15s, transform .15s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.copied { color: var(--good); animation: pop .35s var(--ease); }
.only-mobile { display: none; }

.banner {
  display: flex; gap: 12px; align-items: flex-start; margin: 14px 24px 0; padding: 12px 18px;
  border-radius: var(--r-lg); background: var(--bad-bg); color: var(--text); font-size: 14px;
}
.banner svg { color: var(--bad); margin-top: 1px; }

/* views */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-vocab, .view-quiz, .view-profile { overflow-y: auto; }
.page { width: 100%; max-width: 980px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: 18px; }
.page.narrow { max-width: 680px; }
.page.wide { max-width: 1080px; }

/* ------------------------------------------------------------------ chat */
.view-chat { position: relative; }
.thread {
  flex: 1; overflow-y: auto; padding: 28px 24px 24px; display: flex; flex-direction: column; gap: 18px;
  scroll-behavior: smooth;
}
.thread > * { width: 100%; max-width: 820px; margin-left: auto; margin-right: auto; flex-shrink: 0; }

.hero { margin: auto; text-align: center; max-width: 600px; padding: 24px 0 8px; }
.hero-hello { margin: 18px 0 0; color: var(--accent-ink); font-weight: 600; font-size: 15px; }
.hero h2 {
  font: 500 clamp(26px, 3.6vw, 36px)/1.18 var(--font-display); letter-spacing: -.025em; margin: 8px 0 12px;
}
.hero-tagline { color: var(--text-2); margin: 0 auto; max-width: 46ch; min-height: 3em; transition: opacity .5s ease; }
.hero-tagline.fade { opacity: 0; }
.hero-wave { display: flex; gap: 5px; justify-content: center; align-items: center; height: 64px; }
.hero-wave i {
  display: block; width: 7px; border-radius: 4px; background: var(--h2); height: var(--h);
  animation: wave 1.6s var(--ease) both; animation-delay: var(--d); transform-origin: center;
}
.hero-wave i:nth-child(odd) { background: var(--bubble); }
.hero-wave i:nth-child(4n+3) { background: var(--accent); }
.hero-wave i:nth-child(7) { background: var(--warm); }
.hero-wave i:nth-child(1) { --h: 14px; --d: .00s } .hero-wave i:nth-child(2) { --h: 26px; --d: .04s }
.hero-wave i:nth-child(3) { --h: 40px; --d: .08s } .hero-wave i:nth-child(4) { --h: 22px; --d: .12s }
.hero-wave i:nth-child(5) { --h: 52px; --d: .16s } .hero-wave i:nth-child(6) { --h: 34px; --d: .20s }
.hero-wave i:nth-child(7) { --h: 62px; --d: .24s } .hero-wave i:nth-child(8) { --h: 30px; --d: .28s }
.hero-wave i:nth-child(9) { --h: 46px; --d: .32s } .hero-wave i:nth-child(10) { --h: 20px; --d: .36s }
.hero-wave i:nth-child(11) { --h: 36px; --d: .40s } .hero-wave i:nth-child(12) { --h: 18px; --d: .44s }
.hero-wave i:nth-child(13) { --h: 10px; --d: .48s }
.hero:hover .hero-wave i { animation: breathe 1.2s ease-in-out infinite alternate; animation-delay: var(--d); }
@keyframes wave { 0% { transform: scaleY(.15); opacity: 0 } 60% { transform: scaleY(1.12); opacity: 1 } 100% { transform: scaleY(1) } }
@keyframes breathe { to { transform: scaleY(.7) } }
@keyframes pulse { 50% { opacity: .35 } }
@keyframes pop { 0% { transform: scale(.7) } 60% { transform: scale(1.15) } 100% { transform: scale(1) } }
@keyframes shake { 20%, 60% { transform: translateX(-4px) } 40%, 80% { transform: translateX(4px) } }

.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: var(--pill);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  text-decoration: none; font-size: 14px; font-weight: 500; transition: border-color .2s, color .2s, transform .15s, box-shadow .2s;
}
.chip:hover { color: var(--text); border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.chip:active { transform: scale(.97); }
.chip svg { width: 17px; height: 17px; color: var(--accent-ink); }

/* messages */
.msg-user { display: flex; justify-content: flex-end; }
.bubble {
  background: var(--bubble); border-radius: var(--r-lg) var(--r-lg) 6px var(--r-lg); padding: 12px 16px;
  max-width: min(520px, 88%); animation: rise .35s var(--ease);
}
@keyframes rise { from { transform: translateY(8px); opacity: 0 } }
.bubble-file { display: flex; align-items: center; gap: 10px; font-weight: 600; word-break: break-word; }
.bubble-file svg { color: var(--accent-ink); }
.bubble-meta { font-size: 13px; color: var(--text-2); margin-top: 4px; }

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

/* progress card */
.progress-card { padding: 18px 20px; display: grid; grid-template-columns: 1fr auto; gap: 14px 18px; animation: rise .35s var(--ease); }
.thread > .progress-card { max-width: 560px; margin-left: max(0px, calc((100% - 820px) / 2)); margin-right: auto; }
.pc-head { grid-column: 1; }
.pc-title { font-weight: 600; display: block; }
.pc-hint { font-size: 13px; color: var(--muted); display: block; margin-top: 2px; min-height: 1.4em; transition: opacity .4s; }
.pc-ring { grid-column: 2; grid-row: 1 / span 3; width: 64px; height: 64px; position: relative; align-self: start; }
.pc-ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.pc-ring circle { fill: none; stroke-width: 6; }
.pc-ring .track { stroke: var(--h0); }
.pc-ring .val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s var(--ease); }
.pc-pct { position: absolute; inset: 0; display: grid; place-items: center; font: 500 13px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.steps { grid-column: 1; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.step { display: grid; grid-template-columns: 22px 1fr; gap: 4px 10px; align-items: center; }
.step-dot {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center;
  color: var(--on-accent); background: var(--surface); transition: background .3s, border-color .3s;
}
.step-dot svg { width: 14px; height: 14px; display: none; }
.step-name { font-size: 14px; color: var(--muted); }
.step-bar { grid-column: 2; height: 4px; border-radius: 4px; background: var(--h0); overflow: hidden; display: none; }
.step-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s ease; }
.step.active .step-dot { border-color: var(--accent); border-width: 6px; animation: pulse 1.4s ease-in-out infinite; }
.step.active .step-name { color: var(--text); font-weight: 600; }
.step.active .step-bar { display: block; }
.step.done .step-dot { background: var(--accent-strong); border-color: var(--accent-strong); }
.step.done .step-dot svg { display: block; animation: pop .35s var(--ease); }
.step.done .step-name { color: var(--text-2); }
.pc-upload { grid-column: 1; height: 4px; border-radius: 4px; background: var(--h0); overflow: hidden; }
.pc-upload i { display: block; height: 100%; background: var(--warm); width: 0; transition: width .2s; }
.pc-error { grid-column: 1 / -1; color: var(--bad); font-size: 14px; display: flex; gap: 8px; align-items: flex-start; }
.pc-error svg { margin-top: 1px; }

/* result card */
.result { overflow: hidden; animation: rise .45s var(--ease); }
.r-head { padding: 20px 20px 0; display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.r-title { font: 500 19px/1.3 var(--font-display); letter-spacing: -.02em; margin: 0; flex: 1; min-width: 200px; word-break: break-word; }
.r-meta { font-size: 13px; color: var(--muted); width: 100%; margin-top: -6px; display: flex; flex-wrap: wrap; gap: 6px; }
.r-meta span { background: var(--surface-2); border-radius: var(--pill); padding: 2px 10px; }
.r-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 14px 20px 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.tabs { display: inline-flex; background: var(--surface-2); border-radius: var(--pill); padding: 3px; gap: 2px; border: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 6px 14px; border-radius: var(--pill); font-size: 14px; font-weight: 500; color: var(--text-2); transition: background .2s, color .2s; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.r-search { margin-left: auto; }
.search-box {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--pill);
  background: var(--surface-2); border: 1px solid var(--line); min-width: 0; transition: border-color .2s, box-shadow .2s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box svg { width: 16px; height: 16px; color: var(--muted); }
.search-box input { border: 0; background: none; outline: none; width: 160px; min-width: 0; font-size: 14px; }
.search-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.r-body { display: grid; grid-template-columns: 1fr; }
.r-body.split { grid-template-columns: 1fr 1fr; }
.r-body.split .pane + .pane { border-left: 1px solid var(--line); }
.pane { min-width: 0; display: flex; flex-direction: column; }
.pane-head { display: flex; align-items: center; gap: 4px; padding: 10px 14px 0 20px; }
.pane-label { font-size: 13px; color: var(--muted); flex: 1; }
.pane-head .icon-btn { width: 32px; height: 32px; }
.pane-head .icon-btn svg { width: 17px; height: 17px; }
.text {
  font-family: var(--font-read); font-size: 18.5px; line-height: 1.62; padding: 8px 20px 22px; margin: 0;
  white-space: pre-wrap; word-wrap: break-word; max-height: 56vh; overflow-y: auto;
}
.text.clickable { cursor: text; }
.text mark { background: var(--mark); color: inherit; border-radius: 4px; padding: 0 2px; }
.text mark.current { background: var(--warm); color: #1E2D25; }
.text-empty { color: var(--muted); font-style: italic; }

.r-pick {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 20px; background: var(--tint);
  border-top: 1px solid var(--line); font-size: 14px;
}
.r-pick-label { color: var(--text-2); }
.pick {
  display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--pill); padding: 3px 4px 3px 12px; font: 500 15px/1.3 var(--font-read); animation: pop .3s var(--ease);
}
.pick button { border: 0; background: none; padding: 3px; border-radius: 50%; display: grid; color: var(--muted); }
.pick button:hover { color: var(--bad); background: var(--bad-bg); }
.pick svg { width: 13px; height: 13px; }

.r-actions { display: flex; gap: 10px; padding: 14px 20px 18px; flex-wrap: wrap; border-top: 1px solid var(--line); align-items: center; }
.r-hint { font-size: 13px; color: var(--muted); margin-left: auto; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: var(--pill);
  border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: 14px; white-space: nowrap;
  color: var(--text); text-decoration: none; position: relative;
  transition: border-color .2s, box-shadow .2s, transform .15s, background .2s, filter .2s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent-strong); color: var(--on-accent); border-color: var(--accent-strong); }
.btn.primary:hover { box-shadow: var(--glow); transform: translateY(-1px); }
.btn.primary:active { transform: scale(.97); }
.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-bg); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; filter: none; transform: none; box-shadow: none; }
.btn svg { width: 17px; height: 17px; }
.btn .count { background: color-mix(in srgb, var(--on-accent) 22%, transparent); border-radius: var(--pill); padding: 0 8px; font-size: 12px; line-height: 20px; }
.btn.busy { color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--on-accent); border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn:not(.primary).busy::after { border-color: var(--accent); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg) } }

/* composer */
.composer {
  margin: 0 auto 18px; width: calc(100% - 48px); max-width: 820px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-xl); padding: 10px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft); }
.attached { padding: 4px 6px 2px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--tint); border-radius: var(--pill); padding: 6px 6px 6px 12px;
  max-width: 100%; animation: pop .3s var(--ease);
}
.file-chip svg { width: 16px; height: 16px; color: var(--accent-ink); }
.file-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.file-size { font-size: 13px; color: var(--muted); white-space: nowrap; }
.file-x { border: 0; background: none; display: grid; padding: 4px; border-radius: 50%; color: var(--muted); }
.file-x:hover { color: var(--text); background: var(--surface); }
.composer-fields { display: flex; flex-direction: column; }
.composer-fields input { border: 0; background: none; outline: none; padding: 8px 12px; font-size: 15px; }
.composer-fields .kw-input { font-size: 14px; padding-top: 0; color: var(--text-2); }
.composer-fields input::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: 6px; }
.composer-hint { font-size: 13px; color: var(--muted); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach svg { transition: transform .3s var(--ease); }
.attach:hover svg { transform: rotate(-20deg); }
.send-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: var(--accent-strong); color: var(--on-accent);
  border-radius: var(--pill); padding: 10px 14px 10px 18px; font-weight: 600; font-size: 14px;
  transition: box-shadow .2s, transform .15s, background .2s;
}
.send-btn svg { width: 18px; height: 18px; transition: transform .25s var(--ease); }
.send-btn:not(:disabled):hover { box-shadow: var(--glow); }
.send-btn:not(:disabled):hover svg { transform: translateY(-2px); }
.send-btn:not(:disabled):active { transform: scale(.96); }
.send-btn:disabled { background: var(--h0); color: var(--muted); cursor: default; }

.dropzone {
  position: absolute; inset: 12px; border-radius: var(--r-xl); border: 2px dashed var(--accent);
  background: color-mix(in srgb, var(--bg) 84%, transparent); display: none; place-items: center; z-index: 5;
  font-weight: 600; font-size: 18px; color: var(--accent-ink); backdrop-filter: blur(3px);
}
.dropzone div { display: flex; align-items: center; gap: 10px; animation: breathe 1s ease-in-out infinite alternate; }
.dropzone svg { width: 28px; height: 28px; }
.view-chat.dragging .dropzone { display: grid; }

/* ------------------------------------------------------------------ panels (vocab / quiz / profile) */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.panel-title { margin: 0 0 12px; font: 500 15px/1.3 var(--font-display); letter-spacing: -.01em; }
.panel-sub { margin: -6px 0 14px; color: var(--muted); font-size: 13px; }
.add-words textarea, .panel input:not([type=checkbox]):not([type=radio]):not([type=search]), .panel select, .quiz-free input {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: var(--r-md); padding: 10px 14px;
  outline: none; resize: vertical; transition: border-color .2s, box-shadow .2s;
}
.panel select, .quiz-free input, .panel input:not([type=search]) { border-radius: var(--pill); }
.add-words textarea:focus, .panel input:focus, .panel select:focus, .quiz-free input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row { display: flex; gap: 10px; margin-top: 10px; }
.row input { flex: 1; }
.table-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.table-head .panel-title { margin: 0; }
.table-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-tools select { width: auto; max-width: 240px; padding: 7px 12px; }
.table-tools .search-box input { width: 150px; }

.words-lang { display: inline-flex; align-items: center; gap: 8px; padding: 3px 3px 3px 14px; border-radius: var(--pill); background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; font-weight: 500; }
.panel .words-lang select { width: auto; border: 0; background: var(--surface); padding: 5px 12px; font-weight: 600; color: var(--text); box-shadow: var(--shadow-sm); cursor: pointer; }
.words-wrap { position: relative; min-height: 80px; }
.words-busy {
  position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center; gap: 10px; padding-top: 48px;
  background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(1.5px); border-radius: var(--r-md);
  color: var(--accent-ink); font-weight: 600; font-size: 14px; animation: rise .2s var(--ease); z-index: 2;
}
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: spin .7s linear infinite; }
.w-syn { color: var(--muted); font-size: 13px; font-style: italic; line-height: 1.4; max-width: 240px; }
.words table { width: 100%; border-collapse: collapse; font-size: 14px; }
.words th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.words td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.words tbody tr { transition: background .15s; }
.words tbody tr:hover { background: var(--surface-2); }
.words tr:last-child td { border-bottom: 0; }
.w-word { font-family: var(--font-read); font-size: 17px; font-weight: 500; }
.w-src { color: var(--text-2); }
.w-src button { border: 0; background: var(--tint); padding: 2px 10px; border-radius: var(--pill); font-size: 13px; color: var(--text-2); text-align: left; }
.w-src button:hover { color: var(--text); background: var(--accent-soft); }
.w-date, .w-score { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.score-dots { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 6px; }
.score-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.score-dots i.on { background: var(--accent); }
.score-dots.learned i.on { background: var(--warm); }
.w-del { width: 34px; height: 34px; opacity: .6; }
.words tr:hover .w-del { opacity: 1; }
.w-del svg { width: 17px; height: 17px; }
.w-del:hover { color: var(--bad); background: var(--bad-bg); }
.empty { text-align: center; padding: 34px 10px; color: var(--text-2); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.new-row td { animation: flashrow 1.6s ease-out; }
@keyframes flashrow { from { background: var(--accent-soft) } to { background: transparent } }

/* quiz */
.quiz-setup { display: flex; flex-direction: column; gap: 16px; }
.quiz-setup h2 { margin: 0; font: 500 22px/1.25 var(--font-display); letter-spacing: -.02em; }
.quiz-setup p { margin: 0; color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.seg { align-self: flex-start; display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--pill); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; border-radius: var(--pill); padding: 8px 16px; font-weight: 500; color: var(--text-2); font-size: 14px; transition: background .2s, color .2s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent-strong); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.quiz-setup .actions { display: flex; gap: 10px; flex-wrap: wrap; }

.q-top { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.q-progress { flex: 1; height: 8px; border-radius: 8px; background: var(--h0); overflow: hidden; }
.q-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--h2)); border-radius: inherit; transition: width .45s var(--ease); }
.q-count { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.q-card { padding: 30px 26px 24px; animation: rise .3s var(--ease); }
.q-prompt { font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.q-word { font: 500 clamp(30px, 5vw, 44px)/1.15 var(--font-read); margin: 0 0 24px; word-break: break-word; }
.q-src { font-size: 13px; color: var(--muted); margin: -16px 0 22px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 18px 12px 12px; border-radius: var(--pill);
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 15px; min-height: 54px;
  transition: border-color .15s, background .15s, transform .15s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-2); transform: translateY(-1px); }
.opt:active:not(:disabled) { transform: scale(.98); }
.opt kbd { flex: none; border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center; padding: 0; }
.opt:disabled { cursor: default; }
.opt.correct { background: var(--good-bg); border-color: var(--good); animation: pop .35s var(--ease); }
.opt.correct kbd { border-color: var(--good); color: var(--good); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); animation: shake .35s ease; }
.opt.wrong kbd { border-color: var(--bad); color: var(--bad); }
.opt.dim { opacity: .55; }
.q-feedback { margin-top: 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 42px; }
.q-feedback .verdict { font-weight: 600; flex: 1; animation: rise .25s var(--ease); }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.quiz-free { display: flex; gap: 10px; }
.quiz-free input { flex: 1; font-size: 16px; padding: 12px 18px; }

.summary { text-align: center; padding: 34px 24px; animation: rise .4s var(--ease); }
.ring { width: 136px; height: 136px; margin: 0 auto 14px; position: relative; }
.ring svg { width: 136px; height: 136px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--h0); }
.ring .val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.ring.perfect .val { stroke: var(--warm); }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font: 500 28px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.summary h2 { margin: 6px 0 6px; font: 500 20px/1.3 var(--font-display); letter-spacing: -.02em; }
.summary p { margin: 0 auto 18px; color: var(--text-2); max-width: 42ch; }
.mistakes { text-align: left; margin: 0 auto 20px; max-width: 440px; border-top: 1px solid var(--line); }
.mistakes div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.mistakes .mw { font-family: var(--font-read); font-size: 16px; }
.mistakes .mt { color: var(--text-2); text-align: right; }
.summary .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ------------------------------------------------------------------ profile */
.p-head {
  display: flex; gap: 22px; align-items: center; padding: 24px; flex-wrap: wrap; position: relative; z-index: 2;
  background: radial-gradient(420px 260px at 100% 0%, var(--accent-soft), transparent 70%), var(--surface);
}
.p-avatar-wrap { position: relative; }
.p-avatar-btn { border: 0; padding: 0; background: none; border-radius: 50%; position: relative; }
.p-avatar-btn .avatar { --size: 84px; box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--line); transition: transform .25s var(--ease); }
.p-avatar-btn:hover .avatar { transform: scale(1.04) rotate(-3deg); }
.p-avatar-edit {
  position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-strong);
  color: var(--on-accent); display: grid; place-items: center; font-size: 14px; box-shadow: 0 0 0 3px var(--surface);
}
.emoji-pop {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 20; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 10px; display: grid; grid-template-columns: repeat(6, 40px); gap: 4px;
  animation: rise .2s var(--ease);
}
.emoji-pop button { border: 0; background: none; width: 40px; height: 40px; border-radius: 50%; font-size: 22px; transition: background .15s, transform .15s; }
.emoji-pop button:hover { background: var(--surface-2); transform: scale(1.12); }
.emoji-pop .initials { grid-column: 1 / -1; width: auto; font: 500 13px/1 var(--font-ui); border-radius: var(--pill); background: var(--surface-2); height: 34px; color: var(--text-2); }
.p-id { flex: 1; min-width: 220px; position: relative; }
.p-name {
  font: 500 clamp(22px, 3vw, 30px)/1.2 var(--font-display); letter-spacing: -.025em; border: 0; background: none; outline: none;
  padding: 2px 8px; margin-left: -8px; border-radius: var(--r-sm); width: 100%; max-width: 460px; transition: background .2s;
}
.p-name:hover { background: var(--surface-2); }
.p-name:focus { background: var(--surface-2); box-shadow: 0 0 0 2px var(--accent-soft); }
.p-name::placeholder { color: var(--muted); }
.p-since { color: var(--muted); font-size: 14px; margin-top: 2px; }
.p-goal { display: flex; align-items: center; gap: 14px; position: relative; }
.p-goal-ring { width: 76px; height: 76px; position: relative; }
.p-goal-ring svg { width: 76px; height: 76px; transform: rotate(-90deg); }
.p-goal-ring circle { fill: none; stroke-width: 8; }
.p-goal-ring .track { stroke: var(--h0); }
.p-goal-ring .val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.p-goal-ring.complete .val { stroke: var(--warm); }
.p-goal-num {
  position: absolute; inset: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; text-align: center; line-height: 1;
}
.p-goal-num b { display: block; font: 500 19px/1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 1px; }
.p-goal-num.long b { font-size: 15px; }
.p-goal-num small { display: block; font: 400 10.5px/1 var(--font-ui); color: var(--muted); white-space: nowrap; }
.p-goal-text { font-size: 13px; color: var(--muted); line-height: 1.35; }
.p-goal-text b { color: var(--text); font-weight: 600; display: block; font-size: 14px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; background: var(--surface-2); border-radius: var(--pill); padding: 2px; border: 1px solid var(--line); }
.stepper button { width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--surface); color: var(--text-2); font-weight: 600; box-shadow: var(--shadow-sm); }
.stepper button:hover { color: var(--accent-ink); }
.stepper span { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); font-size: 13px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; transition: transform .2s var(--ease), box-shadow .2s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-num { font: 500 28px/1.1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tile-num small { font: 500 14px/1 var(--font-ui); color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.tile-sub { font-size: 13px; color: var(--text-2); }
.tile-bar { height: 6px; border-radius: 6px; background: var(--h0); overflow: hidden; margin-top: 6px; }
.tile-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); width: 0; transition: width 1s var(--ease); }
.tile.warm { background: linear-gradient(160deg, var(--warm-soft), var(--surface) 70%); }
.tile.warm .tile-num { color: var(--warm-ink); display: flex; align-items: center; gap: 6px; }
.tile.warm svg { width: 22px; height: 22px; color: var(--warm); transform-origin: bottom center; }
.tile.warm:hover svg { animation: flicker .8s ease-in-out infinite alternate; }
@keyframes flicker { from { transform: rotate(-6deg) scale(1) } to { transform: rotate(5deg) scale(1.08) } }

.heat-wrap { overflow-x: auto; padding-bottom: 4px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 16px); gap: 4px; width: max-content; }
.heat i { width: 16px; height: 16px; border-radius: 4px; background: var(--h0); transition: transform .15s; }
.heat i:hover { transform: scale(1.35); outline: 1px solid var(--text-2); }
.heat i.l1 { background: var(--h1); } .heat i.l2 { background: var(--h2); } .heat i.l3 { background: var(--h3); } .heat i.l4 { background: var(--h4); }
.heat i.today { outline: 1.5px solid var(--warm); outline-offset: 1px; }
.heat i.pad { visibility: hidden; }
.heat-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); gap: 12px; flex-wrap: wrap; }
.heat-legend { display: inline-flex; align-items: center; gap: 4px; }
.heat-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.heat-months { display: grid; grid-auto-flow: column; gap: 4px; font-size: 11px; color: var(--muted); margin-bottom: 6px; width: max-content; }
.heat-months span { width: 16px; white-space: nowrap; overflow: visible; }

.p-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.p-grid .panel { min-width: 0; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 14px; }
.bar-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-row .track { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--h0); overflow: hidden; }
.bar-row .track i { display: block; height: 100%; background: var(--accent); border-radius: inherit; width: 0; transition: width .9s var(--ease); }
.hard { list-style: none; margin: 0; padding: 0; }
.hard li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.hard li:last-child { border-bottom: 0; }
.hard .hw { font: 500 16px/1.3 var(--font-read); }
.hard .ht { color: var(--muted); font-size: 13px; }
.hard .hn { color: var(--bad); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.langs { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-radius: var(--pill); background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.lang-chip b { font-weight: 600; }
.lang-chip span { background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--pill); padding: 0 8px; font-size: 12px; line-height: 20px; }
.p-empty { color: var(--muted); font-size: 14px; margin: 0; }

.settings { display: grid; gap: 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.set-row:last-child { border-bottom: 0; padding-bottom: 0; }
.set-row:first-child { padding-top: 0; }
.set-label b { display: block; font-weight: 600; font-size: 14px; }
.set-label span { font-size: 13px; color: var(--muted); }
.set-row select { width: auto; min-width: 180px; }
.set-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* toasts */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); padding: 12px 14px 12px 16px; box-shadow: var(--shadow); font-size: 14px; display: flex; gap: 10px; align-items: flex-start;
  animation: toastin .3s var(--ease); position: relative; overflow: hidden;
}
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.toast.error::before { background: var(--bad); }
.toast.ok::before { background: var(--good); }
.toast b { display: block; margin-bottom: 2px; }
.toast-body { flex: 1; }
.toast button { border: 0; background: none; padding: 3px; color: var(--muted); display: grid; border-radius: 50%; }
.toast button:hover { background: var(--surface-2); }
.toast svg { width: 16px; height: 16px; }
.toast.leaving { animation: toastout .25s ease forwards; }
@keyframes toastin { from { transform: translateX(16px); opacity: 0 } }
@keyframes toastout { to { transform: translateX(16px); opacity: 0 } }

/* modal */
.modal {
  border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface); color: var(--text);
  padding: 24px; width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
.modal[open] { animation: rise .25s var(--ease); }
.modal::backdrop { background: rgba(14, 24, 18, .45); backdrop-filter: blur(2px); }
.modal h2 { margin: 0 0 14px; font: 500 17px/1.3 var(--font-display); letter-spacing: -.01em; }
.modal p { color: var(--text-2); font-size: 14px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0 0 14px; align-items: center; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--text-2); font-size: 14px; }
.modal form[method="dialog"] { display: flex; justify-content: flex-end; margin-top: 8px; }
.modal textarea, .modal input { width: 100%; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: var(--r-md); padding: 10px 14px; outline: none; margin-bottom: 10px; }
.modal input { border-radius: var(--pill); }
.modal textarea:focus, .modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dlg-lang select { width: 100%; border: 1px solid var(--line-strong); background: var(--surface-2); border-radius: var(--pill); padding: 9px 14px; margin-bottom: 10px; }
.modal label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }

.scrim { display: none; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1000px) {
  .r-body.split { grid-template-columns: 1fr; }
  .r-body.split .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
  .p-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .only-mobile { display: grid; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; background: var(--frame); width: min(300px, 86vw);
    transform: translateX(-102%); transition: transform .28s var(--ease); box-shadow: var(--shadow);
  }
  .app.drawer-open .sidebar { transform: none; }
  .app.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(14, 24, 18, .4); }
  .main { margin: 0; border-radius: 0; box-shadow: none; }
  .topbar { padding: 10px 12px; min-height: 56px; gap: 6px; }
  .lang-label { display: none; }
  .lang-pick { padding: 3px; }
  .lang-pick select { max-width: 124px; }
  .thread { padding: 20px 16px; }
  .composer { width: calc(100% - 24px); margin-bottom: max(12px, env(safe-area-inset-bottom)); border-radius: 24px; }
  .send-btn span { display: none; }
  .send-btn { padding: 10px; }
  .page { padding: 18px 16px 40px; }
  .banner { margin: 10px 12px 0; }
  .row { flex-direction: column; }
  .r-search { margin-left: 0; width: 100%; }
  .r-search .search-box input { width: 100%; flex: 1; }
  .r-toolbar, .r-head, .r-actions, .r-pick { padding-left: 14px; padding-right: 14px; }
  .text { padding-left: 14px; padding-right: 14px; font-size: 17.5px; }
  .pane-head { padding-left: 14px; }
  .r-hint { display: none; }
  .options { grid-template-columns: 1fr; }
  .progress-card { grid-template-columns: 1fr auto; }
  .table-tools { width: 100%; }
  .table-tools .search-box { flex: 1 1 150px; }
  .table-tools .search-box input { width: 100%; }
  .table-tools select { flex: 1 1 150px; max-width: none; min-width: 0; }
  .words thead { display: none; }
  .words table, .words tbody, .words tr, .words td { display: block; }
  .words tr { position: relative; padding: 12px 40px 12px 0; border-bottom: 1px solid var(--line); }
  .words tr:last-child { border-bottom: 0; }
  .words td { border: 0; padding: 1px 0; }
  .words td.w-date { display: inline-block; margin-right: 10px; font-size: 13px; }
  .words td.w-score { display: inline-block; font-size: 13px; }
  .words td.w-act { position: absolute; right: 0; top: 10px; }
  .words td.w-syn { max-width: none; margin-bottom: 4px; }
  .words-lang { flex: 1 1 100%; justify-content: space-between; }
  .w-del { opacity: 1; }
  .p-head { padding: 20px 16px; gap: 16px; }
  .p-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile-num { font-size: 24px; }
  .emoji-pop { grid-template-columns: repeat(6, 36px); }
  .emoji-pop button { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
