/* Арамит — design system and screens.
   Light theme: parchment / ivory. Dark theme: deep ink.
   Theme = prefers-color-scheme, overridable with <html data-theme="light|dark">. */

:root {
  color-scheme: light;
  --bg: #f7f2e7;
  --bg-deep: #efe7d6;
  --surface: #fffcf5;
  --surface-2: #f3ecde;
  --surface-3: #e9e0cc;
  --border: #e3d9c4;
  --border-strong: #cdbf9f;
  --text: #241d13;
  --text-2: #4a4033;
  --muted: #6c6150;
  --primary: #34408f;
  --primary-hover: #2a3478;
  --primary-ink: #2f3a85;
  --on-primary: #ffffff;
  --primary-soft: #e7e6f1;
  --accent: #a8721b;
  --amber: #b97a1d;
  --amber-soft: #f7e9cb;
  --learning-bg: rgba(52, 64, 143, 0.13);
  --learning-ring: rgba(52, 64, 143, 0.28);
  --phrase-bg: rgba(168, 120, 40, 0.14);
  --target-bg: rgba(226, 165, 45, 0.33);
  --target-line: #b5761a;
  --name: #2458a6;
  --hl-bg: rgba(226, 165, 45, 0.30);
  --success: #2c7a4b;
  --success-soft: #e1f0e6;
  --danger: #b23a2e;
  --danger-soft: #f7e3e0;
  --focus: #3d55d6;
  --scrim: rgba(36, 29, 19, 0.38);
  --shadow-1: 0 1px 2px rgba(70, 52, 20, 0.06), 0 1px 1px rgba(70, 52, 20, 0.04);
  --shadow-2: 0 6px 20px rgba(70, 52, 20, 0.08), 0 1px 3px rgba(70, 52, 20, 0.06);
  --shadow-sheet: 0 -10px 40px rgba(50, 36, 10, 0.18);
  --tabbar-bg: rgba(255, 252, 245, 0.92);

  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-he: "Frank Ruhl Libre", "Noto Serif Hebrew", "Times New Roman", serif;
  --font-scale: 1;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --content-w: 760px;
  --gutter: 16px;
  --tabbar-h: 64px;
  --topbar-h: 0px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #11131b;
    --bg-deep: #0c0e14;
    --surface: #191c27;
    --surface-2: #212534;
    --surface-3: #2a2f41;
    --border: #2c3144;
    --border-strong: #3c4359;
    --text: #efe8d8;
    --text-2: #d6cebd;
    --muted: #a59d8c;
    --primary: #8f9bf2;
    --primary-hover: #a3adf5;
    --primary-ink: #aeb7f6;
    --on-primary: #10142a;
    --primary-soft: rgba(143, 155, 242, 0.15);
    --accent: #e0aa48;
    --amber: #e3a843;
    --amber-soft: rgba(227, 168, 67, 0.16);
    --learning-bg: rgba(143, 155, 242, 0.22);
    --learning-ring: rgba(143, 155, 242, 0.4);
    --phrase-bg: rgba(227, 168, 67, 0.14);
    --target-bg: rgba(227, 168, 67, 0.32);
    --target-line: #e3a843;
    --name: #8fb9ff;
    --hl-bg: rgba(227, 168, 67, 0.3);
    --success: #62c48f;
    --success-soft: rgba(98, 196, 143, 0.14);
    --danger: #f08174;
    --danger-soft: rgba(240, 129, 116, 0.14);
    --focus: #a9b4ff;
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, 0.5);
    --tabbar-bg: rgba(25, 28, 39, 0.92);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11131b;
  --bg-deep: #0c0e14;
  --surface: #191c27;
  --surface-2: #212534;
  --surface-3: #2a2f41;
  --border: #2c3144;
  --border-strong: #3c4359;
  --text: #efe8d8;
  --text-2: #d6cebd;
  --muted: #a59d8c;
  --primary: #8f9bf2;
  --primary-hover: #a3adf5;
  --primary-ink: #aeb7f6;
  --on-primary: #10142a;
  --primary-soft: rgba(143, 155, 242, 0.15);
  --accent: #e0aa48;
  --amber: #e3a843;
  --amber-soft: rgba(227, 168, 67, 0.16);
  --learning-bg: rgba(143, 155, 242, 0.22);
  --learning-ring: rgba(143, 155, 242, 0.4);
  --phrase-bg: rgba(227, 168, 67, 0.14);
  --target-bg: rgba(227, 168, 67, 0.32);
  --target-line: #e3a843;
  --name: #8fb9ff;
  --hl-bg: rgba(227, 168, 67, 0.3);
  --success: #62c48f;
  --success-soft: rgba(98, 196, 143, 0.14);
  --danger: #f08174;
  --danger-soft: rgba(240, 129, 116, 0.14);
  --focus: #a9b4ff;
  --scrim: rgba(0, 0, 0, 0.55);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, 0.5);
  --tabbar-bg: rgba(25, 28, 39, 0.92);
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary-ink); text-underline-offset: 0.18em; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  inset-inline-start: 12px;
  top: -60px;
  z-index: 100;
  background: var(--primary);
  color: var(--on-primary);
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Hebrew / Aramaic text (the Hebrew UI itself keeps the UI font: html[lang=he] is excluded) */
.heb, [lang="arc"], [lang="he"]:not(html) {
  font-family: var(--font-he);
  direction: rtl;
  unicode-bidi: isolate;
}
.heb-inline { font-family: var(--font-he); unicode-bidi: isolate; }

/* ---------- layout ---------- */

.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.main {
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 12px var(--gutter) calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
  outline: none;
  flex: 1;
}

.screen { animation: screen-in 0.28s var(--ease) both; }
/* entrance animations never fully hide content (a stalled animation stays readable) */
@keyframes screen-in {
  from { opacity: 0.6; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.78rem; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.grow { flex: 1 1 auto; min-width: 0; }

.eyebrow {
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.boot {
  min-height: 60vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
}
.boot-mark {
  width: 64px; height: 64px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-family: var(--font-he);
  font-size: 40px;
  color: #f6ecd3;
  background: linear-gradient(#3d4596, #242862);
  box-shadow: var(--shadow-2);
}

/* ---------- top / bottom navigation ---------- */

.tabbar {
  position: fixed;
  z-index: 40;
  inset-inline: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--tabbar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar .brand { display: none; }
.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 12px;
  transition: color 0.15s;
}
.tab svg { width: 24px; height: 24px; }
.tab-label { max-width: 100%; padding-inline: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--primary-ink); }
.tab[aria-current="page"] .tab-icon {
  background: var(--primary-soft);
}
.tab-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  transition: background 0.2s;
}
.tab-badge {
  position: absolute;
  top: 6px;
  inset-inline-start: calc(50% + 6px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
:root[data-theme="dark"] .tab-badge { color: #1a1306; }

@media (min-width: 880px) {
  :root { --topbar-h: 60px; }
  .app { flex-direction: column; }
  .tabbar {
    position: sticky;
    top: 0;
    bottom: auto;
    height: var(--topbar-h);
    padding: 0 max(24px, calc((100vw - 1080px) / 2));
    display: flex;
    align-items: center;
    gap: 4px;
    border-top: 0;
    border-bottom: 1px solid var(--border);
  }
  .tabbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-inline-end: auto;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
  }
  .tab {
    flex-direction: row;
    gap: 8px;
    padding: 0 14px;
    height: 44px;
    font-size: 0.92rem;
  }
  .tab-icon { width: auto; height: auto; background: none !important; }
  .tab svg { width: 20px; height: 20px; }
  .tab[aria-current="page"] { background: var(--primary-soft); }
  .tab:hover { color: var(--text); }
  .tab-badge { position: static; margin-inline-start: 2px; }
  .main { padding-bottom: 56px; padding-top: 20px; }
}

.brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  box-shadow: var(--shadow-1);
}

/* ---------- screen header ---------- */

.screen-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  margin: 0 0 12px;
}
.screen-head h1 { font-size: 1.35rem; }
.screen-head .sub { color: var(--muted); font-size: 0.9rem; }
.screen-title { min-width: 0; flex: 1; }
.screen-title h1 { overflow-wrap: anywhere; }

.sticky-head {
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  margin: -12px calc(-1 * var(--gutter)) 12px;
  padding: 8px var(--gutter);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.sticky-head.scrolled { border-bottom-color: var(--border); }
@media (min-width: 880px) { .sticky-head { margin-top: -20px; } }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 1.02rem; border-radius: 14px; padding: 0 22px; }
.btn-wrap { white-space: normal; text-align: center; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-ink); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }

/* ---------- cards & lists ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 18px;
}
.card-tight { padding: 14px; }
.card h2 + p, .card h3 + p { margin-top: 4px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.hero-card {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 20px;
  color: #f8f1df;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 214, 140, 0.22), transparent 55%),
    linear-gradient(150deg, #3d4596 0%, #2b316f 60%, #22275c 100%);
  box-shadow: var(--shadow-2);
}
.hero-card .eyebrow { color: rgba(248, 241, 223, 0.78); }
.hero-card h2 { font-size: 1.45rem; color: #fffaf0; }
.hero-card .hero-he {
  font-family: var(--font-he);
  font-size: 1.6rem;
  line-height: 1.3;
  color: #f6e3b5;
  direction: rtl;
}
.hero-card .btn-primary { background: #f6ecd3; color: #23285e; }
.hero-card .btn-primary:hover { background: #fff6df; }
.hero-card .btn-secondary { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.32); color: #fffaf0; }
.hero-card .btn-secondary:hover { background: rgba(255, 255, 255, 0.16); }
.hero-card .muted { color: rgba(248, 241, 223, 0.8); }
.hero-deco {
  display: none;
  position: absolute;
  inset-inline-end: -10px;
  bottom: -38px;
  font-family: var(--font-he);
  font-size: 150px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.06);
  pointer-events: none;
  user-select: none;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.list > li + li { border-top: 1px solid var(--border); }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 14px;
  width: 100%;
  background: none;
  border: 0;
  text-align: start;
  color: inherit;
  text-decoration: none;
}
button.list-row:hover, a.list-row:hover { background: var(--surface-2); }
.list-row .heb { font-size: 1.3rem; line-height: 1.4; }
.list-main { flex: 1; min-width: 0; }
.list-main .title { font-weight: 600; overflow-wrap: anywhere; }
.list-main .sub { color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip-heb { font-family: var(--font-he); font-size: 1.05rem; font-weight: 500; direction: rtl; }
.chip-primary { background: var(--primary-soft); color: var(--primary-ink); }
.chip-amber { background: var(--amber-soft); color: var(--accent); }
.chip-success { background: var(--success-soft); color: var(--success); }
:root:not([data-theme="dark"]) .chip-amber { color: #7d5512; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip-amber { color: var(--accent); } }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
  box-shadow: var(--shadow-1);
}
.stat .num { font-size: 1.45rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.stat svg { width: 18px; height: 18px; display: inline-block; vertical-align: -3px; color: var(--accent); }

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}
.empty .empty-mark {
  font-family: var(--font-he);
  font-size: 44px;
  line-height: 1;
  color: var(--border-strong);
  margin-bottom: 10px;
}
.empty h2 { color: var(--text); margin-bottom: 6px; }

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  color: var(--text);
  font-size: 0.92rem;
}
.notice svg { width: 20px; height: 20px; flex: none; color: var(--accent); margin-top: 1px; }
.notice-error { background: var(--danger-soft); }
.notice-error svg { color: var(--danger); }

/* ---------- forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-weight: 600; font-size: 0.92rem; }
.field .hint { color: var(--muted); font-size: 0.85rem; }

.input, .select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23887a62' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}
[dir="rtl"] .select { background-position: left 10px center; }
.input:focus, .select:focus { border-color: var(--primary); }
.input::placeholder { color: var(--muted); }

.seg-control {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  max-width: 100%;
}
.seg-control button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg-control button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}
.seg-control.full { display: flex; width: 100%; }
.seg-control.full button { flex: 1; padding: 0 6px; }

/* switch: <label class="switch-row"><span>…</span><input type="checkbox" role="switch" class="switch"></label> */
.switch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 8px 0;
  cursor: pointer;
}
.switch-row .grow .title { font-weight: 600; }
.switch-row .grow .sub { color: var(--muted); font-size: 0.86rem; }
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s var(--ease);
}
.switch:checked { background: var(--primary); border-color: var(--primary); }
.switch:checked::after { transform: translateX(20px); }
[dir="rtl"] .switch:checked::after { transform: translateX(-20px); }
:root[data-theme="dark"] .switch:checked::after { background: #10142a; }

.range { width: 100%; accent-color: var(--primary); min-height: 44px; }

/* option cards (levels etc.) */
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-align: start;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.option:hover { border-color: var(--border-strong); }
.option[aria-checked="true"], .option[aria-pressed="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface));
  box-shadow: 0 0 0 1px var(--primary) inset;
}
.option .opt-num {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 700;
  color: var(--text-2);
}
.option[aria-checked="true"] .opt-num { background: var(--primary); color: var(--on-primary); }
.option .opt-title { font-weight: 650; }
.option .opt-desc { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.option .opt-meter { margin-top: 8px; }

/* ---------- progress ---------- */

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.35s var(--ease);
}
.progress.thin { height: 5px; }

.meter-mini { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.meter-mini .progress { flex: 1; height: 6px; }
.meter-mini .progress > span { background: var(--accent); }

/* coverage bar (lesson overview) */
.coverage {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.coverage-bar {
  position: relative;
  display: flex;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
}
.coverage-bar .seg-known { background: var(--primary); transition: width 0.5s var(--ease); }
.coverage-bar .seg-gain {
  background: repeating-linear-gradient(135deg, var(--accent) 0 6px, color-mix(in srgb, var(--accent) 75%, #fff) 6px 12px);
  transition: width 0.5s var(--ease);
}
.coverage-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--text-2); }
.coverage-legend i {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-inline-end: 6px;
  vertical-align: 0;
}
.coverage-nums { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.coverage-nums .big { font-size: 2.2rem; font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.coverage-nums .arrow { color: var(--muted); font-size: 1.4rem; }
.coverage-nums .after { color: var(--accent); }

/* ring */
.ring { position: relative; width: 72px; height: 72px; flex: none; }
.ring svg { width: 72px; height: 72px; transform: rotate(-90deg); }
.ring .ring-bg { stroke: var(--surface-3); }
.ring .ring-fg { stroke: var(--primary); transition: stroke-dashoffset 0.6s var(--ease); }
.ring .ring-label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- reader ---------- */

.reader-head { display: flex; align-items: center; gap: 4px; }
.reader-head .title-block { flex: 1; min-width: 0; padding: 0 4px; }
.reader-head .t1 { font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-head .t2 { font-family: var(--font-he); font-size: 1.02rem; color: var(--muted); white-space: nowrap; direction: rtl; text-align: left; overflow: hidden; text-overflow: ellipsis; }
[dir="rtl"] .reader-head .t2 { text-align: right; }
.reader-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 2px 0 14px;
}
.reader-tools .seg-control button { min-height: 36px; font-size: 0.82rem; padding: 0 10px; }

.page-text { display: flex; flex-direction: column; gap: 6px; }

.seg {
  position: relative;
  padding: 10px 12px 10px;
  border-radius: 14px;
  transition: background 0.2s;
}
.seg + .seg { border-top: 1px dashed color-mix(in srgb, var(--border) 70%, transparent); border-radius: 0; }
.seg.open { background: var(--surface); border-radius: 14px; border-top-color: transparent; box-shadow: var(--shadow-1); }
.seg.open + .seg { border-top-color: transparent; }

.he-text {
  margin: 0;
  font-family: var(--font-he);
  font-size: calc(1.5rem * var(--font-scale));
  line-height: 2.1;
  direction: rtl;
  text-align: justify;
  text-align-last: start;
  color: var(--text);
  font-weight: 400;
  overflow-wrap: break-word;
  font-feature-settings: "kern" 1;
}
.he-text.compact { font-size: calc(1.22rem * var(--font-scale)); line-height: 1.95; text-align: start; }

.w {
  position: relative;
  border-radius: 0.28em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.w::after {
  /* enlarge the touch target without affecting layout */
  content: "";
  position: absolute;
  inset: -0.32em -0.06em;
}
.w:hover { background: color-mix(in srgb, var(--primary-soft) 70%, transparent); }
.w:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.w.emph { font-weight: 700; color: var(--primary-ink); }

.hl-on .w.unknown {
  border-bottom: 2px dotted var(--amber);
  padding-bottom: 1px;
}
.hl-on .w.learning, .hl-learning .w.learning {
  background: var(--learning-bg);
  box-shadow: 0 0 0 1px var(--learning-ring) inset;
  padding: 0 0.08em;
}
.hl-on .w.name { color: var(--name); }
.hl-on .ph.unknown {
  background: var(--phrase-bg);
  border-radius: 0.35em;
  padding: 0.05em 0.1em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.hl-on .ph.learning, .hl-learning .ph.learning {
  background: var(--learning-bg);
  border-radius: 0.35em;
  padding: 0.05em 0.1em;
}
.w.target {
  background: var(--target-bg);
  border-bottom: 2px solid var(--target-line);
  padding: 0 0.08em;
}
.w.active {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  background: var(--primary-soft);
}

.seg-tools {
  display: flex;
  justify-content: flex-start;
  margin-top: 2px;
}
.tr-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  position: relative;
}
.tr-toggle::after { content: ""; position: absolute; inset: -6px -2px; }
.tr-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.tr-toggle[aria-expanded="true"] { background: var(--primary-soft); color: var(--primary-ink); border-color: transparent; }
.tr-toggle svg { width: 14px; height: 14px; }

.en-text {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.en-text .tr-body { text-align: start; }
.en-text .tr-body[lang="he"] { font-size: calc(1.12rem * var(--font-scale)); line-height: 1.8; color: var(--text-2); }
.en-text .tr-body small { font-size: 0.82em; letter-spacing: 0.02em; }
.tr-cap { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.tr-more {
  display: inline-flex; align-items: center; min-height: 36px; margin-top: 6px; padding: 0;
  border: 0; background: none; color: var(--primary-ink); font-size: 0.82rem; font-weight: 650; cursor: pointer;
}
.tr-en { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.en-text b, .en-text strong { color: var(--text); font-weight: 650; }
.en-text i, .en-text em { font-style: italic; }
.en-text .ai-tr { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--text-2); }
.en-text .ai-tr .eyebrow { margin-bottom: 4px; }
.seg .en-text { animation: fade-in 0.2s var(--ease); }
@keyframes fade-in { from { opacity: 0.6; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 10px;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw {
  font-family: var(--font-he);
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.3;
  padding: 0 4px;
  border-radius: 4px;
}
.legend .sw.unknown { border-bottom: 2px dotted var(--amber); border-radius: 0; padding: 0; }
.legend .sw.learning { background: var(--learning-bg); box-shadow: 0 0 0 1px var(--learning-ring) inset; }
.legend .sw.phrase { background: var(--phrase-bg); }
.legend .sw.name { color: var(--name); }
.legend .sw.target { background: var(--target-bg); border-bottom: 2px solid var(--target-line); border-radius: 4px 4px 0 0; }

.amud-nav {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.amud-nav .btn { flex: 1 1 0; min-width: 0; white-space: normal; text-align: center; padding: 6px 10px; line-height: 1.2; }
.amud-nav .btn .muted { display: block; font-weight: 500; font-size: 0.82rem; overflow-wrap: anywhere; }
.amud-label { font-family: var(--font-he); font-weight: 500; }

.page-break {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 6px;
  color: var(--muted);
  font-weight: 650;
  font-size: 0.9rem;
}
.page-break::before, .page-break::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* skeleton */
.skeleton { display: flex; flex-direction: column; gap: 14px; padding: 6px 0; }
.skeleton i {
  display: block;
  height: 18px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
.skeleton i:nth-child(3n) { width: 72%; margin-inline-start: auto; }
.skeleton i:nth-child(3n+1) { width: 94%; margin-inline-start: auto; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.9rem; padding: 8px 0; }

/* ---------- bottom sheet ---------- */

.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 0.25s;
}
.sheet-scrim.show { opacity: 1; }

.sheet {
  position: fixed;
  z-index: 61;
  left: 50%;
  bottom: 0;
  width: min(100%, 720px);
  max-height: min(78vh, 78dvh);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-sheet);
  transform: translate(-50%, 104%);
  transition: transform 0.32s var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
  outline: none;
}
.sheet.show { transform: translate(-50%, 0); }
.sheet.dragging { transition: none; }
.sheet-grab {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 26px;
  cursor: grab;
  touch-action: none;
}
.sheet-grab::before {
  content: "";
  width: 40px;
  height: 5px;
  border-radius: 999px;
  background: var(--border-strong);
}
.sheet-close {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  z-index: 2;
}
.sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 20px 22px;
  -webkit-overflow-scrolling: touch;
}
.sheet-modal .sheet-body { padding-top: 6px; }

/* word sheet content */
.ws-head { display: flex; align-items: flex-start; gap: 12px; padding-inline-end: 40px; }
.ws-word {
  font-family: var(--font-he);
  font-size: 2.6rem;
  line-height: 1.25;
  font-weight: 500;
  direction: rtl;
  color: var(--text);
}
.ws-form { color: var(--muted); font-size: 0.9rem; }
.ws-form .heb-inline { font-size: 1.15rem; color: var(--text-2); }
.ws-breakdown {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  direction: rtl;
  margin: 10px 0 2px;
}
.ws-part {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--surface-2);
  min-width: 46px;
}
.ws-part .p-he { font-family: var(--font-he); font-size: 1.45rem; line-height: 1.3; }
.ws-part .p-gl { font-family: var(--font-ui); font-size: 0.74rem; color: var(--muted); text-align: center; max-width: 9rem; line-height: 1.25; }
.ws-part.base { background: var(--primary-soft); }
.ws-part.base .p-gl { color: var(--primary-ink); }
.ws-plus { align-self: center; color: var(--muted); font-weight: 700; padding: 0 1px; }
.ws-gloss { font-size: 1.28rem; font-weight: 650; line-height: 1.35; margin-top: 12px; overflow-wrap: anywhere; }
.ws-gloss2 { color: var(--muted); font-size: 0.95rem; margin-top: 2px; overflow-wrap: anywhere; }
.ws-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ws-note { margin-top: 12px; color: var(--text-2); font-size: 0.95rem; line-height: 1.55; }
.ws-section { margin-top: 18px; }
.ws-section > .eyebrow { margin-bottom: 8px; display: block; }
.ws-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 16px; }
.ws-actions .btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.ws-actions .btn.known[aria-pressed="true"] { background: var(--success); color: #fff; }
.ws-phrase {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--phrase-bg);
}
.ws-phrase .ph-he { font-family: var(--font-he); font-size: 1.5rem; direction: rtl; line-height: 1.35; }
.ws-phrase .ph-gl { font-weight: 600; margin-top: 2px; }
.ws-phrase .btn-row { margin-top: 10px; }
.ws-phrase .btn { min-height: 40px; }

.dict-entry { padding: 10px 0; border-top: 1px solid var(--border); }
.dict-entry:first-of-type { border-top: 0; padding-top: 0; }
.dict-entry .src { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.dict-entry .hw { font-family: var(--font-he); font-size: 1.2rem; margin-left: 8px; }
.dict-entry .morph { color: var(--muted); font-size: 0.82rem; margin-left: 6px; font-style: italic; }
.dict-entry .def { color: var(--text-2); font-size: 0.93rem; margin-top: 2px; overflow-wrap: anywhere; }

.ai-box { border-radius: 14px; background: var(--primary-soft); padding: 12px 14px; }
.ai-box dl { margin: 0; display: grid; gap: 8px; }
.ai-box dt { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary-ink); }
.ai-box dd { margin: 0; color: var(--text); font-size: 0.95rem; overflow-wrap: anywhere; }

/* examples */
.example {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.example + .example { margin-top: 8px; }
.example .ex-ref { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.example .ex-he {
  font-family: var(--font-he);
  font-size: calc(1.22rem * var(--font-scale));
  line-height: 1.9;
  direction: rtl;
  text-align: start;
  color: var(--text-2);
}
.example .ex-he .hl {
  color: var(--text);
  background: var(--hl-bg);
  border-radius: 0.25em;
  padding: 0 0.1em;
  font-weight: 600;
}
.example .ex-he .ell { color: var(--muted); }
.example details { margin-top: 6px; }
.example summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--primary-ink);
  cursor: pointer;
  list-style: none;
}
.example summary::-webkit-details-marker { display: none; }
.example summary::before { content: "▸"; transition: transform 0.15s; display: inline-block; }
.example details[open] summary::before { transform: rotate(90deg); }
.example .en-text { margin-top: 4px; background: var(--surface); }

details.fold > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  font-weight: 650;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .chev { margin-inline-start: auto; transition: transform 0.2s; color: var(--muted); }
details.fold[open] > summary .chev { transform: rotate(180deg); }

/* ---------- toast ---------- */

.toast-root {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 520px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
@media (min-width: 880px) { .toast-root { bottom: 24px; } }
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 10px;
  padding-inline: 16px 10px;
  min-height: 48px;
  border-radius: 14px;
  background: #2a2419;
  color: #fbf4e4;
  box-shadow: var(--shadow-2);
  font-size: 0.93rem;
  pointer-events: auto;
  animation: toast-in 0.25s var(--ease);
}
:root[data-theme="dark"] .toast { background: #efe8d8; color: #1a1d28; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #efe8d8; color: #1a1d28; } }
.toast .msg { flex: 1; }
.toast .btn { min-height: 36px; padding: 0 12px; background: transparent; color: inherit; border: 1px solid currentColor; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.offline-badge {
  position: fixed;
  z-index: 70;
  top: calc(8px + env(safe-area-inset-top));
  inset-inline-end: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 0.75rem;
  font-weight: 650;
  box-shadow: var(--shadow-1);
}
@media (min-width: 880px) { .offline-badge { top: 70px; } }

/* ---------- home ---------- */

.home-greeting { display: flex; align-items: center; gap: 12px; margin: 4px 0 4px; }
.home-greeting .brand-mark { width: 40px; height: 40px; border-radius: 11px; }
.home-greeting h1 { font-size: 1.3rem; }
.home-greeting p { color: var(--muted); font-size: 0.9rem; }

.review-cta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--amber-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
  text-decoration: none;
}
.review-cta .ic {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
}
.review-cta .ic svg { width: 22px; height: 22px; }
.review-cta .t { font-weight: 700; }
.review-cta .s { color: var(--text-2); font-size: 0.88rem; }
.review-cta:hover { filter: brightness(0.98); }
.review-cta > svg { width: 20px; height: 20px; flex: none; color: var(--muted); }

.picker { display: grid; grid-template-columns: 1fr 124px 96px; gap: 8px; }
.picker .select { padding-inline-end: 30px; background-position: right 8px center; }
[dir="rtl"] .picker .select { background-position: left 8px center; }
@media (max-width: 420px) { .picker { grid-template-columns: 1fr 1fr; } .picker .select:first-child { grid-column: 1 / -1; } }

.history-row .heb { font-size: 1.15rem; }

/* onboarding */
.onb { max-width: 560px; margin: 0 auto; }
.onb-hero { text-align: center; padding: 18px 0 8px; }
.onb-hero .brand-mark { width: 76px; height: 76px; border-radius: 20px; margin: 0 auto 14px; box-shadow: var(--shadow-2); }
.onb-hero h1 { font-size: 1.7rem; }
.onb-hero p { color: var(--muted); margin-top: 8px; }
.onb-steps { display: flex; justify-content: center; gap: 6px; margin: 4px 0 16px; }
.onb-steps i { width: 26px; height: 5px; border-radius: 999px; background: var(--surface-3); }
.onb-steps i.on { background: var(--primary); }
.lang-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lang-pick .option { flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 18px 12px; }
.lang-pick .big { font-size: 1.35rem; font-weight: 700; }

/* ---------- browse ---------- */

.seder-block + .seder-block { margin-top: 22px; }
.seder-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.seder-title .heb-inline { font-size: 1.15rem; color: var(--muted); }
.tractate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tractate-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 76px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s, transform 0.15s;
}
.tractate-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.tractate-card .tn { font-weight: 650; }
.tractate-card .th { font-family: var(--font-he); font-size: 1.15rem; color: var(--text-2); direction: rtl; text-align: right; }
.tractate-card .tm { font-size: 0.78rem; color: var(--muted); }

.daf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(98px, 1fr));
  gap: 8px;
}
.daf-cell {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 6px 6px 6px;
  box-shadow: var(--shadow-1);
}
.daf-cell.studied { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.daf-cell .dn { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 4px; }
.daf-cell .dn b { font-variant-numeric: tabular-nums; }
.daf-cell .dn .heb-inline { color: var(--muted); font-size: 1rem; }
.daf-cell .sides { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.daf-cell .sides button {
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  background: var(--surface-2);
  font-weight: 650;
  color: var(--text-2);
}
.daf-cell .sides button:hover { background: var(--surface-3); }
.daf-cell .sides button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.daf-cell .sides button.done { box-shadow: inset 0 -3px 0 var(--success); }

.action-bar {
  position: sticky;
  bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom));
  z-index: 15;
  margin-top: 14px;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  animation: screen-in 0.2s var(--ease);
}
@media (min-width: 880px) { .action-bar { bottom: 16px; } }
.action-bar .ab-title { font-weight: 700; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.action-bar .btn-row .btn { flex: 1 1 120px; }

/* ---------- lesson ---------- */

.stepper { display: flex; gap: 4px; margin: 0 0 16px; }
.stepper .st {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  min-width: 0;
}
.stepper .st i { height: 4px; border-radius: 999px; background: var(--surface-3); transition: background 0.3s; }
.stepper .st.done i { background: color-mix(in srgb, var(--primary) 55%, var(--surface-3)); }
.stepper .st.cur i { background: var(--primary); }
.stepper .st.cur { color: var(--text); }
.stepper .st span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 400px) { .stepper .st span { display: none; } .stepper .st.cur span { display: block; } .stepper .st.cur { flex: 2.4; } }

.word-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  min-height: 64px;
}
.word-row .heb { font-size: 1.45rem; line-height: 1.35; min-width: 0; }
.word-row .wr-main { flex: 1; min-width: 0; }
.word-row .wr-gloss { font-weight: 600; font-size: 0.95rem; overflow-wrap: anywhere; }
.word-row .wr-sub { color: var(--muted); font-size: 0.8rem; }
.word-row.is-known { opacity: 0.55; }
.word-row.is-known .heb { text-decoration: line-through; text-decoration-color: var(--muted); }
.knew-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 650;
}
.knew-toggle svg { width: 16px; height: 16px; }
.knew-toggle[aria-pressed="true"] { background: var(--success-soft); border-color: transparent; color: var(--success); }

.names-row { display: flex; flex-wrap: wrap; gap: 6px; }

.flashcard {
  position: relative;
  padding: 22px 18px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
}
.flashcard .fc-word {
  font-family: var(--font-he);
  font-size: clamp(2.6rem, 11vw, 3.6rem);
  line-height: 1.2;
  font-weight: 500;
  text-align: center;
  direction: rtl;
  color: var(--text);
}
.flashcard .fc-forms { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.flashcard .fc-gloss { text-align: center; font-size: 1.3rem; font-weight: 650; margin-top: 14px; overflow-wrap: anywhere; }
.flashcard .fc-gloss2 { text-align: center; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.flashcard .fc-he { text-align: center; margin-top: 10px; color: var(--text-2); font-size: 0.92rem; }
.flashcard .fc-he .heb-inline { font-size: 1.2rem; }
.flashcard .fc-note { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 0.93rem; line-height: 1.55; }
.flashcard .fc-count { position: absolute; top: 14px; inset-inline-start: 16px; font-size: 0.8rem; color: var(--muted); font-weight: 650; font-variant-numeric: tabular-nums; }
.flashcard .fc-kind { position: absolute; top: 12px; inset-inline-end: 14px; }
.card-enter { animation: card-in 0.32s var(--ease) both; }
@keyframes card-in { from { opacity: 0.6; transform: translateX(14px) scale(0.99); } to { opacity: 1; transform: none; } }

.lesson-actions {
  position: sticky;
  bottom: calc(var(--tabbar-h) + 8px + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 10px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.lesson-actions .btn { flex: 1; }
@media (min-width: 880px) { .lesson-actions { bottom: 12px; } }

/* quiz */
.quiz-prompt {
  text-align: center;
  padding: 18px 8px 8px;
}
.quiz-prompt .q-label { color: var(--muted); font-size: 0.88rem; font-weight: 600; }
.quiz-prompt .q-he { font-family: var(--font-he); font-size: clamp(2.4rem, 10vw, 3.2rem); line-height: 1.3; direction: rtl; margin-top: 6px; }
.quiz-prompt .q-text { font-size: 1.35rem; font-weight: 700; margin-top: 8px; overflow-wrap: anywhere; }
.quiz-context { margin-top: 10px; text-align: right; }
.quiz-options { display: grid; gap: 10px; margin-top: 16px; }
.quiz-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-align: start;
  font-weight: 600;
  font-size: 1rem;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.quiz-opt:hover { border-color: var(--border-strong); }
.quiz-opt:active { transform: scale(0.99); }
.quiz-opt .k {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}
.quiz-opt .o-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.quiz-opt.he .o-text { font-family: var(--font-he); font-size: 1.55rem; font-weight: 500; direction: rtl; text-align: right; line-height: 1.35; }
.quiz-opt.correct { border-color: var(--success); background: var(--success-soft); }
.quiz-opt.correct .k { background: var(--success); color: #fff; }
.quiz-opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.quiz-opt.wrong .k { background: var(--danger); color: #fff; }
.quiz-opt[disabled] { cursor: default; }
.quiz-opt.dim { opacity: 0.55; }
.quiz-feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 600;
  animation: fade-in 0.2s var(--ease);
}
.quiz-feedback.ok { background: var(--success-soft); color: var(--success); }
.quiz-feedback.bad { background: var(--danger-soft); color: var(--danger); }
.quiz-feedback .fb-detail { color: var(--text); font-weight: 500; }
.quiz-feedback svg { width: 22px; height: 22px; flex: none; }

.done-hero { text-align: center; padding: 10px 0; }
.done-hero .seal {
  width: 84px; height: 84px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--success-soft);
  color: var(--success);
}
.done-hero .seal svg { width: 44px; height: 44px; }
.done-hero h1 { font-size: 1.6rem; }
.done-hero p { color: var(--muted); margin-top: 6px; }
.streak-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--amber-soft); color: var(--text); font-weight: 700; margin-top: 10px; }
.streak-chip svg { width: 18px; height: 18px; color: var(--accent); }

/* ---------- review ---------- */

.review-card { min-height: 300px; display: flex; flex-direction: column; justify-content: center; }
.review-card .fc-ctx { margin-top: 12px; }
.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.grade {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 60px;
  padding: 6px 4px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: var(--shadow-1);
}
.grade .iv { font-size: 0.74rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.grade.again { color: var(--danger); }
.grade.hard { color: var(--accent); }
.grade.good { color: var(--success); }
.grade.easy { color: var(--primary-ink); }
.grade:hover { border-color: currentColor; }
.kbd-hint { text-align: center; color: var(--muted); font-size: 0.78rem; margin-top: 10px; }
@media (hover: none) { .kbd-hint { display: none; } }

/* ---------- words ---------- */

.search-wrap { position: relative; }
.search-wrap svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-wrap .input { padding-inline-start: 38px; }
.due-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-inline-end: 6px; vertical-align: 1px; }

/* ---------- placement ---------- */

.pl-card { text-align: center; padding: 28px 18px 22px; }
.pl-card .pl-word { font-family: var(--font-he); font-size: clamp(2.8rem, 13vw, 4rem); line-height: 1.25; direction: rtl; }
.pl-card .pl-gloss { min-height: 3.2em; margin-top: 10px; color: var(--text-2); font-size: 1.1rem; display: grid; place-items: center; }
.pl-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.band-bars { display: grid; gap: 8px; }
.band-bar { display: grid; grid-template-columns: 92px 1fr 44px; gap: 10px; align-items: center; font-size: 0.85rem; }
.band-bar .progress > span { background: var(--accent); }
.band-bar .pct { text-align: end; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- settings ---------- */

.settings-group { padding: 6px 18px; }
.settings-group > .eyebrow { display: block; padding: 12px 0 2px; }
.settings-group .divider { height: 1px; background: var(--border); margin: 4px 0; }
.settings-item { padding: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.settings-item .title { font-weight: 600; }
.settings-item .sub { color: var(--muted); font-size: 0.86rem; }
.font-preview { font-family: var(--font-he); direction: rtl; font-size: calc(1.5rem * var(--font-scale)); line-height: 1.9; text-align: right; padding: 4px 12px; border-radius: 12px; background: var(--surface-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 6px; background: var(--muted); }
.status-dot.on { background: var(--success); }
.status-dot.off { background: var(--danger); }

/* room to scroll the text above an open word sheet */
body.sheet-open .main { padding-bottom: 62vh; }

/* ---------- motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- languages & RTL ---------- */

/* directional icons (back/next arrows, chevrons) point the other way in a right-to-left UI */
[dir="rtl"] .dir-flip { transform: scaleX(-1); }

/* a gloss shown in another language than the learner chose (English fallback) */
.lang-tag {
  display: inline-block;
  vertical-align: 0.12em;
  margin-inline-start: 4px;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.5;
  cursor: help;
}
.auto-chip { vertical-align: 0.1em; margin-inline-start: 4px; }
.lang-hint { margin-top: 2px; }
.lang-pick .option .big { font-size: 1.2rem; }

/* ---- accounts: login, admin ---------------------------------------------------------- */
body.auth-screen .tabbar { display: none; }
.login-card { max-width: 420px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 14px; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand h1 { font-size: 1.5rem; }
.notice-success { background: var(--success-soft); }
.notice-success svg { color: var(--success); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.02em; }
.secret-box .row .input { flex: 1 1 auto; min-width: 0; }
.admin-user { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--border); }
.admin-user:first-child { border-top: none; }
.admin-user .btn-row > .btn { flex: 0 1 auto; }
.account-actions { display: flex; flex-direction: column; gap: 12px; padding: 6px 0 14px; }
