:root {
  --bg: #f8f4ee;
  --card: #ffffff;
  --ink: #1f1a15;
  --muted: #6c6358;
  --line: #e7ded2;
  --soft: #f1ebe2;
  --accent: #b0102b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe7ea;
  --ok: #1f8a4c;
  --ok-soft: #e3f4ea;
  --bad: #c0392b;
  --bad-soft: #fbe4e1;
  --g-vowel: #2f6fd6;
  --g-easy: #6c6358;
  --g-asp: #c77700;
  --g-ej: #b0102b;
  --g-new: #7b3fc4;
  --shadow: 0 1px 2px rgba(40, 25, 10, .06), 0 4px 14px rgba(40, 25, 10, .06);
  --radius: 14px;
  --ka: "Noto Sans Georgian", system-ui, sans-serif;
  --ka-serif: "Noto Serif Georgian", "Noto Sans Georgian", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15120f; --card: #201c18; --ink: #f2ece4; --muted: #a89e92; --line: #352f29; --soft: #2a251f;
    --accent: #ff5c72; --accent-ink: #1a0a0d; --accent-soft: #3a1c22; --ok: #4cc27f; --ok-soft: #173426;
    --bad: #ff7466; --bad-soft: #3d1d1a; --g-vowel: #6ea2ff; --g-easy: #b5aa9c; --g-asp: #f0a53a; --g-ej: #ff5c72; --g-new: #b98cff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15120f; --card: #201c18; --ink: #f2ece4; --muted: #a89e92; --line: #352f29; --soft: #2a251f;
  --accent: #ff5c72; --accent-ink: #1a0a0d; --accent-soft: #3a1c22; --ok: #4cc27f; --ok-soft: #173426;
  --bad: #ff7466; --bad-soft: #3d1d1a; --g-vowel: #6ea2ff; --g-easy: #b5aa9c; --g-asp: #f0a53a; --g-ej: #ff5c72; --g-new: #b98cff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Georgian", sans-serif;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin-top: 2rem; }
h3 { font-size: 1.05rem; margin-top: 1.4rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.ka { font-family: var(--ka); }

/* header */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-ka { font-family: var(--ka-serif); font-weight: 700; font-size: 1.3rem; color: var(--accent); }
.brand-ru { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abc-btn {
  font-family: var(--ka); border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; font-weight: 600; flex: none;
}
.abc-btn:hover { border-color: var(--accent); }

main { max-width: 980px; margin: 0 auto; padding: 20px 16px 80px; }
.loading { color: var(--muted); }
.crumbs { margin-bottom: 14px; font-size: .92rem; }
.crumbs a { text-decoration: none; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 46em; }

/* playable Georgian */
.say {
  font-family: var(--ka); background: none; border: 0; padding: 0 1px; margin: 0; cursor: pointer;
  color: inherit; border-bottom: 1.5px dotted var(--accent); line-height: inherit; font-size: inherit;
}
.say:hover, .say.playing { color: var(--accent); }
.say:focus-visible, .btn:focus-visible, .tile:focus-visible, .opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* cards and buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 500;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 5px 12px; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

/* home */
.hero { padding: 18px 0 6px; }
.hero h1 span { color: var(--accent); font-family: var(--ka-serif); }
.steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.step { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); transition: transform .12s, border-color .12s; }
.step:hover { transform: translateY(-2px); border-color: var(--accent); }
.step .big { font-family: var(--ka-serif); font-size: 1.6rem; font-weight: 700; color: var(--accent); line-height: 1.2; overflow-wrap: anywhere; }
.step .t { font-weight: 600; }
.step .s { color: var(--muted); font-size: .9rem; }
.prog { height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; margin-top: auto; }
.prog i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.note { font-size: .88rem; color: var(--muted); margin-top: 40px; border-top: 1px solid var(--line); padding-top: 14px; }

/* tiles (words) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tiles.wide { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.tile {
  text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.tile:hover, .tile.playing { border-color: var(--accent); }
.tile .k { font-family: var(--ka); font-size: 1.2rem; font-weight: 600; overflow-wrap: break-word; }
.tile.playing .k { color: var(--accent); }
.tile.long .k { font-size: 1.02rem; }
.tile.xlong .k { font-size: .9rem; }
.tile .r { color: var(--muted); font-size: .93rem; }
.tile .n { font-size: .82rem; color: var(--muted); border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 5px; }
.tile .sw { width: 100%; height: 22px; border-radius: 6px; border: 1px solid var(--line); margin-bottom: 6px; }
.tile.learned { box-shadow: inset 3px 0 0 var(--ok); }
.hide-ru .tile:not(.show) .r, .hide-ru .tile:not(.show) .n, .hide-ru .line:not(.show) .lru { filter: blur(6px); opacity: .6; }
.group-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: .93rem; color: var(--muted); }

/* dialogs */
.dialog { margin-top: 12px; }
.dhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.dhead h3 { margin: 0; }
.line { display: flex; flex-direction: column; align-items: flex-start; margin: 8px 0; max-width: 80%; }
.line.m { margin-left: auto; align-items: flex-end; }
.bubble {
  font-family: var(--ka); font-size: 1.12rem; text-align: left; border: 1px solid var(--line); background: var(--soft);
  border-radius: 16px 16px 16px 4px; padding: 8px 14px; cursor: pointer;
}
.line.m .bubble { border-radius: 16px 16px 4px 16px; background: var(--accent-soft); }
.bubble.playing { border-color: var(--accent); }
.lru { font-size: .88rem; color: var(--muted); margin-top: 3px; padding: 0 6px; }

/* alphabet */
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 10px 0 16px; font-size: .9rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.abc { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.letter {
  aspect-ratio: 1 / 1.05; border: 1px solid var(--line); background: var(--card); border-radius: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px;
  border-top: 4px solid var(--gc, var(--line));
}
.letter b { font-family: var(--ka-serif); font-size: 2rem; line-height: 1.1; font-weight: 500; }
.letter small { color: var(--muted); font-size: .76rem; text-align: center; line-height: 1.2; }
.letter.sel, .letter:hover { border-color: var(--gc); background: var(--soft); }
.g-vowel { --gc: var(--g-vowel); } .g-easy { --gc: var(--g-easy); } .g-asp { --gc: var(--g-asp); } .g-ej { --gc: var(--g-ej); } .g-new { --gc: var(--g-new); }
#detail { position: sticky; top: 58px; z-index: 5; }
.detail { display: grid; grid-template-columns: auto 1fr; gap: 6px 22px; align-items: center; margin-bottom: 16px; border-left: 5px solid var(--gc); }
.detail .bigl { font-family: var(--ka-serif); font-size: 4.6rem; line-height: 1; grid-row: span 3; cursor: pointer; background: none; border: 0; padding: 0 6px; color: var(--ink); }
.detail .bigl:hover { color: var(--accent); }
.detail .snd { font-size: 1.25rem; font-weight: 600; }
.detail .ipa { color: var(--muted); font-weight: 400; font-size: 1rem; margin-left: 6px; }
.detail .grp { font-size: .85rem; color: var(--gc); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.detail .ex { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; border-top: 1px solid var(--line); padding-top: 8px; }
.detail .ex .say { font-size: 1.3rem; }
.mtav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.mtav .card { padding: 10px 14px; }
.mtav .m { font-family: var(--ka); font-size: 1.3rem; font-weight: 700; letter-spacing: .04em; }
.reveal .r { visibility: hidden; }
.reveal .tile.show .r { visibility: visible; }

/* sounds */
.triads { border-collapse: separate; border-spacing: 6px; margin: 6px -6px; }
.triads th { font-size: .82rem; font-weight: 600; color: var(--muted); text-align: center; padding: 0 4px; }
.triads td { text-align: center; }
.triads .say { font-family: var(--ka-serif); font-size: 1.9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); width: 64px; height: 56px; }
.triads .c1 .say { border-bottom: 3px solid var(--g-easy); } .triads .c2 .say { border-bottom: 3px solid var(--g-asp); } .triads .c3 .say { border-bottom: 3px solid var(--g-ej); }
.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.howto h3 { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.chips .say { font-size: 1.15rem; }
.chips .cr { color: var(--muted); font-size: .88rem; margin-left: 4px; }
.pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.pair .pt { font-family: var(--ka); font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.pair .pw { display: flex; flex-direction: column; gap: 4px; }
.pair .pw button { display: flex; align-items: baseline; gap: 10px; text-align: left; border: 0; background: var(--soft); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.pair .pw button:hover, .pair .pw button.playing { background: var(--accent-soft); }
.pair .pw .k { font-family: var(--ka); font-size: 1.3rem; font-weight: 600; }
.pair .pw .r { color: var(--muted); font-size: .9rem; }

/* articles */
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; }
.toc button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: .88rem; }
.toc button:hover { border-color: var(--accent); }
.art section { margin-top: 16px; scroll-margin-top: 70px; }
.art h2 { margin-top: 0; font-size: 1.25rem; }
.art p { max-width: 46em; }
.exl { display: grid; gap: 4px; margin: 6px 0 14px; }
.exl div { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; padding: 6px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.exl .say { font-size: 1.15rem; }
.exl .er { color: var(--muted); }
.tbl-wrap { overflow-x: auto; margin: 6px 0 14px; }
table.t { border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
table.t th, table.t td { padding: 7px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: baseline; }
table.t th { font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--soft); }
table.t td .say, table.t td .ka { font-size: 1.12rem; }
table.t tr:last-child td { border-bottom: 0; }
.tip { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin: 6px 0 14px; max-width: 46em; }

/* quiz & cards */
.quiz { max-width: 640px; margin: 0 auto; }
.qtop { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.qtop .x { text-decoration: none; color: var(--muted); font-size: 1.2rem; }
.qtop .prog { flex: 1; height: 8px; margin: 0; }
.qtop .cnt { color: var(--muted); font-size: .9rem; min-width: 3.5em; text-align: right; }
.qtitle { text-align: center; color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.qprompt { min-height: 130px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; margin-bottom: 18px; }
.qprompt .ka-big { font-family: var(--ka); font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 600; overflow-wrap: anywhere; }
.qprompt .letter-big { font-family: var(--ka-serif); font-size: 5rem; line-height: 1; }
.qprompt .ru-big { font-size: 1.6rem; font-weight: 600; }
.play-big {
  width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  font-size: 2.2rem; cursor: pointer; box-shadow: var(--shadow); display: grid; place-items: center;
}
.play-big:active { transform: scale(.96); }
.opts { display: grid; gap: 8px; }
.opt {
  text-align: left; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px;
  cursor: pointer; display: flex; gap: 12px; align-items: baseline; font-size: 1.05rem;
}
.opt .kb { color: var(--muted); font-size: .8rem; border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; flex: none; }
.opt .ka { font-size: 1.25rem; }
.opt:hover:not([disabled]) { border-color: var(--accent); }
.opt[disabled] { cursor: default; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { min-height: 64px; margin: 14px 0 6px; text-align: center; }
.feedback .fk { font-family: var(--ka); font-size: 1.3rem; }
.feedback .ok { color: var(--ok); font-weight: 600; }
.feedback .no { color: var(--bad); font-weight: 600; }
.qnext { display: flex; justify-content: center; }
.done { text-align: center; }
.done .score { font-size: 3rem; font-weight: 700; color: var(--accent); }
.mist { text-align: left; margin: 18px 0; }
.flash {
  min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; cursor: pointer; margin-bottom: 16px;
}
.flash .ka-big { font-family: var(--ka); font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 600; }
.flash .back { color: var(--muted); font-size: 1.2rem; }
.flash .back .n { font-size: .9rem; margin-top: 6px; }
.flash-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.flash-btns .btn { justify-content: center; padding: 12px; }
.hint { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 12px; }

/* numbers trainer */
.trainer { display: grid; gap: 12px; justify-items: center; text-align: center; }
.trainer input {
  font: inherit; font-size: 1.6rem; width: 9ch; text-align: center; padding: 8px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
}
.trainer input:focus { outline: none; border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 6px 14px; cursor: pointer; font-size: .9rem; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.numgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; margin-top: 10px; }
.numgrid button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 0; cursor: pointer; font-variant-numeric: tabular-nums; }
.numgrid button.playing, .numgrid button:hover { border-color: var(--accent); color: var(--accent); }
details summary { cursor: pointer; color: var(--accent); margin-top: 10px; }

/* alphabet sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-card { background: var(--bg); width: min(720px, 100%); max-height: 80vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 14px 16px 22px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.x { border: 0; background: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
.abc-mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.abc-mini button { border: 1px solid var(--line); border-top: 3px solid var(--gc); background: var(--card); border-radius: 8px; padding: 4px 2px; cursor: pointer; }
.abc-mini b { display: block; font-family: var(--ka-serif); font-size: 1.5rem; font-weight: 500; line-height: 1.2; }
.abc-mini small { color: var(--muted); font-size: .72rem; }

@media (max-width: 560px) {
  .brand-ru { display: none; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .tile { padding: 9px 10px; }
  .tile .k { font-size: 1.05rem; }
  .tile.long .k { font-size: .95rem; }
  .tile.xlong .k { font-size: .84rem; }
  .line { max-width: 92%; }
  .detail .bigl { font-size: 3.6rem; }
  .triads .say { width: 54px; height: 50px; font-size: 1.6rem; }
}
