/* app.css — стили приложения Posta поверх css/shell.css: тёплая бумажная тема. */


/* ---- Палитра и основа: одна тёмная тема студии (--bg и базовые токены — в shell.css) ---- */
:root {
    color-scheme: light;
    --surface: #fffdf7; --surface-2: #f1ecdf; --surface-3: #eae3d3;
    --line: #ded5c3; --line-strong: #bdb29e;
    --text: #27251f; --muted: #716c60;
    --accent: #f3e8ae; --accent-text: #27251f;
    --danger: #a52d25; --red: #a52d25; --link: #514276;
    --ok: #286744; --ok-pill: #286744; --blue: #315e87; --warm: #8a5a00;
    --best-tint: #f3e8ae; --gap-bg: #f1ecdf; --tg-bg: #f1ecdf; --warn-bg: #f8e8df;
    --shadow-ink: #625c50; --shadow-card: 0 8px 24px rgba(54, 43, 25, .10); --shadow-btn: none;
    --plate-blue-ink: #27251f; --plate-danger-ink: #fffdf7; --plate-ok-ink: #fffdf7;
    --dup-text: #514276; --dup-bg: #eee8f5; --dup-line: #8d78a9;
    --modal-dim: rgba(39, 37, 31, .48); --spinner-ink: #716c60; --on-bright: #27251f;
    --radius: 12px; --radius-card: 18px; --border: 1px; --ring: 1px; --ring-active: 2.5px; --spinner-size: 38px;
    --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
    --font-ui: 'Rubik', system-ui, 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
}
body { transition: background-color 0.3s, color 0.3s; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]), select, textarea { border: var(--border) solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
code { font-family: var(--mono); }
input[type="file"]::file-selector-button { margin-right: 10px; padding: 7px 12px; border: var(--border) solid var(--line-strong); border-radius: var(--radius); background: var(--surface-3); color: var(--text); font: 700 13px var(--font-ui); cursor: pointer; }
input[type="file"]::file-selector-button:hover { background: var(--accent); color: var(--accent-text); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* ---- Ссылки, маркер и кольцо загрузки (дизайн K: без радужных переливов) ---- */
@property --spinner-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes spinner-turn { to { --spinner-angle: 360deg; } }
:where(a[href]) { color: var(--link); }
:where(a[href]:hover) { text-decoration: underline 2px; }
.rainbow-text { background: var(--accent); color: var(--accent-text); padding: 0 .2em; }

/* ---- Индикатор загрузки: «эфирное» кольцо — серый трек, жёлтая и красная дуги бегут по кругу; тёмный контур по краям, как у кнопок.
   Всё рисуется градиентами одного элемента (маска обрезает всё лишнее), бежит только угол --spinner-angle. Поверх медиа — класс is-loading у контейнера ---- */
.spinner, .is-loading::before {
    --spinner-r: calc(var(--spinner-size) / 2);
    --spinner-ring: calc(var(--spinner-size) * 0.1);    /* толщина цветного кольца */
    --spinner-edge: 1.5px;                              /* толщина контура */
    --spinner-hole: calc(var(--spinner-r) - var(--spinner-ring) - 2 * var(--spinner-edge));   /* внутренний радиус контура кольца */
    content: ''; display: block; flex: none; box-sizing: border-box; width: var(--spinner-size); height: var(--spinner-size); border-radius: 50%; pointer-events: none;
    background:
        radial-gradient(circle, transparent 0 var(--spinner-hole), var(--spinner-ink) var(--spinner-hole) calc(var(--spinner-hole) + var(--spinner-edge)),
            transparent calc(var(--spinner-hole) + var(--spinner-edge)) calc(var(--spinner-r) - var(--spinner-edge)), var(--spinner-ink) calc(var(--spinner-r) - var(--spinner-edge)) var(--spinner-r)),
        conic-gradient(from var(--spinner-angle), var(--accent) 0 30%, var(--blue) 30% 44%, var(--surface-3) 44% 100%);
    -webkit-mask: radial-gradient(circle, transparent calc(var(--spinner-hole) - 0.5px), #000 var(--spinner-hole));
    mask: radial-gradient(circle, transparent calc(var(--spinner-hole) - 0.5px), #000 var(--spinner-hole));
    animation: spinner-turn 1.1s linear infinite;
}
.spinner-lg { --spinner-size: 64px; }
.is-loading { position: relative; }
.is-loading::before { position: absolute; left: 50%; top: 50%; margin: calc(var(--spinner-size) / -2) 0 0 calc(var(--spinner-size) / -2); z-index: 5; }
.status-msg.is-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.status-msg.is-loading::before { position: static; margin: 0; }
.app-loading { position: fixed; inset: 0; z-index: 5000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: var(--bg); transition: opacity 0.25s ease; }
.app-loading-text { color: var(--text); font: 700 15px var(--font-ui); }
.app-loading.is-done { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Тёплая бумага: оболочка, бренд и общий контраст интерфейса. */
:root { --bg: #f5f1e6; --bg2: #eae3d3; --panel: #fffdf7; --panel2: #f1ecdf; --panel3: #eae3d3; --line2: #bdb29e; --faint: #716c60; --grad: #ffda1a; --font-ui: 'Rubik', system-ui, sans-serif; }
html, body { background: var(--bg); color: var(--text); }
body { font-family: var(--font-ui); }
.side { background: #eae3d3; border-color: #ded5c3; }
.brand { gap: 0; padding: 8px 8px 20px; }
.brand-logo { display: inline-flex; align-items: flex-start; padding: .1em .22em .12em .2em; background: #ffda1a; color: #111; font: 900 29px/1 'Jost', 'Futura', 'Century Gothic', sans-serif; letter-spacing: -.045em; white-space: nowrap; }
.brand-logo sup { position: relative; top: .12em; margin-left: .04em; font-size: .46em; letter-spacing: 0; }
.side-nav a:hover, .side-nav .tab-btn:hover, .side-list li:hover { background: rgba(39, 37, 31, .07); }
.side-nav a.is-active, .side-nav .tab-btn.active, .side-list li.is-active { background: #f3e8ae; color: #27251f; }
.side-nav a.is-active em { background: #d9c66e; color: #27251f; }
.secondary-button, .refresh-button, .account-secondary, .model-panel button { background: #fffdf7; border-color: #ded5c3; color: #27251f; }
.secondary-button:hover, .refresh-button:hover, .account-secondary:hover { background: #f3e8ae; border-color: #bdb29e; }
.topic-switch-button, .topic-switch-menu, .activity-console, .account-card, .proposal-card, .cal-card { background-color: #fffdf7; }
.topic-switch-menu button:hover, .topic-switch-menu button.is-current { background: #f3e8ae; color: #27251f; }
.tab-inactive-bar { background: #eae3d3; color: #27251f; }
.tab-inactive-bar button { background: #ffda1a; border-color: #ffda1a; color: #27251f; }
:focus-visible { outline-color: #725b00; }
input[type="checkbox"], input[type="radio"] { accent-color: #8a7100; }
@media (max-width: 760px) {
  .side .brand { padding: 0 8px 0 2px; }
  .brand-logo { font-size: 21px; }
}


/* ---- Шапка, вкладки, панели ---- */
.debug-toggle { padding: 3px 8px; font-family: var(--font-ui); border: 1px dashed var(--line-strong); border-radius: 999px; background: transparent; color: var(--faint); font-size: 11px; }
.debug-toggle[aria-pressed="true"] { border-style: solid; border-color: var(--accent); background: var(--surface-3); color: var(--text); }
/* Тема поиска: кнопка в стиле вкладки и выпадающий список всех тем */
.topic-switch { position: relative; }
.topic-switch-button { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: 600 14px/1.2 var(--font-ui); }
.topic-switch-caret { font-size: 10px; opacity: 0.7; transition: transform 0.2s; }
.topic-switch-button[aria-expanded="true"] .topic-switch-caret { transform: rotate(180deg); }
.topic-switch-menu { position: absolute; top: calc(100% + 10px); right: 0; z-index: 20; display: grid; gap: 2px; min-width: 240px; max-width: min(90vw, 360px); max-height: min(60vh, 420px); overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 12px 32px rgba(0, 0, 0, .35); margin-top: 8px; pointer-events: auto; }
.topic-switch-menu button { padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; text-align: left; white-space: nowrap; }
.topic-switch-menu button:hover { background: var(--surface-3); color: var(--text); }
.topic-switch-menu button.is-current { background: var(--surface-2); color: var(--text); }
.view-panel { display: none; flex-direction: column; align-items: center; width: 100%; max-width: 420px; margin: 0 auto; transition: opacity 0.2s; }
.view-panel.active { display: flex; }
.view-panel.is-busy { opacity: 0.3; pointer-events: none; }
.view-panel.wide-panel { align-items: stretch; padding: 16px; }
.section-title { margin: 0; font-size: 15px; font-weight: 600; }
.tab-inactive-bar { position: sticky; top: 0; z-index: 900; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line-strong); background: var(--surface-3); font-size: 14px; }
.tab-inactive-bar button { padding: 6px 14px; border: 1px solid var(--accent); border-radius: 5px; background: var(--accent); color: var(--accent-text); }
body.tab-inactive .app-main { opacity: 0.45; pointer-events: none; }
.debug-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; box-sizing: border-box; width: min(100%, 640px); margin: 0 0 20px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 13px; }



/* ---- Журнал ---- */
.activity-console { display: flex; flex-direction: column; box-sizing: border-box; width: min(100%, 900px); height: 850px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: 0 5px 5px 18px rgba(5, 6, 14, .45); font: 13px/1.55 var(--font-ui); }
.activity-console-header { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
/* Плашка статуса: серая «Ожидание», в эфире красная «● В ЭФИРЕ»; текст статуса задаёт JS */
#activity-console-status { margin-left: 0; padding: 3px 8px; border-radius: 4px; background: var(--surface-3); color: var(--muted); font: 700 11px/1.2 var(--font-ui); }
.console-title { font: 16px/1 var(--font-ui); }
#debug-toggle { margin-left: auto; }
.activity-console-log { position: relative; flex: 1; min-height: 0; }
.activity-console-follow { position: absolute; z-index: 2; right: 14px; bottom: 12px; padding: 8px 12px; border: 1px solid #62656f; border-radius: 999px; background: #343740; color: #fffdf7; box-shadow: 0 3px 12px rgba(0, 0, 0, .3); font: 600 12px/1.2 var(--font-ui); }
.activity-console-follow:hover { background: #454954; }
.console-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.activity-console.is-active .console-indicator { background: var(--accent); animation: console-pulse 1.2s ease-in-out infinite; }
/* Надпись мигает тем же ритмом, что и кружок: одинаковая анимация запускается с одним классом .is-active */
.activity-console.is-active #activity-console-status { background: var(--red); color: #ffffff; animation: console-pulse 1.2s ease-in-out infinite; }
.activity-console.is-active #activity-console-status::before { content: '● В ЭФИРЕ · '; }
@keyframes console-pulse { 50% { opacity: 0.25; } }
/* Календарь v4: «Заполнить дыры», Предложка, охват по часам, повтор */
.cal-tools .cal-fill { border-color: var(--red); background: var(--red); color: var(--on-bright); font-weight: 600; }
.cal-hour.is-best { color: var(--red); }
.cal-reach-bar { right: 0; bottom: 1px; background: var(--red); opacity: 0.6; }
.cal-dup-warning { border: 2px solid var(--red); }
.cal-plan, .cal-pool { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.cal-plan-count, .cal-plan-note { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.cal-plan-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 2px 8px; align-items: start; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); }
.cal-plan-row > * { grid-column: 2; }
.cal-plan-row > .cal-plan-thumb { grid-column: 1; grid-row: 1 / span 3; width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.cal-plan-row > .cal-plan-actions { grid-column: 3; grid-row: 1 / span 3; display: flex; flex-direction: column; gap: 4px; }
.cal-plan-row > .cal-plan-actions button { min-height: 28px; padding: 2px 8px; font-size: 13px; }
.cal-plan-when { font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-plan-chan, .cal-pool-meta { font-size: 12px; color: var(--muted); }
.cal-plan-text { font-size: 13px; }
.cal-plan-remove { justify-self: start; border: 0; background: transparent; color: var(--red); font-size: 12px; text-decoration: underline; }
.cal-pool-row { list-style: none; }
.cal-pool-item { grid-template-columns: 44px 1fr; border: 1px solid var(--line); background: var(--surface); }
.cal-pool-item > img { width: 44px; height: 44px; border-radius: 6px; }
.activity-console-output { box-sizing: border-box; height: 100%; overflow-y: auto; padding: 8px 12px; scrollbar-color: var(--line-strong) transparent; }
.activity-console-line { margin: 0 0 7px; padding-left: 1.5em; text-indent: -1.5em; color: var(--text); overflow-wrap: anywhere; }
.console-time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.activity-console-line::before { content: '> '; color: var(--faint); }
.console-link { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 2px; }
/* Обмен с моделью — «пузыри»: запрос, ответ (белая полоса), размышления (пунктир) */
.ai-message { margin: 6px 0; padding: 6px 8px; text-indent: 0; border-left: 2px solid var(--line-strong); border-radius: 3px; background: var(--surface); cursor: pointer; }
.ai-message::before { content: none; }
.ai-response { border-left-color: var(--accent); }
.ai-thinking { border-left: 2px dashed var(--muted); background: transparent; }
.ai-thinking .ai-message-text { color: var(--muted); font-style: italic; }
.ai-message-meta { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.ai-message-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; color: var(--text); line-height: 1.5; }
.ai-thinking.is-live .ai-message-text, .ai-message.is-expanded .ai-message-text { display: block; max-height: 300px; overflow-y: auto; white-space: pre-wrap; }
.ai-thinking.is-live .ai-message-meta::after { content: ' · думает…'; }
.model-panel { flex: none; border-top: 1px solid var(--line); background: var(--surface); }
.model-panel summary { display: flex; gap: 8px; padding: 7px 12px; color: var(--muted); cursor: pointer; list-style: none; }
.model-panel summary::-webkit-details-marker { display: none; }
.model-panel summary::before { content: '▸'; color: var(--faint); }
.model-panel[open] summary::before { content: '▾'; }
.model-panel-title { color: var(--text); font-weight: 600; }
#model-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-panel-body { display: grid; gap: 8px; padding: 0 12px 10px; }
.model-panel-line { color: var(--muted); }
.model-panel-note:empty { display: none; }
.model-loaded { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.model-loaded:empty::before { content: 'Загруженных моделей нет.'; color: var(--faint); }
.model-loaded li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; }
.model-loaded-name { overflow-wrap: anywhere; }
.model-loaded-details { grid-column: 1; color: var(--faint); }
.model-loaded button { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.model-panel-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.model-panel button { padding: 4px 8px; border: 1px solid #62656f; border-radius: 3px; background: #343740; color: #fffdf7; font-size: 11px; font-weight: 600; }
.model-panel button:disabled { opacity: 0.78; }

/* ---- Кнопки: основное действие — белая, второстепенное — тёмная с рамкой ---- */
.primary-button, .secondary-button, .refresh-button, .danger-button, .topic-row button, .debug-banner button, .database-record-actions button {
    min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface-2); font-size: 13px; font-weight: 600; transition: background 0.15s, border-color 0.15s;
}
.secondary-button:hover, .refresh-button:hover, .debug-banner button:hover, .database-record-actions button:hover { border-color: rgba(124, 92, 255, .5); background: var(--surface-3); }
.primary-button, .topic-row button { border: 0; background: linear-gradient(90deg, #7c5cff, #c86bff); color: #ffffff; box-shadow: 0 8px 26px rgba(124, 92, 255, .45); font-weight: 600; }
.primary-button:hover:not(:disabled), .topic-row button:hover:not(:disabled) { box-shadow: 0 10px 30px rgba(124, 92, 255, .6); }
.primary-button:active:not(:disabled), .topic-row button:active:not(:disabled) { transform: none; box-shadow: none; }
.secondary-button, .refresh-button, .account-secondary { border: 1px solid var(--line); background: rgba(255, 255, 255, .03); color: var(--text); }
.secondary-button:hover, .refresh-button:hover, .account-secondary:hover { background: var(--surface-3); }
.primary-button, .secondary-button, .refresh-button, .danger-button, .topic-row button, .account-secondary { border-radius: 14px; }
.refresh-button { width: 42px; padding: 0; font-size: 22px; line-height: 1; }
.danger-button { flex: none; border: var(--border) solid var(--danger); background: transparent; color: var(--danger); }
.danger-button:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.account-secondary { padding: 7px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); font-size: 13px; white-space: nowrap; }

/* ---- Тема поиска и фильтры ---- */
.topic-form { display: grid; gap: 6px; width: 100%; margin-bottom: 4px; }
.topic-form label { color: var(--muted); font-size: 12px; }
#content-tab .topic-form { width: min(100%, 460px); align-self: center; }
.topic-row { display: flex; gap: 8px; }
.topic-row input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.topic2-field { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; border: 1px dashed var(--line-strong); border-radius: 6px; color: var(--faint); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.topic2-field:hover { border-color: var(--muted); color: var(--muted); }
.topic2-field.is-active { border: 1px solid var(--muted); background: var(--bg); color: var(--text); cursor: text; }
.topic2-field.is-busy { opacity: 0.6; }
.topic2-plus { font-size: 16px; line-height: 1; }
#topic2-field #topic2-input { flex: 1; min-width: 0; min-height: 36px; padding: 0; border: 0; border-radius: 0; outline: none; background: transparent; font-size: 13px; cursor: inherit; }   /* id: иначе глобальное правило для input рисует рамку и фон */
.topic2-field input::placeholder { color: var(--faint); }
.topic-link { padding: 0; border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.topic-link:hover { color: var(--text); }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.filter-hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }   /* переносится на телефоне, строка фильтров не растёт вширь */
.check-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px 0 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; transition: background 0.15s, color 0.15s; }
.check-chip input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.check-box { display: grid; place-items: center; flex: none; width: 18px; height: 18px; border: 1.5px solid var(--faint); border-radius: 5px; background: var(--bg); }
.check-box svg { width: 13px; height: 13px; fill: none; stroke: var(--accent-text); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 14; stroke-dashoffset: 14; transition: stroke-dashoffset 0.2s; }
.check-chip:hover, .check-chip:has(input:checked) { color: var(--text); background: var(--surface-2); }
.check-chip:has(input:checked) { border-color: var(--muted); }
.check-chip input:checked + .check-box { border-color: var(--accent); background: var(--accent); }
.check-chip:has(input:checked) { border-color: var(--line-strong); background: var(--accent); color: var(--accent-text); }
.check-chip input:checked + .check-box svg { stroke-dashoffset: 0; }
.check-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.check-chip:has(input:disabled) { opacity: 0.5; cursor: wait; }
.status-msg { margin-top: 20px; color: var(--muted); font-size: 15px; }
.status-msg.rainbow-text { color: var(--accent-text); font-weight: 700; }   /* на жёлтой плашке */
.error-msg { color: var(--danger); text-align: center; }
#test-loading { font-weight: 700; }

/* ---- Поиск контента: тема, сколько осталось и радужная полоса; пока оценки нет — полоса бежит без процентов ---- */
@keyframes search-slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
.search-progress { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; box-sizing: border-box; width: min(100%, 280px); margin-top: 20px; padding: 10px 14px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.search-progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; }
.search-progress-title { min-width: 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.search-progress-title b { color: var(--text); font-weight: 600; }
.search-progress-percent { flex: none; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.search-progress-eta { margin-top: -2px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.search-progress-track { height: 6px; overflow: hidden; border-radius: 999px; background: var(--line); }
.search-progress-fill {
    width: 0; height: 100%; border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.8s ease;
}
.search-progress.is-indeterminate .search-progress-fill { width: 35%; transition: none; animation: search-slide 1.6s ease-in-out infinite; }

/* ---- Карточка записи и источника ---- */
.item-card-wrapper { width: 100%; }
.card { position: relative; display: flex; flex-direction: column; width: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }

/* === АРХИВНАЯ КАРТОЧКА: оранжево-жёлтая пульсирующая рамка === */
/* «Свежак!»: пост моложе двух часов — красная звезда в левом верхнем углу (JS ставит класс is-fresh) */
.card.is-fresh::before {
    content: 'Свежак!'; position: absolute; top: 14px; left: 14px; z-index: 4; display: grid; place-items: center; width: 84px; height: 84px;
    background: var(--red); color: #ffffff; font: 700 14px/1.05 var(--font-ui); text-align: center; transform: rotate(-12deg);
    clip-path: polygon(100% 50%, 89.2% 57.8%, 96.2% 69.1%, 83.3% 72.2%, 85.4% 85.4%, 72.2% 83.3%, 69.1% 96.2%, 57.8% 89.2%, 50% 100%, 42.2% 89.2%, 30.9% 96.2%, 27.8% 83.3%, 14.6% 85.4%, 16.7% 72.2%, 3.8% 69.1%, 10.8% 57.8%, 0% 50%, 10.8% 42.2%, 3.8% 30.9%, 16.7% 27.8%, 14.6% 14.6%, 27.8% 16.7%, 30.9% 3.8%, 42.2% 10.8%, 50% 0%, 57.8% 10.8%, 69.1% 3.8%, 72.2% 16.7%, 85.4% 14.6%, 83.3% 27.8%, 96.2% 30.9%, 89.2% 42.2%);
}

.card.is-archive {
    animation: archive-border-pulse 1.5s ease-in-out infinite;
    border-width: 2px;
    overflow: visible;
}

@keyframes archive-border-pulse {
    0%, 100% {
        border-color: var(--red);
        box-shadow: var(--shadow-card);
    }
    50% {
        border-color: var(--accent);
        box-shadow: var(--shadow-card);
    }
}

/* Яркая полоса предупреждения поверх карточки */
.card.is-archive::before {
    content: '🔥 Пост скоро исчезнет';
    display: block;
    padding: 10px 16px;
    margin: -2px -2px 0 -2px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    border-radius: 13px 13px 0 0;
    z-index: 10;
    animation: archive-banner-glow 1.5s ease-in-out infinite;
    position: relative;
}

@keyframes archive-banner-glow {
    0%, 100% {
        background: var(--accent);
        text-shadow: none;
    }
    50% {
        background: var(--accent);
        text-shadow: none;
    }
}

/* Пульсирующий огонь в полосе */
.card.is-archive::before {
    background-clip: text;
    animation: archive-banner-glow 1.5s ease-in-out infinite, fire-dance 0.7s ease-in-out infinite;
}

@keyframes fire-dance {
    0%, 100% {
        filter: none;
        transform: scale(1);
    }
    50% {
        filter: none;
        transform: scale(1.05);
    }
}

/* Tooltip при наведении мыши на карточку */
.card.is-archive:hover::after {
    content: 'Посты обновляются в реальном времени по мере готовности\AПри новом поиске список полностью обновится';
    white-space: pre-wrap;
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 16px;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--shadow-card);
    z-index: 2000;
    animation: tooltip-fade-in 0.3s ease;
    line-height: 1.4;
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-video, img.is-video-thumb { cursor: pointer !important; }

.media-fallback { display: grid; place-items: center; padding: 24px; color: var(--muted); font-size: 13px; text-align: center; }
#source-card-wrapper .media-fallback { position: absolute; inset: 0; color: rgba(255, 255, 255, 0.75); }   /* лежит на чёрном */
.slide-caption { display: none; }
.info { position: relative; padding: 20px; border-top: 1px solid var(--line); }
.badge { float: right; padding: 4px 10px 5px; border: var(--border) solid var(--line-strong); border-radius: 0; background: var(--accent); color: var(--on-bright); font: 700 16px/1 var(--font-ui); }
#item-rating { position: absolute; top: -14px; right: 14px; z-index: 2; float: none; padding: 6px 10px 7px; font-size: 26px; }
.source-text { color: var(--muted); font-size: 13px; font-weight: 500; }
.source-post-link, .database-source-link, .source-name-link { color: var(--text); font-size: 12px; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; overflow-wrap: anywhere; }
.source-name-link { color: inherit; font-size: inherit; }
.item-ai-note { margin-top: 8px; font-size: 13px; line-height: 1.45; }
.relevance-badge { display: inline-block; margin-top: 8px; padding: 4px 9px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.relevance-badge:empty { display: none; }
.desc-text { max-height: 160px; margin-top: 10px; padding-right: 4px; overflow-y: auto; color: var(--text); font-size: 14px; line-height: 1.5; }
.item-empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.item-empty-actions { display: flex; gap: 10px; }
/* Единственный значок «это видео» на всём сайте (как в предложке, VIDEO_ICON из core.js): в углу, клик проходит сквозь него.
   Контейнер с значком — position: relative (плитка, миниатюра, карточка). Других значков поверх видео нет. */
.video-mark { position: absolute; top: 6px; left: 6px; z-index: 3; display: grid; place-items: center; width: 24px; height: 20px; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 5px; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px); color: #fff; pointer-events: none; }
.video-mark svg { width: 14px; height: 14px; }
/* Мозаика источника: плитки на весь контейнер с зазором 2 px, раскладку выбирает sources.js */
/* Лента остальных файлов кандидата: прокручивается по горизонтали, миниатюры — квадраты */
.source-coverage { margin: 4px 0 0; }
/* Активность и аудитория — «чипы» */
.engagement-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.eng-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; line-height: 1.4; }
.eng-chip b { color: var(--text); font-weight: 600; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-row[hidden] { display: none; }
.tag-chip { padding: 3px 9px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--text); font-size: 12px; line-height: 1.4; }
.tag-chip::before { content: '#'; margin-right: 2px; color: var(--muted); }
.tag-chip.is-nsfw { border-color: var(--danger); color: var(--danger); }
.eng-emoji { font-size: 14px; line-height: 1; }
.eng-up { border-color: var(--line-strong); color: var(--text); }
.eng-down { color: var(--faint); }

/* ---- Панель оценок: две большие кнопки по краям, между ними маленькие; ниже — жалоба и 🚀 ---- */
.controls { position: sticky; bottom: 16px; z-index: 30; display: grid; gap: 14px; box-sizing: border-box; width: 100%; margin-top: 20px; padding: 18px 16px 14px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.controls-row { display: flex; justify-content: center; align-items: center; gap: 12px; }
.controls-actions { gap: 10px; }
.btn { position: relative; display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: var(--border) solid var(--line-strong); border-radius: var(--radius); background: var(--surface); transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s; }
.btn-icon { font-size: 24px; line-height: 1; transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); }
.btn:hover { transform: none; box-shadow: var(--shadow-btn); }
.btn:hover .btn-icon { transform: scale(1.18) rotate(-6deg); }
.btn:active { transform: scale(0.92); }
/* Оценка: «Нравится» и главное действие — градиент студии; «Не нравится» — рамка красным */
.btn-main { width: 76px; height: 76px; border-radius: 18px; border: 0; background: linear-gradient(90deg, #7c5cff, #c86bff); color: #ffffff; box-shadow: 0 8px 26px rgba(124, 92, 255, .45); }
.btn-main[data-vote="dislike"], .btn-main[data-source-vote="reject"] { border: 1px solid var(--bad); background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn-main .btn-icon { font-size: 34px; }
.btn-mini { width: 42px; height: 42px; border-radius: 9px; background: transparent; }
.btn-mini .btn-icon { font-size: 18px; }
.btn-mini:hover, .btn-mini[aria-expanded="true"] { transform: translateY(-2px); background: var(--surface-2); }
.complaint-wrap { position: relative; }
.complaint-menu { position: absolute; bottom: calc(100% + 12px); left: 0; z-index: 20; display: grid; gap: 2px; min-width: 260px; padding: 6px; border: var(--border) solid var(--line-strong); border-radius: 11px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-btn); margin-bottom: 12px; pointer-events: auto; }
.complaint-menu button { padding: 10px 12px; border: 0; border-radius: 7px; background: transparent; font-size: 14px; text-align: left; }
.complaint-menu button:hover { background: var(--surface-3); }
/* Ракета по предварительной проверке поста: перечёркнута — нельзя, жёлтая точка — замечания */
.rocket-blocked, .rocket-warn { position: relative; }
.rocket-blocked .btn-icon, .rocket-blocked.image-viewer-rocket, .proposal-action.rocket-blocked { opacity: 0.55; }
.rocket-blocked::after { content: ''; position: absolute; left: 50%; top: 50%; width: 120%; height: 2.5px; border-radius: 2px; background: var(--danger); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); transform: translate(-50%, -50%) rotate(-45deg); pointer-events: none; }
.rocket-warn::before { content: ''; position: absolute; top: 3px; right: 3px; z-index: 1; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1.5px var(--surface); pointer-events: none; }
.proposal-action.rocket-blocked::after { width: 28px; left: 24px; }
/* Широкий экран: карточка и панель рядом; очень широкий — карточка по центру, панель справа.
   Мем («Подбор») и кандидат («Источники») — разные обёртки: у кандидата лента широкая, без колонки 420 px */
/* Центр карточки — центр окна (LAYOUT_CENTER_VIDEO): сетка «1fr | карточка 420 | 1fr», форма слева, панель решений справа от карточки.
   1240–1499: форма над карточкой, карточка и панель по центру. Журнал развёрнут и окно < 1700 px: всё в одну колонку по центру. */
@media (min-width: 1240px) {
    #content-tab { max-width: none; }
    #content-tab.active { display: grid; grid-template-columns: 0 minmax(0, 1fr) 330px; column-gap: 20px; align-items: start; justify-items: stretch; max-width: none; }
    #content-tab > * { grid-column: 2; }
    #content-tab > .topic-form { grid-column: 1; grid-row: 1; justify-self: start; align-self: start; width: 340px; position: sticky; top: 12px; margin-bottom: 0; }
    #item-card-wrapper { display: contents; }
    #item-card-wrapper[hidden] { display: none; }
    #item-card-wrapper > .card { grid-column: 2; grid-row: 1; width: 100%; box-sizing: border-box; }
    #item-card-wrapper > .controls { grid-column: 3; grid-row: 1; justify-self: start; width: 330px; top: 20px; bottom: auto; margin-top: 0; }   /* кнопки решения липнут к верху окна при прокрутке ленты */
    .item-card-wrapper .complaint-menu { top: calc(100% + 10px); bottom: auto; }
    #source-tab { max-width: 100%; }
    #source-card-wrapper { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 640px) 330px minmax(0, 1fr); column-gap: 20px; align-items: start; }   /* карточка и панель — кластером по центру */
    #source-card-wrapper > .card { grid-column: 2; }
    #source-card-wrapper > .controls { grid-column: 3; justify-self: start; width: 330px; }
}
/* Карточка ленты уже на четверть на широких экранах, чтобы длинный текст читался легче. */
@media (min-width: 720px) {
    #item-card-wrapper > .card { width: 75%; margin-inline: auto; justify-self: center; }
}
@media (min-width: 1240px) and (max-width: 1499px) {
    #content-tab > .topic-form { grid-column: 1 / -1; grid-row: 1; justify-self: center; width: min(100%, 460px); position: static; }
    #item-card-wrapper > .card, #item-card-wrapper > .controls { grid-row: 2; }
}
@media (max-width: 480px) {
    .controls { gap: 8px; padding: 12px 10px; }
    .controls-row { gap: 8px; }
    .btn { width: 48px; height: 48px; border-radius: 11px; }
    .btn-main { width: 62px; height: 62px; border-radius: 14px; }
    .btn-main .btn-icon { font-size: 28px; }
    .btn-mini { width: 38px; height: 38px; }
}

/* ---- Источники ---- */
.discovery-panel { display: flex; align-items: center; justify-content: space-between; gap: 12px; box-sizing: border-box; width: 100%; margin-bottom: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.discovery-text { display: grid; gap: 4px; min-width: 0; font-size: 13px; }
.autopilot-panel { box-sizing: border-box; width: 100%; margin-bottom: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.autopilot-panel p { margin: 6px 0; color: var(--muted); font-size: 13px; }
.autopilot-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 12px 0; }
.autopilot-form label { display: grid; gap: 4px; flex: 1 1 120px; color: var(--muted); font-size: 12px; }
.autopilot-form input, .autopilot-form select, .autopilot-topic-row select { min-width: 0; max-width: 100%; padding: 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); color: inherit; }
.autopilot-topics { display: grid; gap: 8px; }
.autopilot-topic-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.autopilot-topic-row details { flex-basis: 100%; overflow-wrap: anywhere; }
/* Source autopilot: explain the actual pipeline instead of a status paragraph. */
.autopilot-topic-row { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); align-items: stretch; gap: 14px; }
.autopilot-overview { flex-basis: 100%; min-width: 0; display: grid; gap: 14px; }
.autopilot-overview-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; font-size: 16px; }
.autopilot-state { font-size: 12px; font-weight: 600; padding: 5px 9px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--muted); }
.autopilot-state.is-running { color: var(--text); border-color: currentColor; }
.autopilot-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.autopilot-metric { display: grid; align-content: start; gap: 3px; min-width: 0; padding: 12px; background: var(--surface, var(--bg)); border: 1px solid var(--line); border-radius: 10px; }
.autopilot-metric-clickable { cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.autopilot-metric-clickable:hover, .autopilot-metric-clickable:focus-visible { border-color: var(--line-strong); background: var(--surface-2, var(--surface)); }
.autopilot-metric-clickable:focus-visible { outline: 2px solid var(--accent, #e4b849); outline-offset: 2px; }
.autopilot-metric-group { position: relative; min-width: 0; }
.autopilot-metric-group > .autopilot-metric { height: 100%; box-sizing: border-box; padding-bottom: 42px; }
.autopilot-metric-copy { position: absolute; left: 12px; bottom: 10px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface, var(--bg)); color: var(--text); cursor: pointer; font-size: 11px; line-height: 1.3; }
.autopilot-metric-copy:hover, .autopilot-metric-copy:focus-visible { border-color: var(--line-strong); background: var(--surface-2, var(--surface)); }
.autopilot-metric-copy:disabled { opacity: .55; cursor: wait; }
/* The source explorer remains mounted outside refreshed dashboard panels. */
.autopilot-sources-modal { width: min(940px, calc(100vw - 30px)); max-width: 940px; max-height: min(86vh, 900px); margin: auto; padding: 0; color: var(--text); background: var(--surface, var(--bg)); border: 1px solid var(--line-strong, var(--line)); border-radius: 16px; box-shadow: 0 20px 80px rgba(0,0,0,.55); overflow: auto; }

.autopilot-sources-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 12px; }
.autopilot-sources-header h3 { font-size: 21px; line-height: 1.3; margin: 0 0 4px; }
.autopilot-source-subtitle { margin: 0; font-size: 13px; color: var(--muted); }
.autopilot-sources-close { display: grid; place-items: center; flex-shrink: 0; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--bg); font-size: 24px; line-height: 1; cursor: pointer; }
.autopilot-sources-close:hover { border-color: var(--line-strong); }
.autopilot-source-hint { margin: 0 24px 14px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.autopilot-source-grid { display: grid; gap: 10px; padding: 0 24px 20px; }
.autopilot-source-card { display: grid; grid-template-columns: 48px minmax(0, 1fr) 28px; align-items: start; gap: 14px; min-width: 0; padding: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.autopilot-source-brand { display: grid; place-items: center; width: 48px; height: 48px; position: relative; border-radius: 12px; color: white; font-size: 13px; font-weight: 800; letter-spacing: -.5px; }
.autopilot-source-brand img { position: absolute; inset: 10px; width: 28px; height: 28px; object-fit: contain; opacity: 0; }
.autopilot-source-brand.has-artwork { font-size: 0; }
.autopilot-source-brand.has-artwork img { opacity: 1; }
.autopilot-source-card-body { display: grid; gap: 7px; min-width: 0; }
.autopilot-source-card-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.autopilot-source-platform { color: var(--muted); font-size: 12px; font-weight: 600; }
.autopilot-source-state { border: 1px solid var(--line-strong, var(--line)); color: var(--text); background: var(--surface, var(--bg)); border-radius: 6px; padding: 2px 6px; font-size: 11px; }
.autopilot-source-card-name { min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 600; }
.autopilot-source-card-name a { color: var(--text); text-decoration: none; }
.autopilot-source-card-name a:hover { color: var(--accent, #e4b849); text-decoration: underline; }
.autopilot-source-card-reason { font-size: 12px; color: var(--text); }
.autopilot-source-card-meta { display: flex; flex-wrap: wrap; gap: 5px 16px; font-size: 11px; color: var(--muted); }
.autopilot-source-external { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; width: 28px; height: 28px; color: var(--muted); text-decoration: none; font-size: 18px; }
.autopilot-source-external:hover { color: var(--text); border-color: var(--line-strong); }
.autopilot-source-empty { margin: 8px 0; padding: 24px; color: var(--muted); text-align: center; font-size: 13px; }
.autopilot-sources-footer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 24px 20px; border-top: 1px solid var(--line); }
.autopilot-source-progress { margin-left: auto; color: var(--muted); font-size: 12px; }
@media (max-width: 560px) { .autopilot-source-card { grid-template-columns: 40px minmax(0,1fr); gap: 10px; padding: 10px; } .autopilot-source-brand { width: 40px; height: 40px; } .autopilot-source-brand img { inset: 8px; width: 24px; height: 24px; } .autopilot-source-external { display: none; } .autopilot-sources-header { padding: 16px 16px 8px; } .autopilot-source-hint { margin: 0 16px 12px; } .autopilot-source-grid { padding: 0 16px 14px; } .autopilot-sources-footer { padding: 12px 16px 16px; } }
.autopilot-metric-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.autopilot-metric-label { font-weight: 600; }
.autopilot-metric small, .autopilot-phase small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.autopilot-pipeline { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.autopilot-phase { display: grid; grid-template-columns: 12px 1fr; gap: 10px; padding: 12px; align-items: start; }
.autopilot-phase + .autopilot-phase { border-top: 1px solid var(--line); }
.autopilot-phase > div { display: grid; gap: 4px; min-width: 0; }
.autopilot-phase > div > span { font-size: 13px; }
.autopilot-phase-dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; border: 1px solid var(--muted); }
.autopilot-phase-dot.done { background: #46ad82; border-color: #46ad82; }
.autopilot-phase-dot.active { background: #d5a64c; border-color: #d5a64c; }
.autopilot-footnotes { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--muted); }
.autopilot-footnotes span { max-width: 100%; overflow-wrap: anywhere; }
.autopilot-alert { margin: 0; padding: 10px 12px; border-left: 2px solid #d5a64c; background: var(--surface, var(--bg)); border-radius: 5px; font-size: 12px; line-height: 1.5; }
.autopilot-topic-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@media (max-width: 700px) { .autopilot-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } .autopilot-topic-row { padding: 12px; } }

#discovery-status { color: var(--muted); font-size: 12px; line-height: 1.45; }
@media (max-width: 480px) { .discovery-panel { flex-direction: column; align-items: stretch; } }
.source-platform-filter { display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 8px; width: 100%; color: var(--muted); font-size: 13px; }
.source-platform-filter select, .database-toolbar select, .url-input-row input { min-width: 0; padding: 9px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); }
.source-add { width: 100%; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
#source-tab .source-add { max-width: 1100px; align-self: center; }
.source-add-form { display: flex; gap: 8px; }
.source-add-form input { flex: 1; min-width: 0; padding: 10px 12px; font: inherit; }
.source-add-hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.own-content { width: 100%; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
#source-tab .own-content { max-width: 1100px; align-self: center; }
.own-content-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; }
.own-content-actions input[type="text"] { flex: 1 1 220px; min-width: 0; padding: 10px 12px; font: inherit; }
.own-album { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.own-csv-sample { color: var(--muted); font-size: 14px; }
.own-content-errors { margin: 6px 0 0; padding-left: 18px; color: var(--danger); font-size: 13px; }
.best-post-image { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: calc(var(--radius) - 3px); background: var(--surface-2); }
.best-post-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.best-post-text { margin: 0; font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mirror-list { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.mirror-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.mirror-name { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.mirror-form { display: grid; gap: 8px; margin-top: 12px; }
.mirror-form textarea { flex: 1 1 260px; min-width: 0; padding: 10px 12px; font: inherit; }
.mirror-form label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.api-token-actions { display: flex; gap: 8px; margin: 10px 0; }
.api-token-value { display: block; padding: 10px; overflow-wrap: anywhere; user-select: all; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.api-curl { margin: 6px 0 0; padding: 10px; overflow-x: auto; font-size: 12px; background: var(--surface-2); border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere; }
.topic-sources { width: 100%; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.source-tile-card.is-frozen .proposal-media { filter: grayscale(0.85) brightness(0.8); }
.source-tile-card.is-removing { opacity: 0.5; pointer-events: none; }
.source-cover { display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; border-radius: calc(var(--radius) - 3px); background: var(--surface-2); }
.source-cover .source-avatar { width: 72px; height: 72px; font-size: 30px; }
.source-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.source-avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; overflow: hidden; border-radius: 50%; background: var(--surface-3); font-size: 15px; font-weight: 600; }
.source-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.source-head-text { display: grid; min-width: 0; }
.source-head-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-head-text strong { font-size: 14px; }
.source-head-text a { color: var(--muted); font-size: 12px; }
.source-platform-tag, .proposal-vote { flex: none; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11px; }
.source-platform-tag { margin-left: auto; }
.source-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.source-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.source-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.source-status.is-frozen::before { background: var(--faint); }
.source-note { margin: 0; color: var(--faint); font-size: 12px; }

/* ---- «Предложка» и карточки источников темы ---- */
.proposals-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.proposals-filters { display: flex; gap: 6px; }
.proposals-filter { padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; }
.proposals-filter:hover, .proposals-filter.active { border-color: var(--line-strong); color: var(--text); }
.proposals-filter.active { background: var(--surface-3); }
.proposals-count { margin-right: auto; color: var(--faint); font-size: 13px; }
.proposals-status { padding: 24px 0; color: var(--muted); font-size: 14px; }
.proposals-status:empty { display: none; }
/* Фоновое достраивание: закреплена внизу экрана, в вёрстку не входит */

/* ---- Универсальная полоса прогресса (js/progress.js): createProgress() ---- */
.progress { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.progress-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.3s ease-out; }
.progress-text { min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }

/* Independent search profiles */
.tree-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.tree-head-text { display: grid; gap: 4px; min-width: 0; margin-right: auto; }
.tree-current { margin: 0; color: var(--muted); font-size: 13px; }
.tree-current strong { color: var(--text); }
#tree-form { margin-bottom: 10px; }
#tree-form .topic-row input[type="search"] { flex: 1 1 auto; min-width: 0; }
.tree-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tree-card { display: grid; gap: 8px; align-content: start; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: transform 0.12s, box-shadow 0.12s; }
.tree-card:hover { transform: none; box-shadow: var(--shadow-card); }
.tree-card.is-selected { box-shadow: var(--shadow-btn); }
.tree-card.is-current { background: var(--accent); color: var(--accent-text); }
.tree-card-name { flex: 1 1 auto; min-width: 0; font-size: 16px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.tree-card-src { justify-self: start; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tree-card.is-current .tree-card-src { color: inherit; }
.tree-badge { display: inline-flex; align-items: center; padding: 2px 7px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--text); font-size: 11px; font-weight: 600; white-space: nowrap; }
.tree-badge.is-18 { background: var(--red); border-color: var(--red); color: var(--on-bright); }
.tree-detail { display: grid; gap: 12px; align-content: start; min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.tree-detail-title { margin: 0; font-family: var(--font-ui); font-size: 26px; line-height: 1.1; overflow-wrap: anywhere; }
.tree-primary { width: 100%; min-height: 42px; }
.tree-detail-empty { margin: 0; color: var(--faint); font-size: 13px; }
.tree-facts { display: grid; gap: 10px; margin: 0; }
.tree-row { display: grid; gap: 2px; }
.tree-row dt { color: var(--faint); font-size: 11px; }
.tree-row dd { margin: 0; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.profile-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); gap: 16px; align-items: start; width: 100%; }
#tree-tab .tree-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
@media (max-width: 900px) { .profile-layout { grid-template-columns: minmax(0, 1fr); } }

/* ---- Тест ИИ ---- */
.test-panel { max-width: 680px; align-items: stretch; }
.analyze-form, .test-result { box-sizing: border-box; width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.analyze-form { padding: 20px; }
.field-label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.url-input-row { display: flex; gap: 8px; }
.url-input-row input { flex: 1; padding: 11px 12px; }
.form-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: 12px; }
.form-divider::before, .form-divider::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }
.file-picker { position: relative; display: flex; justify-content: center; align-items: center; min-height: 46px; border: 1px dashed var(--line-strong); border-radius: 6px; cursor: pointer; }
.file-picker:hover { border-color: var(--muted); }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.field-hint { margin-top: 8px; color: var(--muted); font-size: 12px; }
.test-result { margin-top: 18px; overflow: hidden; }
.test-image-figure { margin: 0; background: #000; }
.test-image-figure figcaption { display: flex; align-items: center; min-height: 34px; padding: 0 12px; background: var(--surface); color: var(--muted); font-size: 12px; }
.test-preview { display: flex; justify-content: center; align-items: center; min-height: 220px; max-height: 480px; }
.test-preview img { display: block; max-width: 100%; max-height: 480px; object-fit: contain; }
.test-info { padding: 16px 20px; }
.test-result-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.test-result-heading h2 { margin: 0; font-size: 18px; }

/* ---- Личный кабинет ---- */
.account-panel { max-width: 980px; align-items: stretch; gap: 16px; }
.account-nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.account-nav button { flex: 1 1 auto; padding: 9px 14px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; }
.account-nav button:hover { color: var(--text); }
.account-nav button.is-active { border-color: var(--line-strong); background: var(--surface-3); color: var(--text); }
.account-section, .admin-section { display: grid; gap: 16px; }
.account-card { display: grid; gap: 12px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.account-card h3 { margin: 0; font-size: 16px; }
.account-card a[href] { color: var(--text); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.account-warning { border-color: var(--danger); }
.account-muted { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.account-command { display: block; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); font-size: 12px; overflow-wrap: anywhere; user-select: all; }
.account-profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.account-profile-head > div:nth-child(2) { flex: 1 1 240px; display: grid; gap: 4px; }
.account-avatar, .social-logo { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border: 1px solid var(--line-strong); border-radius: 12px; background: linear-gradient(160deg, var(--surface-3), var(--surface-2)); font: 700 18px var(--mono); }
.social-logo { width: 40px; height: 40px; border-radius: 9px; font-size: 13px; }
.account-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.account-stat { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.account-stat strong { font-size: 22px; }
.auth-box { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.auth-box h4 { margin: 0; font-size: 14px; }
.auth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 24px; }
.auth-col { display: grid; align-content: start; gap: 10px; }
.auth-col > strong { font-size: 13px; }
.auth-col > .account-secondary { justify-self: start; }
.auth-form { max-width: 420px; }
.auth-methods { display: grid; gap: 2px; }
.auth-warning { margin: 0; padding: 10px 12px; border: 1px solid var(--danger); border-radius: 8px; font-size: 13px; line-height: 1.5; }
.auth-change summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.auth-change[open] summary { margin-bottom: 10px; }
#auth-status:empty { display: none; }
.account-stat span { color: var(--muted); font-size: 12px; }
.billing-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 22px 16px; padding-top: 16px; }
/* Тарифы — бирки из лендинга: подвесной ценник со срезанными углами, дыркой и ниткой */
.billing-plan { --hole: var(--surface); position: relative; display: grid; grid-template-rows: auto auto 1fr auto; gap: 16px; min-width: 0; padding: 22px 18px 18px;
    border: var(--border) solid var(--text); border-radius: var(--radius-card); background: var(--surface); box-shadow: 0 4px 4px 18px rgba(5, 6, 14, .45); }
.billing-plan h4 { margin: 0; font: italic 700 21px/1.05 var(--font-ui); }
.billing-plan.is-main { --hole: var(--accent); background: var(--accent); color: var(--on-bright); border-color: var(--line-strong); box-shadow: 0 5px 5px 18px rgba(5, 6, 14, .45); }
.billing-plan.is-current { outline: 3px dashed var(--red); outline-offset: 4px; }
.billing-plan-badge { position: absolute; top: -14px; left: 16px; padding: 6px 10px; border: 2.5px solid var(--line-strong); border-radius: 999px; background: var(--red); color: var(--on-bright);
    font: italic 700 12px/1 var(--font-ui); transform: rotate(-3deg); }
.billing-plan .tag-slot { display: grid; justify-items: center; padding-top: 22px; }
.billing-plan .htag-wrap { position: relative; filter: drop-shadow(0 3px 3px 18px rgba(5, 6, 14, .45)); }
.billing-plan.is-main .htag-wrap { filter: drop-shadow(0 3px 3px 18px rgba(5, 6, 14, .45)); }
.billing-plan .htag-wrap::before { content: ""; position: absolute; left: 50%; top: -24px; z-index: 1; width: 2px; height: 38px; margin-left: -1px; background: var(--text); }
.billing-plan.is-main .htag-wrap::before { background: var(--line-strong); }
.billing-plan .htag { --cut: 16px; padding: 2.5px; background: var(--line-strong); clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%, 0 var(--cut));
    transform: rotate(-3deg); transform-origin: 50% 0; transition: transform .35s; }
.billing-plan .htag-wrap:hover .htag { transform: rotate(3deg); }
.billing-plan .htag-in { --cut: 15px; position: relative; display: grid; gap: 3px; justify-items: start; min-width: 176px; padding: 28px 18px 12px; background: var(--accent); color: var(--on-bright);
    clip-path: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%, 0 var(--cut)); }
.billing-plan .htag.red .htag-in { background: var(--red); color: var(--on-bright); }
.billing-plan .hole { position: absolute; top: 9px; left: 50%; width: 11px; height: 11px; margin-left: -5.5px; border: 2px solid var(--line-strong); border-radius: 50%; background: var(--hole); }
.billing-plan .ik-name { font: 600 15px/1 var(--font-ui); }
.billing-plan .ik-desc { max-width: 20ch; font: 700 12px/1.3 var(--font-ui); opacity: .85; }
.billing-plan .ik-price { margin-top: 4px; font: 700 60px/.9 var(--font-ui); font-variant-numeric: tabular-nums; }
.billing-plan .ik-price sup { position: relative; top: .14em; margin-left: .04em; font-size: .36em; vertical-align: top; }
.billing-plan .rub { position: relative; display: inline-block; top: .1em; margin-left: .08em; font-size: .5em; vertical-align: top; }
.billing-plan .rub::after { content: ""; position: absolute; left: -.1em; top: .56em; width: .5em; height: .11em; background: currentColor; }
.billing-plan .ik-unit { font: 700 12px/1.2 var(--font-ui); }
.billing-plan ul { display: grid; gap: 7px; align-content: start; margin: 0; padding: 14px 0 0; border-top: 2px dashed color-mix(in srgb, currentColor 25%, transparent); font-size: 14px; }
.billing-plan li { position: relative; padding-left: 26px; list-style: none; }
.billing-plan li::before { content: "✓"; position: absolute; left: 0; top: .1em; display: grid; place-items: center; width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 50%;
    background: var(--ok); color: var(--on-bright); font: 700 11px/1 var(--font-ui); }
.billing-plan li::before { border-color: var(--text); }
.billing-plan.is-main li::before { border-color: var(--line-strong); }
.billing-plan.is-main .primary-button { background: var(--red); color: var(--on-bright); border-color: var(--line-strong); }
.billing-plan button { width: 100%; }
.billing-plan.is-main .muted { color: #54504A; }
@media (prefers-reduced-motion: reduce) { .billing-plan .htag { transition: none; } }
.billing-custom { display: grid; gap: 14px; }
.billing-custom label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.billing-custom output { color: var(--text); font-weight: 700; }
.billing-custom input[type="range"] { width: 100%; }
.billing-quote { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.billing-quote strong { font-size: 24px; }
.billing-ref { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.billing-ref code { flex: 1 1 260px; min-width: 0; }
.billing-amount-plus { font-weight: 700; }
.social-head { display: flex; align-items: flex-start; gap: 12px; }
.social-head > div { display: grid; gap: 4px; }
.vk-auth-actions { display: flex; align-items: center; gap: 10px; }
#vk-oauth-status { min-width: 0; color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.telegram-connected { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.channel-list { display: grid; gap: 8px; }
.channel-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.channel-main { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.channel-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.channel-default { color: var(--muted); font-size: 12px; }
.channel-limit { margin-top: 8px; font-size: 12px; line-height: 1.4; }
.channel-limit.is-warning { color: var(--danger); }
.telegram-form label[hidden] { display: none; }
.sched-panel { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.sched-panel h4 { margin: 0; font-size: 15px; }
.sched-day { display: grid; grid-template-columns: 170px minmax(0, 1fr); align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.sched-day input { padding: 8px 10px; }
.sched-panel input[type="number"] { width: 90px; padding: 8px 10px; }
.sched-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sched-error { min-height: 1em; margin: 0; color: var(--danger); font-size: 13px; }
.telegram-summary, .queue-main { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.telegram-form { display: grid; gap: 10px; }
.telegram-form label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; }
.telegram-form input { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); }
.telegram-form input:focus-visible { outline: none; }
.telegram-form input::placeholder { color: var(--faint); opacity: 1; }
.telegram-form .primary-button { justify-self: start; }
.telegram-steps { padding-left: 18px; line-height: 1.45; }
.telegram-steps li + li { margin-top: 8px; }
.telegram-steps code { padding: 1px 5px; border-radius: 4px; background: var(--surface-3); color: var(--text); font-size: 12px; }
.telegram-steps b { color: var(--text); font-weight: 600; }
.telegram-queue { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.telegram-queue h4 { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.queue-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); font-size: 13px; }
.queue-error { color: var(--danger); }
.tgu-card { display: grid; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.tgu-card h4 { margin: 0; font-size: 14px; }
.tgu-card form { max-width: 420px; }
.tgu-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tgu-qr { display: grid; gap: 10px; justify-items: start; }
.tgu-qr-image { display: grid; place-items: center; width: 220px; height: 220px; overflow: hidden; border-radius: 9px; background: #fff; }
.privacy-table-wrap { overflow-x: auto; }
.privacy-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.privacy-table th { padding: 8px 10px; border-bottom: 1px solid var(--line-strong); color: var(--faint); font-size: 11px; font-weight: 600; text-align: left; }
.privacy-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.45; }
.privacy-table tr:last-child td { border-bottom: 0; }
.privacy-table code, .privacy-value { font-size: 12px; }
.privacy-value { padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); font-family: var(--mono); text-align: left; overflow-wrap: anywhere; }
.privacy-badge { padding: 2px 7px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ---- Базы данных ---- */
.database-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
}

.database-toolbar label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    flex: 1;
}

.database-toolbar select {
    width: 100%;
    min-width: 0;
}
.database-status { color: var(--muted); font-size: 13px; }
.database-records { display: grid; gap: 8px; }
.database-record { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.database-record-number { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.database-record-summary { min-width: 0; font-size: 13px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.database-record-actions, .dialog-actions { display: flex; align-items: center; gap: 8px; }
.database-record-actions button { min-height: 34px; padding: 0 11px; font-size: 12px; font-weight: 500; }
.database-delete-button { color: var(--danger); }
.database-delete-button:hover { border-color: var(--danger) !important; }
.database-empty { padding: 28px 16px; border: 1px dashed var(--line-strong); border-radius: 6px; color: var(--muted); text-align: center; }

/* ---- Таблица коллекции: ширина по контейнеру, без горизонтальной прокрутки, длинный текст — с многоточием ---- */
.database-danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); font-size: 13px; }
.admin-section[data-admin-section="databases"] { height: 100%; overflow: hidden; }
.database-layout { display: grid; grid-template-columns: minmax(200px, 25%) 1fr; height: 100%; }
.database-sidebar { display: flex; flex-direction: column; min-height: 0; }
.database-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.database-list { flex: 1; display: flex; flex-direction: column; overflow-y: auto; min-height: 0; }
.database-list-item { cursor: pointer; color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; transition: all 150ms ease; }
.database-list-item:hover { border-color: var(--line); }
.database-list-item.active { background: var(--accent); color: var(--accent-text); font-weight: 500; }
.database-browser { display: flex; flex-direction: column; }
.database-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.database-breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--muted); flex: 1; min-width: 0; }
.database-breadcrumb span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.database-breadcrumb .separator { color: var(--faint); }
.database-viewer { display: grid; grid-template-columns: auto 1fr auto; }
.database-nav-btn { padding: 0; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 150ms ease; }
.database-nav-btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.database-nav-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* === ПРОСМОТР ЗАПИСИ БАЗЫ ДАННЫХ === */
.database-record-view {
    flex: 1;
    min-width: 0;
    padding: 0;
    border-radius: 6px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.database-record-item {
    display: grid;
    gap: 0;
    height: 100%;
    grid-template-rows: auto 1fr;
}

/* Медиа контейнер с красивым фоном и закругленными углами */
.database-record-item-media-wrapper {
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    max-height: 400px;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
}

.database-record-item-media {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.database-record-item-media:hover {
    transform: scale(1.02);
}

/* Видео в базе данных */
.database-record-item-media[type="video"] {
    width: 100%;
    height: 100%;
}

.database-record-item-media video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.database-record-item-media img {
    cursor: zoom-in;
}

/* Контент с полями */
.database-record-item-content {
    display: grid;
    gap: 16px;
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.database-record-field {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line-strong);
}

.database-record-field:last-child {
    padding-bottom: 0;
}


.database-record-field-value {
    color: var(--text);
    font-size: 13px;
    word-break: break-word;
    line-height: 1.5;
    font-weight: 500;
}

.database-record-field-value.code {
    font-family: var(--mono);
    background: var(--surface-2);
    padding: 10px 12px;
    border-radius: 5px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.4;
    font-weight: 400;
}

/* URL ссылки в полях */
.database-record-field-value[href] {
    color: var(--link);
    text-decoration: none;
}
.database-record-actions { display: flex; gap: 8px; }

/* ---- Улучшенное отображение записей ---- */
.database-record-item-improved {
    display: flex;
    flex-direction: column;
    gap: 0;
    height: 100%;
    padding: 0;
}

.database-record-top {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 2fr;
    border-bottom: 1px solid var(--line-strong);
    align-items: start;
}

.database-record-item-media-wrapper-large {
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
}

.database-record-item-media-large {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.database-record-item-media-wrapper-large:hover .database-record-item-media-large {
    transform: scale(1.05);
}

.database-record-item-media-large[type="video"],
.database-record-item-media-large video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.database-record-no-media {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    background: var(--surface-2);
    border-radius: 8px;
    color: var(--muted);
    font-size: 14px;
}

.database-record-info-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.database-record-title {
    margin: 0;
    font-weight: 600;
    word-break: break-word;
    color: var(--text);
}

.database-record-priority-fields {
    flex-direction: column;
}

.database-priority-field {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--surface-2);
    border-left: 3px solid var(--line-strong);
}

.database-priority-label {
    flex: 0 0 auto;
    font-size: 18px;
    line-height: 1;
    margin-top: 2px;
}

.database-priority-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.database-priority-content strong {
        color: var(--muted);
        font-weight: 600;
}

.database-priority-value {
    font-size: 13px;
    color: var(--text);
    word-break: break-word;
    line-height: 1.4;
}

.database-priority-link {
    color: var(--link);
    text-decoration: none;
}

.database-priority-link:hover {
    text-decoration: underline;
}

.database-record-expandable {
    padding: 0 16px 16px;
    border-top: 1px solid var(--line-strong);
}

.database-record-expandable summary {
    padding: 12px 0;
    user-select: none;
    transition: color 0.15s;
}

.database-record-expandable summary:hover {
    color: var(--text);
}

.database-record-all-fields {
    display: grid;
    gap: 12px;
    padding-top: 8px;
}

.database-record-field {
    display: grid;
    gap: 6px;
    padding: 10px;
    background: var(--surface-2);
    border-radius: 4px;
    border-left: 2px solid var(--line-strong);
}

.database-record-field:last-child {
    border-bottom: none;
}

.database-record-field-label {
    color: var(--muted);
    font-size: 11px;
            font-weight: 700;
}

.database-record-field-system {
    opacity: 0.6;
    border-left-color: var(--faint) !important;
}

.database-record-field-system .database-record-field-label {
    color: var(--faint);
}

@media (max-width: 600px) {
    .database-toolbar { flex-direction: column; align-items: stretch; }
    .database-toolbar label { flex: 0 1 auto; width: 100%; }
    .database-toolbar .primary-button { flex: 0 1 auto; }
    .database-toolbar .refresh-button { flex: 0 0 42px; }
    .database-record { grid-template-columns: 36px minmax(0, 1fr); }
    .database-record-actions { grid-column: 2; }
    .database-danger-zone { flex-direction: column; align-items: stretch; }
    .database-layout { grid-template-columns: 1fr; }
    .database-viewer { grid-template-columns: 1fr; }
    .database-list { max-height: 200px; }
    .database-record-item-media-wrapper { min-height: 200px; max-height: 300px; }
    .database-record-item-content { padding: 12px; gap: 12px; }

    .database-record-top {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
    }
    .database-record-item-media-wrapper-large {
        min-height: 180px;
        max-height: 280px;
    }
}
.database-edit-dialog { width: min(640px, calc(100vw - 32px)); max-width: none; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); }

.database-edit-dialog form { display: grid; gap: 12px; padding: 20px; }
.database-edit-dialog h2 { margin: 0; font-size: 18px; }
.database-edit-dialog label { color: var(--muted); font-size: 13px; }
.database-edit-dialog textarea { box-sizing: border-box; width: 100%; min-height: 320px; padding: 12px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--bg); font: 13px/1.5 var(--mono); }
.dialog-actions { justify-content: flex-end; }

