/* Nino — A1 Italian for Persian speakers
   Layout: single-column app shell (max 960px), sticky top bar, bottom tab bar on phones,
   RTL Persian UI with LTR Italian islands. */

:root {
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --surface-2: #EAEFF8;
  --fg: #152038;
  --muted: #5D6C88;
  --line: #D9E1EE;
  --primary: #1D5BC9;
  --primary-fg: #FFFFFF;
  --primary-soft: #E1EAFB;
  --accent: #F3B63C;
  --accent-fg: #2A2000;
  --accent-soft: #FFF1CF;
  --success: #1E9A62;
  --success-soft: #DBF4E7;
  --danger: #D8473A;
  --danger-soft: #FBE2DF;
  --shadow: 0 12px 32px rgba(21, 32, 56, .08);
  --shadow-sm: 0 2px 8px rgba(21, 32, 56, .06);
  --radius: 18px;
  --radius-sm: 12px;
  --font-fa: 'Vazirmatn', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --font-it: 'Nunito', 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --nav-h: 64px;
  --tab-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1425; --surface: #151E34; --surface-2: #1D2944; --fg: #EDF1F9; --muted: #9DAAC4; --line: #2A3754;
    --primary: #5E90F0; --primary-fg: #0A1222; --primary-soft: #1B2B4F;
    --accent: #F6C75B; --accent-fg: #2A2000; --accent-soft: #3B2F12;
    --success: #3DBE82; --success-soft: #153826; --danger: #F0705F; --danger-soft: #45201C;
    --shadow: 0 12px 32px rgba(0, 0, 0, .35); --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1425; --surface: #151E34; --surface-2: #1D2944; --fg: #EDF1F9; --muted: #9DAAC4; --line: #2A3754;
  --primary: #5E90F0; --primary-fg: #0A1222; --primary-soft: #1B2B4F;
  --accent: #F6C75B; --accent-fg: #2A2000; --accent-soft: #3B2F12;
  --success: #3DBE82; --success-soft: #153826; --danger: #F0705F; --danger-soft: #45201C;
  --shadow: 0 12px 32px rgba(0, 0, 0, .35); --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: var(--font-fa); font-size: 16px; line-height: 1.7;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
html, body { overflow-x: hidden; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; text-wrap: balance; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Italian islands */
.it, [dir="ltr"] { direction: ltr; font-family: var(--font-it); unicode-bidi: isolate; }
.it { font-weight: 700; }
.display { font-family: var(--font-display); font-weight: 600; direction: ltr; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; height: var(--nav-h);
  display: flex; align-items: center; gap: 12px; padding-inline: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand-mark { width: 36px; height: 36px; flex: 0 0 auto; }
.brand-name { font-family: var(--font-display); font-size: 22px; direction: ltr; letter-spacing: -.01em; }
.brand-name b { color: var(--primary); font-weight: 600; }
.brand-sub { display: block; font-family: var(--font-fa); font-size: 10px; line-height: 1; color: var(--muted); direction: rtl; margin-top: 2px; letter-spacing: 0; }
@media (max-width: 560px) { .brand-sub { display: none; } }
.topnav { display: none; gap: 4px; margin-inline-start: 8px; }
.topnav a { text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 999px; font-weight: 500; }
.topnav a.active, .topnav a:hover { color: var(--fg); background: var(--surface-2); }
.topbar-spacer { flex: 1; }
.stat-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  background: var(--surface-2); font-weight: 700; font-size: 14px; white-space: nowrap;
}
.stat-chip .ic { font-size: 16px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; color: var(--fg);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.wide { width: auto; padding-inline: 10px; gap: 6px; white-space: nowrap; font-size: 13px; font-weight: 700; }
@media (max-width: 560px) { .hide-sm { display: none; } .icon-btn.wide { padding-inline: 0; width: 40px; } }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: var(--primary-fg);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; border: none;
}
.session-chip { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-fg); font-weight: 800; min-width: 72px; padding-inline: 10px; border-radius: 12px; height: 40px; border: 1px solid var(--accent); }

main { max-width: 960px; margin: 0 auto; padding-inline: 16px; padding-block: 20px calc(var(--tab-h) + 28px); }
@media (max-width: 560px) {
  .topbar-inner { gap: 8px; }
  .brand-name { font-size: 17px; }
  .brand-mark { width: 30px; height: 30px; }
  .stat-chip { padding: 4px 8px; font-size: 13px; gap: 4px; }
  .stat-chip .ic { font-size: 14px; }
  #theme-btn { display: none; }
  .icon-btn, .avatar { width: 36px; height: 36px; }
  .stat-tile b { font-size: 22px; }
  .stat-tile { padding: 12px 8px; }
}
@media (min-width: 820px) {
  .topnav { display: flex; }
  main { padding-block: 28px 56px; }
  .tabbar { display: none !important; }
}

.tabbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px;
  text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; min-height: var(--tab-h);
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--primary); }

/* ---------- Primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; direction: ltr; font-family: var(--font-it); text-align: right; display: block; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.accent { background: var(--accent-soft); color: var(--accent-fg); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 14px; border: 1px solid transparent;
  font-weight: 800; font-size: 16px; line-height: 1.2; text-decoration: none;
  background: var(--surface-2); color: var(--fg); transition: transform .08s ease, background .2s, box-shadow .2s;
  min-height: 46px;
}
.btn:hover { filter: brightness(.98); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-fg); box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn-accent { background: var(--accent); color: var(--accent-fg); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-lg { padding: 16px 28px; font-size: 18px; border-radius: 16px; }
.btn-sm { padding: 8px 14px; font-size: 14px; min-height: 36px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn svg { width: 20px; height: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; font-size: 14px; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  min-height: 48px; transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input.it { font-weight: 600; }
.field .err { color: var(--danger); font-size: 13px; min-height: 18px; }
.help { font-size: 13px; color: var(--muted); }

.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.progress.accent > i { background: var(--accent); }
.progress.success > i { background: var(--success); }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { appearance: none; width: 46px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; margin: 0; flex: 0 0 auto; }
.toggle input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle input:checked { background: var(--primary); }
.toggle input:checked::after { transform: translateX(-20px); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: none; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }

.toast-wrap { position: fixed; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom, 0px)); inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; padding-inline: 16px; }
@media (min-width: 820px) { .toast-wrap { bottom: 24px; } }
.toast { background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 700; box-shadow: var(--shadow); animation: toast-in .3s ease; max-width: 100%; }
.toast.ok { background: var(--success); color: #fff; }
.toast.warn { background: var(--accent); color: var(--accent-fg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.page-head h1 { font-size: clamp(24px, 4vw, 32px); font-weight: 800; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.back svg { width: 18px; height: 18px; }

/* ---------- Home / hero ---------- */
.hero { position: relative; overflow: hidden; border-radius: 28px; padding: clamp(24px, 5vw, 48px); background: var(--primary); color: var(--primary-fg); isolation: isolate; }
.hero::before { content: ""; position: absolute; inset: -40% -20% auto auto; width: 60%; aspect-ratio: 1; border-radius: 50%; background: color-mix(in srgb, var(--accent) 80%, transparent); filter: blur(60px); opacity: .55; z-index: -1; }
.hero::after { content: ""; position: absolute; inset: auto auto -50% -10%; width: 55%; aspect-ratio: 1; border-radius: 50%; background: color-mix(in srgb, #fff 40%, transparent); filter: blur(70px); opacity: .35; z-index: -1; }
.hero .eyebrow { text-align: right; }
.hero .display { font-size: clamp(40px, 9vw, 84px); line-height: 1.05; letter-spacing: -.02em; text-align: right; }
.hero .display .blank { display: inline-block; min-width: 3.2ch; border-bottom: .07em solid var(--accent); color: var(--accent); line-height: .95; vertical-align: baseline; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.hero p { max-width: 36rem; opacity: .95; font-size: 17px; margin-top: 10px; }
.hero-form { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.hero-form .input { max-width: 260px; background: color-mix(in srgb, #fff 92%, transparent); color: #152038; border-color: transparent; }
.feature { display: flex; gap: 14px; align-items: flex-start; padding: 18px; }
.feature .ic { width: 44px; height: 44px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 22px; flex: 0 0 auto; }
.feature h3 { font-size: 16px; font-weight: 800; }
.feature p { font-size: 14px; color: var(--muted); }

.greeting { font-size: 14px; color: var(--muted); }
.home-title { font-size: clamp(26px, 5vw, 36px); font-weight: 800; }
.continue-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 20px; border-radius: 22px; background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #7C3AED)); color: var(--primary-fg); box-shadow: 0 14px 34px color-mix(in srgb, var(--primary) 40%, transparent); }
.continue-card .unit-emoji { font-size: 40px; }
.continue-card .btn { background: #fff; color: #152038; }
@media (max-width: 480px) { .continue-card { grid-template-columns: 1fr; } }
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-tile { padding: 14px; text-align: center; }
.stat-tile b { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-tile span { font-size: 12px; color: var(--muted); }
.unit-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.unit-dot { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); font-size: 20px; text-decoration: none; border: 2px solid transparent; }
.unit-dot.done { background: var(--success-soft); border-color: var(--success); }
.unit-dot.current { border-color: var(--primary); background: var(--primary-soft); }
.unit-dot.locked { opacity: .45; filter: grayscale(1); }
.phrase-card { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.phrase-card .it { font-size: 22px; }

/* ---------- Units map ---------- */
.unit-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.unit-card { display: flex; gap: 14px; padding: 18px; text-decoration: none; color: inherit; position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.unit-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.unit-card .emoji { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); display: grid; place-items: center; font-size: 28px; flex: 0 0 auto; }
.unit-card .num { font-size: 12px; color: var(--muted); font-weight: 700; direction: ltr; font-family: var(--font-it); text-align: right; }
.unit-card h3 { font-size: 17px; font-weight: 800; }
.unit-card .title-it { font-family: var(--font-it); direction: ltr; text-align: right; color: var(--muted); font-size: 14px; display: block; }
.unit-card .progress { margin-top: 8px; }
.unit-card.locked { opacity: .55; }
.unit-card.locked .emoji { background: var(--surface-2); filter: grayscale(1); }
.unit-card .lock { position: absolute; top: 12px; inset-inline-start: 12px; }
.unit-card.done .emoji { background: var(--success-soft); }

/* ---------- Unit page ---------- */
.unit-hero { display: flex; gap: 18px; align-items: center; padding: 22px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line); }
.unit-hero .emoji { width: 72px; height: 72px; border-radius: 22px; background: var(--primary-soft); display: grid; place-items: center; font-size: 38px; flex: 0 0 auto; }
.unit-hero h1 { font-size: clamp(22px, 4vw, 30px); font-weight: 800; }
.unit-hero .title-it { font-family: var(--font-display); font-size: 20px; direction: ltr; text-align: right; color: var(--primary); display: block; }
.goals { display: grid; gap: 8px; }
.goal { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.goal .ic { color: var(--success); flex: 0 0 auto; margin-top: 3px; }
.goal .it { font-weight: 600; font-size: 13px; color: var(--muted); display: block; text-align: start; }
.section-list { display: grid; gap: 10px; }
.section-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; color: inherit; transition: transform .12s; }
.section-item:hover { transform: translateX(-3px); }
.section-item .num { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); font-weight: 800; flex: 0 0 auto; }
.section-item.done .num { background: var(--success-soft); color: var(--success); }
.section-item.next .num { background: var(--primary); color: var(--primary-fg); }
.section-item h3 { font-size: 16px; font-weight: 800; }
.section-item p { font-size: 13px; color: var(--muted); }
.section-item .chev { margin-inline-start: auto; color: var(--muted); }
.section-item .chev svg { width: 20px; height: 20px; }

.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h1 { font-size: 22px; font-weight: 800; }
.section-head .crumb { font-size: 13px; color: var(--muted); display: block; }
.section-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- Scene player (motion graphics) ---------- */
.scene { overflow: hidden; }
.scene-title { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 14px 18px 0; }
.scene-title h3 { font-size: 16px; font-weight: 800; }
.scene-title .it { font-size: 14px; color: var(--muted); font-weight: 600; }
.stage-wrap { padding: 14px 18px 0; }
.stage {
  position: relative; width: 100%; aspect-ratio: 360 / 220; border-radius: 16px; overflow: hidden;
  container-type: inline-size; direction: ltr; border: 1px solid var(--line);
  background: var(--surface-2);
}
.stage.bg-sky { background: linear-gradient(180deg, #BEE3FF 0%, #E9F5FF 62%, #CDE8C3 62.5%, #B7DBA8 100%); }
.stage.bg-night { background: linear-gradient(180deg, #0B1838 0%, #1B2E5E 65%, #22314F 65.5%, #1A2740 100%); }
.stage.bg-street { background: linear-gradient(180deg, #DDEBFF 0%, #EEF4FF 58%, #C9CFD9 58.5%, #AEB5C2 100%); }
.stage.bg-room { background: linear-gradient(180deg, #FFF4E3 0%, #FFEBD0 62%, #D9B38C 62.5%, #C69A70 100%); }
.stage.bg-cafe { background: linear-gradient(180deg, #F6E7D3 0%, #F1DDC2 62%, #8E5B3A 62.5%, #74452A 100%); }
.stage.bg-plain { background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.stage.bg-street::before { content: ""; position: absolute; left: 0; right: 0; bottom: 42%; height: 26%;
  background:
    linear-gradient(#B9C6DF, #B9C6DF) 2% 100% / 14% 70% no-repeat,
    linear-gradient(#A8B6D2, #A8B6D2) 20% 100% / 10% 100% no-repeat,
    linear-gradient(#C4D0E6, #C4D0E6) 34% 100% / 18% 55% no-repeat,
    linear-gradient(#AFBDD8, #AFBDD8) 58% 100% / 12% 85% no-repeat,
    linear-gradient(#BFCBE3, #BFCBE3) 75% 100% / 16% 60% no-repeat,
    linear-gradient(#A3B1CD, #A3B1CD) 96% 100% / 10% 95% no-repeat; opacity: .8; }
.stage.bg-night::before { content: ""; position: absolute; inset: 0 0 35% 0; background-image: radial-gradient(#fff 1px, transparent 1.5px), radial-gradient(#fff 1px, transparent 1.5px); background-size: 60px 50px, 90px 70px; background-position: 10px 5px, 40px 30px; opacity: .6; }
.stage.bg-room::before { content: ""; position: absolute; left: 8%; top: 12%; width: 22%; aspect-ratio: 1; border: 2cqw solid #fff; background: linear-gradient(180deg, #9CD3FF, #DFF1FF); border-radius: 1cqw; opacity: .9; }

.el { position: absolute; transform: translate(-50%, -50%); transition: left 1s cubic-bezier(.2,.8,.2,1), top 1s cubic-bezier(.2,.8,.2,1), transform 1s cubic-bezier(.2,.8,.2,1), opacity .6s ease, color .6s ease, filter .6s ease; will-change: transform, opacity; }
.el-shape svg { width: 100%; height: auto; display: block; overflow: visible; }
.el-text { white-space: normal; max-width: 92cqw; text-align: center; font-family: var(--font-it); font-weight: 800; line-height: 1.1; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.el-text[dir="rtl"] { font-family: var(--font-fa); font-weight: 600; }
.el-bubble { background: #fff; color: #152038; border-radius: 3.5cqw; padding: 2.2cqw 3.6cqw; font-family: var(--font-it); font-weight: 800; white-space: normal; max-width: 46cqw; width: max-content; text-align: center; box-shadow: 0 1.5cqw 4cqw rgba(0,0,0,.14); line-height: 1.15; }
.el-bubble::after { content: ""; position: absolute; left: 50%; bottom: -2.4cqw; width: 3.4cqw; height: 3.4cqw; background: #fff; transform: translateX(-50%) rotate(45deg); border-radius: .5cqw; }
.el-chip { background: color-mix(in srgb, var(--fg) 88%, transparent); color: var(--bg); border-radius: 999px; padding: 1.4cqw 3.4cqw; white-space: normal; max-width: 92cqw; width: max-content; text-align: center; font-weight: 700; line-height: 1.3; font-family: var(--font-fa); }
.el-arrow svg { width: 100%; height: auto; display: block; }
.el.glow { filter: drop-shadow(0 0 2.5cqw color-mix(in srgb, var(--accent) 90%, transparent)); }
.el .swap-text { transition: opacity .22s; }
.el.swapping .swap-text { opacity: 0; }

.scene-caption { padding: 14px 18px 4px; min-height: 86px; display: flex; flex-direction: column; gap: 4px; }
.scene-caption .cap-it { font-family: var(--font-it); font-weight: 800; font-size: 20px; direction: ltr; text-align: right; color: var(--primary); transition: opacity .25s; }
.scene-caption .cap-fa { font-size: 15px; color: var(--fg); transition: opacity .25s; }
.scene-caption.fade .cap-it, .scene-caption.fade .cap-fa { opacity: 0; }
.scene-controls { display: flex; align-items: center; gap: 8px; padding: 10px 18px 16px; flex-wrap: wrap; }
.scene-controls .dots { display: flex; gap: 6px; flex: 1; justify-content: center; direction: ltr; }
.scene-controls .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: all .25s; display: block; }
.scene-controls .dots i.on { background: var(--primary); width: 20px; border-radius: 4px; }
.scene-controls .dots i.seen { background: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.scene-done { margin: 0 18px 16px; padding: 12px 14px; border-radius: 12px; background: var(--success-soft); color: var(--success); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.scene-done svg { width: 20px; height: 20px; flex: 0 0 auto; }
/* inline icon sizing safety net */
.goal .ic svg, .section-item .num svg, .gpoint-head .chev svg, .section-item .chev svg { width: 20px; height: 20px; }
.badge svg { width: 14px; height: 14px; }

/* ---------- Conjugation / table widgets ---------- */
.conj { display: grid; gap: 6px; direction: ltr; }
.conj-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.conj-head .verb { font-family: var(--font-display); font-size: 28px; color: var(--primary); }
.conj-head .fa { font-family: var(--font-fa); direction: rtl; color: var(--muted); font-weight: 600; }
.conj-row { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); font-family: var(--font-it); opacity: 0; transform: translateX(-10px); animation: row-in .5s cubic-bezier(.2,.8,.2,1) forwards; cursor: pointer; border: 1px solid transparent; }
.conj-row:hover { border-color: var(--primary); }
.conj-row .pr { color: var(--muted); font-weight: 600; }
.conj-row .form { font-weight: 800; font-size: 19px; }
.conj-row .stem { color: var(--primary); }
.conj-row .end { color: var(--accent-fg); background: var(--accent); border-radius: 6px; padding: 0 5px; display: inline-block; animation: pop .5s cubic-bezier(.2,.8,.2,1) both; }
.conj-row .spk { color: var(--muted); }
.conj-row .spk svg { width: 18px; height: 18px; }
@keyframes row-in { to { opacity: 1; transform: none; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

.gtable { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); font-size: 15px; }
.gtable th { background: var(--surface-2); padding: 10px 12px; text-align: center; font-weight: 800; }
.gtable td { padding: 10px 12px; border-top: 1px solid var(--line); text-align: center; font-family: var(--font-it); font-weight: 600; direction: ltr; }
.gtable td:first-child { font-weight: 800; color: var(--primary); }
.gtable tr { opacity: 0; animation: row-in .45s ease forwards; }
.gtable-wrap { overflow-x: auto; }
.gtable-cap { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---------- Vocabulary ---------- */
.vocab-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.vcard { padding: 16px; display: flex; flex-direction: column; gap: 6px; position: relative; transition: transform .15s, box-shadow .15s; }
.vcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.vcard .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vcard .emoji { font-size: 28px; }
.vcard .it { font-size: 20px; text-align: right; }
.vcard .pos { font-size: 11px; color: var(--muted); font-family: var(--font-it); direction: ltr; text-align: right; }
.vcard .fa { font-weight: 600; }
.vcard .fa.hidden-fa { filter: blur(6px); cursor: pointer; user-select: none; }
.vcard .fa.hidden-fa:hover { filter: blur(3px); }
.vcard .ex { font-size: 13px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 2px; }
.vcard .ex .it { font-size: 13px; font-weight: 600; display: block; }
.vcard .note { font-size: 12px; color: var(--accent-fg); background: var(--accent-soft); border-radius: 8px; padding: 4px 8px; }
.spk-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; color: var(--primary); flex: 0 0 auto; }
.spk-btn:hover { background: var(--primary-soft); }
.spk-btn svg { width: 18px; height: 18px; }
.spk-btn.playing { background: var(--primary); color: var(--primary-fg); }

.flash { perspective: 1200px; }
.flash-card { position: relative; min-height: 260px; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.2,.8,.2,1); cursor: pointer; }
.flash-card.flipped { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; border-radius: var(--radius); }
.flash-face.back { transform: rotateY(180deg); background: var(--primary-soft); }
.flash-face .big { font-size: 34px; }
.flash-face .emoji { font-size: 48px; }
.flash-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }

/* ---------- Dialogue ---------- */
.dialogue-setting { padding: 14px 18px; background: var(--accent-soft); color: var(--accent-fg); border-radius: 14px; font-size: 14px; }
.chat { display: flex; flex-direction: column; gap: 12px; direction: ltr; }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 88%; }
.msg.right { align-self: flex-end; flex-direction: row-reverse; }
.msg .who { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 22px; flex: 0 0 auto; }
.msg .bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 10px 14px; box-shadow: var(--shadow-sm); transition: background .3s, border-color .3s; }
.msg.right .bubble { background: var(--primary-soft); border-color: transparent; }
.msg .bubble .name { font-size: 11px; color: var(--muted); font-family: var(--font-it); font-weight: 700; }
.msg .bubble .it { font-size: 17px; display: block; text-align: left; }
.msg .bubble .fa { direction: rtl; text-align: right; font-size: 14px; color: var(--muted); margin-top: 4px; display: block; }
.msg .bubble .fa.hidden-fa { filter: blur(6px); cursor: pointer; }
.msg.active .bubble { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-fg); }
.msg .spk-btn { width: 32px; height: 32px; }

/* ---------- Grammar ---------- */
.gpoint { overflow: hidden; }
.gpoint-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; cursor: pointer; }
.gpoint-head .num { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; flex: 0 0 auto; }
.gpoint-head h3 { font-size: 17px; font-weight: 800; }
.gpoint-head .it { font-size: 14px; color: var(--muted); display: block; text-align: right; }
.gpoint-head .chev { margin-inline-start: auto; transition: transform .3s; color: var(--muted); }
.gpoint.open .gpoint-head .chev { transform: rotate(180deg); }
.gpoint-body { display: none; padding: 0 18px 18px; gap: 16px; flex-direction: column; }
.gpoint.open .gpoint-body { display: flex; }
.explain p { margin-bottom: 10px; }
.explain p:last-child { margin-bottom: 0; }
.examples { display: grid; gap: 8px; }
.example { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.example .txt { flex: 1; min-width: 0; }
.example .it { display: block; text-align: right; font-size: 16px; }
.example .fa { display: block; font-size: 14px; color: var(--muted); }
.tip { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-fg); font-size: 14px; }
.tip .ic { font-size: 18px; }

/* ---------- Exercises ---------- */
.ex-wrap { max-width: 680px; margin: 0 auto; }
.ex-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.ex-top .progress { flex: 1; }
.ex-top .count { font-weight: 800; font-size: 14px; color: var(--muted); white-space: nowrap; }
.ex-card { padding: 22px; animation: ex-in .35s cubic-bezier(.2,.8,.2,1); }
@keyframes ex-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.ex-type { font-size: 12px; color: var(--muted); font-weight: 700; display: inline-flex; gap: 6px; align-items: center; margin-bottom: 10px; }
.ex-prompt { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.ex-prompt .it { display: block; font-size: 22px; text-align: right; margin-top: 6px; color: var(--primary); }
.ex-sentence { font-size: 24px; direction: ltr; text-align: center; font-family: var(--font-it); font-weight: 800; padding: 16px; background: var(--surface-2); border-radius: 14px; margin-bottom: 14px; line-height: 1.5; }
.ex-sentence .blank { display: inline-block; min-width: 3ch; border-bottom: 3px solid var(--primary); color: var(--primary); padding: 0 6px; }
.ex-sentence .blank.filled { border-bottom-color: transparent; background: var(--primary-soft); border-radius: 8px; }
.ex-trans { text-align: center; color: var(--muted); font-size: 14px; margin-top: -6px; margin-bottom: 14px; }
.options { display: grid; gap: 10px; }
.opt { text-align: start; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; font-size: 17px; transition: all .15s; display: flex; align-items: center; gap: 10px; }
.opt.it { direction: ltr; text-align: left; }
.opt:hover { border-color: var(--primary); }
.opt.selected { border-color: var(--primary); background: var(--primary-soft); }
.opt.correct { border-color: var(--success); background: var(--success-soft); }
.opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.opt .key { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: 13px; color: var(--muted); flex: 0 0 auto; font-family: var(--font-it); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; direction: ltr; }
.chip { padding: 10px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-family: var(--font-it); font-weight: 800; font-size: 17px; transition: all .15s; }
.chip:hover { border-color: var(--primary); transform: translateY(-1px); }
.chip.used { opacity: .3; pointer-events: none; }
.chip.selected { border-color: var(--primary); background: var(--primary-soft); }
.chip.correct { border-color: var(--success); background: var(--success-soft); }
.chip.wrong { border-color: var(--danger); background: var(--danger-soft); }
.builder { min-height: 64px; display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-radius: 14px; border: 2px dashed var(--line); direction: ltr; margin-bottom: 14px; align-items: center; }
.builder:empty::before { content: attr(data-ph); color: var(--muted); font-size: 14px; font-family: var(--font-fa); direction: rtl; width: 100%; text-align: center; }
.builder .chip { border-style: solid; background: var(--primary-soft); border-color: var(--primary); }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: grid; gap: 10px; align-content: start; }
.mt { padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; font-size: 16px; min-height: 52px; transition: all .15s; text-align: center; }
.mt.it { direction: ltr; }
.mt.selected { border-color: var(--primary); background: var(--primary-soft); }
.mt.matched { border-color: var(--success); background: var(--success-soft); opacity: .7; pointer-events: none; }
.mt.wrong { border-color: var(--danger); background: var(--danger-soft); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.listen-btn { width: 96px; height: 96px; border-radius: 50%; background: var(--primary); color: var(--primary-fg); border: none; display: grid; place-items: center; margin: 6px auto 18px; box-shadow: 0 10px 28px color-mix(in srgb, var(--primary) 40%, transparent); transition: transform .15s; }
.listen-btn:hover { transform: scale(1.04); }
.listen-btn svg { width: 40px; height: 40px; }
.listen-btn.slow { width: 44px; height: 44px; margin: 0; box-shadow: none; background: var(--surface-2); color: var(--fg); }
.listen-btn.slow svg { width: 20px; height: 20px; }
.speak-box { text-align: center; }
.speak-box .say { font-size: 26px; display: block; text-align: center; margin-bottom: 6px; }
.speak-box .fa { color: var(--muted); }
.mic-btn { width: 84px; height: 84px; border-radius: 50%; border: none; background: var(--danger); color: #fff; display: grid; place-items: center; margin: 16px auto 8px; box-shadow: 0 10px 28px color-mix(in srgb, var(--danger) 40%, transparent); }
.mic-btn.rec { animation: pulse 1s infinite; }
.mic-btn svg { width: 36px; height: 36px; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.heard { font-family: var(--font-it); direction: ltr; font-weight: 700; padding: 10px 14px; background: var(--surface-2); border-radius: 12px; margin-top: 10px; min-height: 44px; }
.ex-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 14px; display: flex; gap: 12px; align-items: flex-start; animation: ex-in .3s ease; }
.feedback.ok { background: var(--success-soft); color: var(--success); }
.feedback.bad { background: var(--danger-soft); color: var(--danger); }
.feedback .ic { font-size: 24px; line-height: 1; }
.feedback b { display: block; margin-bottom: 2px; }
.feedback p { color: var(--fg); font-size: 14px; }
.feedback .ans { font-family: var(--font-it); direction: ltr; display: inline-block; font-weight: 800; color: var(--fg); }
.result-card { text-align: center; padding: 32px 22px; }
.result-card .score { font-size: 64px; font-weight: 800; line-height: 1; color: var(--primary); font-family: var(--font-it); }
.result-card h2 { font-size: 24px; font-weight: 800; margin-top: 10px; }
.result-card p { color: var(--muted); margin-top: 6px; }
.result-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }

/* ---------- Review ---------- */
.due-pill { font-size: 40px; font-weight: 800; color: var(--primary); font-family: var(--font-it); }

/* ---------- Register ---------- */
.auth { max-width: 460px; margin: 0 auto; }
.auth .card { padding: 26px; }
.auth h1 { font-size: 26px; font-weight: 800; }
.auth .sub { color: var(--muted); margin: 6px 0 18px; }
.auth form { display: grid; gap: 14px; }
.user-pick { display: grid; gap: 8px; }
.user-pick button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: start; }
.user-pick button:hover { background: var(--surface-2); }

/* ---------- Profile ---------- */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: none; }
.setting .lbl b { display: block; font-weight: 700; }
.setting .lbl span { font-size: 13px; color: var(--muted); }
textarea.input { min-height: 120px; direction: ltr; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---------- Guide ---------- */
.timeline { display: grid; gap: 10px; }
.tl { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 12px 14px; }
.tl .when { font-weight: 800; color: var(--primary); }
.prose p { margin-bottom: 10px; }
.prose ul { margin: 0 0 10px; padding-inline-start: 20px; }

/* ---------- Confetti canvas ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* ---------- Session overlay ---------- */
.session-done { position: fixed; inset: 0; z-index: 65; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; }
.session-done .card { max-width: 420px; text-align: center; padding: 30px; }
.session-done .big { font-size: 56px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 48px; margin-bottom: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .conj-row, .gtable tr { opacity: 1; transform: none; }
}
