/* Grammerify — responsive, RTL-first UI with LTR English content. */
/* Palette: "ink & paper" — warm paper, deep green ink, terracotta accent. */
:root {
  --bg: #f5f1e8;
  --surface: #fffdf8;
  --surface-2: #f0eadd;
  --text: #24211c;
  --muted: #6e675b;
  --border: #e3dac8;
  --primary: #1f6f5c;
  --primary-2: #185a4a;
  --primary-ink: #134a3d;
  --primary-soft: #e0eee8;
  --on-primary: #fffdf8;
  --ok: #2f7d3a;
  --ok-soft: #e4f1e1;
  --bad: #c0392b;
  --bad-soft: #fbe6e1;
  --warn: #a05e00;
  --warn-soft: #fbefd7;
  --ai: #b8532a;
  --ai-soft: #fbe9de;
  --sun: #e2a72e;
  --dot: rgba(60, 50, 30, .09);
  --shadow: 0 1px 0 rgba(60, 45, 20, .06), 0 10px 24px -14px rgba(60, 45, 20, .22);
  --radius: 16px;
  --radius-sm: 11px;
  --font-fa: 'Vazirmatn', Tahoma, 'Segoe UI', system-ui, sans-serif;
  --font-en: 'Nunito', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-head: 'Fraunces', Georgia, 'Times New Roman', serif;
  --topbar-h: 56px;
  --bottomnav-h: 64px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161915; --surface: #1e221d; --surface-2: #272c26; --text: #ece6d8; --muted: #a39d8f; --border: #333a32;
    --primary: #6cc3a6; --primary-2: #84d1b7; --primary-ink: #3d8f75; --primary-soft: #1f3530; --on-primary: #0f1a16;
    --ok: #7ccf86; --ok-soft: #1c3320; --bad: #ff8a7a; --bad-soft: #3f211d; --warn: #f0b552; --warn-soft: #3a2d14;
    --ai: #f0a070; --ai-soft: #3b261b; --sun: #f0c25a; --dot: rgba(255, 245, 220, .06);
    --shadow: 0 1px 0 rgba(0,0,0,.35), 0 12px 26px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161915; --surface: #1e221d; --surface-2: #272c26; --text: #ece6d8; --muted: #a39d8f; --border: #333a32;
  --primary: #6cc3a6; --primary-2: #84d1b7; --primary-ink: #3d8f75; --primary-soft: #1f3530; --on-primary: #0f1a16;
  --ok: #7ccf86; --ok-soft: #1c3320; --bad: #ff8a7a; --bad-soft: #3f211d; --warn: #f0b552; --warn-soft: #3a2d14;
  --ai: #f0a070; --ai-soft: #3b261b; --sun: #f0c25a; --dot: rgba(255, 245, 220, .06);
  --shadow: 0 1px 0 rgba(0,0,0,.35), 0 12px 26px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-en), var(--font-fa); font-size: 16px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
.en, [lang="en"], code, kbd { font-family: var(--font-en); }
.en, [lang="en"] { line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.4; margin: 0 0 .6rem; }
h1 { font-size: 1.55rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
h3 { font-size: 1rem; font-weight: 700; margin-top: 1.1rem; }
p { margin: .4rem 0 .8rem; }
small { font-size: .82em; }
.muted { color: var(--muted); }
.sm { font-size: .85rem; }
.center { text-align: center; justify-content: center; }
.x { color: var(--bad); font-weight: 700; }
.v { color: var(--ok); font-weight: 700; }
code { background: var(--surface-2); padding: .05em .35em; border-radius: 5px; font-size: .9em; }
kbd { font-size: .7em; opacity: .7; border: 1px solid currentColor; border-radius: 4px; padding: 0 .3em; margin-inline-start: .3em; }
[hidden] { display: none !important; }
.skip { position: absolute; inset-inline-start: 0; top: 0; transform: translateY(-200%); background: var(--primary); color: var(--on-primary); padding: .5rem 1rem; z-index: 100; }
.skip:focus { transform: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.18em; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .55rem; font-family: var(--font-en); font-weight: 800; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.topbar-stats { display: flex; gap: .4rem; }
.stat-pill { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .65rem; border-radius: 99px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: .9rem; }
.stat-pill:hover { text-decoration: none; background: var(--primary-soft); }
.stat-pill.hot { color: var(--ai); }
.stat-pill.icon-only { padding: .35rem; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
main { min-width: 0; padding: 20px 16px calc(var(--bottomnav-h) + 28px); width: 100%; max-width: 920px; margin: 0 auto; outline: none; }
.sidenav { display: none; }
.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface); border-top: 1px solid var(--border);
}
.bottom-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .7rem; font-weight: 600; text-align: center; line-height: 1.2; }
.bottom-link .ic { width: 22px; height: 22px; }
.bottom-link.active { color: var(--primary); }
.bottom-link:hover { text-decoration: none; }

@media (min-width: 900px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .sidenav { display: flex; flex-direction: column; gap: 4px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); padding: 18px 12px; border-inline-end: 1px solid var(--border); background: var(--surface); }
  .side-link { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: var(--radius-sm); color: var(--text); font-weight: 600; }
  .side-link:hover { background: var(--surface-2); text-decoration: none; }
  .side-link.active { background: var(--primary-soft); color: var(--primary); }
  .bottomnav { display: none; }
  main { padding: 28px 32px 48px; }
}

/* ---------- basics ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.center { display: flex; align-items: center; gap: .7rem; flex-direction: column; padding: 32px; }
.page-head { margin-bottom: 16px; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-2 > .card { margin-bottom: 0; } .grid-2 { margin-bottom: 16px; } }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 42px; padding: .45rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-ai { background: var(--ai-soft); border-color: transparent; color: var(--ai); }
.btn-ai:hover { background: color-mix(in srgb, var(--ai-soft) 70%, var(--ai) 12%); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.sm { min-height: 34px; padding: .25rem .7rem; font-size: .85rem; }
.btn-lg { min-height: 50px; padding: .6rem 1.3rem; font-size: 1.02rem; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; padding: 0; vertical-align: middle; }
.icon-btn:hover { background: var(--surface-2); color: var(--primary); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm .ic { width: 1em; height: 1em; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0 .2rem; font-size: .85rem; }
.link { font-size: .9rem; font-weight: 600; }

.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.chip-soft { background: var(--primary-soft); color: var(--primary); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-ai { background: var(--ai-soft); color: var(--ai); }
a.chip:hover { text-decoration: none; filter: brightness(.97); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.badge { display: inline-flex; align-items: center; padding: .05rem .5rem; border-radius: 99px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.mid { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.hot { background: var(--bad-soft); color: var(--bad); }

input, select, textarea { font: inherit; color: var(--text); }
input[type="text"], input[type="password"], input[type="search"], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: .55rem .8rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; line-height: 1.6; }
.search { margin-top: .6rem; }
.search.sm { max-width: 260px; margin: 0; min-height: 36px; }
.form { display: flex; flex-direction: column; gap: .9rem; }
.form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .95rem; }
.check { display: inline-flex !important; flex-direction: row !important; align-items: flex-start; gap: .5rem; font-weight: 500 !important; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: .3rem; accent-color: var(--primary); flex: none; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 0 0 .8rem; padding: .6rem .8rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .2rem .8rem; font-size: .9rem; }

.spinner { width: 18px; height: 18px; border: 2.5px solid var(--border); border-top-color: var(--primary); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.toasts { position: fixed; z-index: 50; inset-inline: 0; bottom: calc(var(--bottomnav-h) + 16px); display: flex; flex-direction: column; align-items: center; gap: .5rem; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { pointer-events: auto; max-width: 520px; background: var(--text); color: var(--bg); padding: .65rem 1rem; border-radius: 12px; box-shadow: var(--shadow); font-size: .92rem; animation: up .2s ease; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-error { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

/* ---------- progress / bars ---------- */
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .3s; }
.bar.bad > span { background: linear-gradient(90deg, var(--warn), var(--bad)); }
.bars { display: flex; flex-direction: column; gap: .55rem; margin: .4rem 0 .8rem; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; align-items: center; gap: .7rem; color: var(--text); }
.bar-row.link:hover { text-decoration: none; }
.bar-row.link:hover .bar-label { color: var(--primary); }
.bar-label { font-size: .88rem; font-weight: 600; line-height: 1.4; }
.bar-val { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.bar-actions { grid-column: 1 / -1; display: flex; gap: .3rem; margin-top: -.2rem; }
@media (min-width: 640px) { .bar-row:has(.bar-actions) { grid-template-columns: minmax(130px, 30%) 1fr auto auto; } .bar-actions { grid-column: auto; margin: 0; } }
.mini-progress { display: flex; align-items: center; gap: .7rem; margin-top: .8rem; font-size: .85rem; }

.score-ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 1rem;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-2) 0); position: relative; }
.score-ring::before { content: ''; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.score-ring span { position: relative; font-size: 1.6rem; font-weight: 800; }
.score-ring.sm { width: 84px; height: 84px; margin: 0; }
.score-ring.sm::before { inset: 8px; }
.score-ring.sm span { font-size: 1.15rem; }
.score-ring small { font-size: .7rem; color: var(--muted); }

/* ---------- home ---------- */
.hero { display: flex; gap: 1.2rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--primary-soft), var(--surface) 70%); }
.hero > div:first-child { flex: 1 1 340px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .8rem; }
.goal { display: flex; align-items: center; gap: .8rem; }
.goal-text { display: flex; flex-direction: column; line-height: 1.5; }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tool { display: flex; flex-direction: column; gap: .3rem; align-items: flex-start; text-align: start; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text); cursor: pointer; font: inherit; box-shadow: var(--shadow); transition: border-color .15s, transform .1s; }
.tool:hover { border-color: var(--primary); text-decoration: none; transform: translateY(-1px); }
.tool .ic { width: 26px; height: 26px; color: var(--primary); }
.tool strong { font-size: 1rem; display: flex; gap: .4rem; align-items: center; }
.tool small { color: var(--muted); line-height: 1.6; }
.tool.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tool.primary .ic, .tool.primary small { color: var(--on-primary); opacity: .92; }
.card .tools-grid { margin-bottom: 0; }
.card .tool { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.card .tool:hover { border-color: var(--primary); }
.chips-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: .4rem 0 .8rem; }
.tag-card { display: flex; flex-direction: column; padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); border: 1px solid transparent; line-height: 1.5; }
.tag-card:hover { border-color: var(--primary); text-decoration: none; }
.tag-card small { color: var(--muted); }
.tag-card.known { border-inline-start: 3px solid var(--warn); }
.warn-card { background: var(--warn-soft); border-color: transparent; color: var(--text); display: flex; gap: .6rem; align-items: flex-start; }
.warn-card .ic { color: var(--warn); margin-top: .3rem; }

/* ---------- lessons ---------- */
.level { margin-bottom: 22px; }
.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson-row { display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.lesson-row:hover { border-color: var(--primary); text-decoration: none; }
.lesson-row.big { background: var(--surface-2); border-color: transparent; }
.lesson-row .ic { color: var(--muted); }
.lr-text { flex: 1; display: flex; flex-direction: column; line-height: 1.45; min-width: 0; }
.lr-text .en { font-weight: 600; text-align: start; }
.lr-text small { color: var(--muted); }
.num { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: .95rem; }
.num.done { background: var(--ok-soft); color: var(--ok); }
.num.lg { width: 52px; height: 52px; font-size: 1.3rem; border-radius: 14px; }
.soon { opacity: .8; }

.lesson-head { display: flex; gap: 1rem; align-items: center; margin-bottom: .6rem; }
.lesson-head h1 { margin: 0; text-align: left; }
.toc { display: flex; gap: .4rem; overflow-x: auto; padding: .2rem 0 .8rem; margin-bottom: .4rem; scrollbar-width: none; position: sticky; top: var(--topbar-h); z-index: 5; background: var(--bg); }
.toc::-webkit-scrollbar { display: none; }
.toc a { flex: none; padding: .25rem .8rem; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: .85rem; font-weight: 600; }
.toc a:hover { border-color: var(--primary); text-decoration: none; }
.lesson .card { scroll-margin-top: calc(var(--topbar-h) + 56px); }
.en-block { text-align: left; font-size: 1.02rem; }
.en-block p { margin: .3rem 0 .6rem; }
.fa-note { margin-top: .8rem; padding: .7rem .9rem; border-radius: var(--radius-sm); background: var(--warn-soft); border-inline-start: 4px solid var(--warn); }
.fa-note p { margin: 0; }
.formula { display: flex; flex-direction: column; gap: 8px; }
.f-row { display: grid; grid-template-columns: 92px 1fr; gap: .8rem; align-items: start; padding: .6rem .7rem; border-radius: var(--radius-sm); background: var(--surface-2); }
@media (max-width: 520px) { .f-row { grid-template-columns: 1fr; gap: .3rem; } }
.f-k { font-weight: 700; font-size: .85rem; padding: .1rem .5rem; border-radius: 6px; background: var(--surface); text-align: center; justify-self: start; }
.f-k.pos { color: var(--ok); } .f-k.neg { color: var(--bad); } .f-k.q { color: var(--primary); }
.f-body { text-align: left; }
.f-ex { color: var(--muted); font-style: italic; display: flex; align-items: center; gap: .2rem; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; margin: .4rem 0 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table-wrap.tall { max-height: 520px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
td[dir="rtl"] { text-align: right; font-family: var(--font-fa); }
table.verbs tr.weak td { background: var(--bad-soft); }
table.verbs tr.known td:nth-child(2) { color: var(--ok); }
table.memorize td.hideable { color: transparent; background: var(--surface-2) !important; cursor: pointer; border-radius: 4px; }
table.memorize td.hideable.peek { color: var(--text); }
.en-list { text-align: left; padding-left: 1.3rem; padding-right: 0; margin: .3rem 0; }
.en-list li { margin: .25rem 0; }
.examples { list-style: none; padding: 0; margin: 0; text-align: left; display: flex; flex-direction: column; gap: 4px; }
.examples li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem .7rem; border-radius: 8px; background: var(--surface-2); }
.mistakes { display: grid; gap: 10px; }
@media (min-width: 640px) { .mistakes { grid-template-columns: 1fr 1fr; } }
.mistake { padding: .7rem .8rem; border-radius: var(--radius-sm); border: 1px solid var(--border); text-align: left; }
.mx { color: var(--bad); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.mv { color: var(--ok); font-weight: 600; display: flex; align-items: center; gap: .2rem; flex-wrap: wrap; }
.mw { color: var(--muted); font-size: .88rem; margin-top: .2rem; }
.pairs { display: flex; flex-direction: column; gap: 6px; margin: .6rem 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; padding: .4rem .7rem; border-radius: 8px; background: var(--surface-2); text-align: left; font-size: .93rem; }
@media (max-width: 560px) { .pair { grid-template-columns: 1fr; gap: 0; } }
.practice-cta { background: linear-gradient(135deg, var(--primary-soft), var(--surface)); }
.pager { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin: 1rem 0; }
.pager .btn { max-width: 100%; }
.ai-box:not(:empty) { margin-top: .8rem; }
.ai-answer { padding: .8rem 1rem; border-radius: var(--radius-sm); background: var(--ai-soft); border-inline-start: 4px solid var(--ai); }
.ai-answer p { margin: .25rem 0; }
.ai-answer ul, .ai-answer ol { margin: .3rem 0; padding-inline-start: 1.3rem; }
.ai-answer h4 { margin: .6rem 0 .2rem; }
.ask { display: flex; gap: .5rem; margin-top: .8rem; }
.ask input { flex: 1; }

/* Persian on tap */
.fa-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 24px; padding: 0 .45rem; margin-inline-start: .3rem; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: 600 .75rem var(--font-fa); cursor: pointer; vertical-align: middle; }
.fa-btn:hover, .fa-btn.on { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.ai-answer > .fa-btn { margin: .5rem 0 0; height: 30px; padding: 0 .8rem; }
.fa-text { margin-top: .35rem; padding: .45rem .7rem; border-radius: 8px; background: var(--warn-soft); font-family: var(--font-fa); text-align: right; line-height: 1.8; }
.fa-text p { margin: .15rem 0; }
.explain { margin-top: .25rem; }
.explain[dir="ltr"] { text-align: left; }
details.fa-note summary { cursor: pointer; font-weight: 700; color: var(--warn); }
details.fa-note[open] summary { margin-bottom: .4rem; }
.ai-answer[dir="ltr"] { border-inline-start: 0; border-left: 4px solid var(--ai); text-align: left; }
.ai-answer[dir="ltr"] ul, .ai-answer[dir="ltr"] ol { padding-left: 1.3rem; padding-right: 0; }
.msg.bot.ai-answer[dir="ltr"] { border-left: 0; }

/* ---------- runner ---------- */
.runner { max-width: 720px; margin: 0 auto; }
.runner-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .6rem; }
.progress { flex: 1; height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: inherit; transition: width .3s; }
.runner-count, .runner-score { font-weight: 700; font-size: .9rem; white-space: nowrap; display: flex; align-items: center; gap: .2rem; }
.runner-score { color: var(--ok); }
.runner-title { color: var(--muted); font-size: .9rem; margin-bottom: .6rem; text-align: center; }
.q-card { padding: 22px 20px; transition: border-color .2s, background .2s; }
.q-card.is-right { border-color: var(--ok); }
.q-card.is-wrong { border-color: var(--bad); }
.q-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; font-size: .85rem; }
.q-type { font-weight: 700; color: var(--muted); }
.q-lesson { margin-inline-start: auto; font-size: .8rem; }
.q-instr { color: var(--primary); font-weight: 600; margin-bottom: .4rem; text-align: left; }
.q-body { font-size: 1.3rem; line-height: 2.1; margin: .4rem 0 1rem; text-align: left; font-weight: 500; overflow-wrap: anywhere; }
.q-body.fa-prompt { text-align: right; font-family: var(--font-fa); font-size: 1.25rem; padding: .7rem .9rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.gap-input { display: inline-block; width: 9.5em !important; min-height: 40px !important; padding: .2rem .5rem !important; margin: 0 .3rem; font-size: 1.1rem !important; text-align: center; border-width: 0 0 2.5px 0 !important; border-radius: 6px 6px 0 0 !important; background: var(--primary-soft) !important; vertical-align: baseline; }
.answer-input { font-size: 1.1rem !important; }
.options { display: grid; gap: 8px; margin: .2rem 0 .8rem; }
@media (min-width: 560px) { .options { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.option { min-height: 50px; padding: .6rem 1rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-family: var(--font-en); font-size: 1.05rem; font-weight: 600; cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.option.fa { font-family: var(--font-fa); text-align: start; font-weight: 500; }
.option:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.option:disabled { cursor: default; opacity: .75; }
.option.opt-right { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); opacity: 1; }
.option.opt-wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); opacity: 1; }
.order-line { min-height: 58px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: .5rem; border: 2px dashed var(--border); border-radius: var(--radius-sm); margin-bottom: .3rem; }
.order-line .placeholder { color: var(--muted); font-family: var(--font-fa); font-size: .9rem; padding: 0 .4rem; }
.order-end { text-align: left; color: var(--muted); font-size: .85rem; min-height: 1em; margin-bottom: .6rem; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 1rem; min-height: 44px; }
.tile { min-height: 42px; padding: .3rem .8rem; border-radius: 10px; border: 1.5px solid var(--border); border-bottom-width: 3px; background: var(--surface); color: var(--text); font-family: var(--font-en); font-size: 1.05rem; font-weight: 600; cursor: pointer; }
.tile:hover:not(:disabled) { border-color: var(--primary); }
.tile-on { background: var(--primary-soft); border-color: var(--primary); }
.verb-q { display: flex; align-items: center; gap: .8rem; margin: .4rem 0 1rem; flex-wrap: wrap; }
.verb-base { font-size: 1.8rem; font-weight: 800; }
.verb-fa { color: var(--muted); }
.verb-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1rem; }
.verb-inputs label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); font-family: var(--font-en); }
.verb-inputs input { font-size: 1.1rem !important; }
@media (max-width: 420px) { .verb-inputs { grid-template-columns: 1fr; } }
input.in-right { border-color: var(--ok) !important; background: var(--ok-soft) !important; }
input.in-wrong { border-color: var(--bad) !important; background: var(--bad-soft) !important; }
.q-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.q-actions .btn-primary { flex: 1 1 160px; }
.hint { margin: -.4rem 0 .8rem; font-size: .9rem; color: var(--muted); }
.hint summary { cursor: pointer; }

.feedback:not(:empty) { margin-top: .6rem; }
.fb { display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; border-radius: var(--radius-sm); margin-bottom: .6rem; }
.fb-right { background: var(--ok-soft); color: var(--ok); }
.fb-wrong { background: var(--bad-soft); color: var(--bad); }
.fb-wait { background: var(--surface-2); color: var(--muted); }
.fb-warn { padding: .5rem .8rem; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); margin: .4rem 0; display: flex; gap: .4rem; align-items: flex-start; }
.fb-correct { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .4rem 0; font-size: 1.05rem; }
.fb-correct .en { font-weight: 700; color: var(--ok); }
.fb-label { color: var(--muted); font-size: .9rem; }
.fb-line { margin: .3rem 0; color: var(--muted); }
.fb-line .en { color: var(--text); }
.fb-explain { margin: .6rem 0; padding: .5rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); display: flex; gap: .5rem; align-items: flex-start; }
.fb-explain .ic { color: var(--warn); margin-top: .35rem; }
.fb-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.fb-actions.center { justify-content: center; }
.strike { text-decoration: line-through; color: var(--bad) !important; }
.diff { margin: .5rem 0; padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); text-align: left; line-height: 2; font-size: 1.02rem; }
.d-del { color: var(--bad); text-decoration: line-through; background: var(--bad-soft); border-radius: 4px; padding: 0 .15em; }
.d-add { color: var(--ok); font-weight: 700; background: var(--ok-soft); border-radius: 4px; padding: 0 .15em; }
.legend { font-size: .8rem; color: var(--muted); display: flex; gap: .6rem; }
.err-list { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-direction: column; gap: 8px; }
.err-list li { padding: .6rem .8rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.err-list .en { text-align: left; }
.err-list s { color: var(--bad); }
.err-list b { color: var(--ok); }
.err-meta { display: flex; gap: .5rem; align-items: center; margin: .3rem 0; }

.summary { text-align: center; }
.summary .bars, .summary .review-list { text-align: start; }
.review-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.review-list li { padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.rl-q { font-weight: 600; }
.rl-a, .rl-c { text-align: left; }
.rl-a s { color: var(--bad); }
.rl-c { color: var(--ok); font-weight: 700; }
.rl-e { color: var(--muted); font-size: .88rem; }
.empty { text-align: center; }

/* ---------- mistakes ---------- */
.mistake-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.mistake-list li { padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.mistake-list .en { text-align: left; }
.ml-top { display: flex; align-items: center; gap: .5rem; }
.ml-top .icon-btn { margin-inline-start: auto; }
.ml-p { color: var(--muted); font-size: .9rem; }
.ml-n { color: var(--muted); font-size: .88rem; margin-top: .2rem; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; align-items: center; gap: .7rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.history li span:first-child { flex: 1; }
.history li:last-child { border: 0; }

/* ---------- AI tools ---------- */
.big-en { font-size: 1.35rem; font-weight: 700; text-align: left; margin: .3rem 0 .6rem; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; transition: filter .2s; }
.big-en.blur { filter: blur(7px); user-select: none; }
.grammar-points { padding-inline-start: 1.2rem; }
.grammar-points li { margin: .4rem 0; }
.word-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.word { padding: .2rem .6rem; border-radius: 8px; background: var(--surface-2); font-size: .9rem; }
.phrase-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.phrase-list li { padding: .5rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.phrase-list .en { text-align: left; font-weight: 600; }
.task { padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--primary-soft); }
.task .en { font-weight: 600; }
.card.is-right { border-color: var(--ok); }
.card.is-wrong { border-color: var(--bad); }
.chat-log { display: flex; flex-direction: column; gap: 10px; margin-top: .8rem; }
.chat-log.big { min-height: 45vh; max-height: calc(100vh - 330px); overflow-y: auto; padding: .4rem; }
.msg { max-width: 88%; padding: .6rem .9rem; border-radius: 16px; line-height: 1.6; }
.msg.user { align-self: flex-end; background: var(--primary-soft); border-end-start-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--surface-2); border-end-end-radius: 4px; display: flex; align-items: flex-start; gap: .2rem; flex-direction: column; }
.msg.bot.ai-answer { background: var(--ai-soft); }
.msg .en { text-align: left; }
.msg.user { text-align: left; }
.corr { margin-top: .5rem; padding-top: .4rem; border-top: 1px dashed var(--border); font-size: .9rem; text-align: start; }
.corr .diff { font-size: .92rem; background: var(--surface); }
.corr.ok { color: var(--ok); display: flex; gap: .3rem; align-items: center; }
.chat-wrap { display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: .6rem; padding-bottom: .6rem; border-bottom: 1px solid var(--border); }
.chat-head > div { flex: 1; display: flex; flex-direction: column; line-height: 1.4; }
.chat-input { display: flex; gap: .5rem; align-items: flex-end; position: sticky; bottom: calc(var(--bottomnav-h) + 8px); background: var(--bg); padding: .6rem 0; }
@media (min-width: 900px) { .chat-input { bottom: 0; } }
.chat-input textarea { flex: 1; }

/* ---------- guides ---------- */
.check-cards { display: grid; gap: 14px; }
@media (min-width: 760px) { .check-cards { grid-template-columns: 1fr 1fr; } }
.check-cards .card { margin: 0; }
.cl-head { display: flex; align-items: center; gap: .6rem; }
.cl-head h2 { margin: 0; flex: 1; font-size: 1.02rem; }
.cl-check { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); color: transparent; display: grid; place-items: center; cursor: pointer; flex: none; }
.cl.done .cl-check { background: var(--ok); border-color: var(--ok); color: #fff; }
.cl.done { border-color: var(--ok); }
.cl-rule { margin: .5rem 0; }
.cl-rule p { margin: 0; }
.cl-ask { font-size: .9rem; padding: .4rem .7rem; border-radius: 8px; background: var(--warn-soft); margin-bottom: .6rem; }
.decision { padding: .4rem 0; }
.dec-q { font-size: 1.05rem; }
.dec-options { display: grid; gap: 8px; margin: .6rem 0; }
.dec-path { font-size: .82rem; color: var(--muted); margin-bottom: .6rem; display: flex; flex-wrap: wrap; gap: .3rem; }
.dec-path span { background: var(--surface-2); padding: .05rem .5rem; border-radius: 99px; }
.dec-result { padding: .9rem 1rem; border-radius: var(--radius-sm); background: var(--ok-soft); }
.dec-result h3 { margin: 0 0 .3rem; text-align: left; color: var(--ok); font-size: 1.2rem; }
.dec-result .en { text-align: left; }
.tense-list { display: grid; gap: 14px; }
@media (min-width: 760px) { .tense-list { grid-template-columns: 1fr 1fr; } }
.tense { padding: .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tense-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.tense-head h3 { margin: 0; }
.tense-body .en { text-align: left; }
.timeline { width: 100%; height: auto; margin: .4rem 0; direction: ltr; }
.tl-axis { stroke: var(--border); stroke-width: 3; }
.tl-now { stroke: var(--bad); stroke-width: 2; stroke-dasharray: 4 3; }
.tl-mark { fill: var(--primary); }
.tl-hollow { fill: none; stroke: var(--primary); stroke-width: 2; }
.tl-range { fill: color-mix(in srgb, var(--primary) 35%, transparent); stroke: var(--primary); stroke-width: 1.5; }
.tl-tick { stroke: var(--primary); stroke-width: 3; stroke-linecap: round; }
.tl-arrow, .tl-curve { fill: none; stroke: var(--warn); stroke-width: 2; stroke-linecap: round; }
.tl-curve { stroke: var(--primary); stroke-dasharray: 4 4; }
.tl-cal { fill: var(--warn-soft); stroke: var(--warn); stroke-width: 1.5; }
.tl-t { font: 600 10px var(--font-en); fill: var(--muted); }

/* ---------- settings ---------- */
.howto { margin-bottom: 1rem; padding: .6rem .9rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.howto summary { cursor: pointer; font-weight: 700; }
.howto ol { padding-inline-start: 1.3rem; }
.model-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.model-list:empty { display: none; }
.model-opt { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem .7rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: .88rem; }
.model-opt:hover { border-color: var(--primary); }
.ok-text { color: var(--ok); }
.err-text { color: var(--bad); }

@media print { .topbar, .sidenav, .bottomnav, .toc, .ai-tools, .practice-cta, .pager { display: none !important; } main { padding: 0; } .card { box-shadow: none; break-inside: avoid; } }

/* ---------- v2: English UI, accounts, admin ---------- */
[dir="rtl"], :lang(fa), .fa-text, .fa-inline { font-family: var(--font-fa); line-height: 1.85; }
.fa-text.inline { display: inline; margin: 0 0 0 .4rem; padding: .1rem .5rem; }
.fa-inline { color: var(--muted); font-size: .9em; }
.option.text { text-align: start; font-family: var(--font-en); font-weight: 500; }
table.hide-fa .fa-col { display: none; }
.bad-text { color: var(--bad); }
ul.plain { list-style: none; padding: 0; margin: .3rem 0; display: flex; flex-direction: column; gap: 4px; }

body.signed-out .sidenav, body.signed-out .bottomnav { display: none !important; }
body.signed-out .layout { grid-template-columns: minmax(0, 1fr); }
body.signed-out main { padding-bottom: 32px; }
.auth { max-width: 460px; margin: 4vh auto 0; }
.auth-brand { text-align: center; margin-bottom: 1rem; }
.auth-brand h1 { margin: .4rem 0 .2rem; font-size: 1.8rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); margin-bottom: 12px; }
.tab { border: 0; background: transparent; border-radius: 9px; min-height: 40px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.note { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .9rem; border-radius: var(--radius-sm); background: var(--primary-soft); font-size: .92rem; }
.note .ic { color: var(--primary); margin-top: .2rem; }
.form-error { color: var(--bad); font-weight: 600; min-height: 1.2em; }
.grid-form { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .95rem; }
details.more { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .8rem; }
details.more summary { cursor: pointer; font-weight: 600; }
details.more[open] summary { margin-bottom: .6rem; }
.key-status { padding: .5rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: .8rem; display: flex; gap: .4rem; align-items: center; }
.center { text-align: center; }

.side-user { margin-top: auto; padding: .8rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
.side-user span { display: flex; align-items: center; gap: .4rem; font-weight: 600; }
.side-user .link-btn { text-align: start; padding: 0; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); opacity: .7; align-self: center; }
.sync-dot.saving { background: var(--warn); animation: pulse 1s infinite; }
.sync-dot.error { background: var(--bad); opacity: 1; }
.sync-dot.idle { background: var(--border); }
@keyframes pulse { 50% { opacity: .3; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat-v { font-size: 1.45rem; font-weight: 800; line-height: 1.2; }
.stat-l { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat-s { color: var(--muted); font-size: .78rem; }
.admin-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.admin-head h1 small { font-size: .9rem; font-weight: 500; }
.admin-table { font-size: .88rem; }
.admin-table tr[data-user] { cursor: pointer; }
.admin-table tr[data-user]:hover td { background: var(--primary-soft); }
.admin-table tr.disabled td { opacity: .55; }
.grid-2.tight { gap: 12px; margin: 0; }
.insights { padding-inline-start: 1.2rem; display: flex; flex-direction: column; gap: .35rem; }
.insights .ins-weak { color: var(--bad); }
.insights .ins-strong { color: var(--ok); }
.insights ul { color: var(--text); margin: .2rem 0; }
.saved-insight { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .8rem; margin: .5rem 0; }
.saved-insight summary { cursor: pointer; font-weight: 600; }
.saved-insight .chat-log { max-height: 420px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 90px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.spark span { flex: 1; background: var(--primary); border-radius: 2px 2px 0 0; min-width: 2px; }
.spark span.zero { background: var(--surface-2); }
.ai-log { display: flex; flex-direction: column; gap: 6px; }
.ai-log details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .4rem .7rem; }
.ai-log details.failed { border-color: var(--bad); }
.ai-log details.noted { border-color: var(--warn); }
.ai-log summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; font-size: .88rem; }
.log-io { display: grid; gap: 10px; margin-top: .5rem; }
@media (min-width: 760px) { .log-io { grid-template-columns: 1fr 1fr; } }
.log-io h4 { margin: 0 0 .2rem; font-size: .8rem; color: var(--muted); }
.log-io pre { white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; background: var(--surface-2); padding: .5rem; border-radius: 8px; font-size: .8rem; margin: 0; }
@media (min-width: 900px) { .mobile-links { display: none; } }

/* ---------- v3: language switch ---------- */
.lang-btn { font-family: var(--font-fa); border: 0; cursor: pointer; min-width: 42px; justify-content: center; font-weight: 800; }
.lang-btn:hover { background: var(--primary-soft); color: var(--primary); }
html[dir="rtl"] body { line-height: 1.8; }
html[dir="rtl"] .en, html[dir="rtl"] [dir="ltr"] { line-height: 1.6; }
html[dir="rtl"] .en-block, html[dir="rtl"] .f-body, html[dir="rtl"] .examples, html[dir="rtl"] .mistakes, html[dir="rtl"] .pairs { text-align: left; }
html[dir="rtl"] .lesson-head h1 { text-align: right; }
html[dir="rtl"] .fa-note summary { direction: rtl; }
@media (max-width: 480px) {
  .brand span { display: none; }
  .topbar-stats { gap: .25rem; }
  .stat-pill { padding: .25rem .5rem; }
}
.ltr-view { text-align: left; }

/* ================= v4: ink & paper look ================= */
.view { overflow-x: clip; overflow-clip-margin: 24px; }
body { background-color: var(--bg); background-image: radial-gradient(var(--dot) 1px, transparent 1.2px); background-size: 22px 22px; background-attachment: fixed; }
h1, h2, .brand, .auth-brand h1, .stat-v, .score-ring span, .verb-base, .num.lg { font-family: var(--font-head), var(--font-fa); letter-spacing: -.01em; }
h1 { font-weight: 700; font-size: 1.7rem; }
h2 { font-weight: 700; font-size: 1.2rem; }
html[dir="rtl"] h1, html[dir="rtl"] h2 { font-family: var(--font-fa); letter-spacing: 0; }
html[dir="rtl"] h1 [dir="ltr"], html[dir="rtl"] h2 [dir="ltr"], h1[dir="ltr"], h2[dir="ltr"] { font-family: var(--font-head); }
.brand { font-weight: 700; font-size: 1.25rem; }
.brand img, .brand svg { transition: transform .4s var(--ease-spring); }
.brand:hover img, .brand:hover svg { transform: rotate(-8deg) scale(1.06); }
.topbar { background: color-mix(in srgb, var(--bg) 86%, transparent); border-bottom: 1px solid var(--border); }
.card { border-color: var(--border); box-shadow: var(--shadow); }
.page-head h1 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.page-head h1 .ic { color: var(--primary); }

/* side navigation: ink marker instead of a filled pill */
@media (min-width: 900px) {
  .sidenav { background: transparent; }
  .side-link { position: relative; transition: background .2s, color .2s, padding .2s var(--ease-out); }
  .side-link:hover { padding-inline-start: 1rem; }
  .side-link.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
  .side-link.active::before { content: ''; position: absolute; inset-inline-start: -12px; top: 22%; bottom: 22%; width: 4px; border-radius: 4px; background: var(--primary); animation: grow-y .3s var(--ease-out); }
}
.bottomnav { background: var(--surface); }
.bottom-link { position: relative; transition: color .2s; }
.bottom-link.active::after { content: ''; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--primary); animation: grow-x .3s var(--ease-out); }
.bottom-link.active .ic { animation: bob .45s var(--ease-spring); }

/* tactile buttons */
.btn { transition: background .15s, transform .12s var(--ease-out), box-shadow .12s, border-color .15s; }
.btn-primary { box-shadow: 0 3px 0 var(--primary-ink); }
.btn-primary:hover { background: var(--primary-2); transform: translateY(-1px); box-shadow: 0 4px 0 var(--primary-ink); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--primary-ink); }
.btn-ai { border: 1px solid color-mix(in srgb, var(--ai) 25%, transparent); }
.btn-ai .ic { transition: transform .4s var(--ease-spring); }
.btn-ai:hover .ic { transform: rotate(18deg) scale(1.15); }
.btn:active { transform: translateY(1px) scale(.98); }
.option, .tile, .tool, .lesson-row, .tag-card, .stat-pill { transition: border-color .15s, background .15s, transform .15s var(--ease-out), box-shadow .15s; }
.option:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 0 color-mix(in srgb, var(--primary) 30%, transparent); }
.option:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.tool:hover { transform: translateY(-3px); box-shadow: 0 14px 26px -16px color-mix(in srgb, var(--primary) 60%, transparent); }
.tool.primary { background: var(--primary); box-shadow: 0 4px 0 var(--primary-ink); }
.lesson-row:hover { transform: translateX(3px); }
html[dir="rtl"] .lesson-row:hover { transform: translateX(-3px); }
.tile { box-shadow: 0 2px 0 var(--border); border-bottom-width: 1.5px; }
.tile:hover:not(:disabled) { transform: translateY(-2px); }
.order-line .tile { animation: pop .25s var(--ease-spring); }
.hero { background: var(--surface); position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; inset-inline-end: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--sun) 35%, transparent), transparent 70%); pointer-events: none; animation: float 7s ease-in-out infinite; }
.practice-cta { background: var(--surface); border-inline-start: 4px solid var(--primary); }
.progress { background: var(--surface-2); }
.progress span { background: repeating-linear-gradient(-45deg, var(--primary), var(--primary) 10px, var(--primary-2) 10px, var(--primary-2) 20px); background-size: 28px 28px; animation: stripes 1.2s linear infinite; transition: width .45s var(--ease-out); }
.bar > span { transition: width .6s var(--ease-out); }
.view-enter .bar > span { animation: fill .9s var(--ease-out) both; }
.num { background: var(--primary-soft); }
.gap-input { background: var(--primary-soft) !important; border-color: var(--primary) !important; }
.msg.user { background: var(--primary); color: var(--on-primary); }
.msg.user .corr { color: var(--on-primary); border-top-color: color-mix(in srgb, var(--on-primary) 35%, transparent); }
.msg.user .corr .diff { color: var(--text); }
.msg.user .err-list li { color: var(--text); }
.msg.user .corr.ok { color: var(--on-primary); opacity: .9; }
.msg.bot { background: var(--surface); border: 1px solid var(--border); }
.msg.bot.ai-answer { background: var(--ai-soft); border: 0; }
.ai-answer { border-inline-start-color: var(--ai); }
.stat-pill.hot .ic { animation: flicker 2.4s ease-in-out infinite; transform-origin: 50% 90%; }

/* spinner → three bouncing dots */
.spinner { position: relative; width: 6px; height: 6px; border: 0; border-radius: 50%; background: currentColor; color: var(--primary); margin: 0 12px; animation: dot-bounce 1s infinite ease-in-out; animation-delay: .15s; }
.spinner::before, .spinner::after { content: ''; position: absolute; top: 0; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: dot-bounce 1s infinite ease-in-out; }
.spinner::before { left: -10px; }
.spinner::after { left: 10px; animation-delay: .3s; }
.typing { display: inline-flex; gap: 5px; align-items: center; padding: .2rem 0; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--ai); opacity: .5; animation: dot-bounce 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.typing-bubble { padding: .75rem 1rem; }

/* ---------- page + content animations ---------- */
.view-enter > * { animation: rise .45s var(--ease-out) both; }
.view-enter > *:nth-child(2) { animation-delay: .05s; }
.view-enter > *:nth-child(3) { animation-delay: .1s; }
.view-enter > *:nth-child(4) { animation-delay: .15s; }
.view-enter > *:nth-child(5) { animation-delay: .2s; }
.view-enter > *:nth-child(n+6) { animation-delay: .25s; }
.view-enter .tools-grid > *, .view-enter .lesson-list > *, .view-enter .stat-grid > *, .view-enter .role-grid > * { animation: rise .45s var(--ease-out) both; }
.view-enter .tools-grid > *:nth-child(2), .view-enter .lesson-list > *:nth-child(2), .view-enter .stat-grid > *:nth-child(2) { animation-delay: .06s; }
.view-enter .tools-grid > *:nth-child(3), .view-enter .lesson-list > *:nth-child(3), .view-enter .stat-grid > *:nth-child(3) { animation-delay: .12s; }
.view-enter .tools-grid > *:nth-child(4), .view-enter .lesson-list > *:nth-child(4), .view-enter .stat-grid > *:nth-child(4) { animation-delay: .18s; }
.view-enter .tools-grid > *:nth-child(n+5), .view-enter .lesson-list > *:nth-child(n+5), .view-enter .stat-grid > *:nth-child(n+5) { animation-delay: .24s; }
.q-card { animation: slide-in .4s var(--ease-out) both; }
.q-card.is-right { animation: pop-card .45s var(--ease-spring); border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent), var(--shadow); }
.q-card.is-wrong { animation: shake .45s ease; border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent), var(--shadow); }
.feedback > * { animation: rise .35s var(--ease-out) both; }
.feedback > *:nth-child(2) { animation-delay: .06s; }
.feedback > *:nth-child(3) { animation-delay: .12s; }
.feedback > *:nth-child(4) { animation-delay: .18s; }
.feedback > *:nth-child(n+5) { animation-delay: .24s; }
.fb-right .ic { animation: check-pop .5s var(--ease-spring); }
.d-add { animation: highlight 1s ease .3s both; }
.option.opt-right { animation: pop .35s var(--ease-spring); }
.option.opt-wrong { animation: shake .4s ease; }
.ai-answer, .ai-reveal { animation: rise .4s var(--ease-out) both; }
.toast { animation: toast-in .35s var(--ease-spring); }
.fa-text:not([hidden]) { animation: rise .25s var(--ease-out); }

/* score ring fills up */
@property --p { syntax: '<number>'; inherits: true; initial-value: 0; }
.score-ring { animation: ring 1.1s var(--ease-out) both; background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-2) 0); }
.summary h2 { justify-content: center; animation: rise .5s var(--ease-out) .5s both; }
.summary { position: relative; overflow: hidden; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: 38%; width: 8px; height: 12px; border-radius: 2px; opacity: 0; animation: confetti 1.6s cubic-bezier(.15, .7, .3, 1) var(--d) forwards; }

/* chat */
.msg.is-new.user { animation: msg-in-end .3s var(--ease-out) both; }
.msg.is-new.bot { animation: msg-in-start .3s var(--ease-out) both; }
.msg.is-checked .corr { animation: rise .4s var(--ease-out) both; }
.msg.is-typing::after { content: ''; display: inline-block; width: 2px; height: 1em; background: var(--ai); margin-top: .2rem; animation: blink .8s steps(1) infinite; }
.tw { opacity: 0; filter: blur(3px); transition: opacity .25s, filter .25s; }
.tw.on { opacity: 1; filter: none; }

/* timelines draw themselves */
.timeline .tl-mark { transform-box: fill-box; transform-origin: center; animation: pop .45s var(--ease-spring) .25s both; }
.timeline .tl-range { transform-box: fill-box; transform-origin: left center; animation: grow-x .6s var(--ease-out) .15s both; }
.timeline .tl-tick { transform-box: fill-box; transform-origin: center bottom; animation: grow-y .35s var(--ease-spring) both; animation-delay: calc(.1s + var(--i, 0) * .07s); }
.timeline .tl-curve { stroke-dasharray: 4 4; animation: dash 1.2s linear infinite; }
.timeline .tl-now { animation: pulse-now 2s ease-in-out infinite; }
.tl-mark { fill: var(--ai); }
.tl-range { fill: color-mix(in srgb, var(--ai) 28%, transparent); stroke: var(--ai); }
.tl-tick { stroke: var(--ai); }
.tl-now { stroke: var(--primary); }
.tl-curve { stroke: var(--ai); }

/* ---------- sentence anatomy ---------- */
.role-subject { --c: #2f63a8; } .role-aux { --c: #7a4fa0; } .role-be { --c: #0f7f86; } .role-verb { --c: #c4461b; }
.role-neg { --c: #b42318; } .role-object { --c: #3f7d20; } .role-complement { --c: #8a6d00; } .role-place { --c: #8b5a2b; }
.role-time { --c: #b7791f; } .role-adverb { --c: #56606e; } .role-prep { --c: #6e675b; } .role-qword { --c: #a3245e; } .role-link { --c: #6e675b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .role-subject { --c: #7fb0f0; } :root:not([data-theme="light"]) .role-aux { --c: #c39ae6; } :root:not([data-theme="light"]) .role-be { --c: #5fd0d6; }
  :root:not([data-theme="light"]) .role-verb { --c: #ff9a6e; } :root:not([data-theme="light"]) .role-neg { --c: #ff8a7a; } :root:not([data-theme="light"]) .role-object { --c: #94d36f; }
  :root:not([data-theme="light"]) .role-complement { --c: #e6c64e; } :root:not([data-theme="light"]) .role-place { --c: #d9a77a; } :root:not([data-theme="light"]) .role-time { --c: #f0bd5e; }
  :root:not([data-theme="light"]) .role-adverb { --c: #b4bcc8; } :root:not([data-theme="light"]) .role-prep, :root:not([data-theme="light"]) .role-link { --c: #b8b0a0; } :root:not([data-theme="light"]) .role-qword { --c: #f08cbb; }
}
:root[data-theme="dark"] .role-subject { --c: #7fb0f0; } :root[data-theme="dark"] .role-aux { --c: #c39ae6; } :root[data-theme="dark"] .role-be { --c: #5fd0d6; }
:root[data-theme="dark"] .role-verb { --c: #ff9a6e; } :root[data-theme="dark"] .role-neg { --c: #ff8a7a; } :root[data-theme="dark"] .role-object { --c: #94d36f; }
:root[data-theme="dark"] .role-complement { --c: #e6c64e; } :root[data-theme="dark"] .role-place { --c: #d9a77a; } :root[data-theme="dark"] .role-time { --c: #f0bd5e; }
:root[data-theme="dark"] .role-adverb { --c: #b4bcc8; } :root[data-theme="dark"] .role-prep, :root[data-theme="dark"] .role-link { --c: #b8b0a0; } :root[data-theme="dark"] .role-qword { --c: #f08cbb; }

.breakdown { margin-top: .9rem; padding: .9rem 1rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px dashed color-mix(in srgb, var(--primary) 35%, var(--border)); }
.bd-title { font-weight: 800; font-size: .95rem; margin-bottom: .6rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.bd-title .ic { color: var(--primary); }
.bd-title .en { font-weight: 600; color: var(--muted); }
.bd-engine { margin-inline-start: auto; font: 700 .7rem var(--font-en); color: var(--muted); border: 1px solid var(--border); border-radius: 99px; padding: .05rem .5rem; }
.bd-kicker { font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.bd-chips { display: flex; flex-wrap: wrap; gap: 6px 6px; align-items: stretch; }
.part { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; padding: .3rem .6rem .25rem; border-radius: 10px; background: color-mix(in srgb, var(--c) 12%, var(--surface)); border: 1.5px solid color-mix(in srgb, var(--c) 45%, transparent); border-bottom-width: 3px; animation: part-in .4s var(--ease-spring) both; animation-delay: calc(var(--i, 0) * 55ms); }
.part-text { font-family: var(--font-en); font-weight: 700; font-size: 1.02rem; color: var(--text); line-height: 1.35; }
.part-role { font-size: .68rem; font-weight: 800; color: var(--c); text-transform: uppercase; letter-spacing: .04em; line-height: 1.2; white-space: nowrap; }
html[dir="rtl"] .part-role { text-transform: none; letter-spacing: 0; font-family: var(--font-fa); font-size: .72rem; }
.part-error { background: var(--bad-soft); border-color: var(--bad); border-style: dashed; }
.bd-pattern { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: .7rem 0 .2rem; font-size: .8rem; font-weight: 800; }
.bd-pattern i, .order-flow i { font-style: normal; color: var(--muted); font-weight: 600; }
.bd-pattern .pat-sep { margin: 0 .3rem; }
.pat { padding: .05rem .45rem; border-radius: 6px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.bd-notes { margin: .6rem 0 0; padding-inline-start: 1.1rem; font-size: .92rem; display: flex; flex-direction: column; gap: .2rem; }
.bd-notes li::marker { color: var(--primary); }
.bd-notes b { color: var(--text); }
.bd-tense { margin-top: .8rem; padding: .7rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.bd-tense-head { display: flex; gap: .4rem; align-items: baseline; flex-wrap: wrap; }
.bd-tense-head strong { font-family: var(--font-head); font-size: 1.05rem; }
.bd-tense-body { font-size: .92rem; }
.bd-problems { margin-bottom: .8rem; padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--bad-soft); border-inline-start: 4px solid var(--bad); animation: shake .45s ease .1s both; }
.bd-problems ul { margin: .3rem 0 0; padding-inline-start: 1.1rem; }
.bd-problems li { margin: .2rem 0; }
.ai-rule { margin-top: .4rem; display: flex; gap: .4rem; align-items: center; }
.ai-rule .ic { color: var(--warn); }

/* structure guide */
.row-input { display: flex; gap: .5rem; flex-wrap: wrap; }
.row-input input { flex: 1 1 260px; }
.examples-row { display: flex; gap: 6px; flex-wrap: wrap; margin: .7rem 0 .2rem; }
.chip-btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 99px; padding: .2rem .7rem; font: 600 .82rem var(--font-en); cursor: pointer; transition: border-color .15s, transform .15s var(--ease-out); }
.chip-btn:hover { border-color: var(--primary); transform: translateY(-1px); }
.order-flow { display: flex; flex-wrap: wrap; align-items: center; margin: .2rem 0 .8rem; gap: 6px; font-weight: 800; font-size: .9rem; }
.order-flow .pat { padding: .25rem .6rem; animation: part-in .4s var(--ease-spring) both; animation-delay: calc(var(--i, 0) * 70ms); }
.role-grid { display: grid; gap: 12px; }
@media (min-width: 760px) { .role-grid { grid-template-columns: 1fr 1fr; } }
.role-card { padding: .8rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--border); border-top: 4px solid var(--c); background: var(--surface); }
.role-card .bd-chips { margin-top: .5rem; }
.role-name { display: flex; align-items: center; gap: .45rem; font-weight: 800; color: var(--c); font-size: 1.02rem; }
.role-name .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.role-q { font-weight: 700; margin: .1rem 0 .3rem; }
.role-card p { margin: .2rem 0; }
.forms-table td:first-child { white-space: nowrap; }
.patterns { display: grid; gap: 10px; }
@media (min-width: 760px) { .patterns { grid-template-columns: 1fr 1fr; } }
.pattern { padding: .7rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.pattern-head { display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; margin-bottom: .45rem; }
.pattern-head code { background: var(--surface); }
.pair-btn { width: 100%; border: 1px solid transparent; cursor: pointer; font: inherit; color: inherit; transition: border-color .15s, transform .15s var(--ease-out); }
.pair-btn:hover { border-color: var(--primary); transform: translateX(2px); }
.note-fa { margin-top: .6rem; }
.analyzer [data-out] .breakdown { border-style: solid; }

.err-meta { flex-wrap: wrap; }
.err-meta .chip { white-space: normal; }
.msg.user .err-list a { color: var(--primary); }

/* question bank */
.bank-stat { display: flex; gap: .4rem; flex-wrap: wrap; margin: -.2rem 0 .6rem; }
.report-btn { margin-inline-start: auto; color: var(--muted); }
.report-box:not([hidden]) { margin-top: .6rem; padding: .6rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); animation: rise .3s var(--ease-out); }
.report-q { font-weight: 700; margin-bottom: .3rem; }
.fill-card h2 { justify-content: center; margin-top: .4rem; }
.fill-card .bar { width: min(320px, 100%); flex: none; }
.bank-link { display: flex; align-items: center; gap: .7rem; color: var(--text); }
.bank-link:hover { text-decoration: none; border-color: var(--primary); }
.bank-link span { display: flex; flex-direction: column; line-height: 1.4; }
.bank-link .ic { color: var(--primary); width: 26px; height: 26px; }
.bar-row.compact { grid-template-columns: 1fr auto; min-width: 140px; }
.nowrap { white-space: nowrap; }
.qb-list { display: flex; flex-direction: column; gap: 10px; }
.qb-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .9rem; display: flex; flex-direction: column; gap: .35rem; }
.qb-top { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.qb-q { font-weight: 600; font-size: 1.02rem; }
.qb-card textarea { font-size: .92rem; }

/* dictionary */
.dict-hero { position: relative; overflow: visible; z-index: 3; }
.dict-search { position: relative; }
.dict-input { display: flex; align-items: center; gap: .5rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 0 .8rem; background: var(--surface); }
.dict-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.dict-input .ic { color: var(--muted); }
.dict-input input { border: 0 !important; box-shadow: none !important; padding-inline: 0 !important; font-size: 1.1rem !important; background: transparent !important; }
.dict-suggest { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 10; list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 340px; overflow-y: auto; animation: rise .2s var(--ease-out); }
.dict-suggest li a { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border-radius: 8px; color: var(--text); }
.dict-suggest li a:hover { background: var(--primary-soft); text-decoration: none; }
.dict-suggest li.muted { padding: .45rem .6rem; }
.dict-suggest .badge, .word-head .badge { margin-inline-start: auto; }
.dict-recent { align-items: center; margin-bottom: 0; }
.lvl { font-family: var(--font-en); }
.lvl-A1, .lvl-A2 { --lc: var(--ok); } .lvl-B1, .lvl-B2 { --lc: var(--warn); } .lvl-C1, .lvl-C2 { --lc: var(--bad); }
.badge.lvl { background: color-mix(in srgb, var(--lc) 14%, transparent); color: var(--lc); }
.level-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.level-tile { display: grid; place-items: center; padding: .9rem; border-radius: var(--radius-sm); border: 1.5px solid color-mix(in srgb, var(--lc) 40%, var(--border)); color: var(--lc); font-family: var(--font-head); font-size: 1.3rem; transition: transform .15s var(--ease-out), background .15s; }
.level-tile:hover { background: color-mix(in srgb, var(--lc) 10%, transparent); text-decoration: none; transform: translateY(-2px); }
.level-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: .5rem; }
.chip-btn.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.word-card { margin-top: 12px; }
.word-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.word-title { font-size: 2.1rem; margin: 0; font-family: var(--font-head); }
.save-word { margin-inline-start: auto; }
.word-sound { display: flex; align-items: center; gap: .3rem .5rem; flex-wrap: wrap; margin: .3rem 0 .4rem; }
.ipa { font-family: 'Segoe UI', 'Noto Sans', 'DejaVu Sans', sans-serif; color: var(--muted); }
.say small { font-size: .62rem; font-weight: 800; margin-inline-start: 1px; }
.icon-btn.say { width: auto; padding: 0 .35rem; border-radius: 99px; }
.word-forms { margin-bottom: .6rem; }
.senses { padding-inline-start: 1.4rem; margin: .6rem 0; display: flex; flex-direction: column; gap: .7rem; }
.senses > li::marker { color: var(--primary); font-weight: 800; }
.senses .pos { font-style: italic; color: var(--ai); font-weight: 700; }
.senses .def { font-size: 1.08rem; font-weight: 600; }
.senses .pattern code { font-size: .85rem; }
.examples { list-style: none; padding: 0; margin: .3rem 0 0; display: flex; flex-direction: column; gap: 2px; }
.senses .examples li, .wikt .examples li { display: flex; align-items: center; justify-content: flex-start; gap: .3rem; color: var(--muted); font-style: italic; padding: 0; background: none; }
.senses .examples li::before, .wikt .examples li::before { content: '›'; font-style: normal; color: var(--primary); }
.word-block h3 { font-size: .9rem; margin: .8rem 0 .3rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wikt { margin-top: 1rem; border-top: 1px dashed var(--border); padding-top: .6rem; }
.wikt summary { cursor: pointer; font-weight: 700; }
.wikt-pos h3 { font-style: italic; color: var(--ai); margin: .6rem 0 .2rem; }
.wikt-pos ol { padding-inline-start: 1.3rem; margin: 0; }
.wikt-pos ol > li { margin: .25rem 0; }
.word-links { margin-top: .8rem; }
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.word-tile { padding: .4rem .6rem; border-radius: 8px; background: var(--surface-2); color: var(--text); font-weight: 600; display: flex; align-items: center; gap: .3rem; }
.word-tile:hover { background: var(--primary-soft); text-decoration: none; }
.word-tile.saved { color: var(--ok); }
.my-words { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.my-words li { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto auto; gap: .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.my-words li:last-child { border: 0; }
.my-words .def { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .my-words li { grid-template-columns: 1fr auto auto; } .my-words .def { grid-column: 1 / -1; grid-row: 2; white-space: normal; } }
.attribution { text-align: center; }
.word-def { font-size: 1.15rem; }
.word-hint { font-family: var(--font-en); letter-spacing: .15em; margin: -.4rem 0 .5rem; }
.word-input { max-width: 320px; }
/* select-to-look-up */
.lookup-btn { position: absolute; z-index: 60; display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .7rem; border: 0; border-radius: 99px; background: var(--text); color: var(--bg); font: 600 .85rem var(--font-en); box-shadow: var(--shadow); cursor: pointer; animation: pop .2s var(--ease-spring); }
.lookup-pop { position: fixed; z-index: 70; inset-inline: 16px; bottom: calc(var(--bottomnav-h) + 16px); max-width: 480px; margin: 0 auto; animation: rise .25s var(--ease-out); }
@media (min-width: 900px) { .lookup-pop { bottom: 24px; } }
.lp-head { display: flex; align-items: center; gap: .4rem; }
.lp-word { font-family: var(--font-head); font-size: 1.4rem; }
.lp-close { margin-inline-start: auto; }
.lp-body { margin: .4rem 0 .6rem; font-size: 1.02rem; }
.lp-ex { color: var(--muted); font-style: italic; margin-top: .2rem; }
@media (max-width: 400px) { .bottom-link { font-size: .62rem; } }

/* mini-lessons */
.fix-offer { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin: .7rem 0; padding: .7rem .9rem; border-radius: var(--radius-sm); background: var(--ai-soft); border: 1px solid color-mix(in srgb, var(--ai) 30%, transparent); animation: rise .4s var(--ease-out) .2s both; }
.fix-offer > .ic { color: var(--ai); width: 24px; height: 24px; }
.fix-offer > div { flex: 1 1 220px; display: flex; flex-direction: column; line-height: 1.5; }
.fix-offer span { font-size: .9rem; color: var(--muted); }
.fix-banner { display: flex; align-items: center; gap: .8rem; color: var(--text); background: var(--ai-soft); border-color: color-mix(in srgb, var(--ai) 30%, transparent); }
.fix-banner:hover { text-decoration: none; transform: translateY(-1px); }
.fix-banner > .ic:first-child { color: var(--ai); width: 28px; height: 28px; }
.fix-banner span { flex: 1; display: flex; flex-direction: column; line-height: 1.5; }
.fix-banner small { color: var(--muted); }
body.sheet-open { overflow: hidden; }
.ml-sheet { position: fixed; inset: 0; z-index: 80; background: var(--bg); overflow-y: auto; animation: sheet-up .35s var(--ease-out); padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.ml-inner { max-width: 760px; margin: 0 auto; }
.ml-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: .6rem; padding: .7rem 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.ml-kicker { font-weight: 800; color: var(--ai); display: inline-flex; gap: .3rem; align-items: center; }
.ml-versions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0 0 12px; }
.ml-loading p { margin: .4rem 0 0; }
.ml-hero h1 { margin: .5rem 0 .3rem; }
.ml-why { font-size: 1.05rem; }
.ml-fixes { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.ml-fixes li { padding: .2rem 0 .6rem; border-bottom: 1px dashed var(--border); }
.ml-fixes li:last-child { border: 0; }
.ml-fixes .diff { margin: 0 0 .3rem; }
.ml-right { color: var(--ok); font-weight: 700; }
.ml-rule { font-size: 1.1rem; font-weight: 600; }
.ml-formula { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: .4rem 0 .5rem; font-size: 1.05rem; font-weight: 800; }
.ml-formula .pat { padding: .35rem .7rem; border-radius: 10px; border: 1.5px solid color-mix(in srgb, var(--c) 45%, transparent); animation: part-in .45s var(--ease-spring) both; animation-delay: calc(var(--i, 0) * 90ms); }
.ml-formula i { font-style: normal; color: var(--muted); }
.ml-legend { display: flex; gap: 6px; flex-wrap: wrap; font-size: .75rem; font-weight: 700; }
.ml-steps { padding-inline-start: 1.3rem; display: flex; flex-direction: column; gap: .4rem; margin: .8rem 0 0; }
.ml-tip { display: flex; gap: .6rem; align-items: flex-start; background: var(--warn-soft); border-color: transparent; }
.ml-tip > .ic { color: var(--warn); margin-top: .3rem; }
.ml-check .runner { margin-top: .6rem; }
.ml-check .runner .card { box-shadow: none; }
.ml-result { margin-top: .8rem; }
.ml-foot { justify-content: center; margin-bottom: 1rem; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- keyframes ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } }
html[dir="rtl"] .q-card { animation-name: slide-in-rtl; }
@keyframes slide-in-rtl { from { opacity: 0; transform: translateX(-24px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes part-in { 0% { transform: translateY(8px) scale(.85); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes pop-card { 0% { transform: scale(1); } 40% { transform: scale(1.015); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
@keyframes check-pop { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes highlight { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 100% { box-shadow: 0 0 0 6px transparent; } }
@keyframes ring { from { --p: 0; } }
@keyframes confetti { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)); } }
@keyframes msg-in-end { from { opacity: 0; transform: translate(14px, 8px) scale(.96); } }
@keyframes msg-in-start { from { opacity: 0; transform: translate(-14px, 8px) scale(.96); } }
@keyframes dot-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-6px); opacity: 1; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes dash { to { stroke-dashoffset: -16; } }
@keyframes pulse-now { 50% { opacity: .45; } }
@keyframes bob { 40% { transform: translateY(-4px); } }
@keyframes float { 50% { transform: translate(-12px, 14px); } }
@keyframes stripes { to { background-position: 28px 0; } }
@keyframes fill { from { width: 0; } }
@keyframes flicker { 0%, 100% { transform: rotate(0) scale(1); } 30% { transform: rotate(-6deg) scale(1.08); } 60% { transform: rotate(5deg) scale(.96); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.95); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .tw { opacity: 1; filter: none; }
}
.ml-saved { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.ml-saved a { display: flex; flex-direction: column; gap: .15rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); transition: border-color .15s, transform .15s var(--ease-out); }
.ml-saved a:hover { border-color: var(--ai); text-decoration: none; transform: translateY(-1px); }
