/* ТПАС Менеджер AI — дизайн-токены и базовые компоненты Mini App
   Тёмный графит + янтарный «гидравлический» акцент. Подключать после сброса стилей. */

/* шрифты Google подключены в index.html без блокировки загрузки; без них — системные */

:root {
  /* фон и поверхности */
  --bg: #0B0E13;
  --bg-deep: #07090D;
  --surface: #141922;
  --surface-2: #10141B;
  --surface-3: #0E1219;
  --line: #232B39;
  --line-soft: #1C2330;
  --line-strong: #2A3344;
  --bubble-user: #232B39;
  --grid-line: #18202C;

  /* текст */
  --text: #EEF2F7;
  --text-2: #B7C2D2;
  --muted: #8B97A8;
  --faint: #5E6A7C;

  /* акценты */
  --accent: #FFB020;      /* янтарный — кнопки, иконки разделов, цены */
  --on-accent: #0B0E13;   /* текст на акценте */
  --live: #3EE0D0;        /* бирюзовый — «прайс актуален», AI */
  --live-bg: #10201F;

  /* шрифты */
  --font-display: "Unbounded", sans-serif;
  --font-body: "Manrope", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  /* радиусы */
  --r-xl: 24px;
  --r-lg: 20px;
  --r-md: 16px;
  --r-sm: 13px;
  --r-pill: 999px;

  --gutter: 20px;
  --tabbar-h: 74px;
}

html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.app { min-height: 100vh; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

/* шапка */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px var(--gutter) 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; }
.screen-title { font-family: var(--font-display); font-weight: 600; font-size: 20px; }

/* метка актуальности прайса */
.price-badge { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--live); flex: none; }

/* строка «Спросить» / поиск */
.ask { margin: 22px var(--gutter) 0; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 8px 8px 16px; box-sizing: border-box; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.ask input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--text); font: inherit; font-size: 14px; }
.ask input::placeholder { color: var(--muted); }
.mic { width: 42px; height: 42px; flex: none; border-radius: var(--r-sm); border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }

/* заголовок секции */
.section-label { margin: 26px var(--gutter) 12px; font-family: var(--font-display); font-size: 13px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* плитки разделов */
.tiles { margin: 0 var(--gutter); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { min-height: 108px; box-sizing: border-box; padding: 14px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; text-align: left; transition: border-color .15s, transform .1s; }
.tile:active { transform: scale(.98); border-color: var(--accent); }
.tile svg { width: 44px; height: 44px; color: var(--accent); }
.tile-title { font-weight: 700; font-size: 15px; }
.tile-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* строка списка (недавние) */
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px; box-sizing: border-box; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line-soft); }
.row-model { font-family: var(--font-mono); font-weight: 600; font-size: 14px; width: 74px; }
.row-kind { flex: 1; font-size: 13px; color: var(--muted); }
.price { font-family: var(--font-mono); font-weight: 600; color: var(--accent); }

/* чипы категорий */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 var(--gutter); scrollbar-width: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 700; }
.chip svg { width: 24px; height: 24px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* карточка модели в каталоге */
.model-card { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.model-thumb { width: 52px; height: 52px; flex: none; border-radius: 14px; background: var(--surface-3); border: 1px solid var(--line-soft); display: grid; place-items: center; color: var(--accent); }
.model-thumb svg { width: 34px; height: 34px; }
.model-name { font-family: var(--font-mono); font-weight: 600; font-size: 16px; }
.model-meta { font-size: 12px; color: var(--muted); }
.empty { padding: 28px 20px; border-radius: 18px; border: 1px dashed var(--line-strong); text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* hero модели — «чертёжная» сетка */
.hero { margin: 8px var(--gutter) 0; height: 236px; border-radius: var(--r-xl); border: 1px solid var(--line-soft); background-color: var(--surface-3); background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px); background-size: 24px 24px; position: relative; display: grid; place-items: center; color: var(--accent); }
.hero svg { width: 290px; height: 200px; stroke-width: .9; }
.hero-code { position: absolute; left: 16px; top: 14px; font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.model-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 34px; letter-spacing: -.01em; }
.stock { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--r-pill); background: var(--live-bg); color: var(--live); font-size: 12px; font-weight: 600; }

/* характеристики */
.specs { margin: 16px var(--gutter) 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.spec { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.spec-label { font-size: 11px; color: var(--muted); }
.spec-value { margin-top: 4px; font-family: var(--font-mono); font-weight: 600; font-size: 16px; }

/* блок цены */
.price-card { margin: 12px var(--gutter) 0; padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--accent); display: flex; justify-content: space-between; align-items: center; }
.price-card .price { font-size: 24px; }

/* кнопки */
.btn { height: 54px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 15px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); }
.btn svg { width: 22px; height: 22px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-sm { height: 44px; border-radius: var(--r-sm); font-size: 14px; }
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px var(--gutter) calc(22px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line-soft); display: flex; gap: 10px; }
.action-bar .btn { flex: 1; }
.action-bar .btn-primary { flex: 1.4; }

/* чат */
.msg-user { align-self: flex-end; max-width: 78%; padding: 12px 14px; border-radius: 18px 18px 6px 18px; background: var(--bubble-user); font-size: 14px; line-height: 1.45; }
.msg-bot { align-self: flex-start; width: 100%; box-sizing: border-box; padding: 16px; border-radius: 18px 18px 18px 6px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.calc-row { display: flex; justify-content: space-between; font-size: 14px; }
.calc-row span:first-child { color: var(--muted); }
.calc-row span:last-child { font-family: var(--font-mono); }
.calc-total { font-weight: 700; }
.calc-total span:first-child { color: var(--text); }
.calc-total span:last-child { color: var(--accent); }
.suggest { flex: none; height: 40px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600; }

/* нижнее меню */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); box-sizing: border-box; padding: 8px 12px calc(14px + env(safe-area-inset-bottom)); background: var(--surface-3); border-top: 1px solid var(--line-soft); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--muted); border: 0; background: transparent; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--accent); }

/* доступность */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Светлая тема (shell-v34): та же палитра бренда на светлом фоне. Включается атрибутом data-theme="light" на <html>
   (переключатель «Тема» в «Истории → Это устройство», запоминается на устройстве). Тёмная — по умолчанию. */
:root[data-theme="light"] {
  --bg: #F3F5F8;
  --bg-deep: #E9EDF2;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --surface-3: #EEF1F5;
  --line: #DCE2EA;
  --line-soft: #E6EAF0;
  --line-strong: #C3CCD8;
  --bubble-user: #E6EAF0;
  --grid-line: #E3E8EE;

  --text: #121722;
  --text-2: #3A4454;
  --muted: #5B6778;
  --faint: #687384;

  --accent: #9C5A00;       /* янтарный для текста и иконок на светлом (контраст ≥ 4.5) */
  --accent-fill: #FFB020;  /* фирменный янтарный — заливки кнопок и знака */
  --on-accent: #0B0E13;
  --live: #0B8277;
  --live-bg: #DDF3F0;
}
