/* ───────────────────────── Tokens ───────────────────────── */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #efede7;
  --surface-3: #e7e4dc;
  --line: #e4e1d9;
  --line-strong: #d4d0c5;
  --text: #1c1b18;
  --muted: #6d695f;
  --faint: #9e998d;
  --accent: #2f4bd8;
  --accent-hover: #2440c9;
  --accent-soft: rgba(47, 75, 216, .09);
  --accent-ring: rgba(47, 75, 216, .28);
  --on-accent: #ffffff;
  --err: #e5484d;
  --err-soft: rgba(229, 72, 77, .12);
  --warn: #d68a00;
  --warn-soft: rgba(214, 138, 0, .14);
  --style: #8e4ec6;
  --style-soft: rgba(142, 78, 198, .12);
  --ok: #1f9d63;
  --ok-soft: rgba(31, 157, 99, .12);
  --shadow-sm: 0 1px 2px rgba(28, 27, 24, .06);
  --shadow: 0 1px 2px rgba(28, 27, 24, .05), 0 6px 24px -8px rgba(28, 27, 24, .14);
  --shadow-lg: 0 2px 6px rgba(28, 27, 24, .06), 0 24px 60px -16px rgba(28, 27, 24, .28);
  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ui: "Poppins", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Poppins", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --surface: #1a1a18; --surface-2: #22221f; --surface-3: #2b2b27;
    --line: #2c2c28; --line-strong: #3a3a35; --text: #ecebe5; --muted: #a29e93; --faint: #6f6c64;
    --accent: #7b8fff; --accent-hover: #93a3ff; --accent-soft: rgba(123, 143, 255, .12); --accent-ring: rgba(123, 143, 255, .35);
    --on-accent: #0f1226; --err: #ff6b6f; --err-soft: rgba(255, 107, 111, .16); --warn: #f2b13e; --warn-soft: rgba(242, 177, 62, .16);
    --style: #c49af0; --style-soft: rgba(196, 154, 240, .15); --ok: #3fcf8e; --ok-soft: rgba(63, 207, 142, .14);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 28px -8px rgba(0,0,0,.6);
    --shadow-lg: 0 2px 8px rgba(0,0,0,.4), 0 28px 70px -16px rgba(0,0,0,.75);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --surface: #1a1a18; --surface-2: #22221f; --surface-3: #2b2b27;
  --line: #2c2c28; --line-strong: #3a3a35; --text: #ecebe5; --muted: #a29e93; --faint: #6f6c64;
  --accent: #7b8fff; --accent-hover: #93a3ff; --accent-soft: rgba(123, 143, 255, .12); --accent-ring: rgba(123, 143, 255, .35);
  --on-accent: #0f1226; --err: #ff6b6f; --err-soft: rgba(255, 107, 111, .16); --warn: #f2b13e; --warn-soft: rgba(242, 177, 62, .16);
  --style: #c49af0; --style-soft: rgba(196, 154, 240, .15); --ok: #3fcf8e; --ok-soft: rgba(63, 207, 142, .14);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 28px -8px rgba(0,0,0,.6);
  --shadow-lg: 0 2px 8px rgba(0,0,0,.4), 0 28px 70px -16px rgba(0,0,0,.75);
  color-scheme: dark;
}

/* ───────────────────────── Base ───────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 13.5px/1.55 var(--ui);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
::selection { background: var(--accent-ring); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ───────────────────────── Layout ───────────────────────── */
.app { display: grid; grid-template-columns: 268px minmax(0, 1fr); height: 100vh; height: 100dvh; }

.sidebar {
  display: flex; flex-direction: column; gap: 18px;
  padding: 18px 14px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  min-height: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 6px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 4px 14px -4px var(--accent-ring), inset 0 1px 0 rgba(255,255,255,.18);
}
.brand-mark svg { width: 22px; height: 22px; stroke: none; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--faint); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; text-align: left;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-badge {
  margin-left: auto; font-size: 11.5px; font-weight: 600; min-width: 22px; padding: 1px 7px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted); text-align: center; font-variant-numeric: tabular-nums;
}
.nav-badge.accent { background: var(--accent); color: var(--on-accent); }
.nav-item.active .nav-badge:not(.accent) { background: var(--surface); color: var(--accent); }

.side-section { display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; }
.side-head {
  display: flex; align-items: center; justify-content: space-between; padding: 0 6px 0 10px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint);
}

.search {
  display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 36px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid transparent; color: var(--faint);
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.search:focus-within { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 16px; height: 16px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); height: 100%; }
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); opacity: .5; }
.search.grow { flex: 1; min-width: 160px; }

.note-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px 6px; min-height: 0; scrollbar-width: thin; }
.note-item {
  display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; padding: 9px 10px; border-radius: var(--radius-sm);
  text-align: left; transition: background .16s var(--ease); position: relative;
}
.note-item:hover { background: var(--surface-2); }
.note-item.active { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.note-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-time { font-size: 11.5px; color: var(--faint); align-self: center; font-variant-numeric: tabular-nums; }
.note-preview { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-empty { padding: 18px 10px; color: var(--faint); font-size: 13px; text-align: center; }

.side-foot { display: flex; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.theme-toggle {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--muted);
  transition: background .16s, color .16s;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}
.lang {
  margin-left: auto; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  padding: 6px 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; outline: none;
}
.lang:focus { border-color: var(--accent); }

.main { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.view { position: absolute; inset: 0; display: none; min-height: 0; }
.view.active { display: flex; flex-direction: column; animation: viewIn .32s var(--ease); }
.view-notes.active { flex-direction: row; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topbar {
  display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 20px; flex: none;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  position: relative; z-index: 5;
}
.page-title { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.icon-btn.menu-btn { display: none; }
.status-row { display: flex; gap: 6px; min-width: 0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.wordcount { font-size: 12.5px; color: var(--faint); margin-right: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px; border-radius: 99px;
  font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface-2); white-space: nowrap;
  transition: color .2s, background .2s;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); transition: background .2s; }
.pill.ok .pill-dot { background: var(--ok); }
.pill.busy .pill-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.pill.warn .pill-dot { background: var(--warn); }
.pill.err { color: var(--err); background: var(--err-soft); }
.pill.err .pill-dot { background: var(--err); }
@keyframes pulse { 50% { opacity: .3; transform: scale(.7); } }

/* ───────────────────────── Buttons ───────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); font-weight: 550; white-space: nowrap; user-select: none;
  transition: background .16s var(--ease), color .16s, box-shadow .16s, transform .12s var(--ease), opacity .16s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 4px 12px -4px var(--accent-ring); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.outline { border: 1px solid var(--line-strong); background: var(--surface); }
.btn.outline:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 46px; font-size: 15px; border-radius: 11px; }
.btn.block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); color: var(--muted);
  transition: background .16s, color .16s, transform .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn.danger-hover:hover, .icon-btn.confirm { color: var(--err); background: var(--err-soft); }
kbd {
  font: 500 11px var(--mono); padding: 1px 5px; border-radius: 5px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--muted); box-shadow: 0 1px 0 var(--line);
}

/* ───────────────────────── Editor ───────────────────────── */
.editor-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.editor-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; position: relative; }
.paper { max-width: 760px; margin: 0 auto; padding: 56px 48px 30vh; }
.title-input {
  width: 100%; border: 0; outline: 0; background: none; padding: 0;
  font: 600 34px/1.2 var(--serif); letter-spacing: -.02em; color: var(--text);
}
.title-input::placeholder { color: var(--faint); opacity: .7; }
.note-meta { margin: 10px 0 26px; font-size: 12.5px; color: var(--faint); display: flex; gap: 14px; flex-wrap: wrap; }

.ed-wrap { position: relative; }
.ed-text {
  margin: 0; padding: 0; border: 0;
  font: 400 17px/1.85 var(--serif);
  letter-spacing: 0; word-spacing: .01em;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; tab-size: 4;
  font-kerning: normal; font-variant-ligatures: common-ligatures;
}
.ed-backdrop { color: transparent; min-height: 50vh; pointer-events: none; }
.ed-input {
  position: absolute; inset: 0; width: 100%; height: 100%; resize: none; overflow: hidden;
  background: transparent; outline: none; color: var(--text); caret-color: var(--accent);
}
.ed-input::placeholder { color: var(--faint); opacity: .8; font-style: italic; }

.ed-backdrop mark {
  color: transparent; background: transparent; border-radius: 3px;
  background-image: linear-gradient(var(--c), var(--c));
  background-size: 100% 2px; background-position: 0 calc(100% - 1px); background-repeat: no-repeat;
  transition: background-color .18s var(--ease);
  animation: markIn .35s var(--ease);
}
@keyframes markIn { from { background-size: 0 2px; } }
.ed-backdrop mark.spelling { --c: var(--err); background-color: var(--err-soft); }
.ed-backdrop mark.grammar  { --c: var(--warn); background-color: var(--warn-soft); }
.ed-backdrop mark.style    { --c: var(--style); background-color: transparent; }
.ed-backdrop mark.active { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 45%, transparent); }
.ed-backdrop mark.spelling.active { background-color: color-mix(in srgb, var(--err) 22%, transparent); }

/* ───────────────────────── Empty state ───────────────────────── */
.empty-state { max-width: 440px; margin: 12vh auto 0; padding: 0 24px; text-align: center; animation: viewIn .4s var(--ease); }
.empty-state h2 { font: 600 26px/1.2 var(--serif); margin: 18px 0 8px; letter-spacing: -.01em; }
.empty-state p { color: var(--muted); margin: 0 0 22px; line-height: 1.6; }
.empty-art svg { width: 140px; height: 105px; stroke-width: 0; }
.ea-paper { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.ea-line { stroke: var(--line-strong); stroke-width: 4; stroke-linecap: round; }
.ea-err { stroke: var(--err); stroke-width: 4; stroke-linecap: round; opacity: .8; }
.ea-dot { fill: var(--accent); }
.ea-check { stroke: var(--on-accent); stroke-width: 2.6; fill: none; }

/* ───────────────────────── Suggestions panel ───────────────────────── */
.issues {
  width: 320px; flex: none; display: flex; flex-direction: column; gap: 12px; padding: 18px 16px;
  border-left: 1px solid var(--line); background: var(--surface); min-height: 0;
}
.issues-head { display: flex; justify-content: space-between; align-items: flex-start; }
.issues-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.issues-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.issues-close { display: none; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.lg.spelling { background: var(--err); } .lg.grammar { background: var(--warn); } .lg.style { background: var(--style); }
.issue-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 2px 4px 12px; }
.issue {
  --c: var(--err);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: var(--surface);
  cursor: pointer; position: relative; overflow: hidden;
  transition: border-color .18s, box-shadow .18s var(--ease), transform .18s var(--ease), opacity .2s;
  animation: issueIn .3s var(--ease) both;
}
.issue::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); }
.issue.grammar { --c: var(--warn); } .issue.style { --c: var(--style); }
.issue:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.issue.active { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 14%, transparent); }
.issue.leaving { opacity: 0; transform: translateX(14px); }
@keyframes issueIn { from { opacity: 0; transform: translateY(4px); } }
.issue-cat { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--c); }
.issue-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.issue-wrong { font: 500 16px var(--serif); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--c) 70%, transparent); color: var(--muted); }
.issue-arrow { color: var(--faint); width: 14px; height: 14px; }
.issue-fix {
  font: 600 14.5px var(--ui); padding: 3px 10px; border-radius: 7px; background: var(--ok-soft); color: var(--ok);
  transition: background .15s, transform .12s;
}
.issue-fix:hover { background: var(--ok); color: #fff; }
.issue-fix:active { transform: scale(.96); }
.issue-msg { margin-top: 6px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.issues-empty { text-align: center; padding: 30px 10px; color: var(--muted); font-size: 13px; }
.issues-empty .ok-ring {
  width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok);
}

/* ───────────────────────── Popover ───────────────────────── */
.popover {
  position: fixed; z-index: 100; width: 300px; padding: 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  transform-origin: top left; animation: popIn .18s var(--ease);
}
.popover.above { transform-origin: bottom left; }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.97); } }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 650; letter-spacing: .05em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 99px;
}
.badge.spelling { background: var(--err-soft); color: var(--err); }
.badge.grammar { background: var(--warn-soft); color: var(--warn); }
.badge.style { background: var(--style-soft); color: var(--style); }
.pop-msg { margin: 9px 2px 10px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.pop-sugs { display: flex; flex-wrap: wrap; gap: 6px; }
.sug {
  padding: 6px 11px; border-radius: 8px; font-weight: 600; font-size: 14px; background: var(--surface-2); border: 1px solid var(--line);
  transition: background .14s, border-color .14s, color .14s, transform .1s;
}
.sug:first-child { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sug:hover { border-color: var(--accent); }
.sug:not(:first-child):hover { color: var(--accent); background: var(--accent-soft); }
.sug:active { transform: scale(.96); }
.pop-none { font-size: 13px; color: var(--faint); font-style: italic; }
.pop-foot { display: flex; gap: 4px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.pop-foot .btn { height: 28px; font-size: 12.5px; padding: 0 9px; }

/* ───────────────────────── Pages ───────────────────────── */
.page { flex: 1; overflow-y: auto; padding: 28px 32px 60px; }
.page > * { max-width: 1080px; margin-left: auto; margin-right: auto; }
.page.narrow > * { max-width: 640px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.stat-label svg { width: 15px; height: 15px; color: var(--faint); }
.stat-value { font: 600 28px/1.1 var(--ui); margin-top: 8px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; color: var(--faint); font-weight: 500; margin-left: 2px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); gap: 2px; }
.seg button { padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 550; color: var(--muted); transition: background .16s, color .16s, box-shadow .16s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.word-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 14px;
  display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s;
  animation: issueIn .35s var(--ease) both;
}
.word-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--line-strong); }
.wc-top { display: flex; align-items: flex-start; gap: 8px; }
.wc-word { font: 600 23px/1.2 var(--serif); letter-spacing: -.01em; word-break: break-word; }
.wc-actions { margin-left: auto; display: flex; gap: 2px; opacity: .55; transition: opacity .16s; }
.word-card:hover .wc-actions { opacity: 1; }
.wc-miss { display: flex; flex-wrap: wrap; gap: 5px; }
.miss-chip {
  font: 500 13px var(--serif); padding: 2px 8px; border-radius: 6px; background: var(--err-soft); color: var(--err);
  text-decoration: line-through; text-decoration-thickness: 1px;
}
.miss-chip b { font: 600 10.5px var(--ui); text-decoration: none; display: inline-block; margin-left: 4px; opacity: .8; }
.wc-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--faint); margin-top: auto; padding-top: 4px; }
.mastery { display: flex; align-items: center; gap: 4px; }
.mastery i { width: 16px; height: 5px; border-radius: 3px; background: var(--surface-3); transition: background .3s; }
.mastery i.on { background: var(--ok); }
.mastery span { margin-left: 4px; font-weight: 550; }
.mastery.done span { color: var(--ok); }

.empty-block {
  grid-column: 1 / -1; text-align: center; padding: 56px 20px; color: var(--muted);
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 50%, transparent);
}
.empty-block h3 { margin: 0 0 6px; color: var(--text); font: 600 20px var(--serif); }
.empty-block p { margin: 0 auto; max-width: 380px; line-height: 1.55; }

/* ───────────────────────── Exam ───────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.stage { animation: viewIn .35s var(--ease); }
.setup-card { padding: 28px; display: flex; flex-direction: column; gap: 24px; }
.setup-hero h2 { font: 600 28px/1.15 var(--serif); margin: 0 0 6px; letter-spacing: -.015em; }
.setup-hero p { margin: 0; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 10px; }
.field-label { display: flex; justify-content: space-between; align-items: baseline; font-weight: 550; }
.field-label output { font: 600 22px var(--ui); color: var(--accent); font-variant-numeric: tabular-nums; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 99px; background: var(--surface-3); outline: none; cursor: pointer;
  background-image: linear-gradient(var(--accent), var(--accent)); background-repeat: no-repeat; background-size: var(--fill, 50%) 100%; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow); transition: transform .15s var(--ease); }
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
input[type="range"]:disabled { opacity: .4; cursor: not-allowed; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); font-size: 12.5px; font-weight: 550; color: var(--muted);
  transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode {
  text-align: left; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; gap: 2px; transition: all .18s var(--ease);
}
.mode strong { font-weight: 600; }
.mode span { font-size: 12.5px; color: var(--muted); }
.mode:hover { border-color: var(--line-strong); background: var(--surface-2); }
.mode.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.mode.active strong { color: var(--accent); }

.switch-row { display: flex; align-items: center; gap: 14px; cursor: pointer; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); }
.switch-row > span:first-child { flex: 1; display: flex; flex-direction: column; }
.switch-row small { color: var(--muted); font-size: 12.5px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 40px; height: 24px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .2s var(--ease); flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .22s var(--ease); }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

.history { margin-top: 26px; }
.history h4 { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.hist-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 11px; transition: background .15s; }
.hist-row:hover { background: var(--surface); }
.hist-score { width: 46px; font-weight: 650; font-variant-numeric: tabular-nums; }
.hist-bar { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.hist-bar i { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.hist-meta { font-size: 12.5px; color: var(--faint); min-width: 120px; text-align: right; }

.run-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.progress { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--ok))); transition: width .5s var(--ease); }
.run-count { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 52px; text-align: right; }

.q-card { padding: 34px 32px 28px; min-height: 380px; display: flex; flex-direction: column; }
.q-card.swap-out { animation: qOut .2s var(--ease) forwards; }
.q-card.swap-in { animation: qIn .34s var(--ease); }
@keyframes qOut { to { opacity: 0; transform: translateX(-18px); } }
@keyframes qIn { from { opacity: 0; transform: translateX(18px); } }
.q-kind { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.q-title { font: 600 26px/1.25 var(--serif); margin: 10px 0 6px; letter-spacing: -.01em; }
.q-context {
  margin: 14px 0 0; padding: 14px 16px; border-radius: 12px; background: var(--surface-2);
  font: italic 400 17px/1.6 var(--serif); color: var(--muted);
}
.q-context .blank { font-style: normal; color: var(--accent); font-weight: 600; letter-spacing: .1em; }
.q-wrote { margin-top: 12px; font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-wrote .miss-chip { font-size: 15px; }
.q-hint { font-size: 13px; color: var(--faint); margin-top: 8px; }
.q-body { margin-top: 24px; }
.listen-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600; transition: background .15s, transform .12s; text-transform: none; letter-spacing: 0; }
.listen-btn:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.listen-btn:active { transform: scale(.95); }
.listen-btn svg { width: 15px; height: 15px; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; padding: 15px 16px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); text-align: left; font: 500 19px var(--serif);
  transition: border-color .16s, background .16s, transform .12s var(--ease), box-shadow .16s;
}
.opt kbd { font-size: 11px; }
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.opt:active:not(:disabled) { transform: scale(.98); }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); animation: pop .35s var(--ease); }
.opt.wrong { border-color: var(--err); background: var(--err-soft); color: var(--err); animation: shake .4s var(--ease); }
.opt.dim { opacity: .45; }
@keyframes pop { 40% { transform: scale(1.03); } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

.type-row { display: flex; gap: 10px; }
.type-input {
  flex: 1; min-width: 0; height: 56px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--surface); outline: none; font: 500 22px var(--serif); letter-spacing: .01em;
  transition: border-color .16s, box-shadow .16s;
}
.type-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.type-input.right { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.type-input.wrong { border-color: var(--err); background: var(--err-soft); color: var(--err); animation: shake .4s var(--ease); }
.type-row .btn { height: 56px; padding: 0 22px; border-radius: 12px; }
.skip-link { margin-top: 10px; font-size: 13px; color: var(--faint); }
.skip-link:hover { color: var(--muted); text-decoration: underline; }

.feedback {
  margin-top: auto; padding-top: 22px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  animation: viewIn .3s var(--ease);
}
.fb-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.fb-icon svg { width: 20px; height: 20px; stroke-width: 2.4; }
.feedback.right .fb-icon { background: var(--ok-soft); color: var(--ok); }
.feedback.wrong .fb-icon { background: var(--err-soft); color: var(--err); }
.fb-text { flex: 1; min-width: 160px; }
.fb-text strong { display: block; }
.fb-text span { color: var(--muted); font-size: 13.5px; }
.fb-text em { font: italic 600 16px var(--serif); color: var(--text); }
.feedback .btn { margin-left: auto; }

.results { padding: 34px 30px 28px; text-align: center; }
.ring { width: 150px; height: 150px; margin: 0 auto 12px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); stroke-width: 10; }
.ring .track { stroke: var(--surface-3); }
.ring .fill { stroke: var(--ok); stroke-dasharray: 402; stroke-dashoffset: 402; transition: stroke-dashoffset 1.1s var(--ease) .15s; }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; }
.ring-label b { font: 650 36px var(--ui); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ring-label span { font-size: 12.5px; color: var(--muted); }
.results h2 { font: 600 26px var(--serif); margin: 6px 0 4px; }
.results > p { color: var(--muted); margin: 0 0 22px; }
.res-list { text-align: left; border-top: 1px solid var(--line); margin-top: 6px; }
.res-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); animation: issueIn .3s var(--ease) both; }
.res-row .fb-icon { width: 26px; height: 26px; }
.res-row .fb-icon svg { width: 14px; height: 14px; }
.res-row.right .fb-icon { background: var(--ok-soft); color: var(--ok); }
.res-row.wrong .fb-icon, .res-row.skip .fb-icon { background: var(--err-soft); color: var(--err); }
.res-word { font: 600 17px var(--serif); }
.res-ans { margin-left: auto; font-size: 13px; color: var(--faint); text-align: right; }
.res-ans s { color: var(--err); font-family: var(--serif); font-size: 14.5px; }
.res-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }

/* ───────────────────────── Dictation ───────────────────────── */
.dict-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.dict-stats .stat { padding: 12px 14px; }
.dict-stats .stat-value { font-size: 22px; margin-top: 4px; }
.dict-card { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 18px; }
.dict-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.player {
  display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface-2);
}
.play-btn {
  width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center; position: relative;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 8px 22px -8px var(--accent-ring), inset 0 1px 0 rgba(255,255,255,.2);
  transition: transform .15s var(--ease), background .15s;
}
.play-btn:hover { background: var(--accent-hover); transform: scale(1.04); }
.play-btn:active { transform: scale(.95); }
.play-btn .i-play { width: 26px; height: 26px; fill: currentColor; stroke: none; margin-left: 3px; }
.play-btn::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; pointer-events: none;
}
.bars { display: none; gap: 3px; align-items: center; height: 22px; }
.bars i { width: 4px; border-radius: 2px; background: currentColor; animation: bar 0.9s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: -.2s; } .bars i:nth-child(3) { animation-delay: -.45s; } .bars i:nth-child(4) { animation-delay: -.65s; }
@keyframes bar { 0%, 100% { height: 6px; } 50% { height: 22px; } }
.play-btn.is-playing .i-play { display: none; }
.play-btn.is-playing .bars { display: flex; }
.play-btn.is-playing::after { animation: ring 1.4s var(--ease) infinite; }
@keyframes ring { 0% { opacity: .55; transform: scale(.92); } 100% { opacity: 0; transform: scale(1.25); } }
.player-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.player-info strong { font-size: 15px; font-weight: 600; }
.player-info span { font-size: 13px; color: var(--muted); }

.dict-input {
  width: 100%; resize: vertical; min-height: 96px; padding: 14px 16px; border-radius: 12px;
  border: 1.5px solid var(--line-strong); background: var(--surface); outline: none;
  font: 400 20px/1.55 var(--serif); transition: border-color .16s, box-shadow .16s;
}
.dict-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.dict-input:read-only { background: var(--surface-2); color: var(--muted); }
.dict-input.shake { animation: shake .4s var(--ease); }
.dict-actions { display: flex; align-items: center; gap: 8px; }
.dict-hints { margin-right: auto; font-size: 12px; color: var(--faint); }
.dict-note { text-align: center; font-size: 12.5px; color: var(--faint); margin-top: 14px; }

.dict-result { border-top: 1px solid var(--line); padding-top: 18px; animation: viewIn .32s var(--ease); }
.dr-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.dr-score {
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font: 650 17px var(--ui); font-variant-numeric: tabular-nums;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0);
  position: relative;
}
.dr-score::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.dr-score span { position: relative; }
.dr-title strong { display: block; font-size: 16px; }
.dr-title span { font-size: 13px; color: var(--muted); }
.diff { font: 400 20px/2.1 var(--serif); padding: 14px 16px; border-radius: 12px; background: var(--surface-2); }
.dw { display: inline; padding: 2px 3px; border-radius: 5px; }
.dw.ok { color: var(--text); }
.dw.bad s, .dw.extra s { color: var(--err); text-decoration-thickness: 1.5px; margin-right: 4px; }
.dw.bad ins, .dw.miss ins { text-decoration: none; color: var(--ok); font-weight: 600; background: var(--ok-soft); padding: 1px 5px; border-radius: 5px; }
.dw.miss ins { border: 1.5px dashed color-mix(in srgb, var(--ok) 55%, transparent); background: transparent; }
.dw.extra s { opacity: .8; }
.diff-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.diff-legend span { display: inline-flex; align-items: center; gap: 6px; }
.diff-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dr-answer { margin-top: 14px; font-size: 13px; color: var(--muted); }
.dr-answer b { display: block; font-weight: 600; color: var(--faint); font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; margin-bottom: 3px; }
.dr-answer p { margin: 0; font: italic 400 16px/1.5 var(--serif); color: var(--text); }
.dr-foot { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.dr-foot .btn.primary { margin-left: auto; }
.dr-logged { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.dr-logged svg { width: 15px; height: 15px; color: var(--accent); }

@media (max-width: 860px) {
  .dict-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dict-card { padding: 18px 16px; }
  .dict-hints { display: none; }
  .dict-actions .btn.primary { margin-left: auto; }
  .player { flex-wrap: wrap; }
  .diff, .dict-input { font-size: 18px; }
}

/* ───────────────────────── Translation ───────────────────────── */
:root { --ar: "Cairo", "Geeza Pro", "Noto Naskh Arabic", "Segoe UI", sans-serif; }
.ar-badge {
  width: 28px; height: 28px; border-radius: 8px; display: inline-grid; place-items: center; flex: none;
  font: 700 16px/1 var(--ar); background: var(--accent-soft); color: var(--accent); padding-bottom: 3px;
}
.ar-badge.sm { width: 20px; height: 20px; font-size: 13px; border-radius: 6px; padding-bottom: 2px; }
.side-tool {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; cursor: pointer;
  background: var(--surface-2); transition: background .16s;
}
.side-tool:hover { background: var(--surface-3); }
.side-tool-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.side-tool-text strong { font-size: 12.5px; font-weight: 600; }
.side-tool-text small { font-size: 11px; color: var(--faint); }
.side-tool input { position: absolute; opacity: 0; pointer-events: none; }
.switch.sm { width: 32px; height: 19px; }
.switch.sm::after { width: 13px; height: 13px; }
.side-tool input:checked + .switch { background: var(--accent); }
.side-tool input:checked + .switch.sm::after { transform: translateX(13px); }
.side-tool input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
body.click-translate .main { cursor: help; }
body.click-translate .main :is(button, input, select, a, .ed-input) { cursor: auto; }
body.click-translate .main button { cursor: pointer; }
body.click-translate .ed-input { cursor: text; }

.tpop {
  position: fixed; z-index: 110; width: 320px; max-width: calc(100vw - 24px); border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  overflow: hidden; animation: popIn .18s var(--ease); transform-origin: top left;
}
.tp-head { padding: 14px 14px 12px; display: flex; align-items: flex-start; gap: 10px; border-bottom: 1px solid var(--line); }
.tp-word { flex: 1; min-width: 0; }
.tp-word strong { display: block; font-size: 17px; font-weight: 600; line-height: 1.3; word-break: break-word; }
.tp-word strong.long { font-size: 14px; font-weight: 500; }
.tp-phon { font-size: 12.5px; color: var(--faint); font-family: var(--mono); }
.tp-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 12px; max-height: 340px; overflow-y: auto; }
.tp-ar {
  direction: rtl; text-align: right; font: 700 26px/1.5 var(--ar); color: var(--accent);
  padding: 8px 12px; border-radius: 12px; background: var(--accent-soft);
}
.tp-ar.long { font-size: 18px; font-weight: 600; line-height: 1.75; }
.tp-section b { display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.tp-pos { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.tp-pos > span { font-size: 11.5px; color: var(--muted); min-width: 64px; font-style: italic; }
.tp-terms { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; direction: rtl; justify-content: flex-start; }
.tp-terms i { font: 600 14px/1.6 var(--ar); font-style: normal; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); }
.tp-def { font-size: 13px; line-height: 1.5; margin-bottom: 6px; }
.tp-def em { font-size: 11.5px; color: var(--muted); margin-right: 4px; }
.tp-def q { display: block; color: var(--muted); font-style: italic; font-size: 12.5px; margin-top: 2px; }
.tp-def q::before, .tp-def q::after { content: '"'; }
.skel { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; }
.skel.big { height: 44px; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.tp-err { font-size: 13px; color: var(--err); }

.sel-translate {
  position: fixed; z-index: 105; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px;
  border-radius: 10px; background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: popIn .15s var(--ease);
}
.sel-translate .ar-badge { background: rgba(127,127,127,.25); color: inherit; }
.pop-ar {
  margin-top: 10px; padding: 7px 10px; border-radius: 9px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px;
}
.pop-ar span:last-child { direction: rtl; font: 700 16px/1.4 var(--ar); }

/* ───────────────────────── Toasts ───────────────────────── */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; padding: 10px 16px; border-radius: 11px; background: var(--text); color: var(--bg);
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 9px;
  opacity: 0; transform: translateY(10px) scale(.97); transition: opacity .25s var(--ease), transform .25s var(--ease);
  max-width: min(92vw, 460px);
}
.toast.in { opacity: 1; transform: none; }
.toast.err::before, .toast.ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.toast.err::before { background: var(--err); }
.toast.ok::before { background: var(--ok); }

.scrim { display: none; }

/* ───────────────────────── Responsive ───────────────────────── */
@media (max-width: 1180px) {
  .issues {
    position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow-lg);
    transform: translateX(105%); transition: transform .3s var(--ease); visibility: hidden;
  }
  .issues.open { transform: none; visibility: visible; }
  .issues-close { display: inline-grid; }
}
@media (min-width: 1181px) { #btn-issues { display: none; } }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 284px;
    transform: translateX(-102%); visibility: hidden;
    transition: transform .3s var(--ease), visibility 0s linear .3s;
  }
  .sidebar.open { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform .3s var(--ease); }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .3s; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .icon-btn.menu-btn { display: inline-grid; margin-left: -6px; }
  .topbar { padding: 0 16px; gap: 8px; }
  .paper { padding: 32px 16px 30vh; }
  .title-input { font-size: 28px; }
  .ed-text { font-size: 16px; }
  .wordcount, #check-status { display: none; }
  .page { padding: 20px 16px 48px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-grid { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
  .q-card { padding: 24px 18px 20px; }
  .setup-card { padding: 22px 18px; }
  .issues { width: min(340px, 92vw); }
  .hist-meta { min-width: 0; }
}

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

/* ───────────────────────── Listen buttons: loading / playing ───────────────────────── */
.spin {
  width: 15px; height: 15px; flex: none; border-radius: 50%; display: inline-block;
  border: 2px solid currentColor; border-right-color: transparent; opacity: .85;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.is-loading { pointer-events: none; cursor: progress; }
.is-loading > svg, .is-loading > .i-play, .is-loading > .bars { display: none !important; }
.icon-btn.is-loading .spin { width: 14px; height: 14px; }
.play-btn .spin { width: 26px; height: 26px; border-width: 3px; }
.play-btn.is-loading { background: var(--accent-hover); }

.is-playing:not(.play-btn) { color: var(--accent) !important; background: var(--accent-soft) !important; }
.is-playing:not(.play-btn) > svg { animation: soundPulse 0.9s ease-in-out infinite; }
@keyframes soundPulse { 50% { transform: scale(1.18); opacity: .7; } }
#dict-slow.is-playing, [data-dict-replay].is-playing { border-color: var(--accent); }
