/* Mobile-first styles. Desktop just centres a phone-width column. */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --ink: #1b1d24;
  --muted: #6b6f7b;
  --line: #e2e0d9;
  --accent: #2f5fd0;
  --accent-ink: #ffffff;
  --accent-soft: #e5ecfb;
  --good: #1f9254;
  --good-soft: #e1f4e8;
  --bad: #d1373f;
  --bad-soft: #fde6e6;
  --gold: #e6a700;
  --flame: #f06a24;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 22, 30, .06), 0 4px 14px rgba(20, 22, 30, .06);
  --tabbar-h: 64px;
  --topbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c;
    --surface: #1d2029;
    --surface-2: #272a35;
    --ink: #eef0f5;
    --muted: #9aa0ae;
    --line: #2f3340;
    --accent: #7c9cff;
    --accent-ink: #0d1020;
    --accent-soft: #252e4d;
    --good: #45c27d;
    --good-soft: #17352a;
    --bad: #ff6b6f;
    --bad-soft: #3d1f24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

/* Same dark values for an explicit dark choice. */
:root[data-theme="dark"] {
  --bg: #14161c;
  --surface: #1d2029;
  --surface-2: #272a35;
  --ink: #eef0f5;
  --muted: #9aa0ae;
  --line: #2f3340;
  --accent: #7c9cff;
  --accent-ink: #0d1020;
  --accent-soft: #252e4d;
  --good: #45c27d;
  --good-soft: #17352a;
  --bad: #ff6b6f;
  --bad-soft: #3d1f24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.icon { display: inline-flex; width: 24px; height: 24px; flex: none; }
.icon svg { width: 100%; height: 100%; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; justify-content: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row.gap { gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

[lang="ru"] { font-feature-settings: "kern"; }

/* Stress accent drawn above the vowel (see ui.js ru()). */
.st { position: relative; }
.st::after {
  content: "";
  position: absolute;
  left: 50%;
  top: .12em;
  width: .085em;
  min-width: 1.5px;
  height: .26em;
  border-radius: 1px;
  background: currentColor;
  transform: translateX(-10%) skewX(-38deg);
  pointer-events: none;
}
.st.up::after { top: -.12em; }

/* ---------- Shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) 12px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar h1 {
  font-size: 1.15rem;
  font-weight: 700;
  padding-left: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 16px calc(var(--tabbar-h) + var(--safe-b) + 24px);
  outline: none;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
}
.tabbar a.active { color: var(--accent); }
.tabbar a .icon { width: 26px; height: 26px; }

body.in-session .tabbar,
body.in-session .topbar { display: none; }
body.in-session main { padding: 0; max-width: 640px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------- Common pieces ---------- */

.page { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.lead { color: var(--muted); }
.section-title { font-size: 1.05rem; margin-top: 12px; }

.card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
a.card:active { transform: scale(.985); }
.card h3 { font-size: 1.05rem; }
.go { color: var(--muted); margin-left: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 20px;
  border: 0;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
}
.btn .icon { width: 20px; height: 20px; }
.btn.block { display: flex; width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 60%, black); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 60%, black); }
.btn.primary:disabled { background: var(--surface-2); color: var(--muted); box-shadow: none; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }

.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--accent); transition: width .35s ease; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { padding: 4px 12px; border-radius: 99px; background: var(--surface-2); font-size: .9rem; font-weight: 600; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

.speak {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.speak .icon { width: 22px; height: 22px; }
.speak.big { width: 72px; height: 72px; }
.speak.big .icon { width: 34px; height: 34px; }
.speak.playing { animation: pulse 1s ease-in-out infinite; }
.speak:active { transform: scale(.94); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); }
  50% { box-shadow: 0 0 0 10px transparent; }
}

.notice {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bad-soft);
  font-size: .9rem;
}
.notice .icon { color: var(--bad); }

.note {
  font-size: .85rem;
  color: var(--muted);
  border-left: 3px solid var(--gold);
  padding-left: 8px;
  margin-top: 4px;
}

.ring { position: relative; width: 48px; height: 48px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring .ring-bg { stroke: var(--surface-2); }
.ring .ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; }

/* ---------- Home ---------- */

.hero { padding: 8px 4px 4px; }
.hero-greet { font-size: 1.05rem; color: var(--muted); font-weight: 600; }
.hero-name { font-size: 1.9rem; line-height: 1.15; }
.stats { display: flex; gap: 10px; margin-top: 16px; }
.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.stat strong { font-size: 1.3rem; line-height: 1.2; }
.stat span:last-child { font-size: .75rem; color: var(--muted); }
.stat .icon { width: 20px; height: 20px; color: var(--muted); }
.icon.flame { color: var(--flame); }
.icon.star { color: var(--gold); }

.card.next { background: var(--accent); color: var(--accent-ink); }
.card.next .muted, .card.next .go { color: inherit; opacity: .85; }
.card.next h3 { font-size: 1.25rem; }
.eyebrow { font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.card.review .icon:first-child { color: var(--accent); }

.path-num {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}
.path-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.path-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }

/* ---------- Alphabet ---------- */

.lesson-body { flex: 1; min-width: 0; }
.lesson-letters { margin-top: 4px; font-weight: 700; letter-spacing: .04em; color: var(--accent); word-spacing: 4px; }

.letter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 400px) { .letter-grid { grid-template-columns: repeat(5, 1fr); } }
.letter-tile {
  --s: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.letter-tile.started {
  border-color: color-mix(in srgb, var(--good) calc(var(--s) * 100%), var(--line));
  background: color-mix(in srgb, var(--good-soft) calc(var(--s) * 100%), var(--surface));
}
.letter-tile:active { transform: scale(.95); }
.lt-letter { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.lt-letter small { font-size: 1.1rem; font-weight: 500; margin-left: 2px; color: var(--muted); }
.lt-label { font-size: .7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 4px; }

.letter-big {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  margin: 0 auto;
  padding: 8px 28px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 5.5rem;
  font-weight: 700;
  line-height: 1.1;
}
.letter-big .lower { font-size: 4rem; font-weight: 500; color: var(--muted); }

.letter-detail { display: flex; flex-direction: column; gap: 14px; text-align: center; }
.sound { font-size: 1.05rem; }
.example {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: left;
}
.example-ru { font-size: 1.5rem; font-weight: 700; }

.tip { flex-direction: column; align-items: stretch; }
.tip h3 { display: flex; align-items: center; gap: 10px; }
.tip-num {
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .9rem;
}
.tip-examples { display: flex; flex-direction: column; gap: 8px; }
.tip-example {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2);
}
.tip-ru { font-size: 1.3rem; font-weight: 700; }

/* ---------- Words & phrases ---------- */

.cat-icon {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 12px; background: var(--surface-2); font-size: 1.5rem;
}

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 12px 14px;
  background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.li-main { flex: 1; min-width: 0; }
.li-ru { font-size: 1.3rem; font-weight: 700; }

.dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--line); }
.dot.seen { background: var(--gold); }
.dot.learned { background: var(--accent); }
.dot.mastered { background: var(--good); }

.phrase { flex-direction: column; align-items: stretch; }
.phrase-head { display: flex; gap: 12px; align-items: flex-start; }
.phrase-head .dot { margin-top: 10px; }
.phrase-ru { font-size: 1.25rem; font-weight: 700; }
.phrase-en { margin-top: 2px; }

.gloss { display: flex; flex-wrap: wrap; gap: 6px; }
.gloss-word {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  text-align: left;
}
.gloss-word .ru { font-weight: 700; }
.gloss-word small { color: var(--muted); font-size: .75rem; }
.gloss-word:active { background: var(--accent-soft); }

/* ---------- Session ---------- */

.session { display: flex; flex-direction: column; min-height: 100dvh; }
.session-top {
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 8px) 12px 8px 6px;
}
.session-bar { flex: 1; height: 12px; }
.session-bar .bar-fill { background: var(--good); }

.session-body { flex: 1; padding: 8px 16px 24px; }
.session-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px calc(14px + var(--safe-b));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.session-foot.feedback { animation: slide-up .2s ease-out; }
.session-foot.good { background: var(--good-soft); border-color: transparent; }
.session-foot.bad { background: var(--bad-soft); border-color: transparent; }
.session-foot.good .btn.primary { background: var(--good); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--good) 60%, black); }
.session-foot.bad .btn.primary { background: var(--bad); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--bad) 60%, black); }
.feedback-head { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; }
.good .feedback-head { color: var(--good); }
.bad .feedback-head { color: var(--bad); }
.feedback-detail { display: flex; flex-direction: column; gap: 4px; }
.fd-row { display: flex; align-items: center; gap: 10px; }
.fd-ru { font-size: 1.3rem; font-weight: 700; }
.fd-letter { font-size: 2rem; font-weight: 700; }

@keyframes slide-up { from { transform: translateY(30%); opacity: 0; } }

.ex { display: flex; flex-direction: column; gap: 16px; animation: fade-in .25s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }
.ex.intro { text-align: center; align-items: center; padding-top: 8px; }
.prompt { font-size: 1.3rem; line-height: 1.3; }
.stage { display: flex; justify-content: center; padding: 12px 0; }
.stage-word { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; text-align: center; }

.letter-prompt { font-size: 6rem; font-weight: 700; line-height: 1; }
.letter-prompt span { font-size: 4.2rem; font-weight: 500; color: var(--muted); margin-left: 12px; }
.big-ru { font-size: 2.6rem; font-weight: 700; line-height: 1.2; }
.phrase-big { font-size: 1.7rem; font-weight: 700; line-height: 1.3; }
.pron { font-size: 1.1rem; color: var(--accent); font-weight: 600; letter-spacing: .02em; }
.translation { font-size: 1.15rem; }

.options { display: grid; grid-template-columns: 1fr; gap: 10px; }
.option {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 60px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 14px;
  background: var(--surface);
  font-size: 1.15rem;
  font-weight: 600;
  text-align: left;
}
.option .ru { font-size: 1.35rem; }
.option.latin { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.1rem; }
.opt-letter { font-size: 1.6rem; }
.opt-key {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none;
  border: 1.5px solid var(--line); border-radius: 8px;
  font-size: .8rem; color: var(--muted); font-family: var(--font);
}
.option:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.option:disabled { cursor: default; opacity: .55; }
.option.correct { opacity: 1; border-color: var(--good); background: var(--good-soft); color: var(--good); }
.option.wrong { opacity: 1; border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
@media (min-width: 420px) { .options:has(.opt-letter) { grid-template-columns: 1fr 1fr; } }

.build-answer {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px;
  min-height: 112px;
  padding: 12px 4px;
  border-bottom: 2px solid var(--line);
  background-image: linear-gradient(transparent 51px, var(--line) 51px, var(--line) 53px, transparent 53px);
  background-size: 100% 56px;
}
.build-answer.correct .tile { border-color: var(--good); color: var(--good); }
.build-answer.wrong .tile { border-color: var(--bad); color: var(--bad); }
.build-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 8px; }
.tile {
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 12px;
  background: var(--surface);
  font-size: 1.15rem;
  font-weight: 600;
}
.tile:active:not(:disabled) { transform: translateY(2px); }

.speak-ex { align-items: center; text-align: center; }
.mic {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 128px; height: 128px; margin-top: 8px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: .85rem;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 60%, black);
}
.mic .icon { width: 40px; height: 40px; }
.mic:active { transform: translateY(3px); box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 60%, black); }
.mic.listening { background: var(--bad); box-shadow: 0 0 0 0 var(--bad); animation: listening 1.2s ease-out infinite; }
.mic:disabled { background: var(--good); box-shadow: none; }
@keyframes listening {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 50%, transparent); }
  100% { box-shadow: 0 0 0 28px transparent; }
}
.speak-result { min-height: 3em; display: flex; flex-direction: column; gap: 4px; }

.finish { align-items: center; text-align: center; padding-top: 10vh; }
.finish-emoji, .empty-emoji { font-size: 4.5rem; }
.finish h2 { font-size: 2rem; }
.finish-stats { display: flex; gap: 10px; width: 100%; margin-top: 12px; }

.empty { align-items: center; text-align: center; padding: 20vh 24px 0; }

/* ---------- Bottom sheet ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(10, 12, 18, 0);
  transition: background .25s;
}
.sheet-backdrop.open { background: rgba(10, 12, 18, .45); }
.sheet {
  position: relative;
  width: 100%; max-width: 560px; max-height: 90dvh; overflow-y: auto;
  padding: 12px 20px calc(24px + var(--safe-b));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  transform: translateY(100%);
  transition: transform .25s ease-out;
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-handle { width: 40px; height: 5px; margin: 0 auto 12px; border-radius: 99px; background: var(--line); }
.sheet-close { position: absolute; top: 8px; right: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 60;
  width: max-content; max-width: calc(100% - 32px);
  padding: 10px 18px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-weight: 600; text-align: center;
  transform: translate(-50%, 20px); opacity: 0; transition: .25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Profile ---------- */

.summary { flex-direction: column; align-items: stretch; }
.summary .stats { margin-top: 0; }
.summary .stat { box-shadow: none; background: var(--surface-2); }
.mastery { display: flex; flex-direction: column; gap: 6px; }
.mastery-row { display: flex; justify-content: space-between; }

.settings, .about { flex-direction: column; align-items: stretch; gap: 0; padding: 4px 16px; }
.about { gap: 14px; padding: 16px; }
.reset-confirm { display: flex; flex-direction: column; gap: 10px; }
.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.setting:last-child { border-bottom: 0; }
.setting.stack { flex-direction: column; align-items: stretch; gap: 8px; }
.setting input[type="text"], .setting select {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.setting input[type="range"] { width: 100%; accent-color: var(--accent); }
input[role="switch"] {
  appearance: none; -webkit-appearance: none;
  position: relative; width: 50px; height: 30px; flex: none; margin: 0;
  border-radius: 99px; background: var(--line); transition: background .2s;
}
input[role="switch"]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s;
}
input[role="switch"]:checked { background: var(--good); }
input[role="switch"]:checked::after { transform: translateX(20px); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Accounts ---------- */

.account { flex-direction: column; align-items: stretch; gap: 14px; }
.account-head { display: flex; align-items: center; gap: 12px; }
.account-head > .icon { width: 36px; height: 36px; padding: 6px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.avatar {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 1.2rem;
}
.sync-status { display: flex; align-items: center; gap: 8px; font-size: .875rem; color: var(--muted); }
.sync-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--line); }
.sync-status.synced .sync-dot { background: var(--good); }
.sync-status.syncing .sync-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.sync-status.offline .sync-dot { background: var(--gold); }
.sync-status.error .sync-dot { background: var(--bad); }
.sync-status.error { color: var(--bad); }

.account-actions { display: flex; flex-direction: column; gap: 10px; }
.expander { border-top: 1px solid var(--line); }
.expander-btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: 48px; padding: 0; border: 0; background: none;
  font-weight: 600; text-align: left;
}
.expander-btn .icon { width: 20px; height: 20px; color: var(--muted); transition: transform .2s; }
.expander-btn[aria-expanded="true"] .icon { transform: rotate(90deg); }
.expander-body:not(:empty) { padding-bottom: 14px; }

.auth { gap: 16px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; font-size: .9rem; }
.field input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); font-size: 1rem;
}
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.field-row { display: flex; gap: 8px; }
.field-row input { flex: 1; min-width: 0; }
.field-toggle {
  flex: none; min-width: 64px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--muted); font-weight: 600; font-size: .875rem;
}
.form-error { color: var(--bad); font-weight: 600; font-size: .9rem; }
.form-error:empty { display: none; }
.auth-switch { text-align: center; color: var(--muted); }
.auth-switch a { color: var(--accent); font-weight: 700; }

.account-prompt .icon:first-child { color: var(--accent); }

/* ---------- Welcome ---------- */

.welcome {
  gap: 18px; max-width: 480px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 28px) 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
}
.welcome-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.1rem; }
.welcome-mark {
  display: grid; place-items: center; width: 52px; height: 52px; flex: none;
  border-radius: 14px; background: linear-gradient(135deg, #3d6ee0, #2447a8); color: #fff;
  font-family: Georgia, "Times New Roman", serif; font-size: 1.5rem; font-weight: 700;
}
.welcome-title { font-size: 2.1rem; line-height: 1.15; text-wrap: balance; }
.welcome-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.welcome-steps li { display: flex; align-items: center; gap: 12px; }
.welcome-steps .path-num { width: 34px; height: 34px; border-radius: 10px; font-size: .9rem; }
.welcome-form {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.welcome-form label { font-weight: 700; }
.welcome-form input {
  width: 100%; min-height: 52px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 1.1rem;
}
.welcome-form input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.welcome-account { display: flex; flex-direction: column; gap: 10px; }
.welcome-or { text-align: center; color: var(--muted); font-weight: 600; font-size: .9rem; }

/* ---------- Admin ---------- */

.admin .stat strong { font-size: 1.4rem; }
.admin-link .icon { color: var(--accent); }
.admin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.admin-item { flex-direction: column; align-items: stretch; gap: 10px; }
.admin-item-head { display: flex; align-items: flex-start; gap: 12px; }
.admin-name { font-weight: 700; }
.admin-actions { display: flex; flex-direction: column; gap: 10px; }
.admin-actions:not(:empty) { padding-bottom: 12px; }
.invite-form { flex-direction: column; align-items: stretch; gap: 12px; }
.invite-form .field, .admin-item .field { flex: 1; min-width: 130px; }
.field select, .invite-form input {
  width: 100%; min-height: 46px; padding: 8px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 1rem;
}
.row.wrap { flex-wrap: wrap; }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: .9rem; border-radius: 10px; }
.confirm-row { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.4rem; font-weight: 700; letter-spacing: .04em; word-break: break-all; }
.small-code { font-size: 1rem; }
.new-code { flex-direction: column; align-items: stretch; gap: 8px; border: 2px solid var(--good); }
.pill {
  flex: none; padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted);
}
.pill.active { background: var(--good-soft); color: var(--good); }
.pill.admin { background: var(--accent-soft); color: var(--accent); }
.pill.revoked, .pill.expired { background: var(--bad-soft); color: var(--bad); }
