/* Токены палитры и типографики SUTRA (muhurta.ru)
 * Тёмная тема «Ночь»: --surface-page #08060A, карточка #1E150D, фокус #2B1D14
 * Светлая тема «Альманах»: --surface-page #EFE9DC, карточка #FAF6EE, фокус #FDFBF6
 * Гарнитуры: Cormorant Garamond (display), Jost (body), JetBrains Mono (mono)
 */

:root {
  --space-1: 4px;  --space-2: 8px;   --space-3: 12px;  --space-4: 16px;  --space-5: 20px;  --space-6: 24px;
  --space-8: 32px; --space-10: 40px; --space-12: 48px; --space-16: 64px; --space-24: 96px;

  --radius-card: 4px;
  --radius-inner: 2px;
  --radius-chip: 2px;
  --radius-pill: 999px;

  --ease-inout: cubic-bezier(.4, 0, .2, 1);
  --duration-fast: 120ms;
  --duration-mid: 220ms;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Jost', sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
}

/* ── СВЕТЛАЯ ТЕМА «АЛЬМАНАХ» («ЛИСТ») ─────────────────────────────────────────────────────── */
:root, [data-theme="light"], [data-theme="almanac"], html.light:not([data-theme="dark"]) {
  color-scheme: light;
  --surface-page: #EFE9DC;
  --surface-card: #FAF6EE;
  --surface-focal: #FDFBF6;

  --text-ink: #241F17;
  --text-body: #473F31;
  --text-muted: #6B5F4D;
  --text-soft: #6B5F4D;

  --accent-struct: #B08D4F;
  --accent-struct-text: #7A5E32;
  --accent-emphasis: #B08D4F;
  --text-on-struct: #241F17;
  --accent-action: #2F6356;
  --accent-action-text: #2C5A4E;
  --text-on-action: #FDFBF6;
  --accent-hot: #9B2D1F;
  --text-on-hot: #FDF6E3;

  --status-good: #37704F;
  --status-warn: #7E5F22;
  --status-bad: #9B2D1F;

  --hairline: rgba(176, 141, 79, .26);
  --hairline-2: rgba(176, 141, 79, .14);
  --shadow-card: 0 1px 2px rgba(60, 48, 28, .04), 0 6px 20px rgba(60, 48, 28, .07), inset 0 0 0 1px var(--hairline-2);
  --shadow-card-hover: 0 2px 4px rgba(60, 48, 28, .06), 0 14px 34px rgba(60, 48, 28, .11), inset 0 0 0 1px var(--hairline);
  --shadow-focal: 0 2px 6px rgba(60, 48, 28, .05), 0 18px 46px rgba(60, 48, 28, .10), inset 0 0 0 1px rgba(176, 141, 79, .18);

  --glass-bg: transparent;  --glass-blur: 0px;  --glass-border: transparent;
  --glow-soft: none;  --glow-card: none;  --glow-strong: none;

  /* Слой соответствия для компонентов площадки (WCAG >= 5.0:1 на странице и карточке) */
  --bg: var(--surface-page);
  --surface: var(--surface-card);
  --surface-2: var(--surface-focal);
  --text: var(--text-ink);
  --text-m: var(--text-body);
  --text-d: var(--text-muted);
  --gold: var(--accent-struct-text);
  --gold-b: var(--accent-struct-text);
  --gold-d: rgba(176, 141, 79, .10);
  --accent: var(--gold);
  --accent-b: var(--gold-b);
  --accent-d: var(--gold-d);
  --mars: var(--status-bad);
  --mars-d: rgba(155, 45, 31, .08);
  --rahu: var(--accent-struct-text);
  --rahu-d: rgba(176, 141, 79, .08);
  --mint: var(--accent-action-text);
  --mint-d: rgba(47, 99, 86, .08);
  --border: var(--hairline);
  --border-s: var(--hairline-2);
  --card-hover: rgba(176, 141, 79, .06);
  --blur-overlay: rgba(239, 233, 220, .90);
}

/* ── ТЁМНАЯ ТЕМА «НОЧЬ» (SUTRA) ───────────────────────────────────────────────────────────── */
[data-theme="dark"], [data-theme="astra"], html.dark:not([data-theme="light"]):not([data-theme="almanac"]) {
  color-scheme: dark;
  --surface-page: #08060A;
  --surface-card: #1E150D;
  --surface-focal: #2B1D14;

  --text-ink: #FDF6E3;
  --text-body: #C6B69A;
  --text-muted: #968065;
  --text-soft: #968065;

  --accent-struct: #C19A6B;
  --accent-struct-text: #C19A6B;
  --accent-emphasis: #C19A6B;
  --text-on-struct: #160F09;
  --accent-action: #8FC4B0;
  --accent-action-text: #8FC4B0;
  --text-on-action: #160F09;
  --accent-hot: #9B2D1F;
  --text-on-hot: #FDF6E3;

  --status-good: #5A9E6A;
  --status-warn: #D4A830;
  --status-bad: #C97070;

  --hairline: rgba(193, 154, 107, .26);
  --hairline-2: rgba(193, 154, 107, .14);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, .45), inset 0 0 0 1px var(--hairline-2);
  --shadow-card-hover: 0 0 15px rgba(193, 154, 107, .15), inset 0 0 0 1px var(--hairline);
  --shadow-focal: 0 0 0 1px rgba(193, 154, 107, .12), 0 6px 28px rgba(0, 0, 0, .50);

  --glass-bg: rgba(30, 21, 13, .62);  --glass-blur: 5px;  --glass-border: rgba(193, 154, 107, .18);
  --glow-soft: 0 0 5px rgba(193, 154, 107, .20);
  --glow-card: 0 0 15px rgba(193, 154, 107, .15);
  --glow-strong: 0 0 25px rgba(193, 154, 107, .50);

  /* Слой соответствия для компонентов площадки */
  --bg: var(--surface-page);
  --surface: var(--surface-card);
  --surface-2: var(--surface-focal);
  --text: var(--text-ink);
  --text-m: var(--text-body);
  --text-d: var(--text-muted);
  --gold: var(--accent-struct);
  --gold-b: var(--accent-struct);
  --gold-d: rgba(193, 154, 107, .08);
  --accent: var(--gold);
  --accent-b: var(--gold-b);
  --accent-d: var(--gold-d);
  --mars: var(--status-bad);
  --mars-d: rgba(201, 112, 112, .08);
  --rahu: var(--accent-struct);
  --rahu-d: rgba(193, 154, 107, .06);
  --mint: var(--accent-action);
  --mint-d: rgba(143, 196, 176, .08);
  --border: var(--hairline);
  --border-s: var(--hairline-2);
  --card-hover: rgba(193, 154, 107, .05);
  --blur-overlay: rgba(8, 6, 10, .90);
}

/* Первый визит без JS: тема = система посетителя */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]):not(.light) {
    color-scheme: dark;
    --surface-page: #08060A;  --surface-card: #1E150D;  --surface-focal: #2B1D14;
    --text-ink: #FDF6E3;  --text-body: #C6B69A;  --text-muted: #968065;  --text-soft: #968065;
    --accent-struct: #C19A6B;  --accent-struct-text: #C19A6B;  --accent-emphasis: #C19A6B;  --text-on-struct: #160F09;
    --accent-action: #8FC4B0;  --accent-action-text: #8FC4B0;  --text-on-action: #160F09;  --accent-hot: #9B2D1F;  --text-on-hot: #FDF6E3;
    --status-good: #5A9E6A;  --status-warn: #D4A830;  --status-bad: #C97070;
    --hairline: rgba(193, 154, 107, .26);  --hairline-2: rgba(193, 154, 107, .14);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, .45), inset 0 0 0 1px var(--hairline-2);
    --shadow-card-hover: 0 0 15px rgba(193, 154, 107, .15), inset 0 0 0 1px var(--hairline);
    --shadow-focal: 0 0 0 1px rgba(193, 154, 107, .12), 0 6px 28px rgba(0, 0, 0, .50);
    --glass-bg: rgba(30, 21, 13, .62);  --glass-blur: 5px;  --glass-border: rgba(193, 154, 107, .18);
    --glow-soft: 0 0 5px rgba(193, 154, 107, .20);  --glow-card: 0 0 15px rgba(193, 154, 107, .15);
    --glow-strong: 0 0 25px rgba(193, 154, 107, .50);
    --bg: var(--surface-page);  --surface: var(--surface-card);  --surface-2: var(--surface-focal);
    --text: var(--text-ink);  --text-m: var(--text-body);  --text-d: var(--text-muted);
    --gold: var(--accent-struct);  --gold-b: var(--accent-struct);  --gold-d: rgba(193, 154, 107, .08);
    --accent: var(--gold);  --accent-b: var(--gold-b);  --accent-d: var(--gold-d);
    --mars: var(--status-bad);  --mars-d: rgba(201, 112, 112, .08);
    --rahu: var(--accent-struct);  --rahu-d: rgba(193, 154, 107, .06);
    --mint: var(--accent-action);  --mint-d: rgba(143, 196, 176, .08);
    --border: var(--hairline);  --border-s: var(--hairline-2);
    --card-hover: rgba(193, 154, 107, .05);  --blur-overlay: rgba(8, 6, 10, .90);
  }
}

:root {
  --brass: var(--accent-struct);
}

/* Выравнивание общих виджетов (sutra-reviews, sutra-feedback, ai-guru) */
.srvb-h, .srv-btn, .srv-h, .srv-code, .srv-banner-cta, .ag-title, .ag-limit-btn, .sf-title, .sf-btn {
  font-family: var(--font-mono, 'JetBrains Mono', monospace) !important;
}
.srv-btn, .sf-btn, .ag-fab, .ag-send {
  background-image: none !important;
  background-color: var(--accent-emphasis, #C9A96E) !important;
  color: var(--text-on-struct, #1A1610) !important;
  border: 1px solid var(--gold, #C9A96E) !important;
  border-radius: var(--radius-card, 4px) !important;
  box-shadow: none !important;
}
