/* Lexio - design tokens, reset, layout. Colours come from CSS variables so the brand colour can be set in the admin panel. */
:root {
  --brand: #147a54;
  --brand-dark: color-mix(in srgb, var(--brand) 74%, #000);
  --brand-ink: color-mix(in srgb, var(--brand) 80%, #000);   /* brand colour used as TEXT on light surfaces */
  --on-brand: #ffffff;
  --brand-soft: color-mix(in srgb, var(--brand) 13%, var(--surface));
  --bg: #f4f7f4; --surface: #ffffff; --surface-2: #eef3ef; --ink: #1c2a24; --ink-2: #51635a; --line: #d9e3dc;
  --gold: #f5a524; --gold-soft: #fff3d6; --gold-ink: #7a5000; --flame: #a63d08; --danger: #a8202a; --danger-btn: #b42329; --danger-soft: #fdecec; --info: #1f5cb0; --info-soft: #e7f0fd; --ok: #0f6243; --ok-soft: #e0f5eb;
  --radius: 16px; --radius-sm: 10px; --gap: 16px;
  --shadow: 0 1px 2px rgba(20,40,30,.06), 0 6px 18px rgba(20,40,30,.06);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --focus: 0 0 0 3px color-mix(in srgb, var(--info) 55%, transparent);
  --sidebar: 248px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f1713; --surface: #17221c; --surface-2: #1d2b24; --ink: #e9f2ec; --ink-2: #a3b5aa; --line: #2b3b32; --gold-soft: #3a2f12; --gold-ink: #f7c05f; --flame: #ff9a66; --danger-soft: #3a1b1d; --danger: #ff8187; --info-soft: #17283f; --info: #9cc4fa; --ok: #6fe0a8; --ok-soft: #163a2b; --brand-ink: color-mix(in srgb, #fff 60%, var(--brand)); --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3); }
}
:root[data-theme="dark"] { --bg: #0f1713; --surface: #17221c; --surface-2: #1d2b24; --ink: #e9f2ec; --ink-2: #a3b5aa; --line: #2b3b32; --gold-soft: #3a2f12; --gold-ink: #f7c05f; --flame: #ff9a66; --danger-soft: #3a1b1d; --danger: #ff8187; --info-soft: #17283f; --info: #9cc4fa; --ok: #6fe0a8; --ok-soft: #163a2b; --brand-ink: color-mix(in srgb, #fff 60%, var(--brand)); --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5; min-height: 100vh; overflow-x: hidden; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.5rem, 4.5vw, 2rem); } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; overflow-wrap: anywhere; }
a { color: var(--brand-ink); }
img { max-width: 100%; }
svg { width: 1.25em; height: 1.25em; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--surface); padding: 8px 14px; border-radius: 8px; z-index: 100; box-shadow: var(--shadow); }
.skip:focus { top: 8px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); } .small { font-size: .875rem; } .center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 2px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; text-decoration: none; color: var(--brand-ink); font-weight: 900; font-size: 1.35rem; letter-spacing: -.02em; }
.brand img { width: 34px; height: 34px; flex: none; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; text-decoration: none; color: var(--ink-2); font-weight: 800; letter-spacing: .02em; text-transform: uppercase; font-size: .82rem; border: 2px solid transparent; min-height: 44px; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.nav svg { width: 24px; height: 24px; flex: none; }
.sidebar .spacer { flex: 1; }
.main { min-width: 0; padding: 24px clamp(14px, 3vw, 32px) 96px; }
.content { max-width: 980px; margin: 0 auto; }
.topbar { display: none; }
.tabbar { display: none; }

@media (max-width: 899px) {
  .app { display: block; }
  .sidebar { display: none; }
  .main { padding: 12px 14px 92px; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); padding: 8px 14px; border-bottom: 2px solid var(--line); }
  .topbar .brand { padding: 0; font-size: 1.15rem; }
  .topbar .brand img { width: 28px; height: 28px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 2px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px; text-decoration: none; color: var(--ink-2); font-size: .68rem; font-weight: 800; border-radius: 12px; padding: 4px 2px; overflow: hidden; }
  .tabbar a[aria-current="page"] { color: var(--brand-ink); background: var(--brand-soft); }
  .tabbar svg { width: 24px; height: 24px; }
  .tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- stats chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-weight: 800; font-size: .9rem; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.chip svg { width: 18px; height: 18px; }
.chip.flame { color: var(--flame); } .chip.bolt { color: var(--gold-ink); } .chip.heart { color: var(--danger); }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--gold-soft); color: var(--gold-ink); } .chip.bad { background: var(--danger-soft); color: var(--danger); } .chip.info { background: var(--info-soft); color: var(--info); }

/* ---------- buttons ---------- */
.btn { --b: var(--brand); --bd: var(--brand-dark); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 22px; border: 0; border-radius: 14px; background: var(--b); color: var(--on-brand); font-weight: 900; letter-spacing: .03em; text-transform: uppercase; font-size: .92rem; cursor: pointer; text-decoration: none; box-shadow: 0 4px 0 var(--bd); transition: transform .08s, box-shadow .08s, filter .15s; max-width: 100%; text-align: center; }
.btn:hover { filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--bd); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--line); color: var(--ink-2); box-shadow: 0 4px 0 color-mix(in srgb, var(--line) 70%, #000); cursor: not-allowed; filter: none; }
.btn.secondary { --b: var(--surface); --bd: var(--line); color: var(--brand-ink); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.btn.danger { --b: var(--danger-btn); --bd: color-mix(in srgb, var(--danger-btn) 70%, #000); color: #fff; }
.btn.ghost { background: transparent; color: var(--brand-ink); box-shadow: none; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .8rem; box-shadow: 0 3px 0 var(--bd); }
.btn.block { display: flex; width: 100%; }
/* reduced motion is handled in motion.css (system setting or the Profile → Animations choice) */

/* ---------- cards, forms ---------- */
.card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: var(--gap); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.field { display: block; margin-bottom: 14px; }
.field > span.label { display: block; font-weight: 800; font-size: .88rem; margin-bottom: 6px; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2); color: var(--ink); }
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { outline: none; border-color: var(--info); box-shadow: var(--focus); background: var(--surface); }
.field.invalid .input { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: .85rem; font-weight: 700; margin-top: 4px; }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: 10px 14px; font-weight: 700; margin-bottom: 12px; }
.notice { background: var(--info-soft); color: var(--ink); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; border: 2px solid color-mix(in srgb, var(--info) 30%, transparent); }
.progress { height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .35s ease; min-width: 0; }
.progress.gold > i { background: var(--gold); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; background: var(--surface-2); color: var(--ink-2); }
.toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: 90px; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-weight: 700; box-shadow: var(--shadow); animation: pop .2s ease; pointer-events: auto; }
.toast.error { background: var(--danger-btn); color: #fff; } .toast.success { background: var(--brand); color: var(--on-brand); }
@keyframes pop { from { transform: translateY(8px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
dialog { border: 2px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); padding: 0; width: min(94vw, 460px); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 20, 15, .5); }
.dialog-body { padding: 22px; } .dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.spinner { width: 28px; height: 28px; border: 4px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 28px 12px; color: var(--ink-2); }
.empty img { width: 96px; height: 96px; margin-bottom: 8px; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 900; flex: none; overflow: hidden; }
.avatar svg { width: 62%; height: 62%; }

/* ---------- guest / auth pages ---------- */
.guest { min-height: 100vh; display: grid; place-items: center; padding: 20px 14px; }
.auth-card { width: min(100%, 440px); }
.auth-card .mascot { width: 96px; height: 96px; display: block; margin: 0 auto 8px; }
.landing { max-width: 1040px; margin: 0 auto; padding: 24px 16px 60px; }
.landing-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 36px; }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 32px; align-items: center; margin-bottom: 40px; }
.hero img { width: 100%; max-width: 340px; justify-self: center; }
.hero h1 { font-size: clamp(1.9rem, 6vw, 2.9rem); }
@media (max-width: 720px) { .hero { grid-template-columns: 1fr; text-align: center; } .hero .row { justify-content: center; } .hero img { max-width: 220px; order: -1; } }

/* ---------- language selector ---------- */
.lang-switcher { position: relative; display: inline-block; max-width: 100%; }
.lang-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; max-width: 100%; padding: 6px 12px; border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; background: var(--surface); color: var(--ink); font-weight: 800; cursor: pointer; }
.lang-btn:hover { background: var(--surface-2); }
.lang-btn:active { border-bottom-width: 2px; transform: translateY(2px); }
.lang-flag { font-size: 1.25rem; line-height: 1; flex: none; }
.lang-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-code { display: none; font-size: .85rem; letter-spacing: .04em; }
.lang-caret { width: 1em; height: 1em; opacity: .7; transition: transform .15s; }
.lang-switcher.open .lang-caret { transform: rotate(180deg); }
.lang-list { position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; margin: 0; padding: 6px; list-style: none; min-width: 100%; width: max-content; max-width: min(92vw, 280px); background: var(--surface); border: 2px solid var(--line); border-radius: 14px; box-shadow: var(--shadow), 0 12px 32px rgba(0,0,0,.18); outline: none; }
.lang-option { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border-radius: 10px; font-weight: 800; cursor: pointer; }
.lang-option:hover, .lang-option.active { background: var(--surface-2); }
.lang-option.active { box-shadow: inset 0 0 0 2px var(--info); }
.lang-option.current { color: var(--brand-ink); }
.lang-label { flex: 1; min-width: 0; }
.lang-active { display: inline-flex; color: var(--brand-ink); }
.lang-switcher.wide .lang-btn { width: 100%; justify-content: flex-start; }
.lang-switcher.wide { display: block; }
.lang-switcher.wide .lang-caret { margin-left: auto; }
.side-lang { margin-top: auto; padding: 8px 4px 0; }
.side-lang .lang-list, .adm-side .lang-list { top: auto; bottom: calc(100% + 6px); }
.guest-bar { position: fixed; top: 10px; right: 12px; z-index: 40; }
.guest-bar .lang-list { left: auto; right: 0; }
.topbar .lang-switcher { margin-left: auto; }
.topbar .lang-list { left: auto; right: 0; }
.field .lang-switcher.wide { max-width: 360px; }
.field .lang-list { top: calc(100% + 6px); bottom: auto; }
@media (max-width: 899px) { .topbar { flex-wrap: wrap; } .lang-switcher.compact .lang-btn { padding: 6px 10px; } }
@media (max-width: 520px) {
  .lang-switcher.compact .lang-name { display: none; }
  .lang-switcher.compact .lang-code { display: inline; }
  .topbar .brand-name { max-width: 28vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* long translations (Russian words are often 30-40% longer than English): wrap instead of overflowing */
.btn, .chip, .badge, .option, .nav-i, .fchip, .tile-btn { overflow-wrap: anywhere; hyphens: auto; }
.btn { max-width: 100%; text-align: center; }
.page-head, .row, .chips { min-width: 0; }
.page-head > * { min-width: 0; }
.nav-i { line-height: 1.25; }
.tabbar a span { hyphens: auto; }
@media (max-width: 380px) { .tabbar a { font-size: .62rem; } }
