/* =====================================================================
   OKAK design system — «Midnight Gold» (2026-10)
   1. Fonts (self-hosted woff2, cyrillic + latin)
   2. Tokens (+ aliases for legacy variable names used by older pages)
   3. Global safe base (applies to every page that links this file)
   4. Components — scoped to body.mg so legacy pages (cabinet) keep
      their own markup styles and only receive the new palette.
   ===================================================================== */

/* ---------- 1. Fonts ---------- */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* ₽ (U+20BD) for Inter text is taken from Manrope's latin-ext file (15 KB) */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/manrope-latin-ext-wght-normal.woff2") format("woff2");
    unicode-range: U+20BD;
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/manrope-cyrillic-wght-normal.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/manrope-latin-wght-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/manrope-latin-ext-wght-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+20A0-20AB, U+20AD-20C0;
}
@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url("../fonts/jetbrains-mono-cyrillic-wght-normal.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- 2. Tokens ---------- */
:root {
    color-scheme: dark;

    /* palette */
    --color-bg: #0A0A0F;
    --color-bg-2: #0E0E14;
    --color-surface: #13131A;
    --color-surface-2: #1B1B24;
    --color-surface-3: #23232E;
    --color-border: rgba(255, 255, 255, .08);
    --color-border-strong: rgba(255, 255, 255, .14);
    --color-text: #F4F4F6;
    --color-text-2: #A1A1AA;
    --color-text-3: #8A8A94;
    --color-accent: #F5B83D;
    --color-accent-hover: #FFCB5C;
    --color-on-accent: #17120A;
    --color-accent-soft: rgba(245, 184, 61, .12);
    --color-accent-border: rgba(245, 184, 61, .32);
    --color-success: #34D399;
    --color-success-soft: rgba(52, 211, 153, .12);
    --color-warning: #FBBF24;
    --color-warning-soft: rgba(251, 191, 36, .12);
    --color-danger: #F87171;
    --color-danger-soft: rgba(248, 113, 113, .12);
    --color-neutral-soft: rgba(161, 161, 170, .12);
    --color-tg: #2AABEE;
    --color-tg-hover: #43B8F3;
    --color-focus: #F5B83D;

    /* type */
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Manrope", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    --text-xs: 14px;
    --text-sm: 15px;
    --text-md: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --h1: clamp(36px, 5.4vw, 64px);
    --h2: clamp(28px, 3.4vw, 42px);
    --h3: 20px;

    /* shape & depth */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .45);
    --shadow-accent: 0 10px 30px rgba(245, 184, 61, .18);

    /* motion */
    --ease-out: cubic-bezier(.22, 1, .36, 1);
    --dur-fast: 150ms;
    --dur: 240ms;

    /* layout */
    --container: 1160px;
    --container-narrow: 680px;
    --gutter: 16px;
    --header-h: 64px;
    --tg-top: var(--tg-miniapp-top, 0px);
    --tg-bottom: var(--tg-miniapp-bottom, env(safe-area-inset-bottom, 0px));

    /* ---- legacy aliases (pages not yet redesigned read these) ---- */
    --okak-bg: var(--color-bg);
    --okak-surface: var(--color-surface);
    --okak-surface-raised: var(--color-surface-2);
    --okak-border: var(--color-border-strong);
    --okak-text: var(--color-text);
    --okak-muted: var(--color-text-2);
    --okak-accent: var(--color-accent);
    --okak-accent-strong: var(--color-accent-hover);
    --okak-focus: var(--color-focus);
    --okak-radius: 18px;

    --bg: var(--color-bg);
    --bg-card: var(--color-surface);
    --bg-card-hover: var(--color-surface-2);
    --accent: var(--color-accent);
    --accent-light: var(--color-accent-hover);
    --accent-glow: var(--color-accent-soft);
    --text: var(--color-text);
    --text-sec: var(--color-text-2);
    --text-dim: var(--color-text-3);
    --text-muted: var(--color-text-2);
    --text-light: var(--color-text-2);
    --border: #26262F;
    --success: var(--color-success);
    --success-bg: var(--color-success-soft);
    --warning: var(--color-warning);
    --warning-bg: var(--color-warning-soft);
    --danger: var(--color-danger);
    --danger-bg: var(--color-danger-soft);
    --info: var(--color-text-2);
    --info-bg: var(--color-neutral-soft);
    --unknown: var(--color-text-2);
    --unknown-bg: var(--color-neutral-soft);
    --blue-bg: var(--color-neutral-soft);
    --orange-bg: var(--color-accent-soft);
    --primary: var(--color-accent);
    --primary-dark: #D99A1E;
    --primary-light: var(--color-accent-hover);

    --landing-bg: var(--color-bg);
    --landing-card: var(--color-surface);
    --landing-accent: var(--color-accent);
    --landing-accent-light: var(--color-accent-hover);
    --landing-text: var(--color-text);
    --landing-text-sec: var(--color-text-2);
    --landing-border: var(--color-border-strong);
}

/* ---------- 3. Global safe base (unchanged behaviour, new focus colour) ---------- */
html { scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { touch-action: manipulation; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--color-focus) !important;
    outline-offset: 2px;
}
:where(input, select, textarea) { min-height: 46px; }
:where(button, .button, .btn, [role="button"]) { min-height: 44px; }
::selection { background: rgba(245, 184, 61, .3); color: var(--color-text); }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* =====================================================================
   4. Components (body.mg)
   ===================================================================== */
body.mg {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-md);
    line-height: 1.6;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
}
.mg *, .mg *::before, .mg *::after { box-sizing: border-box; }
.mg :where(h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd) { margin: 0; }
.mg :where(ul[class], ol[class]) { list-style: none; padding: 0; }
.mg img, .mg svg, .mg video { max-width: 100%; }
.mg :where(h1, h2, h3, h4) {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-text);
    text-wrap: balance;
}
.mg h1, .mg .h1 { font-size: var(--h1); line-height: 1.05; }
.mg h2, .mg .h2 { font-size: var(--h2); line-height: 1.12; }
.mg h3, .mg .h3 { font-size: var(--h3); line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.mg h4 { font-size: 17px; line-height: 1.4; font-weight: 700; letter-spacing: -0.01em; }
.mg p { text-wrap: pretty; }
.mg :where(a) { color: var(--color-accent); text-decoration: none; transition: color var(--dur-fast) ease; }
.mg :where(a):hover { color: var(--color-accent-hover); }
.mg :where(code, kbd, samp, .mono) { font-family: var(--font-mono); font-size: .92em; }
.mg :where(code) {
    padding: .1em .4em;
    border-radius: 6px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}
.mg strong, .mg b { font-weight: 600; color: var(--color-text); }
.mg .muted { color: var(--color-text-2); }
.mg .small { font-size: var(--text-xs); line-height: 1.5; }
.mg .lead { font-size: var(--text-lg); line-height: 1.6; color: var(--color-text-2); }
.mg .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.mg .skip-link {
    position: absolute; left: 16px; top: -60px; z-index: 2000;
    padding: 10px 16px; border-radius: var(--radius-md);
    background: var(--color-accent); color: var(--color-on-accent); font-weight: 600;
}
.mg .skip-link:focus { top: calc(var(--tg-top) + 8px); color: var(--color-on-accent); }

/* ---------- icons ---------- */
.mg .icon {
    width: 20px; height: 20px; flex: none;
    stroke: currentColor; fill: none;
    stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
    vertical-align: middle;
}
.mg .icon--sm { width: 16px; height: 16px; }
.mg .icon--lg { width: 24px; height: 24px; }
.mg .icon--xl { width: 32px; height: 32px; }
.mg .logo-svg { width: 24px; height: 24px; fill: currentColor; stroke: none; flex: none; }
.mg .icon-tile {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; flex: none;
    border-radius: var(--radius-md);
    background: var(--color-accent-soft);
    color: var(--color-accent);
    border: 1px solid rgba(245, 184, 61, .18);
}
.mg .icon-tile--neutral { background: var(--color-surface-2); color: var(--color-text); border-color: var(--color-border); }

/* ---------- layout ---------- */
.mg .container {
    width: 100%;
    max-width: calc(var(--container) + 2 * var(--gutter));
    margin-inline: auto;
    padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px));
}
.mg .container--narrow { max-width: calc(var(--container-narrow) + 2 * var(--gutter)); }
.mg .container--mid { max-width: calc(880px + 2 * var(--gutter)); }
@media (min-width: 768px) { .mg { --gutter: 24px; } }
@media (min-width: 1200px) { .mg { --gutter: 32px; } }
.mg .section { padding-block: clamp(56px, 8vw, 104px); }
.mg .section--tight { padding-block: clamp(40px, 5vw, 64px); }
.mg .section + .section { border-top: 1px solid var(--color-border); }
.mg .section--flush + .section, .mg .section + .section--flush { border-top: 0; }
.mg .section-head { max-width: 720px; margin-bottom: clamp(28px, 4vw, 48px); }
.mg .section-head--center { margin-inline: auto; text-align: center; }
.mg .section-head h2 + p { margin-top: 14px; }
.mg .eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    margin-bottom: 14px;
    font-size: var(--text-xs); font-weight: 600; line-height: 1.4;
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--color-accent);
}
.mg .stack { display: flex; flex-direction: column; gap: 16px; }
.mg .cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.mg .grid { display: grid; gap: 16px; }
@media (min-width: 640px) {
    .mg .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mg .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mg .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
    .mg .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .mg .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .mg .grid { gap: 20px; }
}

/* ---------- buttons ---------- */
.mg .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 48px; padding: 0 22px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-family: var(--font-sans); font-size: var(--text-md); font-weight: 600; line-height: 1.2;
    text-align: center; text-decoration: none; white-space: nowrap;
    cursor: pointer; user-select: none;
    transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.mg .btn:active { transform: translateY(1px); }
.mg .btn--primary { background: var(--color-accent); color: var(--color-on-accent); box-shadow: var(--shadow-accent); }
.mg .btn--primary:hover { background: var(--color-accent-hover); color: var(--color-on-accent); }
.mg .btn--secondary { background: rgba(255, 255, 255, .04); color: var(--color-text); border-color: var(--color-border-strong); }
.mg .btn--secondary:hover { background: rgba(255, 255, 255, .08); color: var(--color-text); border-color: rgba(255, 255, 255, .22); }
.mg .btn--ghost { background: transparent; color: var(--color-text); }
.mg .btn--ghost:hover { background: rgba(255, 255, 255, .06); color: var(--color-text); }
.mg .btn--tg { background: var(--color-tg); color: #06121A; } /* dark on #2AABEE = 7.4:1 (white was 2.57:1), same as cabinet */
.mg .btn--tg:hover { background: var(--color-tg-hover); color: #06121A; } /* 8.5:1 */
.mg .btn--danger { background: var(--color-danger-soft); color: var(--color-danger); border-color: rgba(248, 113, 113, .3); }
.mg .btn--danger:hover { background: rgba(248, 113, 113, .2); color: var(--color-danger); }
.mg .btn--lg { min-height: 52px; padding: 0 26px; font-size: 17px; }
.mg .btn--sm { min-height: 44px; padding: 0 16px; font-size: var(--text-sm); }
.mg .btn--block { width: 100%; }
.mg .btn[disabled], .mg .btn.is-disabled { opacity: .5; pointer-events: none; }
.mg .btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
@media (max-width: 520px) {
    .mg .btn-row--stack { flex-direction: column; }
    .mg .btn-row--stack .btn { width: 100%; }
}

/* ---------- cards ---------- */
.mg .card {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: clamp(20px, 2.4vw, 28px);
}
.mg .card--raised { background: var(--color-surface-2); }
.mg .card--accent {
    border-color: var(--color-accent-border);
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(245, 184, 61, .10), transparent 60%),
        var(--color-surface);
}
.mg .card--interactive { transition: border-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), background-color var(--dur) ease; }
.mg .card--interactive:hover { border-color: var(--color-border-strong); background-color: var(--color-surface-2); }
.mg .card h3 + p { margin-top: 8px; color: var(--color-text-2); }

/* ---------- badges & pills ---------- */
.mg .badge {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 26px; padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs); font-weight: 600; line-height: 1.3;
    background: var(--color-neutral-soft); color: var(--color-text-2);
    border: 1px solid transparent;
    white-space: nowrap;
}
.mg .badge--accent { background: var(--color-accent-soft); color: var(--color-accent); border-color: rgba(245, 184, 61, .2); }
.mg .badge--success { background: var(--color-success-soft); color: var(--color-success); }
.mg .badge--warning { background: var(--color-warning-soft); color: var(--color-warning); }
.mg .badge--danger { background: var(--color-danger-soft); color: var(--color-danger); }
.mg .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.mg .status-pill {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 44px; padding: 0 16px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--color-border-strong);
    background: rgba(255, 255, 255, .03);
    color: var(--color-text-2);
    font-size: var(--text-xs); font-weight: 500; white-space: nowrap;
    text-decoration: none;
}
.mg a.status-pill:hover { color: var(--color-text); border-color: rgba(255, 255, 255, .22); }
.mg .status-pill .dot { color: var(--color-text-3); }
.mg .status-pill[data-level="ok"] .dot { color: var(--color-success); box-shadow: 0 0 0 4px rgba(52, 211, 153, .15); }
.mg .status-pill[data-level="warning"] .dot { color: var(--color-warning); box-shadow: 0 0 0 4px rgba(251, 191, 36, .15); }
.mg .status-pill[data-level="critical"] .dot { color: var(--color-danger); box-shadow: 0 0 0 4px rgba(248, 113, 113, .15); }

/* ---------- alerts (also covers Flask flash categories) ---------- */
.mg .alert {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface-2);
    color: var(--color-text);
    font-size: var(--text-sm); line-height: 1.55;
}
.mg .alert .icon { margin-top: 1px; }
.mg :is(.alert--success, .alert-success) { background: var(--color-success-soft); border-color: rgba(52, 211, 153, .3); }
.mg :is(.alert--success, .alert-success) .icon { color: var(--color-success); }
.mg :is(.alert--warning, .alert-warning) { background: var(--color-warning-soft); border-color: rgba(251, 191, 36, .3); }
.mg :is(.alert--warning, .alert-warning) .icon { color: var(--color-warning); }
.mg :is(.alert--danger, .alert-danger, .alert-error) { background: var(--color-danger-soft); border-color: rgba(248, 113, 113, .3); }
.mg :is(.alert--danger, .alert-danger, .alert-error) .icon { color: var(--color-danger); }
.mg :is(.alert--accent, .alert-info, .alert-status, .alert-message) { background: var(--color-accent-soft); border-color: rgba(245, 184, 61, .26); }
.mg :is(.alert--accent, .alert-info, .alert-status, .alert-message) .icon { color: var(--color-accent); }
.mg .flash-stack { display: grid; gap: 10px; margin-top: 16px; }

/* ---------- forms ---------- */
.mg .field { display: grid; gap: 8px; font-size: var(--text-sm); font-weight: 500; color: var(--color-text); }
.mg .input,
.mg .field :is(input[type="email"], input[type="text"], input[type="password"], input[type="tel"], input[type="number"], select, textarea) {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-strong);
    background: var(--color-bg-2);
    color: var(--color-text);
    font-family: var(--font-sans); font-size: var(--text-md); font-weight: 400;
    transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.mg .input::placeholder, .mg .field input::placeholder { color: var(--color-text-3); }
.mg .input:hover, .mg .field :is(input, select, textarea):hover { border-color: rgba(255, 255, 255, .22); }
.mg .input:focus, .mg .field :is(input, select, textarea):focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(245, 184, 61, .2); }
.mg .hint { font-size: var(--text-xs); line-height: 1.5; color: var(--color-text-2); font-weight: 400; }

/* ---------- table ---------- */
.mg .table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
.mg .table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.mg .table :is(th, td) { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.mg .table th { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-2); background: rgba(255, 255, 255, .02); }
.mg .table tr:last-child td { border-bottom: 0; }
.mg .table .num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- copy / code box ---------- */
.mg .code-box {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--color-bg-2);
    border: 1px solid var(--color-border-strong);
    font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text);
    overflow-wrap: anywhere; word-break: break-all;
}

/* ---------- FAQ (details) ---------- */
.mg .faq { display: grid; gap: 12px; }
.mg .faq-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    transition: border-color var(--dur) ease, background-color var(--dur) ease;
}
.mg .faq-item[open] { border-color: var(--color-border-strong); background: var(--color-surface-2); }
.mg .faq-item > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    min-height: 56px; padding: 14px 20px;
    cursor: pointer; list-style: none;
    font-weight: 600; font-size: var(--text-md); line-height: 1.45;
}
.mg .faq-item > summary::-webkit-details-marker { display: none; }
.mg .faq-item > summary .icon { color: var(--color-text-2); transition: transform var(--dur) var(--ease-out); }
.mg .faq-item[open] > summary .icon { transform: rotate(180deg); color: var(--color-accent); }
.mg .faq-item__body { padding: 0 20px 18px; color: var(--color-text-2); }
.mg .faq-item__body p + p { margin-top: 8px; }

/* ---------- steps ---------- */
.mg .steps { counter-reset: step; display: grid; gap: 16px; }
@media (min-width: 900px) { .mg .steps--row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
.mg .step { counter-increment: step; }
.mg .step__num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; margin-bottom: 16px;
    border-radius: 10px;
    background: var(--color-accent-soft); color: var(--color-accent);
    border: 1px solid rgba(245, 184, 61, .24);
    font-family: var(--font-display); font-weight: 800; font-size: 16px;
}
.mg .step__num::before { content: counter(step); }

/* ---------- check list ---------- */
.mg .checklist { display: grid; gap: 10px; }
.mg .checklist li { display: flex; gap: 10px; align-items: flex-start; color: var(--color-text); line-height: 1.5; }
.mg .checklist li .icon { color: var(--color-accent); margin-top: 2px; }

/* ---------- recommended apps (Happ + INCY) ---------- */
.mg .apps-rec {
    padding: 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-accent-border);
    background: radial-gradient(120% 100% at 0% 0%, rgba(245, 184, 61, .08), transparent 60%), var(--color-surface);
}
.mg .apps-rec__head { margin-bottom: 14px; }
.mg .apps-rec__title { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 18px; line-height: 1.3; font-weight: 800; letter-spacing: -0.01em; }
.mg .apps-rec__title .icon { color: var(--color-accent); }
.mg .apps-rec__sub { margin-top: 4px; color: var(--color-text-2); font-size: var(--text-sm); }
.mg .apps-rec__list { display: grid; gap: 10px; }
.mg .app-rec { display: grid; gap: 12px; align-items: center; padding: 12px; border-radius: var(--radius-md); background: var(--color-bg-2); border: 1px solid var(--color-border); }
@media (min-width: 760px) { .mg .app-rec { grid-template-columns: 200px minmax(0, 1fr); } }
.mg .app-rec__name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mg .app-rec__name > span:last-child { display: flex; flex-direction: column; line-height: 1.3; }
.mg .app-rec__desc { font-size: var(--text-xs); color: var(--color-text-2); }
.mg .app-rec__logo {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 40px; height: 40px; border-radius: 11px;
    background: linear-gradient(145deg, #FFD27A, var(--color-accent));
    color: var(--color-on-accent); font-family: var(--font-display); font-weight: 800; font-size: 18px;
}
.mg .app-rec__logo--alt { background: var(--color-surface-3); color: var(--color-text); border: 1px solid var(--color-border-strong); }
.mg .app-rec__links { display: flex; flex-wrap: wrap; gap: 8px; }
.mg .store-link {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 44px; padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--color-border-strong);
    background: rgba(255, 255, 255, .03);
    color: var(--color-text); font-size: var(--text-sm); font-weight: 500;
}
.mg .store-link:hover { color: var(--color-text); border-color: var(--color-accent-border); background: var(--color-accent-soft); }
.mg .store-link .logo-svg { width: 18px; height: 18px; color: var(--color-text-2); }
.mg .app-rec__ver { font-size: var(--text-xs); color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.mg .app-rec__note { grid-column: 1 / -1; margin: 0; font-size: var(--text-xs); color: var(--color-text-2); }

/* =====================================================================
   Site chrome: header, mobile drawer, bottom nav, footer
   ===================================================================== */
.mg .site-header {
    position: sticky; top: 0; z-index: 900;
    padding-top: var(--tg-top);
    background: rgba(10, 10, 15, .72);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    backdrop-filter: saturate(160%) blur(16px);
    border-bottom: 1px solid var(--color-border);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .mg .site-header { background: rgba(10, 10, 15, .96); }
}
.mg .site-header__inner { display: flex; align-items: center; gap: 24px; min-height: var(--header-h); }
.mg .brand {
    display: inline-flex; align-items: center; gap: 10px;
    min-height: 44px;
    color: var(--color-text); text-decoration: none;
    font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: -0.02em;
}
.mg .brand:hover { color: var(--color-text); }
.mg .brand__mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(145deg, #FFD27A 0%, var(--color-accent) 55%, #D99A1E 100%);
    color: var(--color-on-accent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 4px 14px rgba(245, 184, 61, .25);
}
.mg .brand__mark .icon { width: 18px; height: 18px; stroke-width: 2.2; }
.mg .brand__tag { font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 500; color: var(--color-text-2); letter-spacing: 0; }

.mg .site-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.mg .site-nav a {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
    border-radius: 10px;
    color: var(--color-text-2); font-size: var(--text-sm); font-weight: 500;
}
.mg .site-nav a:hover { color: var(--color-text); background: rgba(255, 255, 255, .04); }
.mg .site-nav a[aria-current="page"] { color: var(--color-text); }
.mg .site-header__actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.mg .site-header__user { display: inline-flex; align-items: center; gap: 8px; color: var(--color-text-2); font-size: var(--text-xs); max-width: 180px; }
.mg .site-header__user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* burger + drawer (ids #navBurger / #navMenu / #navOverlay kept for JS) */
.mg .nav-burger {
    display: none;
    align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-strong);
    background: rgba(255, 255, 255, .03);
    color: var(--color-text);
    cursor: pointer;
}
.mg .nav-burger .icon-close { display: none; }
.mg .nav-burger.active .icon-open { display: none; }
.mg .nav-burger.active .icon-close { display: block; }
.mg .nav-overlay { display: none; }
.mg .nav-drawer { display: none; }

@media (max-width: 900px) {
    .mg .site-nav, .mg .site-header__user, .mg .site-header__actions .btn--desktop { display: none; }
    .mg .nav-burger { display: inline-flex; }
    .mg .site-header__inner { gap: 12px; }
    .mg .nav-drawer {
        display: flex; flex-direction: column; gap: 4px;
        position: fixed; top: 0; right: 0; bottom: 0; z-index: 1000;
        width: min(86vw, 340px);
        padding: calc(var(--tg-top) + 76px) 16px calc(var(--tg-bottom) + 24px);
        background: var(--color-surface);
        border-left: 1px solid var(--color-border-strong);
        box-shadow: var(--shadow-lg);
        transform: translateX(105%);
        visibility: hidden;
        transition: transform var(--dur) var(--ease-out), visibility 0s linear var(--dur);
        overflow-y: auto;
    }
    .mg .nav-drawer.active { transform: none; visibility: visible; transition: transform var(--dur) var(--ease-out), visibility 0s; }
    .mg .nav-drawer a:not(.btn) {
        display: flex; align-items: center; gap: 12px;
        min-height: 52px; padding: 0 14px;
        border-radius: var(--radius-md);
        color: var(--color-text); font-weight: 500;
    }
    .mg .nav-drawer a:not(.btn):hover { background: rgba(255, 255, 255, .05); }
    .mg .nav-drawer a:not(.btn) .icon { color: var(--color-text-2); }
    .mg .nav-drawer .btn { margin-top: 12px; }
    .mg .nav-drawer__user { padding: 12px 14px; color: var(--color-text-2); font-size: var(--text-xs); border-top: 1px solid var(--color-border); margin-top: 12px; overflow-wrap: anywhere; }
    .mg .nav-overlay {
        position: fixed; inset: 0; z-index: 950;
        background: rgba(0, 0, 0, .55);
        opacity: 0; transition: opacity var(--dur) ease;
    }
    .mg .nav-overlay.active { display: block; opacity: 1; }
    .mg .nav-burger { position: relative; z-index: 1001; }
}
@media (max-width: 420px) {
    .mg .site-header .status-pill__text { display: none; }
    .mg .site-header .status-pill { width: 44px; height: 44px; padding: 0; justify-content: center; }
}
@media (max-width: 360px) { .mg .brand__tag { display: none; } }

/* bottom nav (mobile, base.html) */
.mg .bottom-nav { display: none; }
@media (max-width: 768px) {
    .mg.has-bottom-nav { padding-bottom: calc(72px + var(--tg-bottom)); }
    .mg .bottom-nav {
        display: grid; grid-template-columns: repeat(4, 1fr);
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 800;
        padding: 6px 8px calc(6px + var(--tg-bottom));
        background: rgba(13, 13, 19, .9);
        -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
        border-top: 1px solid var(--color-border);
    }
    .mg .bottom-nav__item {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        min-height: 56px; border-radius: var(--radius-md);
        color: var(--color-text-2); font-size: 14px; font-weight: 500; line-height: 1.2;
    }
    .mg .bottom-nav__item:hover { color: var(--color-text); }
    .mg .bottom-nav__item.is-active { color: var(--color-accent); background: var(--color-accent-soft); }
}

/* footer */
.mg .site-footer {
    margin-top: 0;
    padding: 56px 0 calc(32px + var(--tg-bottom));
    border-top: 1px solid var(--color-border);
    background: #08080C;
    color: var(--color-text-2);
    font-size: var(--text-sm);
}
.mg .site-footer__grid { display: grid; gap: 32px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .mg .site-footer__grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
.mg .site-footer h2 {
    font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 600;
    letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-3);
    margin-bottom: 12px;
}
.mg .site-footer ul { display: grid; gap: 2px; list-style: none; margin: 0; padding: 0; }
.mg .site-footer a:not(.brand) { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--color-text-2); }
.mg .site-footer a:not(.brand):hover { color: var(--color-text); }
.mg .site-footer__about { max-width: 34ch; margin-top: 12px; line-height: 1.6; }
.mg .site-footer__bottom {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
    margin-top: 40px; padding-top: 24px;
    border-top: 1px solid var(--color-border);
    font-size: var(--text-xs); color: var(--color-text-3);
}

/* Telegram Mini App: site chrome on standalone pages is replaced by the app's own back button */
.mg .tg-only { display: none; }
html.tg-miniapp-shell .mg .tg-hide { display: none !important; }
html.tg-miniapp-shell .mg .tg-only { display: flex; }

/* back bar shown only inside the Mini App */
.mg .back-bar {
    align-items: center; gap: 12px;
    padding: calc(var(--tg-top) + 8px) 0 8px;
}
.mg .back-bar a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: var(--radius-md);
    background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text);
}
.mg .back-bar span { font-family: var(--font-display); font-weight: 700; font-size: 18px; }

/* page hero for inner pages */
.mg .page-hero { position: relative; padding: clamp(40px, 6vw, 72px) 0 clamp(24px, 4vw, 40px); }
.mg .page-hero h1 { font-size: clamp(32px, 4.4vw, 52px); }
.mg .page-hero .lead { margin-top: 14px; max-width: 60ch; }
.mg .glow { position: relative; isolation: isolate; }
.mg .glow::before {
    content: ""; position: absolute; z-index: -1; pointer-events: none;
    top: -120px; left: 50%; width: min(1100px, 100%); height: 420px; transform: translateX(-50%);
    background: radial-gradient(50% 50% at 50% 30%, rgba(245, 184, 61, .13), transparent 70%);
}
.mg .noise { position: relative; isolation: isolate; }
.mg .noise::after {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    opacity: .06; mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* prose (legal pages) */
.mg .prose { max-width: var(--container-narrow); font-size: 17px; line-height: 1.7; color: var(--color-text); text-align: left; hyphens: manual; }
.mg .prose > * + * { margin-top: 16px; }
.mg .prose h2 { font-size: 24px; line-height: 1.3; margin-top: 48px; scroll-margin-top: calc(var(--header-h) + var(--tg-top) + 24px); }
.mg .prose h2:first-child { margin-top: 0; }
.mg .prose h3 { margin-top: 28px; }
.mg .prose :is(ul, ol) { padding-left: 1.3em; }
.mg .prose li + li { margin-top: 8px; }
.mg .prose li::marker { color: var(--color-accent); }
.mg .prose a { text-decoration: underline; text-decoration-color: rgba(245, 184, 61, .4); text-underline-offset: 3px; }
.mg .prose a:hover { text-decoration-color: currentColor; }
.mg .doc-layout { display: grid; gap: 32px; }
@media (min-width: 1024px) {
    .mg .doc-layout { grid-template-columns: 240px minmax(0, var(--container-narrow)); gap: 64px; justify-content: center; }
}
.mg .toc { display: none; }
@media (min-width: 1024px) {
    .mg .toc { display: block; position: sticky; top: calc(var(--header-h) + var(--tg-top) + 32px); align-self: start; max-height: calc(100vh - 140px); overflow-y: auto; }
    .mg .toc h2 { font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-3); margin-bottom: 12px; }
    .mg .toc ol { display: grid; gap: 2px; list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--color-border); }
    .mg .toc a { display: flex; align-items: center; min-height: 44px; padding: 6px 0 6px 16px; margin-left: -1px; border-left: 1px solid transparent; color: var(--color-text-2); font-size: var(--text-xs); line-height: 1.45; }
    .mg .toc a:hover { color: var(--color-text); border-left-color: var(--color-border-strong); }
    .mg .toc a.is-active { color: var(--color-accent); border-left-color: var(--color-accent); }
}

/* scroll reveal — content is visible by default; JS opts in via html.reveal-ready */
.reveal-ready .mg [data-reveal]:not(.is-in) { opacity: 0; transform: translateY(14px); }
.reveal-ready .mg [data-reveal] { transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out); }
@media (prefers-reduced-motion: reduce) {
    .reveal-ready .mg [data-reveal]:not(.is-in) { opacity: 1; transform: none; }
}
