/* /public/assets/css/internal-ui.css
 *
 * Операторский слой оформления для закрытого внутреннего инструмента.
 * Подключается ПОСЛЕДНИМ (см. app/templates/dashboard/document-head.php),
 * поэтому переопределяет потребительский вид из dashboard.css / public.css.
 *
 * Принципы:
 *   - тёмная нейтральная палитра по умолчанию, без градиентов и декора;
 *   - плотная сетка: информационная единица — строка таблицы, а не карточка;
 *   - один акцентный цвет, только на главном действии экрана;
 *   - системный гротеск, табличные цифры для чисел;
 *   - компактные отступы, минимум «воздуха».
 */

/* ---------- 1. Токены ---------- */
:root {
    --ui-bg: #0e1013;
    --ui-surface: #14171c;
    --ui-surface-2: #191d23;
    --ui-surface-3: #1f242c;
    --ui-text: #e4e7eb;
    --ui-text-strong: #f4f6f8;
    --ui-muted: #8a919c;
    --ui-muted-2: #6b727d;
    --ui-line: #262b33;
    --ui-line-strong: #333a44;

    /* единственный акцент — действие */
    --ui-accent: #4d7cff;
    --ui-accent-hover: #628bff;
    --ui-accent-dim: rgba(77, 124, 255, 0.14);

    /* статусные цвета: только смысл, не украшение */
    --ui-ok: #3f9d6a;
    --ui-ok-dim: rgba(63, 157, 106, 0.14);
    --ui-warn: #c08a2e;
    --ui-warn-dim: rgba(192, 138, 46, 0.14);
    --ui-danger: #d05a52;
    --ui-danger-dim: rgba(208, 90, 82, 0.14);
    --ui-info: #5a7fa8;
    --ui-info-dim: rgba(90, 127, 168, 0.14);

    --ui-radius: 6px;
    --ui-radius-sm: 4px;
    --ui-gap: 12px;
    --ui-gap-sm: 8px;
    --ui-pad: 16px;

    --ui-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ui-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --ui-fs: 13px;
    --ui-fs-sm: 12px;
    --ui-fs-xs: 11px;
    --ui-fs-lg: 15px;
    --ui-fs-title: 20px;

    /* переопределяем старые токены, чтобы унаследованные правила попали в палитру */
    --bg: var(--ui-bg);
    --surface: var(--ui-surface);
    --surface-muted: var(--ui-surface-2);
    --text: var(--ui-text);
    --muted: var(--ui-muted);
    --line: var(--ui-line);
    --accent: var(--ui-accent);
    --accent-hover: var(--ui-accent-hover);
    --success: var(--ui-ok);
    --success-bg: var(--ui-ok-dim);
    --danger: var(--ui-danger);
    --danger-bg: var(--ui-danger-dim);
    --sidebar-width: 232px;
    --navigator-width: 288px;
}

/* старая «тёмная тема» и «крафт» больше не нужны — интерфейс всегда тёмный */
html[data-theme="kraft"] {
    --bg: var(--ui-bg);
    --surface: var(--ui-surface);
}

/* ---------- 2. База ---------- */
html {
    color-scheme: dark;
}

body {
    min-width: 320px;
    background: var(--ui-bg);
    color: var(--ui-text);
    font-family: var(--ui-font);
    font-size: var(--ui-fs);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

/* Никакого декоративного фона-градиента из public.css */
body::before,
body::after {
    display: none !important;
}

h1,
h2,
h3,
h4 {
    color: var(--ui-text-strong);
    font-family: var(--ui-font);
    font-weight: 600;
    letter-spacing: -0.01em;
}

a {
    color: var(--ui-text);
    text-decoration-color: var(--ui-line-strong);
}

a:hover {
    color: #fff;
}

::selection {
    background: var(--ui-accent-dim);
}

:focus-visible {
    outline: 2px solid var(--ui-accent);
    outline-offset: 1px;
}

/* скрываем декоративные SVG-иллюстрации потребительского интерфейса */
.empty-books-state-icon {
    display: none !important;
}

/* ---------- 3. Каркас: 2 колонки, навигатор — по необходимости ---------- */
.app {
    display: grid;
    min-height: 100vh;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    background: var(--ui-bg);
}

.app.has-navigator {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--navigator-width);
}

.sidebar {
    padding: 0;
    border-right: 1px solid var(--ui-line);
    background: var(--ui-surface);
}

.sidebar-right {
    padding: 0;
    border-left: 1px solid var(--ui-line);
    border-right: 0;
    background: var(--ui-surface);
}

/* правая панель нужна только в генераторе (навигатор структуры) */
.app:not(.has-navigator) .sidebar-right,
.app:not(.has-navigator) .navigator-toggle {
    display: none !important;
}

.workspace {
    padding: 0;
    height: 100dvh;
    overflow-y: auto;
    background: var(--ui-bg);
}

/* ---------- 4. Боковая навигация ---------- */
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 var(--ui-pad);
    border-bottom: 1px solid var(--ui-line);
    color: var(--ui-text-strong);
    font-size: var(--ui-fs-lg);
    font-weight: 600;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.brand:hover {
    color: #fff;
}

.brand-logo {
    width: 20px;
    height: 20px;
    filter: grayscale(1) brightness(2.4);
    opacity: 0.9;
}

.menu-title {
    margin: 0;
    padding: 16px var(--ui-pad) 6px;
    color: var(--ui-muted-2);
    font-size: var(--ui-fs-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.menu {
    display: flex;
    flex-direction: column;
    padding: 0 8px 8px;
    gap: 1px;
}

.menu a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--ui-radius-sm);
    color: var(--ui-text);
    font-size: var(--ui-fs);
    font-weight: 500;
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease;
}

.menu a:hover {
    background: var(--ui-surface-3);
    color: #fff;
}

.menu a.active {
    background: var(--ui-surface-3);
    color: #fff;
    box-shadow: inset 2px 0 0 var(--ui-accent);
}

/* счётчик в пункте меню */
.menu a .menu-count {
    color: var(--ui-muted);
    font-size: var(--ui-fs-xs);
    font-variant-numeric: tabular-nums;
}

.menu-logout-form {
    margin: 0;
    padding: 0;
}

.menu-logout {
    display: flex;
    width: 100%;
    align-items: center;
    padding: 7px 10px;
    border: 0;
    border-radius: var(--ui-radius-sm);
    background: transparent;
    color: var(--ui-muted);
    font: inherit;
    font-size: var(--ui-fs);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.menu-logout:hover {
    background: var(--ui-surface-3);
    color: var(--ui-danger);
}

.menu-administration {
    margin: 8px 0 0;
    padding-top: 8px;
    border-top: 1px solid var(--ui-line);
}

.menu-administration .menu-title {
    padding-top: 4px;
}

/* ---------- 5. Верхняя панель ---------- */
.page-header-menu {
    display: none;
    width: 32px;
    height: 32px;
    flex: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius-sm);
    background: transparent;
    color: var(--ui-text);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.page-header-menu:hover {
    background: var(--ui-surface-3);
    color: #fff;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0;
    padding: 14px var(--ui-pad);
    border-bottom: 1px solid var(--ui-line);
    background: var(--ui-surface);
    position: sticky;
    top: 0;
    z-index: 20;
}

.page-header-main {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.page-header h1 {
    margin: 0;
    font-size: var(--ui-fs-title);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.page-header-subtitle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.subtitle {
    margin: 0;
    color: var(--ui-muted);
    font-size: var(--ui-fs-sm);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* «таблетки» в шапке: баланс/тема/профиль превращаем в плоские кнопки */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius-sm);
    background: transparent;
    color: var(--ui-text);
    font: inherit;
    font-size: var(--ui-fs-sm);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.theme-toggle:hover {
    background: var(--ui-surface-3);
    color: #fff;
}

/* ---------- 6. Контент ---------- */
.content-grid {
    display: flex;
    flex-direction: column;
    gap: var(--ui-gap);
    padding: var(--ui-pad);
}

.card {
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    box-shadow: none;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px var(--ui-pad);
    border-bottom: 1px solid var(--ui-line);
    background: var(--ui-surface-2);
}

.card-header h2,
.card-header h3 {
    margin: 0;
    font-size: var(--ui-fs);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.card-body {
    padding: var(--ui-pad);
}

/* ---------- 7. Кнопки: один акцент ---------- */
.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 30px;
    padding: 5px 12px;
    border: 1px solid transparent;
    border-radius: var(--ui-radius-sm);
    background: var(--ui-accent);
    color: #fff;
    font: inherit;
    font-size: var(--ui-fs-sm);
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none;
    transition: background 120ms ease;
}

.button:hover {
    background: var(--ui-accent-hover);
    color: #fff;
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* вторичное действие — нейтральная рамка, без заливки */
.button-secondary,
.button.button-secondary,
.button-ghost {
    border-color: var(--ui-line-strong);
    background: transparent;
    color: var(--ui-text);
}

.button-secondary:hover,
.button-ghost:hover {
    background: var(--ui-surface-3);
    color: #fff;
}

.button-danger {
    border-color: rgba(208, 90, 82, 0.5);
    background: transparent;
    color: #f09a94;
}

.button-danger:hover {
    background: var(--ui-danger-dim);
    color: #ffc2bd;
}

/* компактная кнопка для строк таблицы */
.button-sm {
    min-height: 24px;
    padding: 2px 8px;
    font-size: var(--ui-fs-xs);
}

.button-loader {
    width: 11px;
    height: 11px;
    border-width: 1.5px;
}

/* ---------- 8. Сводка на рабочем столе ---------- */
.desk-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1px;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
    background: var(--ui-line);
    overflow: hidden;
}

.desk-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px var(--ui-pad);
    background: var(--ui-surface);
    min-width: 0;
}

.desk-metric-label {
    color: var(--ui-muted);
    font-size: var(--ui-fs-xs);
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.desk-metric-value {
    color: var(--ui-text-strong);
    font-size: 22px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.desk-metric-value.is-ok {
    color: var(--ui-ok);
}

.desk-metric-value.is-warn {
    color: var(--ui-warn);
}

.desk-metric-value.is-danger {
    color: var(--ui-danger);
}

.desk-metric-hint {
    color: var(--ui-muted-2);
    font-size: var(--ui-fs-xs);
    font-variant-numeric: tabular-nums;
}

.desk-metric.is-action {
    cursor: pointer;
    text-decoration: none;
}

.desk-metric.is-action:hover {
    background: var(--ui-surface-2);
}

/* ---------- 9. Таблицы: основная информационная единица ---------- */
.data-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--ui-fs);
    min-width: 720px;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 8px 12px;
    border-bottom: 1px solid var(--ui-line-strong);
    background: var(--ui-surface-2);
    color: var(--ui-muted);
    font-size: var(--ui-fs-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--ui-line);
    color: var(--ui-text);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover td {
    background: var(--ui-surface-2);
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.data-table .col-title {
    max-width: 340px;
    min-width: 200px;
}

.data-table .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.data-table a.row-link {
    color: var(--ui-text-strong);
    font-weight: 500;
    text-decoration: none;
}

.data-table a.row-link:hover {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.data-table .row-sub {
    margin-top: 1px;
    color: var(--ui-muted-2);
    font-size: var(--ui-fs-xs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 340px;
}

.data-table .cell-mono {
    font-family: var(--ui-mono);
    font-size: var(--ui-fs-xs);
    color: var(--ui-muted);
}

/* мини-прогресс в строке */
.row-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 96px;
}

.row-progress-track {
    flex: 1 1 auto;
    height: 4px;
    border-radius: 2px;
    background: var(--ui-surface-3);
    overflow: hidden;
}

.row-progress-fill {
    height: 100%;
    background: var(--ui-accent);
    border-radius: inherit;
}

.row-progress-fill.is-ok {
    background: var(--ui-ok);
}

.row-progress-value {
    color: var(--ui-muted);
    font-size: var(--ui-fs-xs);
    font-variant-numeric: tabular-nums;
    min-width: 30px;
    text-align: right;
}

/* ---------- 10. Статусы ---------- */
.status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 7px;
    border: 1px solid var(--ui-line-strong);
    border-radius: 999px;
    color: var(--ui-text);
    font-size: var(--ui-fs-xs);
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
}

.status::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.status-ok {
    border-color: rgba(63, 157, 106, 0.4);
    background: var(--ui-ok-dim);
    color: #7dd3a0;
}

.status-work {
    border-color: rgba(77, 124, 255, 0.4);
    background: var(--ui-accent-dim);
    color: #9ab4ff;
}

.status-warn {
    border-color: rgba(192, 138, 46, 0.4);
    background: var(--ui-warn-dim);
    color: #e0b566;
}

.status-danger {
    border-color: rgba(208, 90, 82, 0.4);
    background: var(--ui-danger-dim);
    color: #f09a94;
}

.status-idle {
    border-color: var(--ui-line-strong);
    background: transparent;
    color: var(--ui-muted);
}

/* ---------- 11. Компактные списки вместо карточек ---------- */
.projects.projects-dashboard,
.projects {
    display: block;
    gap: 0;
}

/* карточки книг в потребительском виде больше не используются —
   список книг выводится таблицей (books-list.php). */

.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--ui-gap);
}

.story-card {
    min-height: 0;
    padding: 12px 14px;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    box-shadow: none;
}

.story-card:hover {
    border-color: var(--ui-line-strong);
}

.story-card-title-row h3 {
    margin: 0;
    font-size: var(--ui-fs);
    font-weight: 600;
}

.story-card-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
    margin: 10px 0;
    font-size: var(--ui-fs-xs);
}

.story-card-meta dt {
    color: var(--ui-muted-2);
}

.story-card-meta dd {
    margin: 0;
    color: var(--ui-text);
}

.story-card-logline {
    margin: 0 0 10px;
    color: var(--ui-muted);
    font-size: var(--ui-fs-sm);
    line-height: 1.5;
}

/* ---------- 12. Формы ---------- */
input,
textarea,
select {
    font-family: var(--ui-font);
}

.form-field input,
.form-field textarea,
.form-field select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea,
select {
    border-color: var(--ui-line-strong);
    background: var(--ui-surface-2);
    color: var(--ui-text);
    border-radius: var(--ui-radius-sm);
    font-size: var(--ui-fs);
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: var(--ui-accent);
    outline: none;
    box-shadow: 0 0 0 2px var(--ui-accent-dim);
}

label {
    color: var(--ui-text);
    font-size: var(--ui-fs-sm);
}

/* ---------- 13. Пустые состояния ---------- */
.empty,
.empty-books-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px 20px;
    min-height: 0;
    border: 1px dashed var(--ui-line-strong);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    color: var(--ui-muted);
    font-size: var(--ui-fs);
    text-align: center;
}

.empty-books-state p {
    margin: 0;
}

.empty-books-state-action {
    margin-top: 2px;
}

/* ---------- 14. Алерты и флеши ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface-2);
    color: var(--ui-text);
    font-size: var(--ui-fs-sm);
}

.alert-success {
    border-color: rgba(63, 157, 106, 0.4);
    background: var(--ui-ok-dim);
    color: #a7e0c0;
}

.alert-error,
.alert-danger {
    border-color: rgba(208, 90, 82, 0.4);
    background: var(--ui-danger-dim);
    color: #f5b7b2;
}

/* ---------- 15. Правая панель (навигатор структуры) ---------- */
.navigator-head,
.sidebar-right > .card-header {
    padding: 12px var(--ui-pad);
    border-bottom: 1px solid var(--ui-line);
}

.sidebar-right h2,
.sidebar-right h3 {
    margin: 0;
    font-size: var(--ui-fs);
    font-weight: 600;
}

.tree-item,
.tree-part {
    border-radius: var(--ui-radius-sm);
    font-size: var(--ui-fs-sm);
}

/* ---------- 16. Экран входа ---------- */
.auth-page {
    min-height: 100vh;
    background: var(--ui-bg);
    color: var(--ui-text);
}

.auth-backdrop {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--ui-bg);
}

.auth-modal {
    width: min(100%, 360px);
    padding: 28px 26px 24px;
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    box-shadow: none;
}

.auth-modal h1 {
    margin: 0 0 4px;
    color: var(--ui-text-strong);
    font-size: var(--ui-fs-title);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    margin: 0 0 20px;
    color: var(--ui-muted);
    font-size: var(--ui-fs-sm);
}

.auth-close {
    display: none;
}

.auth-modal .form-field {
    margin-bottom: 10px;
}

.auth-modal .form-field input {
    width: 100%;
    height: 34px;
    padding: 0 10px;
}

.auth-submit {
    width: 100%;
    height: 34px;
    margin-top: 4px;
    border: 0;
    border-radius: var(--ui-radius-sm);
    background: var(--ui-accent);
    color: #fff;
    font: inherit;
    font-size: var(--ui-fs-sm);
    font-weight: 600;
    cursor: pointer;
}

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

.auth-switch {
    margin: 14px 0 0;
    color: var(--ui-muted-2);
    font-size: var(--ui-fs-xs);
    text-align: center;
}

.auth-errors {
    margin-bottom: 12px;
    padding: 8px 10px;
    border: 1px solid rgba(208, 90, 82, 0.4);
    border-radius: var(--ui-radius-sm);
    background: var(--ui-danger-dim);
    color: #f5b7b2;
    font-size: var(--ui-fs-sm);
}

.auth-errors p {
    margin: 0 0 4px;
}

.auth-errors p:last-child {
    margin-bottom: 0;
}

/* ---------- 17. Юридический футер и cookie — убраны из разметки ---------- */
.legal-footer,
.cookie-notice {
    display: none !important;
}

/* ---------- 17.1 Мобильное меню ---------- */
.internal-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(6, 8, 10, 0.6);
}

@media (min-width: 901px) {
    .internal-menu-backdrop {
        display: none;
    }
}

body.internal-menu-open {
    overflow: hidden;
}

/* ---------- 18. Скроллбары ---------- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--ui-line-strong) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 6px;
    background-clip: content-box;
    background-color: var(--ui-line-strong);
}

*::-webkit-scrollbar-thumb:hover {
    background-color: #454d59;
}


/* ---------- 20. Экран «Новая книга»: компактный выбор режима ---------- */
.new-project-choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--ui-gap);
    width: 100%;
    max-width: none;
    margin: 0 0 var(--ui-gap);
    padding: 0;
}

.new-project-choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-items: start;
    place-items: start;
    gap: 3px;
    min-height: 0;
    padding: 14px 16px;
    font-size: var(--ui-fs);
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.45;
    text-align: left;
    transform: none !important;
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    color: var(--ui-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease;
}

.new-project-choice:hover {
    border-color: var(--ui-accent);
    background: var(--ui-surface-2);
}

.new-project-choice svg {
    display: none;
}

/* снимаем декоративные градиенты и «свечения» потребительского вида */
.new-project-choice::before,
.new-project-choice::after {
    content: none !important;
    display: none !important;
    background: none !important;
}

html[data-theme="dark"] .new-project-choice,
.new-project-choice {
    background-image: none !important;
    box-shadow: none !important;
}

.new-project-choice > span {
    display: block;
    max-width: none;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
}

.new-project-choice-title {
    color: var(--ui-text-strong);
    font-size: var(--ui-fs);
    font-weight: 600;
}

.new-project-choice-desc {
    color: var(--ui-muted);
    font-size: var(--ui-fs-sm);
    font-weight: 400;
}

.new-project-choice-title {
    color: var(--ui-text-strong);
    font-size: var(--ui-fs);
    font-weight: 600;
}

.new-project-choice-desc {
    color: var(--ui-muted);
    font-size: var(--ui-fs-sm);
}

/* диалоги создания книги: убираем декоративные тени/градиенты потребительского вида */
.new-project-dialog,
.generator-entity-modal,
dialog[class*="dialog"] {
    border: 1px solid var(--ui-line-strong);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    color: var(--ui-text);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.new-project-dialog::backdrop,
.generator-entity-modal::backdrop,
dialog::backdrop {
    background: rgba(6, 8, 10, 0.72);
}

.new-project-dialog-header h2,
.new-project-dialog h2 {
    font-size: var(--ui-fs-lg);
}

.new-project-dialog-eyebrow {
    color: var(--ui-muted-2);
    font-size: var(--ui-fs-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

@media (max-width: 640px) {
    .new-project-choices {
        grid-template-columns: minmax(0, 1fr);
    }
}


/* ---------- 21. Генератор: вкладки, правая панель, переключатели ---------- */
.sidebar-right {
    padding: var(--ui-pad) 0;
    overflow-y: auto;
}

.navigator-heading {
    margin: 0 0 8px;
    padding: 0 var(--ui-pad);
    color: var(--ui-muted);
    font-family: var(--ui-font);
    font-size: var(--ui-fs-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.navigator-project {
    margin: 0 0 12px;
    padding: 0 var(--ui-pad);
    color: var(--ui-text-strong);
    font-size: var(--ui-fs);
    font-weight: 600;
    line-height: 1.35;
}

.navigator-task {
    margin: 0 12px 10px;
    padding: 10px 12px;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface-2);
}

.navigator-task-title {
    color: var(--ui-text-strong);
    font-size: var(--ui-fs-sm);
    font-weight: 600;
    margin-bottom: 6px;
}

/* вкладки генератора: плотные подчёркнутые, а не «таблетки» */
.generator-tabs,
.tabs,
nav[class*="tab"] {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--ui-line);
    margin-bottom: var(--ui-gap);
}

.generator-tabs a,
.generator-tab,
.tabs a,
nav[class*="tab"] a {
    padding: 8px 12px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--ui-muted);
    font-size: var(--ui-fs);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.generator-tabs a:hover,
.generator-tab:hover,
.tabs a:hover,
nav[class*="tab"] a:hover {
    color: var(--ui-text-strong);
    background: transparent;
}

.generator-tabs a.active,
.generator-tab.is-active,
.tabs a.active,
.generator-tabs a[aria-current="page"],
.tabs a[aria-current="page"],
nav[class*="tab"] a.active {
    border-bottom-color: var(--ui-accent);
    color: var(--ui-text-strong);
    font-weight: 600;
    background: transparent;
}

/* активная вкладка не должна заливаться акцентом */
.generator-tab.is-active {
    border-radius: 0;
    box-shadow: none;
}

/* переключатели/тумблеры публикации — нейтральные */
.publication-toggle,
.toggle,
.switch {
    border-color: var(--ui-line-strong);
    background: var(--ui-surface-2);
}

/* карточки/панели внутри генератора: без теней и больших радиусов */
.book-generator section,
.book-generator .card {
    border-radius: var(--ui-radius);
    box-shadow: none;
}

.book-generator h1,
.book-generator h2 {
    letter-spacing: -0.01em;
}

.book-generator h1 {
    font-size: 18px;
}

/* ---------- 19. Адаптив ---------- */
@media (max-width: 1180px) {
    :root {
        --sidebar-width: 208px;
        --navigator-width: 260px;
    }

    .content-grid {
        padding: 12px;
    }

    .desk-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .app,
    .app.has-navigator {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: fixed;
        z-index: 40;
        top: 0;
        bottom: 0;
        left: 0;
        width: 260px;
        max-width: 86vw;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 160ms ease;
        box-shadow: 0 0 0 1px var(--ui-line);
    }

    .sidebar.is-open {
        transform: none;
    }

    .sidebar-right {
        display: none;
    }

    .workspace {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    /* Селекторы намеренно с высокой специфичностью: dashboard-header-mobile.css
       содержит правила вида `.sidebar:not(.sidebar-right) > .page-header`,
       которые переносят шапку в меню потребительского прототипа. */
    .workspace > .page-header,
    .sidebar:not(.sidebar-right) > .page-header {
        position: sticky;
        top: 0;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        margin: 0;
        padding: 10px 12px;
        border-bottom: 1px solid var(--ui-line);
        background: var(--ui-surface);
    }

    .page-header-menu {
        display: inline-flex;
    }

    .workspace > .page-header .page-header-main,
    .sidebar:not(.sidebar-right) > .page-header .page-header-main {
        flex: 1 1 auto;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 1px;
        order: 0;
    }

    .workspace > .page-header h1,
    .sidebar:not(.sidebar-right) > .page-header h1 {
        margin: 0;
        font-size: var(--ui-fs-lg);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .workspace > .page-header .subtitle,
    .sidebar:not(.sidebar-right) > .page-header .subtitle {
        font-size: var(--ui-fs-xs);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .workspace > .page-header .header-actions,
    .sidebar:not(.sidebar-right) > .page-header .header-actions {
        flex: 0 0 auto;
        order: 1;
        display: flex;
        width: auto;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .workspace > .page-header .header-actions > form,
    .sidebar:not(.sidebar-right) > .page-header .header-actions > form {
        display: none;
    }

    /* на узких экранах вторичные действия прячем, чтобы шапка не «съедала» экран */
    .workspace > .page-header .header-actions .button-secondary,
    .sidebar:not(.sidebar-right) > .page-header .header-actions .button-secondary {
        display: none;
    }

    /* плавающие «язычки» из прототипа больше не нужны: меню открывается из шапки,
       а правая панель на телефоне скрыта */
    .sidebar-toggle,
    .navigator-toggle {
        display: none !important;
    }

    /* вкладки генератора прокручиваются горизонтально, но не ломают шапку */
    .generator-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        margin-bottom: 10px;
    }

    .generator-tabs::-webkit-scrollbar {
        display: none;
    }

    .generator-tab {
        flex: 0 0 auto;
        padding: 8px 10px;
        font-size: var(--ui-fs-sm);
    }

    .page-header h1 {
        font-size: var(--ui-fs-lg);
    }

    .header-actions {
        gap: 6px;
    }

    .theme-toggle {
        height: 28px;
        padding: 0 8px;
        font-size: var(--ui-fs-xs);
    }

    .content-grid {
        padding: 10px;
        gap: 10px;
    }

    .desk-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .desk-metric {
        padding: 10px 12px;
    }

    .desk-metric-value {
        font-size: 18px;
    }

    .data-table {
        min-width: 0;
        width: 100%;
        table-layout: fixed;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 8px 10px;
    }

    /* На телефоне оставляем книгу, статус и действия: остальное — в подписи строки. */
    .data-table .col-stage,
    .data-table .col-chapters,
    .data-table .col-words,
    .data-table .col-updated,
    .data-table thead th.col-stage,
    .data-table thead th.col-chapters,
    .data-table thead th.col-words,
    .data-table thead th.col-updated {
        display: none;
    }

    .data-table .col-title {
        max-width: none;
        min-width: 0;
        white-space: normal;
    }

    .data-table .row-sub {
        max-width: none;
        white-space: normal;
    }

    .data-table .row-progress {
        min-width: 0;
    }

    .data-table .col-actions .button {
        padding: 2px 6px;
    }
}

@media (max-width: 480px) {
    .desk-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-header {
        flex-wrap: wrap;
    }

    .page-header-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .stories-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
