:root {
  --bg: #f7f3e8;
  --bg-deep: #efe9d9;
  --card: #fffdf8;
  --ink: #1c2821;
  --muted: #66736a;
  --faint: #8b968d;
  --line: #ded7c7;
  --line-strong: #c9c0ac;
  --accent: #1f6f54;
  --accent-strong: #15523e;
  --accent-ink: #ffffff;
  --accent-soft: #e1efe7;
  --accent-soft-2: #eef7f1;
  --record: #c4462f;
  --record-strong: #a63622;
  --record-soft: #f7e4df;
  --warm: #c78a2a;
  --warm-soft: #f7ecd5;
  --success: #1f7a4d;
  --success-soft: #e2f2e8;
  --danger: #a33a2f;
  --danger-soft: #f8e5e1;
  --shadow: 0 22px 60px rgba(38, 44, 35, 0.10);
  --shadow-soft: 0 8px 24px rgba(38, 44, 35, 0.07);
  --radius: 24px;
  --radius-sm: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-ar: "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, "Geeza Pro", "Arabic Typesetting", sans-serif;
  --font-latin: "Noto Sans", "DejaVu Sans", "Segoe UI", "Arial Unicode MS", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101713;
    --bg-deep: #0b110e;
    --card: #18211c;
    --ink: #edf3ed;
    --muted: #a7b3a9;
    --faint: #7f8d83;
    --line: #2d3a32;
    --line-strong: #405146;
    --accent: #78d0ab;
    --accent-strong: #9fe3c3;
    --accent-ink: #0c1d15;
    --accent-soft: #20352a;
    --accent-soft-2: #1a2a21;
    --record: #f07e66;
    --record-strong: #ff9a84;
    --record-soft: #3a211c;
    --warm: #e4b562;
    --warm-soft: #352b1a;
    --success: #8de0b4;
    --success-soft: #1d3327;
    --danger: #f09282;
    --danger-soft: #3a211d;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  color-scheme: light dark;
  height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1000px 600px at 8% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, var(--warm-soft), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[dir="rtl"] body,
body[dir="rtl"] { font-family: var(--font-ar); }

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { letter-spacing: -0.035em; line-height: 1.12; }
h2 { letter-spacing: -0.02em; }
::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 65%, transparent);
  outline-offset: 3px;
}

.site { min-height: 100vh; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.latin {
  font-family: var(--font-latin);
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

/* ---------------------------------------------------------- language gate */

.language-screen {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px 20px;
  overflow: hidden;
  isolation: isolate;
}

.language-orb {
  position: absolute;
  z-index: -1;
  width: 42vw;
  height: 42vw;
  min-width: 320px;
  min-height: 320px;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.7;
}

.language-orb-a {
  top: -16vw;
  left: -10vw;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 68%);
}

.language-orb-b {
  right: -12vw;
  bottom: -18vw;
  background: radial-gradient(circle, var(--warm-soft) 0%, transparent 70%);
}

.language-inner {
  width: min(860px, 100%);
  text-align: center;
  animation: rise 0.55s ease both;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 28%, transparent);
}

.brand-mark-xl {
  width: 74px;
  height: 74px;
  margin-bottom: 18px;
  border-radius: 24px;
  font-size: 2.1rem;
  box-shadow: 0 18px 40px color-mix(in srgb, var(--accent) 30%, transparent);
}

.language-inner .eyebrow {
  margin-bottom: 14px;
}

.language-inner h1 {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 auto 18px;
  font-size: clamp(2rem, 5vw, 3.6rem);
  max-width: 18ch;
}

.title-ar {
  font-family: var(--font-ar);
  font-size: 0.78em;
  font-weight: 750;
  letter-spacing: 0;
}

.language-sub {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 620px;
  margin: 0 auto 34px;
  color: var(--muted);
  font-size: clamp(0.98rem, 2vw, 1.12rem);
}

.sub-ar {
  font-family: var(--font-ar);
}

.language-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  max-width: 700px;
  margin: 0 auto;
}

.language-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 190px;
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.language-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow);
}

.language-card:active { transform: translateY(-1px); }

.language-glyph {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 1.65rem;
  font-weight: 800;
}

.language-card:first-child .language-glyph {
  font-family: var(--font-ar);
  font-size: 1.9rem;
}

.language-name { font-size: 1.35rem; font-weight: 800; }
.language-note { color: var(--muted); font-size: 0.92rem; }

.language-help {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 28px auto 0;
  color: var(--faint);
  font-size: 0.86rem;
}

/* ------------------------------------------------------------------- app */

.app-screen {
  min-height: 100vh;
  animation: fade 0.4s ease both;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 10px max(18px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.98rem;
  white-space: nowrap;
}

.brand-text strong { color: var(--accent); font-weight: 800; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 14px;
  background: transparent;
  color: var(--ink);
  font-weight: 650;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--accent-soft-2);
}

.ghost:disabled { opacity: 0.45; }

.topbar-guide { font-size: 0.88rem; }

.lang-toggle {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-deep);
}

.lang-toggle button {
  min-width: 38px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  font-size: 0.86rem;
}

.lang-toggle button[aria-pressed="true"] {
  background: var(--card);
  color: var(--accent-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 38px 22px 26px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}

.hero-copy { max-width: 760px; }

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.9rem, 4.2vw, 3.15rem);
  max-width: 20ch;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.12rem);
  max-width: 62ch;
}

.hero-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 85%, transparent);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
  white-space: nowrap;
}

.meta-icon { flex: 0 0 auto; }

.meta-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.record-card {
  position: relative;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent-soft-2) 55%, transparent), transparent 220px),
    var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.record-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--warm), var(--record));
  opacity: 0.75;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.card-head h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.6rem);
}

.community-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
  border-radius: 999px;
  background: var(--accent-soft-2);
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.community-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

/* --------------------------------------------------------------- states */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 260px;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent-soft-2) 45%, transparent);
  text-align: center;
}

.state p { margin: 0; color: var(--muted); }

.loading-state { border-style: solid; }
.loading-state p { font-weight: 600; }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.error-state { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--danger-soft); }
.error-state p { color: var(--danger); font-weight: 650; }

.empty-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  font-size: 1.55rem;
  font-weight: 800;
}

.empty-state h3 { margin: 0; font-size: 1.15rem; }
.empty-state p { max-width: 42ch; }

/* --------------------------------------------------------------- example */

.example-card {
  position: relative;
  padding: 28px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  border-radius: 20px;
  background:
    radial-gradient(600px 220px at 50% -40%, var(--accent-soft), transparent 70%),
    color-mix(in srgb, var(--card) 72%, var(--accent-soft-2));
  animation: rise 0.28s ease both;
}

.example-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 14px;
}

.headword {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 100%;
  padding: 4px 12px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-latin);
  direction: ltr;
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.example-sep { color: var(--faint); }

.gloss {
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 600;
}

.example-text {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: clamp(1.75rem, 4.6vw, 3rem);
  font-weight: 650;
  line-height: 1.28;
  letter-spacing: 0.005em;
  overflow-wrap: anywhere;
}

.example-text:empty::after {
  content: "—";
  color: var(--faint);
}

.example-translation {
  display: inline-block;
  margin: 0 0 18px;
  padding: 8px 12px;
  border-inline-start: 3px solid var(--warm);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--warm-soft) 55%, transparent);
  color: var(--muted);
  font-size: 0.98rem;
}

[dir="rtl"] .example-translation {
  border-radius: 8px 0 0 8px;
}

.letter-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.letter-hint {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 80%, transparent);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
}

.letter-hint b {
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.9rem;
}

.letter-hint.more {
  border-style: dashed;
  background: transparent;
  color: var(--accent);
}

/* --------------------------------------------------------------- recorder */

.recorder {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.record-main {
  display: flex;
  align-items: center;
  gap: 20px;
}

.record-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 210px;
  min-height: 72px;
  padding: 12px 26px;
  border: 0;
  border-radius: 999px;
  background: var(--record);
  color: #fff;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 12px 26px color-mix(in srgb, var(--record) 30%, transparent);
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

[dir="rtl"] .record-btn { font-family: var(--font-ar); }

.record-btn:hover:not(:disabled) {
  background: var(--record-strong);
  transform: translateY(-2px);
  box-shadow: 0 16px 32px color-mix(in srgb, var(--record) 34%, transparent);
}

.record-btn:active:not(:disabled) { transform: translateY(0); }
.record-btn:disabled { opacity: 0.45; box-shadow: none; }

.record-btn .stop-square { display: none; width: 22px; height: 22px; border-radius: 5px; background: currentColor; }
.record-btn.recording .icon-mic { display: none; }
.record-btn.recording .stop-square { display: block; }

.record-btn.recording {
  background: var(--record-strong);
  animation: pulse 1.7s ease-in-out infinite;
}

.record-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.record-copy strong {
  font-size: 1rem;
  line-height: 1.25;
}

.record-copy strong.error { color: var(--danger); }

.timer-line {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

#record-timer { color: var(--ink); font-weight: 700; }
.timer-limit { color: var(--faint); }

.level {
  height: 8px;
  margin-top: 16px;
  border-radius: 999px;
  background: var(--bg-deep);
  overflow: hidden;
}

.level span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--warm), var(--record));
  transition: width 70ms linear;
}

.take {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 65%, var(--accent-soft-2));
  animation: rise 0.22s ease both;
}

.play-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
}

.play-btn:hover { background: var(--accent-strong); }
.play-btn .icon-pause { display: none; }
.play-btn.playing .icon-play { display: none; }
.play-btn.playing .icon-pause { display: block; }

.take-progress {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--bg-deep);
  overflow: hidden;
}

.take-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 80ms linear;
}

.take-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
}

.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }

.discard-btn { flex: 0 0 auto; }

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 24px;
  border: 0;
  border-radius: 13px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--accent) 24%, transparent);
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.primary:hover:not(:disabled) { background: var(--accent-strong); transform: translateY(-1px); }
.primary:disabled { opacity: 0.42; box-shadow: none; }
.primary .spinner { width: 18px; height: 18px; border-width: 2px; border-top-color: currentColor; border-color: color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; }

.save-btn { flex: 1; max-width: 330px; }
.skip-btn { color: var(--muted); }
[dir="rtl"] .primary,
[dir="rtl"] .ghost { font-family: var(--font-ar); }

.save-status {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.save-status.success { color: var(--success); }
.save-status.error { color: var(--danger); }
.save-status.saving { color: var(--accent); }

.fineprint {
  margin: 12px 0 0;
  color: var(--faint);
  font-size: 0.78rem;
}

.tips {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--warm-soft) 50%, transparent);
}

.tips p {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.tip-icon { flex: 0 0 auto; width: 15px; height: 15px; margin-top: 2px; }

/* ---------------------------------------------------------------- sidebar */

.side {
  display: grid;
  gap: 16px;
}

.side-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  box-shadow: var(--shadow-soft);
}

.side-card h2 {
  margin: 0 0 12px;
  font-size: 0.98rem;
}

.how-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.how-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.how-num {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.side-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 750;
}

.name-card input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.name-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.side-hint {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 0.76rem;
  line-height: 1.4;
}

.session-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.session-grid div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-radius: 12px;
  background: var(--accent-soft-2);
}

.session-grid strong {
  color: var(--accent-strong);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.session-grid span {
  color: var(--muted);
  font-size: 0.76rem;
}

.help-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 750;
  font-size: 0.86rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.76rem;
}

.footer p { margin: 0; }
.footer-source { white-space: nowrap; }

/* ----------------------------------------------------------------- dialog */

.guide-dialog {
  width: min(900px, calc(100vw - 28px));
  max-height: min(92vh, 920px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.guide-dialog::backdrop {
  background: rgba(10, 18, 14, 0.55);
  backdrop-filter: blur(4px);
}

.guide-dialog[open] { animation: rise 0.24s ease both; }

.guide-inner {
  max-height: min(92vh, 920px);
  padding: 30px 34px 34px;
  overflow-y: auto;
}

.guide-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.guide-head h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3.4vw, 2.3rem);
}

.guide-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 1.4rem;
}

.guide-close:hover { background: var(--danger-soft); }

.guide-intro {
  max-width: 70ch;
  margin: 14px 0 20px;
  color: var(--muted);
  font-size: 0.98rem;
}

.alphabet-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 28px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  font-family: var(--font-latin);
  direction: ltr;
  justify-content: center;
}

.alphabet-strip span {
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 36px;
  padding: 0 4px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 650;
}

.alphabet-strip span.special {
  background: var(--warm-soft);
  color: var(--warm);
  font-weight: 850;
}

.alphabet-strip span.loan {
  border: 1px dashed var(--line-strong);
  opacity: 0.62;
}

.guide-section { margin-top: 26px; }

.guide-section h2 {
  margin: 0 0 12px;
  font-size: 1.02rem;
}

.alpha-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.alpha-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--bg) 52%, transparent);
}

.alpha-letter {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-latin);
  font-size: 1.4rem;
  font-weight: 850;
}

.alpha-body { min-width: 0; }

.alpha-sound {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.35;
}

.alpha-example {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.alpha-example b {
  color: var(--accent-strong);
  font-family: var(--font-latin);
  font-size: 0.92rem;
  direction: ltr;
}

.alpha-grid-vowels .alpha-card { align-items: center; }

.guide-text {
  max-width: 72ch;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.guide-text-small {
  margin-top: 10px;
  font-size: 0.8rem;
}

.easy-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  direction: ltr;
}

.easy-chips span {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font-latin);
  font-size: 0.92rem;
  font-weight: 650;
}

.guide-note {
  margin: 26px 0 0;
  padding: 14px 16px;
  border-inline-start: 3px solid var(--warm);
  border-radius: 0 10px 10px 0;
  background: var(--warm-soft);
  color: var(--muted);
  font-size: 0.86rem;
}

[dir="rtl"] .guide-note { border-radius: 10px 0 0 10px; }

.guide-actions {
  position: sticky;
  bottom: -34px;
  display: flex;
  justify-content: flex-end;
  margin: 26px -34px -34px;
  padding: 16px 34px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(8px);
}

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  z-index: 60;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 650;
  text-align: center;
  animation: toast-in 0.2s ease both;
}

.toast.error { background: var(--danger); color: #fff; border-color: transparent; }
.toast.success { background: var(--success); color: #fff; border-color: transparent; }

body.guide-open { overflow: hidden; }

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 70;
  padding: 16px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  text-align: center;
  font-weight: 650;
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 920px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { align-items: flex-start; }
}

@media (max-width: 680px) {
  .language-choices { grid-template-columns: 1fr; }
  .language-card { min-height: 148px; padding: 20px; }
  .language-inner h1 { font-size: clamp(1.75rem, 8vw, 2.6rem); }
  .topbar { padding-inline: 14px; }
  .brand-text { display: none; }
  .main { padding: 26px 14px 20px; }
  .hero { display: block; margin-bottom: 20px; }
  .hero-meta { flex-direction: row; flex-wrap: wrap; align-items: center; margin-top: 16px; }
  .record-card { padding: 18px; border-radius: 20px; }
  .card-head { display: block; }
  .community-pill { margin-top: 10px; }
  .example-card { padding: 20px; }
  .example-text { font-size: clamp(1.55rem, 7.5vw, 2.25rem); }
  .record-main { flex-direction: column; align-items: stretch; gap: 14px; }
  .record-btn { width: 100%; min-height: 76px; }
  .record-copy { align-items: center; }
  .actions { flex-direction: column; align-items: stretch; }
  .save-btn { max-width: none; width: 100%; }
  .skip-btn { width: 100%; }
  .side { grid-template-columns: 1fr; }
  .footer { display: block; }
  .footer-source { margin-top: 6px; }
  .guide-inner { padding: 22px 18px 26px; }
  .guide-actions { bottom: -26px; margin: 22px -18px -26px; padding: 13px 18px; }
  .guide-actions .primary { width: 100%; }
  .alpha-grid { grid-template-columns: 1fr; }
  .toast { bottom: 14px; }
}

@media (max-width: 420px) {
  .topbar-guide { padding: 8px 10px; font-size: 0.8rem; }
  .lang-toggle button { min-width: 32px; }
  .example-head { gap: 6px; }
  .headword { font-size: 0.98rem; }
  .take { gap: 8px; padding: 8px; }
  .take-time { font-size: 0.72rem; }
}

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

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--record) 35%, transparent), 0 12px 26px color-mix(in srgb, var(--record) 30%, transparent); }
  50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--record) 0%, transparent), 0 12px 26px color-mix(in srgb, var(--record) 30%, transparent); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
