﻿/* ===== Итогика — общий стиль ===== */
/* IBM Plex Sans — self-hosted (woff2, кириллица+латиница). Без внешних зависимостей. */
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-sans-cyrillic-400-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-400-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/ibm-plex-sans-cyrillic-500-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-500-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/ibm-plex-sans-cyrillic-600-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-600-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/ibm-plex-sans-cyrillic-700-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/ibm-plex-sans-latin-700-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+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --accent: #1e3a5f;       /* navy — бренд, ссылки, активные состояния */
  --accent-d: #16304e;
  --cta: #047857;          /* «денежный» зелёный — CTA в банк (AA с белым текстом) */
  --cta-d: #065f46;
  --btn: #1e3a5f;          /* сплошной фон кнопок/активных табов (всегда под белым текстом) */
  --btn-d: #16304e;
  --ok: #059669;           /* успех, онлайн, новинки */
  --warn: #d97706;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.07);
  --radius: 14px;
  --maxw: 1080px;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1117;
  --surface: #161b24;
  --surface-2: #1c2330;
  --text: #e7ebf3;
  --muted: #9aa6bd;
  --border: #28303f;
  --accent: #6ea8fe;       /* в тёмной теме — светлее navy для читаемости */
  --accent-d: #5a95f0;
  --cta: #047857;          /* зелёный CTA всегда под белым текстом — держим тёмным в обеих темах */
  --cta-d: #036249;
  --btn: #2f5e93;          /* в тёмной теме — навигационный синий, читаемый под белым текстом */
  --btn-d: #27507d;
  --ok: #34d399;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

/* Доступность: видимый фокус для клавиатуры + уважение к prefers-reduced-motion */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* SVG-иконки (Lucide) */
.ic { width: 24px; height: 24px; display: block; flex: 0 0 auto; }
.ic-inline { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo svg { width: 26px; height: 26px; color: var(--accent); }
.nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.nav a { color: var(--muted); font-weight: 600; font-size: 14px; padding: 8px 10px; border-radius: 8px; }
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.theme-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 16px; }
.burger { display: none; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; }

/* Search */
.search { position: relative; flex: 0 1 clamp(260px, 34vw, 420px); min-width: 220px; display: flex; align-items: center; }
.search-ico { position: absolute; left: 11px; display: flex; opacity: .6; pointer-events: none; color: var(--muted); }
.search-ico .ic { width: 16px; height: 16px; }
.search-input { width: 100%; padding: 10px 36px; font-size: 16px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; outline: none; -webkit-appearance: none; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-input:focus { border-color: var(--accent); background: var(--surface); }
.search-clear { position: absolute; right: 7px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: var(--border); color: var(--text); cursor: pointer; font-size: 16px; line-height: 22px; padding: 0; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden auto; z-index: 60; max-height: 70vh; }
.search-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; color: var(--text); border-bottom: 1px solid var(--border); }
.search-item:last-child { border-bottom: 0; }
.search-item:hover, .search-item:focus { background: var(--surface-2); text-decoration: none; }
.search-item small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.search-empty { padding: 16px; color: var(--muted); font-size: 14px; text-align: center; }
.no-results { padding: 36px 0; text-align: center; color: var(--muted); }
.nav-all { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 14px; padding: 8px 12px; border-radius: 8px; white-space: nowrap; }
.nav-all:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.hero-hint { font-size: 15px; margin-top: 12px; opacity: .9; }

/* Tabs + Recent + NEW badge */
.cat-tabs { display: flex; gap: 8px; margin: 14px 0 4px; flex-wrap: wrap; }
.cat-tabs button { border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 999px; cursor: pointer; }
.cat-tabs button.active { background: var(--btn); border-color: var(--btn); color: #fff; }
.cat-tabs button:hover:not(.active) { color: var(--text); border-color: var(--accent); }
.recent-panel { margin: 18px 0 6px; }
.recent-clear { float: right; border: 0; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; text-transform: none; letter-spacing: 0; }
.recent-clear:hover { color: var(--accent); }
.badge-new { display: inline-block; vertical-align: middle; font-size: 10px; font-weight: 800; letter-spacing: .03em; color: #fff; background: var(--cta); padding: 2px 6px; border-radius: 6px; margin-left: 4px; }

/* Главная: промо-блоки (Популярное, Что посчитать, Новинки) */
.hero-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px; margin: 20px 0 0; }
.hero-badges span { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 6px 12px; border-radius: 999px; }
.home-block { margin: 6px 0 4px; }
.home-block .grid { margin: 12px 0 26px; }
.block-link { float: right; font-size: 12px; font-weight: 700; text-transform: none; letter-spacing: 0; }
.catalog-label { margin-top: 30px; }
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; margin: 12px 0 26px; }
.task-chip { display: flex; align-items: center; gap: 12px; padding: 13px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--text); box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease; }
.task-chip:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.task-chip .task-ico { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--accent); flex: 0 0 auto; }
.task-chip .task-ico .ic { width: 20px; height: 20px; }
.task-chip .task-q { flex: 1; font-weight: 600; font-size: 15px; line-height: 1.3; }
.task-chip .task-go { color: var(--accent); font-weight: 800; }

/* Тихий режим: прячем необязательный «шум» */
html[data-quiet="1"] .pc-extra { display: none !important; }
.footer-tools { margin-top: 18px; }
.quiet-toggle { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.quiet-toggle:hover { color: var(--text); border-color: var(--accent); }

/* Сохранение расчёта + история */
.calc-tools { display: flex; gap: 10px; margin: -6px 0 18px; flex-wrap: wrap; }
.calc-tools .ch-note-input { flex: 1; min-width: 200px; }
.calc-tools .btn { width: auto; white-space: nowrap; }
.calc-history { margin: 6px 0 22px; }
.ch-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; }
.ch-main { min-width: 0; }
.ch-sum { font-weight: 700; }
.ch-note { color: var(--muted); font-size: 14px; margin-top: 2px; word-break: break-word; }
.ch-time { color: var(--muted); font-size: 12px; margin-top: 3px; }
.ch-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.ch-btn { width: auto !important; padding: 8px 12px; font-size: 13px; }
.ch-link { border: 0; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px 8px; border-radius: 7px; }
.ch-link:hover { color: var(--accent); background: var(--surface-2); }

/* Авторизация + кабинет */
.auth-area { display: flex; align-items: center; justify-content: flex-end; flex: 0 0 104px; min-width: 0; }
.auth-area .auth-link { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.auth-link { color: var(--muted); font-weight: 600; font-size: 14px; padding: 8px 12px; border-radius: 8px; white-space: nowrap; }
.auth-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.auth-wrap { display: flex; justify-content: center; padding: 40px 0; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.auth-card h1 { margin: 0 0 18px; }
.auth-card .btn { margin-top: 6px; }
.auth-alt { margin-top: 16px; font-size: 14px; color: var(--muted); }
.auth-error { background: color-mix(in srgb, #e23 14%, var(--surface)); color: #e23; border: 1px solid color-mix(in srgb, #e23 40%, var(--border)); padding: 10px 12px; border-radius: 9px; margin-bottom: 14px; font-size: 14px; }
.kb-stat-cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 22px; min-width: 150px; }
.kb-num { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.kb-lbl { color: var(--muted); font-size: 14px; }
.kb-byslug { display: grid; gap: 8px; margin-bottom: 6px; }
.kb-stat-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); }
.kb-stat-row:hover { border-color: var(--accent); text-decoration: none; }
.kb-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.kb-actions .btn { width: auto; }
.kb-hide { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--muted); font-size: 14px; cursor: pointer; }

/* Админ-панель */
.admin-section { margin-top: 22px; }
.admin-report-group { margin-top: 18px; }
.admin-report-group h3 { margin: 0 0 10px; font-size: 18px; }
.admin-report-text { color: var(--text); font-size: 14px; margin-top: 5px; white-space: pre-wrap; word-break: break-word; }
.admin-report .ch-main { flex: 1; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; margin-top: 18px; }
.admin-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.admin-list { display: grid; gap: 8px; }
.admin-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.admin-row-main { min-width: 0; }
.admin-row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-sub { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-num { font-weight: 800; white-space: nowrap; }

/* Уровень в кабинете */
.kb-level { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.lvl-top { display: flex; align-items: center; gap: 14px; }
.lvl-badge { width: 48px; height: 48px; flex: 0 0 48px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--btn); color: #fff; font-size: 22px; font-weight: 800; }
.lvl-info { flex: 1; min-width: 0; }
.lvl-title { font-weight: 700; }
.lvl-sub { color: var(--muted); font-size: 13px; }
.lvl-link { white-space: nowrap; font-size: 14px; font-weight: 600; }
.lvl-bar { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; margin-top: 12px; overflow: hidden; }
.lvl-bar span { display: block; height: 100%; background: var(--btn); border-radius: 99px; }

/* Рейтинг /top/ */
.top-board { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 18px 0; }
.top-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.top-head strong { display: block; }
.top-head span { color: var(--muted); font-size: 13px; }
.top-head .btn { width: auto; }
.top-list { display: grid; gap: 8px; }
.top-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.top-rank { width: 30px; height: 30px; flex: 0 0 30px; display: flex; align-items: center; justify-content: center; font-weight: 800; border-radius: 50%; background: var(--border); color: var(--text); font-size: 14px; }
.top-rank-1 { background: #f5c518; color: #3a2d00; }
.top-rank-2 { background: #c8ccd4; color: #23262b; }
.top-rank-3 { background: #e0a06a; color: #3a1f00; }
.top-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-lvl { color: var(--muted); font-size: 13px; white-space: nowrap; }
.top-xp { font-weight: 700; white-space: nowrap; }

/* XP-уведомление */
.pc-toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 10px; font-weight: 700; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s, transform .25s; z-index: 200; pointer-events: none; }
.pc-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Онлайн-счётчик */
.online-badge { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 56px; color: var(--ok); font-weight: 700; font-size: 13px; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.online-badge.is-pending { visibility: hidden; pointer-events: none; }
.online-badge:hover { background: var(--surface-2); text-decoration: none; }

/* Чат */
.chat-tabs { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.chat-tabs button { border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 999px; cursor: pointer; }
.chat-tabs button.active { background: var(--btn); border-color: var(--btn); color: #fff; }
.chat-box { height: 52vh; min-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.chat-meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.chat-meta b { color: var(--text); }
.chat-text { white-space: pre-wrap; word-break: break-word; }
.chat-actions { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.chat-mini { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 7px; border-radius: 6px; }
.chat-mini:hover { background: var(--bg); color: var(--accent); }
.chat-vote { border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 8px; }
.chat-vote.voted { background: var(--btn); color: #fff; border-color: var(--btn); cursor: default; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form .input { flex: 1; }
.chat-form .btn { width: auto; }

/* Сообщество / конструктор */
.cc-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 14px 0 18px; }
.cc-bar .btn { width: auto; }
.cc-meta { margin-top: 10px; font-size: 13px; color: var(--muted); }
.b-grid { display: grid; grid-template-columns: 1fr 380px; gap: 22px; align-items: start; }
.b-preview { position: sticky; top: 76px; }
.b-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.b-row .input { flex: 1; min-width: 120px; }
.b-fi-options { flex-basis: 100%; }
.b-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.b-actions .btn { width: auto; }
.b-del { color: var(--muted); font-size: 16px; }
@media (max-width: 860px) { .b-grid { grid-template-columns: 1fr; } .b-preview { position: static; } }

/* Имя-ссылка для ЛС + сообщения ЛС */
.chat-name { cursor: pointer; }
.chat-name:hover { color: var(--accent); text-decoration: underline; }
.chat-msg.dm-mine { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); margin-left: 24px; }
.chat-peerbar { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.chat-peerbar .dm-back { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; cursor: pointer; padding: 4px 10px; font-size: 15px; }
.dm-threads { display: grid; gap: 8px; }
.dm-thread { text-align: left; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 10px; padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; }
.dm-thread:hover { border-color: var(--accent); }
.dm-thread b { font-size: 14px; }
.dm-thread span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Плавающее мини-окно чата */
.chat-fab { position: fixed; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--btn); color: #fff; font-size: 24px; cursor: pointer; box-shadow: 0 6px 20px rgba(20,30,60,.28); z-index: 150; }
.chat-fab:hover { background: var(--accent-d); }
.chat-fab-badge { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #e23; color: #fff; font-size: 12px; font-weight: 800; line-height: 20px; }
.chat-widget { position: fixed; right: 18px; bottom: 84px; width: 360px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(20,30,60,.3); z-index: 150; overflow: hidden; display: flex; flex-direction: column; }
.chat-widget-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.chat-widget-close { border: 0; background: var(--surface-2); color: var(--text); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; }
.chat-widget-body { padding: 12px; }
.chat-widget .chat-box { height: 46vh; min-height: 240px; }
.chat-widget .chat-tabs { gap: 5px; }
.chat-widget .chat-tabs button { padding: 6px 10px; font-size: 12px; }
@media (max-width: 460px) { .chat-widget { right: 10px; left: 10px; width: auto; bottom: 78px; } .chat-fab { right: 14px; bottom: 14px; } }
.chat-widget[hidden] { display: none !important; }  /* фикс: hidden перебивал display:flex */

/* Эмодзи/стикер-пикер */
.chat-form { position: relative; }
.chat-emoji-btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 10px; cursor: pointer; font-size: 18px; width: 42px; flex: 0 0 42px; }
.emoji-picker { position: absolute; bottom: 52px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 30; max-height: 260px; display: flex; flex-direction: column; }
.emoji-picker[hidden] { display: none; }
.ep-tabs { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
.ep-tabs button { border: 0; background: var(--surface-2); color: var(--muted); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; }
.ep-tabs button.active { background: var(--btn); color: #fff; }
.ep-grid { overflow-y: auto; padding: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
.ep-item { border: 0; background: transparent; color: var(--text); cursor: pointer; font-size: 24px; padding: 4px; border-radius: 8px; line-height: 1; }
.ep-item:hover { background: var(--surface-2); }
.ep-item.locked { opacity: .35; cursor: not-allowed; position: relative; }
.ep-lock { font-size: 10px; color: var(--muted); text-align: center; grid-column: 1 / -1; padding: 2px 0 0; }

/* Стикеры в сообщениях */
.pc-sticker { font-size: 44px; display: inline-block; line-height: 1; }
.anim-bounce { animation: pc-bounce 1s ease-in-out infinite; }
.anim-spin { animation: pc-spin 2.2s linear infinite; }
.anim-pulse { animation: pc-pulse 1.1s ease-in-out infinite; }
.anim-fly { animation: pc-fly 1.6s ease-in-out infinite; }
@keyframes pc-bounce { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }
@keyframes pc-spin { from { transform: rotate(0) } to { transform: rotate(360deg) } }
@keyframes pc-pulse { 0%,100% { transform: scale(1) } 50% { transform: scale(1.25) } }
@keyframes pc-fly { 0% { transform: translate(0,4px) } 50% { transform: translate(6px,-6px) } 100% { transform: translate(0,4px) } }

/* Ники: эффекты и радуга */
.pc-nick { font-weight: 700; }
.fx-glow { text-shadow: 0 0 7px currentColor; }
.fx-pulse { display: inline-block; animation: pc-pulse 1.4s ease-in-out infinite; }
.fx-shimmer { animation: pc-bright 1.8s ease-in-out infinite; }
@keyframes pc-bright { 0%,100% { filter: brightness(1) } 50% { filter: brightness(1.6) } }
.nick-rainbow { background: linear-gradient(90deg,#ff5f6d,#ffc371,#47e891,#5b9df9,#b06ab3); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* В чате оформление видно всегда, но активные эффекты включаются только при наведении на сообщение. */
.chat-msg .fx-glow { text-shadow: none; transition: text-shadow .15s ease; }
.chat-msg .fx-pulse,
.chat-msg .fx-shimmer { animation: none; }
.chat-msg:hover .fx-glow,
.chat-msg:focus-within .fx-glow { text-shadow: 0 0 7px currentColor; }
.chat-msg:hover .fx-pulse,
.chat-msg:focus-within .fx-pulse { animation: pc-pulse 1.4s ease-in-out infinite; }
.chat-msg:hover .fx-shimmer,
.chat-msg:focus-within .fx-shimmer { animation: pc-bright 1.8s ease-in-out infinite; }

/* Оформление в кабинете */
.cos-group { margin: 10px 0 16px; }
.cos-group h4 { margin: 0 0 8px; font-size: 14px; }
.cos-options { display: flex; flex-wrap: wrap; gap: 8px; }
.cos-opt { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 9px; padding: 7px 12px; cursor: pointer; font-size: 13px; }
.cos-opt.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.cos-opt.locked { color: var(--muted); cursor: not-allowed; }
.cos-preview { padding: 12px 0; font-size: 18px; }

/* Профиль */
.profile-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-avatar { width: 64px; height: 64px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 30px; }
.profile-status { color: var(--muted); margin-top: 4px; }
.profile-bio { white-space: pre-wrap; word-break: break-word; margin: 14px 0; }
.post { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.post-text { white-space: pre-wrap; word-break: break-word; }
.post-meta { color: var(--muted); font-size: 12px; margin-top: 6px; display: flex; gap: 10px; align-items: center; }
.post-meta button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.post-meta button:hover { color: var(--accent); }
.comment { border-top: 1px dashed var(--border); padding: 8px 0; font-size: 14px; }
.comment-meta { color: var(--muted); font-size: 12px; }
.comment-meta button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0 4px; }
.comment-meta button:hover { color: var(--accent); }
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 5px; vertical-align: middle; }
.offline-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 5px; vertical-align: middle; opacity: .5; }

/* Hero */
.hero { padding: 46px 0 24px; text-align: center; }
.hero h1 { font-size: clamp(28px, 5vw, 44px); line-height: 1.15; margin: 0 0 12px; letter-spacing: -.02em; }
.hero p { color: var(--muted); font-size: 18px; max-width: 640px; margin: 0 auto; }

/* Tool grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin: 28px 0; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); text-decoration: none; }
.card .ico { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 11px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--accent); }
.card .ico .ic { width: 24px; height: 24px; }
.card h3 { margin: 10px 0 6px; font-size: 17px; color: var(--text); }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.cat-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin: 26px 0 10px; }

/* Tool page layout */
.tool-head { padding: 30px 0 8px; }
.breadcrumbs { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.breadcrumbs a { color: var(--muted); }
.tool-head h1 { font-size: clamp(24px, 4vw, 34px); margin: 0 0 8px; letter-spacing: -.02em; }
.tool-head .lead { color: var(--muted); font-size: 17px; margin: 0; max-width: 720px; }

.calc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin: 22px 0;
}
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.input, select.input {
  width: 100%; padding: 12px 14px; font-size: 16px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; outline: none;
}
.input:focus { border-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 7px; cursor: pointer; font-size: 14px; font-weight: 600; }
.seg button.active { background: var(--btn); color: #fff; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--btn); color: #fff; border: 0; border-radius: 10px;
  padding: 13px 20px; font-size: 16px; font-weight: 700; cursor: pointer; width: 100%;
}
.btn:hover { background: var(--btn-d); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* Result */
.result { margin-top: 18px; padding: 18px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--border); }
.result.hidden { display: none; }
.result .big { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.result .big small { font-size: 16px; font-weight: 600; color: var(--muted); }
.result-rows { margin-top: 12px; display: grid; gap: 8px; }
.result-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px dashed var(--border); }
.result-row:first-child { border-top: 0; }
.result-row span:first-child { color: var(--muted); }
.result-row span:last-child { font-weight: 700; }

/* Schedule table */
.table-wrap { overflow-x: auto; margin-top: 12px; }
table.sched { width: 100%; border-collapse: collapse; font-size: 14px; }
table.sched th, table.sched td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.sched th:first-child, table.sched td:first-child { text-align: left; }
table.sched th { color: var(--muted); font-weight: 600; }

/* Affiliate block */
.affiliate {
  display: flex; align-items: center; gap: 14px; margin: 18px 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 12px; padding: 16px 18px;
}
.affiliate .a-ico { font-size: 26px; }
.affiliate .a-text strong { display: block; font-size: 15px; }
.affiliate .a-text span { font-size: 13px; color: var(--muted); }
.affiliate .a-cta { margin-left: auto; white-space: nowrap; background: var(--cta); color: #fff; padding: 10px 16px; border-radius: 9px; font-weight: 700; font-size: 14px; }
.affiliate .a-cta:hover { background: var(--cta-d); text-decoration: none; }
.ad-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }

/* Ad slot */
.ad-slot { margin: 22px 0; min-height: 90px; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: 13px; background: var(--surface); }

/* Article */
.article { margin: 30px 0; }
.article h2 { font-size: 24px; margin: 28px 0 12px; letter-spacing: -.01em; }
.article h3 { font-size: 19px; margin: 22px 0 8px; }
.article p, .article li { color: var(--text); }
.article ul, .article ol { padding-left: 22px; }
.article .formula { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow-x: auto; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px 16px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 700; padding: 12px 0; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--muted); font-weight: 400; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0 0 14px; color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 50px; padding: 30px 0; background: var(--surface); }
.footer-cols { display: flex; flex-wrap: wrap; gap: 30px; justify-content: space-between; }
.footer-cols h4 { font-size: 14px; margin: 0 0 10px; }
.footer-cols a { display: block; color: var(--muted); font-size: 14px; padding: 3px 0; }
.footer-note { color: var(--muted); font-size: 12px; margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }

/* Cookie banner */
.cookie { position: fixed; left: 14px; right: 14px; bottom: 14px; max-width: 560px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 12px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; z-index: 100; font-size: 13px; }
.cookie.hidden { display: none; }
.cookie button { white-space: nowrap; background: var(--btn); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 700; cursor: pointer; }

@media (max-width: 720px) {
  .header-inner { gap: 10px; }
  .search { flex: 1 1 auto; min-width: 0; max-width: none; }
  .site-header .pc-extra { display: none !important; }
  .nav-all { display: none; }
  .admin-grid { grid-template-columns: 1fr; }
  .auth-area { flex: 0 0 auto; }
  .row, .row-3 { grid-template-columns: 1fr; }
  .hero { padding: 30px 0 16px; }
  .hero p { font-size: 16px; }
  .result .big { font-size: 24px; }
  .affiliate { flex-wrap: wrap; }
  .affiliate .a-cta { margin-left: 0; width: 100%; text-align: center; }
  .calc { padding: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}
@media (max-width: 460px) {
  .logo-text { display: none; }
  .container { padding: 0 14px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
}
