/* Inter - лежит у нас, не тянется с Google на каждой загрузке.
   Один переменный файл на начертание 100-900, подмножества латиницы и
   кириллицы. Обновлять - скриптом из истории этапа 2. */
/* cyrillic-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(/static/fonts/inter-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(/static/fonts/inter-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* latin-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(/static/fonts/inter-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(/static/fonts/inter-latin.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;
}

/* Fira Sans - основной шрифт интерфейса, лежит локально в
   static/fonts/fira-sans/. Веса 400/500/600/700, подмножества латиницы
   и кириллицы. Файлы - статические WOFF2 из Google Fonts (v18, дизайн
   Mozilla Foundation / Telefonica, лицензия OFL 1.1 рядом: OFL.txt).
   Inter выше оставлен нетронутым. Внешних font URL нет. */
/* Fira Sans 400 cyrillic-ext */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-400-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* Fira Sans 400 cyrillic */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-400-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* Fira Sans 400 latin-ext */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-400-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Fira Sans 400 latin */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-400-latin.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;
}
/* Fira Sans 500 cyrillic-ext */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-500-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* Fira Sans 500 cyrillic */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-500-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* Fira Sans 500 latin-ext */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-500-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Fira Sans 500 latin */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-500-latin.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;
}
/* Fira Sans 600 cyrillic-ext */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-600-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* Fira Sans 600 cyrillic */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-600-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* Fira Sans 600 latin-ext */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-600-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Fira Sans 600 latin */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-600-latin.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;
}
/* Fira Sans 700 cyrillic-ext */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-700-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* Fira Sans 700 cyrillic */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-700-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* Fira Sans 700 latin-ext */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-700-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Fira Sans 700 latin */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/fonts/fira-sans/fira-sans-700-latin.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;
}

/* Палитра. Тёмная тема — база (значения по умолчанию в :root),
   светлая включается атрибутом data-theme="light" на <html>.
   Атрибут ставится ещё в <head> из localStorage, см. templates/index.html. */
:root {
    color-scheme: dark;

    --bg: #0f1115;
    --bg-2: #14161c;
    --surface: #1a1d24;
    --surface-2: #1d2028;
    --border: #23262f;
    --border-2: #2a2e37;

    --text: #e8e8e8;
    --text-2: #c7cad1;
    --text-muted: #8a8f98;
    --text-faint: #565b66;

    --accent: #5b8def;
    --accent-hover: #4a7be0;
    --accent-soft: #26304a;
    --accent-soft-2: #2f3b5c;
    --accent-soft-border: #3d4d78;

    --danger: #f28b82;
    --danger-2: #e05a5a;
    --danger-bg: #3a1f1f;
    --danger-bg-strong: #7a2b2b;
    --danger-bg-stronger: #8f3333;
    --danger-border: #6b2b2b;

    --success: #4ebf7a;
    --warning: #e5a50a;

    --shadow: rgba(0, 0, 0, 0.4);
    --star-opacity: 0.5;
}

:root[data-theme="light"] {
    color-scheme: light;

    /* Фон - очень светлая лаванда; поверхности кнопок на пару тонов
       насыщеннее фона, чтобы кнопка читалась без обводки. */
    --bg: #f3f1fb;
    --bg-2: #faf9fe;
    --surface: #eae6f8;
    --surface-2: #e1dbf4;
    --border: #ded8f1;
    --border-2: #cec6e9;

    --text: #14121d;
    --text-2: #3a3450;
    --text-muted: #6b6386;
    --text-faint: #9d95b6;

    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-soft: #e8e0fc;
    --accent-soft-2: #dbcffa;
    --accent-soft-border: #c2adf3;

    --danger: #c0392b;
    --danger-2: #c0392b;
    --danger-bg: #fdecea;
    --danger-bg-strong: #d9534f;
    --danger-bg-stronger: #c9433f;
    --danger-border: #f1b8b3;

    --success: #1e8e4a;
    --warning: #a8760a;

    --shadow: rgba(40, 24, 84, 0.14);
    --star-opacity: 0;
}

/* Выбранное в светлой теме заливается ярким фиолетовым с белым текстом -
   в тёмной для этого хватает мягкой подложки. */
:root[data-theme="light"] .nav-item.active {
    background: var(--accent);
    color: #fff;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: "Fira Sans", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    background: var(--bg);
    color: var(--text);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-repeat: repeat;
    background-size: 220px 200px;
    background-image:
        radial-gradient(1px 1px at 18px 24px, rgba(255, 255, 255, 0.55), transparent 100%),
        radial-gradient(1px 1px at 64px 92px, rgba(255, 255, 255, 0.35), transparent 100%),
        radial-gradient(1.5px 1.5px at 112px 18px, rgba(255, 255, 255, 0.5), transparent 100%),
        radial-gradient(1px 1px at 150px 130px, rgba(255, 255, 255, 0.3), transparent 100%),
        radial-gradient(1px 1px at 190px 60px, rgba(255, 255, 255, 0.45), transparent 100%),
        radial-gradient(1.5px 1.5px at 40px 150px, rgba(255, 255, 255, 0.4), transparent 100%),
        radial-gradient(1px 1px at 100px 175px, rgba(255, 255, 255, 0.3), transparent 100%),
        radial-gradient(1px 1px at 205px 110px, rgba(255, 255, 255, 0.55), transparent 100%);
    opacity: var(--star-opacity);
}

.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

/* Sidebar */

/* Панель - отдельный блок: своя подложка, рамка и скруглённые углы, отбитые
   от края и от рабочей области. */
.sidebar {
    width: 288px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: 10px 0 10px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 10px;
    overflow: hidden;
}

.sidebar-top {
    padding-bottom: 10px;
}

.brand {
    font-size: 18px;
    font-weight: 700;
    padding: 8px 10px 4px;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 6px;
    color: var(--text);
    text-decoration: none;
}

.sidebar .brand:hover .brand-name {
    color: var(--accent);
}

.brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    object-fit: cover;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.user-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: var(--text-2);
}

.user-link {
    color: var(--accent);
    text-decoration: none;
}

.user-link:hover {
    text-decoration: underline;
}

.theme-toggle {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: 50%;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.theme-toggle:hover {
    background: var(--surface-2);
    border-color: var(--accent);
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 9px 12px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}

/* Значки штриховые: цвет берут у текста пункта, поэтому на залитой активной
   плашке сами становятся белыми. */
.nav-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.85;
}

.nav-label {
    flex: 1;
}

button.nav-item:hover {
    background: var(--surface-2);
}

.nav-item.active {
    background: var(--accent-soft);
    font-weight: 600;
}

.nav-item.active .nav-icon {
    opacity: 1;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 4px;
}

.history-block {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-search {
    position: relative;
    flex-shrink: 0;
}

.history-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    fill: none;
    stroke: var(--text-faint);
    stroke-width: 2;
    stroke-linecap: round;
    pointer-events: none;
}

.history-search input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: 10px;
    padding: 8px 10px 8px 34px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
}

.history-search input::placeholder {
    color: var(--text-faint);
}

.history-search input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Крестик очистки у type=search рисуется браузером тёмным и на тёмной теме
   пропадает - убираем и полагаемся на Esc и выделение. */
.history-search input::-webkit-search-cancel-button {
    display: none;
}

.history-group-title {
    padding: 8px 10px 2px;
    font-size: 12px;
    color: var(--text-muted);
}

.history-group-title:first-child {
    padding-top: 0;
}

.history-list {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-bottom {
    flex-shrink: 0;
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid var(--border);
}

.sidebar-danger-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid var(--border-2);
    border-radius: 10px;
    padding: 9px 12px;
    color: var(--text-2);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
}

.sidebar-danger-btn:hover {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger);
}

.history-empty {
    font-size: 12px;
    color: var(--text-faint);
    padding: 4px 10px;
}

.history-item {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 2px;
    border-radius: 8px;
    padding: 6px 4px 6px 10px;
    color: var(--text);
}

.history-item:hover {
    background: var(--surface-2);
}

.history-item.active {
    background: var(--accent-soft);
}

.history-item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    text-align: left;
    padding: 2px 0;
    font: inherit;
}

.history-title {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.history-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.history-menu-wrap {
    position: relative;
    flex-shrink: 0;
}

.history-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 6px;
}

.history-menu-btn:hover,
.history-menu-btn.active {
    background: var(--border);
    color: var(--text);
}

.history-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: 8px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 150px;
    z-index: 10;
    box-shadow: 0 8px 24px var(--shadow);
}

.history-menu[hidden] {
    display: none;
}

.history-menu-item {
    background: transparent;
    border: none;
    color: var(--text);
    text-align: left;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.history-menu-item:hover {
    background: var(--border);
}

.history-menu-item.danger {
    color: var(--danger);
}

.history-menu-item.danger:hover {
    background: var(--danger-bg);
}

/* Chat panel */

.chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chat-header-titles {
    min-width: 0;
}

.sidebar-toggle-btn {
    display: none;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    color: var(--text-2);
    font-size: 16px;
    cursor: pointer;
}

.sidebar-toggle-btn:hover {
    background: var(--surface-2);
}

.sidebar-backdrop {
    display: none;
}

.toolbar-logo {
    display: none;
}

/* Заголовок раздела на пустом экране совпадает краями с полем ввода. Две
   колонки держат название и пояснение рядом без двойного пустого отступа. */
.section-intro {
    position: absolute;
    left: 50%;
    top: calc(56% - 150px);
    transform: translate(-50%, -50%);
    /* У composer шириной 748px по 24px внутреннего отступа с каждой стороны:
       видимое поле и intro поэтому имеют одинаковую полезную ширину 700px. */
    width: min(700px, calc(100% - 48px));
    display: grid;
    grid-template-columns: minmax(0, 40fr) minmax(0, 60fr);
    align-items: center;
    pointer-events: none;
}

/* В изображениях поле и сетка шире текстовой колонки. Заголовок следует за
   шириной поля, а не за одним жёстким размером для всех разделов. */
.app.section-image .section-intro {
    width: min(852px, calc(100% - 48px));
}

.section-intro[hidden] {
    display: none;
}

.section-intro-title {
    margin: 0;
    padding-right: 12px;
    font-size: 32px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.section-intro-title > span {
    display: block;
    white-space: nowrap;
}

.section-intro-lead {
    margin: 0;
    padding-left: 12px;
    border-left: 1px solid var(--border-2);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-muted);
}

/* Подпись под полем ввода. */
.composer-note {
    margin: 0;
    padding: 0 24px 12px;
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-faint);
}

.chat-title {
    font-size: 16px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.ghost-btn {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border-2);
    color: var(--text-2);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
}

.ghost-btn:hover {
    background: var(--surface-2);
}

.chat-body {
    flex: 1;
    min-height: 0;
    position: relative;
}

/* Колонка текста - не шире 700px (у .msg-row 720px это ширина за вычетом
   собственных отступов строки). Читать длинные строки во всю ширину экрана
   тяжело, поэтому лента держится середины, а не краёв. */
.messages {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 24px 24px 12px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message-context-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: 8px;
    padding: 4px;
    min-width: 140px;
    z-index: 50;
    box-shadow: 0 8px 24px var(--shadow);
}

.message-context-menu[hidden] {
    display: none;
}

.message-context-menu .history-menu-item {
    width: 100%;
}

.msg-row {
    display: flex;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: default;
}

.msg-row.from-user {
    justify-content: flex-end;
}

.msg-row.from-bot {
    justify-content: flex-start;
}

.msg-row.selected {
    background: rgba(91, 141, 239, 0.16);
    outline: 1px solid rgba(91, 141, 239, 0.4);
}

.msg-content {
    display: block;
    width: fit-content;
    max-width: 78%;
}

/* Ответ модели читают, а не разглядывают: он занимает всю колонку. */
.from-bot .msg-content {
    width: 100%;
    max-width: 100%;
}

.bubble {
    padding: 11px 16px;
    border-radius: 16px;
    font-size: 16px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Вопрос - в спокойном сером пузыре: он короткий и служебный, кричать ему
   незачем. Ярким остаётся только то, на что нажимают. */
.from-user .bubble {
    background: var(--surface-2);
    color: var(--text);
    border-bottom-right-radius: 6px;
}

/* Ответ модели - свободный текст во всю колонку, без рамки и подложки.
   Его читают целыми абзацами, и рамка вокруг длинного текста только мешает. */
.from-bot .bubble {
    background: transparent;
    border: none;
    padding: 2px 0;
}

.bubble img {
    max-width: 100%;
    border-radius: 10px;
    display: block;
}

.bubble audio {
    max-width: 100%;
    display: block;
}

.speech-panel {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
}
.speech-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.speech-result { margin-top: 10px; }
/* Настоящий программный код (code/pre) - только локальный системный
   monospace-стек, без загрузки веб-шрифтов. Сейчас таких элементов в
   разметке нет: сообщения, включая раздел «Кодинг», рендерятся обычным
   текстом через textContent в .bubble, markdown-парсера нет. Правило
   защитное - на случай появления code/pre в будущем. */
code, pre {
    font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", "Courier New", monospace;
}
/* Расшифровка аудио - обычный текст, pre сохраняет только переносы.
   Шрифт - шрифт интерфейса (Fira Sans через inherit от body), а не
   monospace: селектор с классом специфичнее правила выше и побеждает. */
.speech-result pre { white-space: pre-wrap; margin: 0 0 8px; font: inherit; font-family: inherit; }
.section-transcription .input-shell,
.section-transcription .composer-note { display: none; }

/* ---------------------------------------------------------------------------
   Раздел изображений. Картинки рассматривают, а не читают, поэтому результаты
   стоят сеткой по 2-3 в ряд, а не лентой сообщений. Карточки складываются в
   одну сетку, пока идут подряд: одна отправка - один ряд.
--------------------------------------------------------------------------- */
/* Сетке нужна ширина: колонка текста ей мала. Просьба человека и поле ввода
   держатся той же ширины, что и сетка, - иначе левые края разъедутся. */
.app.section-image .composer,
.app.section-image .msg-row {
    max-width: 900px;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    align-items: start;
    gap: 16px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* Карточка в сетке шириной со свою ячейку - ограничения колонки
   на неё не распространяются. */
.image-grid .image-card {
    max-width: none;
    margin: 0;
    padding: 0;
}

.image-card .msg-content {
    width: 100%;
    max-width: 100%;
}

.image-card .bubble {
    padding: 0;
}

/* Карточка в сетке может растянуться на всю ширину ряда (900px, см. выше) -
   без верхней границы 16:9 при такой ширине не помещался по высоте на
   экране. Ограничиваем реальные width/max-width/max-height (не transform:
   scale - он не подвинул бы соседей и оставил бы пустое место в разметке),
   картинка остаётся с исходными пропорциями и просто центрируется в ячейке.
   Скачивание и сохранённый файл берут src напрямую - их эти правила не
   касаются. */
.image-card .bubble img {
    display: block;
    width: auto;
    height: auto;
    max-width: min(100%, 780px);
    max-height: 55vh;
    object-fit: contain;
    margin: 0 auto;
}

.media-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}

.media-actions .copy-btn,
.media-actions .download-btn,
.media-actions .repeat-btn {
    margin-top: 0;
}

.copy-btn,
.download-btn,
.repeat-btn {
    display: block;
    margin-top: 4px;
    background: transparent;
    border: none;
    color: var(--text-faint);
    font-size: 13px;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 6px;
    text-decoration: none;
    width: fit-content;
}

.copy-btn:hover,
.download-btn:hover,
.repeat-btn:hover {
    background: var(--surface-2);
    color: var(--text-2);
}

.copy-btn.copied {
    color: var(--accent);
}

#statusBar {
    min-height: 20px;
    padding: 0 24px;
    font-size: 13px;
    color: var(--text-muted);
}

#statusBar.error {
    color: var(--danger);
}

/* Поле ввода встаёт ровно под колонку текста: 748px за вычетом отступов -
   те же 700px, что и у сообщений. */
.composer {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 748px;
    width: 100%;
    margin: 0 auto;
    padding: 16px 24px 20px;
}

.composer.centered {
    position: absolute;
    top: 56%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0 24px;
}

/* Скрепка живёт внутри поля ввода, слева от остальных кнопок: margin-right
   разводит её и правую группу (модель, микрофон, отправка) по краям. */
.attach-btn {
    flex-shrink: 0;
    margin-right: auto;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Модели, которые не принимают картинку на вход, прячут скрепку через
   свойство hidden - без этого правила display:flex его перебивал, и кнопка
   оставалась на экране. */
.attach-btn[hidden] {
    display: none;
}

.attach-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

.attach-icon {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.composer-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

/* Параметры и переключатель режима делят одну строку: .image-options несёт
   три селекта, .image-mode-tabs (сегментированный Коллаж/Анализ) прижат
   вправо margin-left: auto. Оба остаются центрированы по высоте друг
   относительно друга через align-items на общем родителе. */
.image-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 2px 2px 4px;
}

.image-controls[hidden] {
    display: none;
}

.image-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 0;
}

.image-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.image-options .opt-short {
    display: none;
}

.image-options select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

.image-options select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Превью вложений живёт внутри .input-shell, над textarea - в границах той
   же рамки, что и остальное поле, а не отдельной полосой над ним. */
.attach-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px 0;
}

.attach-warning {
    margin: 8px 14px 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--danger);
}

.attach-preview-list[hidden],
.attach-warning[hidden],
.image-options[hidden],
.image-mode-tabs[hidden] {
    display: none;
}

/* Переключатель режима рубрики «Изображения»: коллаж/редактирование, с нуля,
   анализ. Список моделей под каждой вкладкой задаёт catalog.py (image_mode),
   разметка только переключает activeImageMode в app.js. */
.image-mode-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 0;
    margin-left: auto;
}

.image-mode-tab {
    flex: 0 0 auto;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-2);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

.image-mode-tab:hover {
    background: var(--surface-2);
    color: var(--text);
}

.image-mode-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.attach-thumb {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-2);
    background: var(--surface-2);
    flex-shrink: 0;
}

.attach-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.attach-thumb-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(15, 17, 21, 0.85);
    border: none;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.attach-thumb-remove:hover {
    background: var(--danger);
    color: var(--surface);
}

.input-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: 10px;
}

.input-shell:focus-within {
    border-color: var(--accent);
}

.input-shell textarea {
    width: 100%;
    resize: none;
    min-height: 64px;
    max-height: 380px;
    overflow-y: auto;
    background: transparent;
    color: var(--text);
    border: none;
    padding: 12px 14px 6px;
    /* 16px, как и текст сообщений. Заодно iOS не увеличивает страницу при
       попадании в поле - он делает это, только если шрифт мельче 16px. */
    font-size: 16px;
    font-family: inherit;
}

.input-shell textarea:focus {
    outline: none;
}

.input-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 4px 10px 10px;
}

/* Выбор модели. Это не <select>, а свой дропдаун: нативный список
   не умеет показывать описание второй строкой под названием модели. */
.model-select {
    position: relative;
    flex-shrink: 0;
}

.model-select-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 220px;
    height: 40px;
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--border-2);
    border-radius: 10px;
    padding: 0 8px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

.model-select-btn:hover,
.model-select-btn:focus,
.model-select.open .model-select-btn {
    outline: none;
    border-color: var(--accent);
}

.model-select-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-select-caret {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 10px;
}

.model-select.open .model-select-caret {
    transform: rotate(180deg);
}

.model-select-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    z-index: 30;
    width: 300px;
    max-width: min(300px, calc(100vw - 32px));
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 8px 24px var(--shadow);
}

.model-option {
    width: 100%;
    display: block;
    text-align: left;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
}

.model-option:hover {
    background: var(--surface-2);
}

.model-option.selected {
    background: var(--accent-soft);
}

.model-option-name {
    display: inline;
    font-size: 13px;
    font-weight: 600;
}

/* Явная отметка платной модели рядом с бесплатными в одном списке (например,
   Gemini 3 Flash Preview в чате), чтобы её не выбрали по ошибке вместо
   бесплатной. */
.model-option-paid {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--danger);
}

.mic-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-btn:hover {
    background: var(--accent-hover);
}

.mic-btn.listening {
    background: var(--danger-bg-strong);
    border-color: var(--danger);
    color: #fff;
    animation: mic-pulse 1.2s infinite;
}

.mic-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

@keyframes mic-pulse {
    0% { box-shadow: 0 0 0 0 rgba(242, 139, 130, 0.5); }
    70% { box-shadow: 0 0 0 8px rgba(242, 139, 130, 0); }
    100% { box-shadow: 0 0 0 0 rgba(242, 139, 130, 0); }
}

.send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: var(--accent-hover);
}

.send-btn.stop-mode {
    background: var(--danger-bg-strong);
}

.send-btn.stop-mode:hover {
    background: var(--danger-bg-stronger);
}

/* Auth pages (login / admin) */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 340px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    display: flex;
    flex-direction: column;
}

.auth-card .brand {
    text-align: center;
}

.auth-card h1 {
    font-size: 18px;
    margin: 0 0 18px;
    text-align: center;
}

.auth-card label,
.add-user-form label {
    font-size: 13px;
    color: var(--text-muted);
    margin: 10px 0 6px;
}

.auth-card input,
.add-user-form input[type="text"],
.add-user-form input[type="password"] {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border-2);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
}

.password-field {
    position: relative;
}

.password-field input[type="password"],
.password-field input[type="text"] {
    width: 100%;
    padding-right: 40px;
}

.password-field .password-toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    padding: 6px 8px;
    cursor: pointer;
    margin-top: 0;
}

.password-field .password-toggle:hover {
    background: transparent;
    color: var(--text);
}

.auth-card input:focus,
.add-user-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-card button,
.add-user-form button {
    margin-top: 18px;
    padding: 11px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.auth-card button:hover,
.add-user-form button:hover {
    background: var(--accent-hover);
}

.auth-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

.admin-card {
    width: 100%;
    max-width: 620px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.admin-header .brand {
    padding: 0;
}

.spend-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.spend-stat {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
}

.spend-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.spend-stat-value {
    font-size: 20px;
    font-weight: 600;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 24px;
}

.user-table th,
.user-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.user-table th {
    color: var(--text-muted);
    font-weight: 600;
}

.models-checked-at {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 8px;
}

.model-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.model-badge-ok {
    background: rgba(78, 191, 122, 0.15);
    color: var(--success);
}

.model-badge-bad {
    background: rgba(224, 90, 90, 0.15);
    color: var(--danger-2);
}

.add-user-form {
    display: flex;
    flex-direction: column;
}

.add-user-form h2 {
    font-size: 15px;
    margin: 0 0 4px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-2);
}

.checkbox-label input {
    width: auto;
}

/* Mobile layout */

@media (max-width: 768px) {
    .sidebar-toggle-btn {
        display: flex;
    }

    /* На телефоне заголовок раздела разворачивается в столбик: черта из
       вертикальной становится горизонтальной. */
    .section-intro {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        top: calc(50% - 130px);
        width: calc(100% - 28px);
    }

    .section-intro-title {
        padding-right: 0;
        max-width: 100%;
        font-size: 26px;
    }

    .section-intro-lead {
        padding: 12px 0 0;
        border-left: none;
        border-top: 1px solid var(--border-2);
        font-size: 14px;
    }

    .app.section-image .section-intro {
        width: calc(100% - 28px);
    }

    .composer-note {
        padding: 0 14px 10px;
        font-size: 11px;
    }

    /* Выехавшая панель занимает всю высоту экрана - рамка и отступы,
       которые делают из неё отдельный блок, здесь только мешают. */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 200;
        width: 82vw;
        max-width: 300px;
        margin: 0;
        border: none;
        border-right: 1px solid var(--border);
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 4px 0 24px var(--shadow);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
    }

    .sidebar-backdrop[hidden] {
        display: none;
    }

    .chat {
        width: 100%;
        min-width: 0;
    }

    .chat-header {
        padding: 12px 14px;
    }

    .chat-title {
        font-size: 15px;
    }

    .messages {
        padding: 14px;
    }

    .msg-content {
        max-width: 88%;
    }

    .bubble {
        font-size: 15px;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }

    .composer {
        padding: 12px 14px 14px;
        gap: 6px;
    }

    .attach-btn {
        width: 32px;
        height: 32px;
    }

    .attach-thumb {
        width: 54px;
        height: 54px;
    }

    /* The three image controls wrapped onto two or three lines here. Forbid
       wrapping: labels hold their width, the selects absorb the shrinking, so
       the row fits without needing exact text metrics. (The -42px pull that
       used to compensate for the attach button outside the field went away
       with the button itself - it now sits inside the input.) */
    /* .image-options занимает всю ширину строки сама - тогда переключателю
       режима не остаётся места и он аккуратно переносится на вторую строку
       (без wrap внутри самих трёх селектов, см. ниже). */
    .image-controls {
        gap: 8px;
    }

    .image-options {
        flex: 1 1 100%;
        flex-wrap: nowrap;
        gap: 8px;
        font-size: 11px;
    }

    .image-options label {
        flex: 1 1 auto;
        min-width: 0;
        gap: 4px;
        font-size: 11px;
        white-space: nowrap;
    }

    .image-options select {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 11px;
    }

    .image-options .opt-full {
        display: none;
    }

    .image-options .opt-short {
        display: inline;
    }

    .model-select-btn {
        max-width: min(220px, calc(100vw - 140px));
        font-size: 12px;
    }

    .toolbar-logo {
        display: block;
        flex-shrink: 0;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        object-fit: cover;
    }

    .mic-btn,
    .send-btn {
        width: 36px;
        height: 36px;
    }

    .input-toolbar {
        position: relative;
        gap: 6px;
        padding: 4px 6px 8px;
    }

    /* The menu is right-anchored. Hanging it off .model-select left it only
       100vw - 104px of room (send + mic buttons and their gaps sit to its
       right), so a 300px menu ran off the LEFT edge below ~404px - and being
       off-screen to the left, no scrollbar could reach it. Anchoring to the
       toolbar instead puts its right edge ~14px from the viewport, which is
       what the existing calc(100vw - 32px) cap already assumed. */
    .model-select {
        position: static;
    }

    #statusBar {
        padding: 0 14px;
    }

    .composer.centered {
        top: 50%;
        padding: 0 14px;
    }
}

/* ---------------------------------------------------------------------------
   Раздел без моделей (пока — только /video). Переписки и поля ввода нет,
   на экране остаётся заголовок раздела с пояснением.
--------------------------------------------------------------------------- */
.app.section-video .chat-body,
.app.section-video .composer,
.app.section-video .composer-note,
.app.section-video #statusBar {
    display: none;
}

/* ---------------------------------------------------------------------------
   Публичная главная (/). Открыта без входа - это единственная страница,
   которую видит незалогиненный человек и поисковик.
--------------------------------------------------------------------------- */
.home-body {
    height: auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
}

.home-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 18px;
}

.home-logo img {
    width: 30px;
    height: 30px;
}

.home-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.home-nav a {
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
}

.home-nav a:hover {
    background: var(--surface);
    color: var(--text);
}

.home-nav .home-login-btn {
    margin-left: 6px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.home-nav .home-login-btn:hover {
    background: var(--accent-hover);
    color: #fff;
}

.home-main {
    flex: 1;
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: 0 20px 64px;
}

/* Первый экран помещается в экран целиком: шапка, логотип, название,
   переключатель задачи и поле ввода. Всё остальное - ниже, за
   стрелкой. 72px - высота шапки. */
.hero {
    position: relative;
    min-height: calc(100vh - 72px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 0 72px;
}

@supports (height: 100dvh) {
    /* На телефонах адресная строка съедает часть 100vh - dvh считает честно. */
    .hero {
        min-height: calc(100dvh - 72px);
    }
}

.scroll-down {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-2);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-2);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.scroll-down:hover {
    background: var(--surface-2);
    color: var(--text);
}

.home-rest {
    padding-bottom: 8px;
}

.hero-logo {
    width: 76px;
    height: 76px;
    margin-bottom: 18px;
}

.hero-title {
    margin: 0;
    font-size: 64px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* Переключатель задачи и поле запроса */
.starter {
    width: 100%;
    max-width: 720px;
    margin-top: 20px;
}

.starter-tasks {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.starter-task {
    padding: 9px 20px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-2);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
}

.starter-task:hover {
    background: var(--surface-2);
    color: var(--text);
}

.starter-task.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Поиск и Кодинг в этом ряду - только на мобильном, где помещаются все 6
   рубрик; на десктопе ряд остаётся из 4, как был. */
.starter-task-mobile {
    display: none;
}

.starter-task .label-short {
    display: none;
}

.starter-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 18px;
    border: 1px solid var(--border-2);
    border-radius: 999px;
    background: var(--bg-2);
    box-shadow: 0 2px 10px var(--shadow);
}

.starter-input input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
    padding: 8px 0;
}

.starter-input input::placeholder {
    color: var(--text-faint);
}

.starter-input .mic-btn {
    width: 38px;
    height: 38px;
    font-size: 15px;
}

.home-model-select {
    position: relative;
    flex: 0 1 auto;
    min-width: 0;
}

.home-model-select-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 170px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--border-2);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

#homeModelSelectValue {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-model-select-caret {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 10px;
}

.home-model-select.open .home-model-select-caret {
    transform: rotate(180deg);
}

.home-model-select-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 40;
    width: 260px;
    max-width: calc(100vw - 32px);
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border-2);
    border-radius: 12px;
    background: var(--bg-2);
    box-shadow: 0 8px 24px var(--shadow);
}

.home-model-option {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.home-model-option:hover,
.home-model-option.selected {
    background: var(--accent-soft);
}

.starter-submit {
    border: none;
    border-radius: 999px;
    padding: 11px 24px;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.starter-submit:hover {
    background: var(--accent-hover);
}

.starter-submit:disabled,
.starter-input input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.starter-note {
    margin: 10px 0 0;
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
}

/* Плитки разделов */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    padding-top: 24px;
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-2);
    text-decoration: none;
    color: var(--text);
}

.tile:hover {
    border-color: var(--accent-soft-border);
    background: var(--surface);
}

.tile-title {
    font-size: 18px;
    font-weight: 600;
}

.tile-desc {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-muted);
}

.tile-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    font-size: 14px;
}

.tile-count {
    color: var(--text-faint);
}

.tile-price {
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-2);
}

.tile-price-free {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

/* Рассказ о сервисе - колонка не шире 700px, как договорились */
.about {
    max-width: 700px;
    margin: 56px auto 0;
}

.about h2 {
    margin: 0 0 12px;
    font-size: 24px;
    font-weight: 600;
}

.about p {
    margin: 0 0 14px;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-2);
}

.home-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    border-top: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 14px;
}

.home-footer a {
    color: var(--text-muted);
    text-decoration: none;
}

.home-footer a:hover {
    color: var(--text);
}

@media (max-width: 768px) {
    .home-header {
        padding: 10px 14px;
        flex-wrap: nowrap;
    }

    /* Компактный логотип по образцу принципа мобильной шапки DeepAI - свой
       текст, свой шрифт, просто чуть меньше, чем на десктопе. */
    .home-logo {
        gap: 8px;
        font-size: 16px;
    }

    .home-logo img {
        width: 26px;
        height: 26px;
    }

    /* Список рубрик и логин-кнопка в шапке уходят под гамбургер - иначе не
       помещаются в ряд и наезжают на логотип (см. плашку .home-mobile-menu
       ниже). Кнопка темы - обычный button, .home-nav a её не трогает. */
    .home-nav {
        flex-wrap: nowrap;
        gap: 8px;
    }

    .home-nav a {
        display: none;
    }

    .home-mobile-menu {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: 0;
        z-index: 300;
        padding: 20px;
        background: var(--bg-2);
    }

    .home-mobile-menu[hidden] {
        display: none;
    }

    .home-mobile-menu-close {
        align-self: flex-end;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 20px;
        border: 1px solid var(--border-2);
        border-radius: 8px;
        background: transparent;
        color: var(--text-2);
        font-size: 18px;
        cursor: pointer;
    }

    .home-mobile-menu-close:hover {
        background: var(--surface-2);
    }

    .home-mobile-menu a {
        padding: 16px 4px;
        border-bottom: 1px solid var(--border);
        color: var(--text);
        text-decoration: none;
        font-size: 20px;
        font-weight: 600;
    }

    .home-mobile-menu a:last-of-type {
        border-bottom: none;
    }

    .hero {
        padding: 24px 0 64px;
    }

    .hero-title {
        font-size: 44px;
    }

    .hero-logo {
        width: 60px;
        height: 60px;
    }

    /* Все 6 рубрик в один ряд: подписи короче (label-short вместо label-full),
       таблетки уже. Ширина промерена реальным шрифтом Inter (вес 500,
       inter-cyrillic.woff2): при font-size 11px / padding 6px 8px / gap 4px
       сумма ширин - 305.5px против 335px доступных на экране 375px (запас
       ~30px), перенос и горизонтальная прокрутка не нужны. */
    .starter-task-mobile {
        display: inline-flex;
    }

    .starter-tasks {
        flex-wrap: nowrap;
        gap: 4px;
    }

    .starter-task {
        flex: 0 0 auto;
        padding: 6px 8px;
        font-size: 11px;
        white-space: nowrap;
    }

    .starter-task .label-full {
        display: none;
    }

    .starter-task .label-short {
        display: inline;
    }

    .starter-input {
        padding-left: 14px;
    }

    .home-model-select-btn {
        max-width: 112px;
        padding: 0 8px;
        font-size: 12px;
    }

    .home-model-select {
        position: static;
    }

    .starter-input {
        position: relative;
    }

    .starter-submit {
        padding: 10px 16px;
    }

    .about {
        margin-top: 40px;
    }
}

/* ---------------------------------------------------------------------------
   Карточка модели на пустом экране раздела: /chat/<модель> и подобные.
--------------------------------------------------------------------------- */
.model-intro {
    max-width: 700px;
    margin: 40px auto 0;
    padding: 0 16px;
    text-align: center;
}

.model-intro-name {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.model-intro-desc {
    margin: 10px 0 14px;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-muted);
}

.model-intro-price {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 14px;
    cursor: help;
}

.model-intro-price.free {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

/* Логотип на форме входа - ссылка на публичную главную. */
.auth-brand {
    display: block;
    text-align: center;
    text-decoration: none;
    color: var(--text);
}
