/* ══════════════════════════════════════
   STUDIOPLAI — CREATOR
   Чат-интерфейс. Три колонки.
   Версия: 68
   ══════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --cream:        #FFF8F2;
    --cream-dark:   #F0E8E0;
    --warm:         #E8D5C0;
    --warm-light:   #F5EDE4;
    --orange:       #D4700A;
    --orange-light: #E8881F;
    --orange-glow:  rgba(212,112,10,0.10);
    --orange-border:rgba(212,112,10,0.15);
    --text:         #1A1A1A;
    --text-mid:     #555555;
    --text-light:   #999999;
    --text-muted:   #BBBBBB;
    --card:         #FFFFFF;
    --card-hover:   #FFFAF6;
    --border:       #EDE5DC;
    --border-light: #F3EDE6;
    --sidebar-w:    280px;
    --panel-w:      300px;
    --input-h:      140px;
    --header-h:     58px;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--cream);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--orange-glow);
    color: var(--text);
}

/* Скроллбары */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--warm); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--orange-border); }

/* ══════════════════════════════
   LAYOUT — три колонки, 100vh
   ══════════════════════════════ */

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
    grid-template-rows: var(--header-h) auto minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.sidebar, .chat, .app-panel-slot {
    grid-row: 3;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Верхние вкладки продукта: Сценарий / Дизайн / Видео / Агент */
.app-product-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 0;
    padding: 0 12px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    z-index: 50;
}

.app-product-tab {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-mid);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 14px;
    margin-bottom: -1px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
}

.app-product-tab:hover {
    color: var(--text);
    background: var(--warm-light);
}

.app-product-tab.is-active {
    color: var(--orange);
    border-bottom-color: var(--orange);
}

.app-panel-slot {
    grid-column: 3;
    grid-row: 3;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: visible !important;
    background: var(--card);
    border-left: 1px solid var(--border);
    position: relative;
}

.app-panel-slot > .panel {
    flex: 1;
    min-height: 0;
    border-left: none;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-panel-slot > .panel[hidden] {
    display: none !important;
}

/* ── HEADER (top bar) ── */
.app-header {
    grid-column: 1 / -1;
    grid-row: 1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px 20px;
    padding: 0 20px;
    min-height: var(--header-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.app-header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-width: 0;
    padding: 4px 0;
}

/* Как название у логотипа StudioPlai (Georgia 16px bold) */
.app-header-project {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Как раньше мелкая специализация справа от Creator */
.app-header-chain {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    line-height: 1.3;
    margin-top: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-logo {
    font-family: 'Georgia', serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-logo-accent {
    color: var(--orange);
}

.app-logo-badge {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--orange);
    background: var(--orange-glow);
    border: 1px solid var(--orange-border);
    padding: 2px 8px;
    border-radius: 4px;
}

.app-header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    max-width: 55%;
}

/* Правая зона шапки: одна строка, как в типичных SaaS */
.header-tray {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: nowrap;
    min-width: 0;
}

.header-model-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 140px;
    min-width: 0;
    padding: 4px 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-light);
    white-space: nowrap;
}

.header-model-dot {
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2e7d32;
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2);
}

.header-model-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-balance-pill {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--orange);
    text-decoration: none;
    white-space: nowrap;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 106, 0, 0.08);
    border: 1px solid rgba(255, 106, 0, 0.2);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.header-balance-pill:hover {
    background: rgba(255, 106, 0, 0.12);
    border-color: rgba(255, 106, 0, 0.35);
}

.header-user-menu {
    position: relative;
    flex-shrink: 0;
}

.header-user-menu > summary {
    list-style: none;
    cursor: pointer;
}

.header-user-menu > summary::-webkit-details-marker {
    display: none;
}

.header-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px 4px 4px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.header-user-trigger:hover {
    background: var(--warm-light);
    border-color: var(--border);
}

.header-user-menu[open] .header-user-trigger {
    background: var(--warm-light);
    border-color: var(--border);
}

.header-user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    color: var(--orange);
    background: var(--orange-glow);
    border: 1px solid var(--orange-border);
}

.header-user-name {
    max-width: 120px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-user-chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.header-user-menu[open] .header-user-chevron {
    transform: rotate(180deg);
}

.header-user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    padding: 6px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(26, 26, 26, 0.1);
    z-index: 200;
}

.header-user-dropdown-item {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    transition: background 0.12s ease;
}

.header-user-dropdown-item:hover {
    background: var(--warm-light);
}

.header-user-dropdown-item--danger {
    color: #b71c1c;
}

.header-user-dropdown-item--danger:hover {
    background: rgba(183, 28, 28, 0.06);
}

/* ══════════════════════════════
   SIDEBAR — левая колонка (диалоги)
   ══════════════════════════════ */

.sidebar {
    grid-column: 1;
    grid-row: 3;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-head {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-light);
}

.sidebar-new-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--orange-glow);
    border: 1px solid var(--orange-border);
    border-radius: 6px;
    color: var(--orange);
    font-size: 16px;
    cursor: pointer;
    transition: all .2s;
    line-height: 1;
}

.sidebar-new-btn:hover {
    background: var(--orange);
    color: #FFF;
    border-color: var(--orange);
}

.sidebar-search {
    padding: 10px 16px;
    flex-shrink: 0;
}

.sidebar-search-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--text);
    outline: none;
    transition: border-color .2s;
}

.sidebar-search-input:focus {
    border-color: var(--orange);
}

.sidebar-search-input::placeholder {
    color: var(--text-muted);
}

.sidebar-switch {
    display: flex;
    gap: 8px;
    padding: 10px 16px 0;
}

.sidebar-switch-btn {
    flex: 1;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.sidebar-switch-btn.is-active {
    background: var(--orange-glow);
    border-color: var(--orange-border);
    color: var(--orange);
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.sidebar-list--gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-content: start;
}

.sidebar-list--gallery .sidebar-group-label,
.sidebar-list--gallery .sidebar-empty {
    grid-column: 1 / -1;
}

.sidebar-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 10px 6px;
}

.sidebar-chat-row {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    min-width: 0;
}

.sidebar-chat-row + .sidebar-chat-row {
    margin-top: 2px;
}

.sidebar-item {
    display: block;
    width: auto;
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    transition: background .15s;
    font-family: 'Inter', sans-serif;
}

.sidebar-item:hover {
    background: var(--warm-light);
}

.sidebar-item.active {
    background: var(--orange-glow);
    border: 1px solid var(--orange-border);
}

.sidebar-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item-sub {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item.active .sidebar-item-title {
    color: var(--orange);
}

.sidebar-item-menu-btn {
    width: 34px;
    min-width: 34px;
    flex-shrink: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}

.sidebar-item-menu-btn span {
    font-size: 16px;
    line-height: 1;
    transform: translateY(-1px);
    letter-spacing: 1px;
}

.sidebar-chat-row:hover .sidebar-item-menu-btn,
.sidebar-chat-row.is-menu-open .sidebar-item-menu-btn {
    background: var(--warm-light);
    color: var(--text);
}

.sidebar-item-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 20;
    min-width: 180px;
    padding: 8px;
    background: #efe2cf;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 14px 32px rgba(0,0,0,0.12);
    display: none;
}

.sidebar-chat-row.is-menu-open .sidebar-item-menu {
    display: block;
}

.sidebar-item-menu-action {
    width: 100%;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    text-align: left;
    padding: 0 14px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.sidebar-item-menu-action:hover {
    background: rgba(255,255,255,0.45);
}

.sidebar-item-menu-action--danger {
    color: #d7372f;
}

.sidebar-item-menu-action--danger:hover {
    background: rgba(215,55,47,0.08);
}

.sidebar-empty {
    padding: 14px 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.gallery-card {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 8px;
    margin: 0;
    cursor: pointer;
    min-width: 0;
}

.gallery-card-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: var(--warm-light);
    margin-bottom: 8px;
}

.gallery-card-image,
.gallery-card-video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.gallery-card-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-card-sub {
    font-size: 10px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.gallery-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: flex-start;
}

.gallery-action-btn {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}

.gallery-action-btn svg {
    width: 15px;
    height: 15px;
    display: block;
    flex: 0 0 auto;
}

.gallery-action-btn:hover {
    background: var(--warm-light);
    border-color: var(--border);
    color: var(--text-mid);
}

.gallery-action-btn--danger {
    color: #b04444;
}

.gallery-action-btn--danger:hover {
    background: rgba(200,60,60,0.1);
    border-color: rgba(200,60,60,0.2);
    color: #C03030;
}

/* ══════════════════════════════
   CHAT — центральная колонка
   ══════════════════════════════ */

.chat {
    grid-column: 2;
    grid-row: 3;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--cream);
}

.chat-main-stack {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workspace-tab {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workspace-tab[hidden] {
    display: none !important;
}

.workspace-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
}

.workspace-placeholder-icon {
    font-size: 28px;
    color: var(--orange);
    opacity: 0.45;
    margin-bottom: 12px;
    line-height: 1;
}

.workspace-placeholder-title {
    font-family: 'Georgia', serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 10px;
}

.workspace-placeholder-text {
    font-size: 14px;
    color: var(--text-mid);
    line-height: 1.5;
    max-width: 28rem;
    margin: 0;
}

/* Лента сообщений */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.chat-empty-inner {
    max-width: 400px;
}

.chat-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.chat-empty-title {
    font-family: 'Georgia', serif;
    font-size: 22px;
    font-weight: 700;
    font-style: italic;
    color: var(--text);
    margin-bottom: 8px;
}

.chat-empty-sub {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.6;
}

.chat-empty-sub p {
    margin: 0 0 0.35em;
}

.chat-empty-sub p:last-child {
    margin-bottom: 0;
}

.design-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 32px 0;
}

.design-toolbar label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.design-toolbar select {
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--card);
    color: var(--text);
    font-size: 12px;
}

.design-right-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    padding: 10px;
}

.design-right-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.design-right-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-light);
    margin-top: 2px;
}

.design-right-select {
    width: 100%;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--cream);
    color: var(--text);
    font-size: 12px;
    padding: 0 10px;
}

.design-mode-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.design-mode-btn {
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text-mid);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.design-mode-btn:hover {
    border-color: var(--orange-border);
}

.design-mode-btn.is-active {
    background: var(--orange-glow);
    border-color: var(--orange-border);
    color: var(--orange);
}

.design-ratio-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.design-ratio-btn {
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text-mid);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.design-ratio-btn:hover {
    border-color: var(--orange-border);
}

.design-ratio-btn.is-active {
    background: var(--orange-glow);
    border-color: var(--orange-border);
    color: var(--orange);
}

.design-help-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(0,0,0,0.02);
}

.design-help-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.design-help-box p {
    margin: 0 0 8px;
    font-size: 12px;
    line-height: 1.4;
}

.design-help-box p:last-child {
    margin-bottom: 0;
}

.design-inline-note {
    font-size: 11px;
    line-height: 1.45;
    color: var(--text-muted);
    margin-top: -2px;
}

.design-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 2px;
    font-size: 12px;
    color: var(--text-mid);
    cursor: pointer;
}

.design-checkbox-row input {
    accent-color: var(--orange);
}

.design-panel-btn {
    width: 100%;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.design-panel-btn:hover {
    border-color: var(--orange-border);
    color: var(--orange);
}

.design-panel-reopen {
    padding: 8px 10px 0;
}

.design-panel-reopen-btn {
    height: 32px;
    border: 1px solid var(--orange-border);
    border-radius: 8px;
    background: var(--orange-glow);
    color: var(--orange);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 10px;
}

.msg-design-download, .msg-design-variation {
    height: 28px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--card);
    padding: 0 10px;
    font-size: 12px;
    cursor: pointer;
}

/* Сообщение */
.msg {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg--ai {
    align-self: flex-start;
}

.msg--audio-player {
    width: min(100%, 760px);
    max-width: 100%;
}

.msg--audio-player .msg-col {
    width: 100%;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.msg--user .msg-avatar {
    background: var(--orange-glow);
    border: 1px solid var(--orange-border);
    color: var(--orange);
}

.msg--ai .msg-avatar {
    background: var(--warm-light);
    border: 1px solid var(--border);
    color: var(--text-mid);
}

.msg-bubble {
    border-radius: 12px;
    padding: 14px 18px;
    line-height: 1.7;
}

.msg--user .msg-bubble {
    background: var(--orange);
    color: #FFFFFF;
    font-size: 14px;
    border-bottom-right-radius: 4px;
}

.msg--ai .msg-bubble {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}

.msg--audio-player .msg-bubble {
    width: 100%;
    box-sizing: border-box;
}

.msg--ai .msg-bubble p {
    margin-bottom: 0.8em;
    line-height: 1.8;
}

.msg--ai .msg-bubble p:last-child {
    margin-bottom: 0;
}

.msg-design-image {
    width: 100%;
    max-width: 520px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: block;
    cursor: zoom-in;
}

.msg-video {
    width: 100%;
    max-width: 560px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #000;
    display: block;
}

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

.msg-audio-wrap {
    width: 100%;
}

/* Индикатор печатания */
.msg-typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.msg-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--warm);
    border-radius: 50%;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.msg-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.msg-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); background: var(--warm); }
    30% { transform: translateY(-6px); background: var(--orange); }
}

/* Метка времени */
.msg-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.msg-actions {
    margin-top: 8px;
}

.msg-add-scene-btn {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--orange);
    background: rgba(255, 106, 0, 0.1);
    border: 1px solid rgba(255, 106, 0, 0.28);
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.msg-add-scene-btn:hover {
    background: rgba(255, 106, 0, 0.16);
    border-color: var(--orange);
}

.msg-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

.msg--user .msg-time { text-align: right; }

/* ── Поле ввода ── */
.chat-input-wrap {
    flex-shrink: 0;
    padding: 16px 32px 20px;
    background: var(--cream);
    border-top: 1px solid var(--border-light);
    position: relative;
    z-index: 5;
}

.chat-input-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s;
}

.chat-onboarding-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-onboarding-text {
    font-size: 13px;
    color: var(--text-mid);
    line-height: 1.4;
    min-width: 0;
}

.chat-onboarding-btn {
    flex-shrink: 0;
    padding: 10px 14px;
    border: 1px solid var(--orange);
    border-radius: 10px;
    background: var(--orange);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.chat-onboarding-btn:hover {
    filter: brightness(1.05);
}

.chat-composer--onboarding .chat-input-card {
    display: none;
}

.chat-input-card:focus-within {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-glow);
}

.chat-textarea {
    width: 100%;
    min-height: 80px;
    max-height: 180px;
    resize: none;
    border: none;
    outline: none;
    padding: 14px 16px 0;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: transparent;
}

.chat-textarea::placeholder {
    color: var(--text-muted);
}

.chat-input-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px 10px;
}

.chat-input-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-tool-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-light);
    font-size: 16px;
    cursor: pointer;
    transition: all .15s;
}

.chat-tool-btn:hover {
    background: var(--warm-light);
    border-color: var(--border);
    color: var(--text-mid);
}

.chat-send-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--orange);
    color: #FFF;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
}

.chat-send-btn:hover {
    background: var(--orange-light);
    transform: translateY(-1px);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.chat-send-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.chat-input-hint {
    text-align: center;
    padding: 6px 0 0;
    font-size: 11px;
    color: var(--text-muted);
}

.chat-input-hint kbd {
    background: var(--warm-light);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
}

/* ══════════════════════════════
   PANEL — правая колонка (репозиторий)
   ══════════════════════════════ */

.panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: var(--card);
    min-height: 0;
    overflow: hidden;
    position: relative;
    border: 2px solid transparent; /* ДЛЯ ОТЛАДКИ */
}

.panel--empty {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px 16px;
}

.panel--agent {
    align-items: stretch;
    justify-content: flex-start;
    text-align: left;
    padding: 0;
    overflow: auto;
}

.agent-right-panel {
    margin: 16px;
}

.sound-right-panel {
    margin: 16px;
}

.sound-voice-picker-btn {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.sound-voice-picker-btn:hover {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.08);
}

.sound-voice-picker-btn__title {
    font-size: 14px;
    font-weight: 600;
}

.sound-voice-picker-btn__meta {
    font-size: 12px;
    color: var(--text-muted);
}

.sound-voice-selected {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-mid);
}

.panel-empty-inner {
    max-width: 240px;
}

.panel-empty-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-light);
    margin: 0 0 8px;
}

.panel-empty-text {
    font-size: 13px;
    color: var(--text-mid);
    line-height: 1.45;
    margin: 0;
}

.panel-head {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.panel-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-light);
}

.panel-tabs {
    display: flex;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.panel-tab {
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all .15s;
    font-family: 'Inter', sans-serif;
}

.panel-tab:hover {
    color: var(--text-mid);
}

.panel-tab.active {
    color: var(--orange);
    border-bottom-color: var(--orange);
}

.panel-body {
    flex: 1;
    overflow: hidden;
    overflow-x: hidden;
    padding: 12px;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#tabRepo, #tabSettings {
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

#tabRepo {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#tabSettings {
    display: block;
    overflow-y: auto;
}

#tabRepo > :not(#repoV2) {
    flex: 0 0 auto;
}

#repoLegacyWrap {
    display: none !important;
}

/* Проект в боковой панели */
.repo-project-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.repo-project-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    width: 100%;
}

.repo-project-select {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--cream);
    color: var(--text);
}

.repo-project-actions {
    display: flex;
    gap: 4px;
}

.repo-project-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--cream);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-mid);
}

.repo-project-btn:hover {
    background: var(--warm-light);
    border-color: var(--orange);
    color: var(--orange);
}

.repo-project-btn--text {
    font-size: 14px;
}

.repo-project-btn--danger:hover {
    border-color: #c62828;
    color: #c62828;
}

.repo-project-hint {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0 0 12px;
    padding: 0 2px;
}

.repo-scene-repo-chat-hint {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0 0 8px;
    padding: 0 2px;
}

.repo-item-ctx-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    padding-top: 1px;
}

.repo-item-ctx-left--muted {
    opacity: 0.55;
    pointer-events: none;
}

.repo-scene-repo-label {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    cursor: pointer;
    line-height: 1;
}

.repo-chat-ctx-cb {
    width: 15px;
    height: 15px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--orange);
}

.repo-publish-block {
    margin: 0 0 14px;
}

.repo-publish-btn {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(180deg, var(--orange-light) 0%, var(--orange) 100%);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(212, 112, 10, 0.25);
}

.repo-publish-btn:hover {
    filter: brightness(1.05);
}

.repo-publish-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.repo-publish-msg {
    font-size: 11px;
    color: var(--text-mid);
    margin: 8px 0 0;
    line-height: 1.4;
    word-break: break-word;
}

.repo-publish-msg a {
    color: var(--orange);
    font-weight: 600;
}

/* Элементы репозитория */
.repo-section {
    margin-bottom: 16px;
}

.repo-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 8px 6px;
}

.repo-spoiler {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    margin: 10px 0;
    overflow: visible !important;
}

.repo-spoiler-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 12px;
    background: linear-gradient(90deg, rgba(212,112,10,0.10) 0%, transparent 62%);
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    text-align: left;
}
.repo-spoiler-head:hover {
    background: linear-gradient(90deg, rgba(212,112,10,0.14) 0%, transparent 68%);
}
.repo-spoiler-chev {
    font-size: 11px;
    color: var(--orange);
    opacity: 0.8;
    transition: transform .2s ease, opacity .2s ease;
    flex-shrink: 0;
}
.repo-spoiler.open .repo-spoiler-chev {
    transform: rotate(180deg);
    opacity: 1;
}
.repo-spoiler-body {
    display: none;
    border-top: 1px solid var(--border-light);
    padding: 6px 2px;
    background: rgba(0,0,0,0.015);
    flex-direction: column;
    max-height: none !important;
}

.repo-spoiler.open .repo-spoiler-body {
    display: flex;
}

.repo-filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 4px;
}
.repo-filter-input {
    flex: 1;
    min-width: 0;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 12px;
    outline: none;
}
.repo-filter-input:focus {
    border-color: rgba(212,112,10,0.45);
    box-shadow: 0 0 0 3px rgba(212,112,10,0.10);
}
.repo-filter-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.repo-item--deleted {
    opacity: 0.55;
}

.repo-empty--small {
    padding: 14px 10px;
}

.repo-entity-desc {
    font-size: 13px;
    line-height: 1.45;
}
.repo-entity-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
}
.repo-entity-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 55%;
    text-align: right;
}
.scene-modal-box--repo-entity {
    max-width: 820px;
}

.repo-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.repo-item-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
}
.repo-item-btn:hover {
    opacity: 1;
    background: rgba(212,112,10,0.10);
    color: var(--orange);
}
.repo-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 6px 10px 8px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--orange-border);
    background: var(--orange-glow);
    color: var(--orange);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.repo-add-btn:hover {
    background: rgba(212,112,10,0.14);
}

.repo-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: default;
    transition: background .15s;
    min-height: 60px; /* ГАРАНТИЯ ВЫСОТЫ */
    flex-shrink: 0;   /* ЗАПРЕТ СЖАТИЯ */
}

.repo-item:hover {
    background: var(--warm-light);
}

.repo-item--scene {
    cursor: pointer;
}

.repo-item--scene:active {
    filter: brightness(0.98);
}

.repo-scene-drag-handle {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.repo-scene-drag-handle:active {
    cursor: grabbing;
}

.repo-item--scene.repo-item--dragging {
    opacity: 0.5;
    outline: 1px dashed var(--orange);
    outline-offset: 1px;
}

.repo-item-del {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.65;
}

.repo-item-del:hover {
    opacity: 1;
    color: #c62828;
    background: rgba(198, 40, 40, 0.08);
}

.repo-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    background: var(--cream);
    border: 1px solid var(--border);
}

.repo-item-text {
    flex: 1;
    min-width: 0;
}

.repo-item-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.repo-item-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 1px;
}

.repo2 {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
}

#repoV2 {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
}

.repo2-block + .repo2-block {
    margin-top: 12px;
}

.repo2-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    flex-shrink: 0;
}

.repo2-tab {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-mid);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.repo2-tab.is-active {
    border-color: var(--orange-border);
    color: var(--orange);
    background: var(--orange-glow);
}

.repo2-block {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    overflow: hidden;
}

.repo2-pane {
    display: none;
}

.repo2-pane.is-active {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
}

.repo2-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 12px;
    background: linear-gradient(90deg, rgba(212,112,10,0.10) 0%, transparent 62%);
    flex-shrink: 0;
}

.repo2-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.repo2-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid var(--orange-border);
    background: var(--orange-glow);
    color: var(--orange);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.repo2-btn:hover {
    background: rgba(212,112,10,0.14);
}

.repo2-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}

.repo2-input {
    flex: 1;
    min-width: 0;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 12px;
    outline: none;
}

.repo2-input:focus {
    border-color: rgba(212,112,10,0.45);
    box-shadow: 0 0 0 3px rgba(212,112,10,0.10);
}

.repo2-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.repo2-list {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

#repo2Characters,
#repo2Locations,
#repo2Lore {
    max-height: none;
}

.repo2-empty {
    padding: 14px 12px;
    color: var(--text-muted);
    font-size: 12px;
}

.repo2-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-top: 1px solid var(--border-light);
    min-height: 56px;
}

.repo2-item:first-child {
    border-top: none;
}

.repo2-item:hover {
    background: var(--warm-light);
}

.repo2-item-main {
    flex: 1;
    min-width: 0;
}

.repo2-item-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.repo2-item-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.repo2-del {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.65;
}

.repo2-del:hover {
    opacity: 1;
    color: #c62828;
    background: rgba(198, 40, 40, 0.08);
}

/* Пустое состояние репозитория */
.repo-empty {
    padding: 32px 16px;
    text-align: center;
}

.repo-empty-icon {
    font-size: 32px;
    opacity: 0.3;
    margin-bottom: 10px;
}

.repo-empty-text {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Настройки в панели */
.panel-setting {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
}

.panel-setting-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 4px 0;
}

.panel-setting-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-mid);
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-setting-label .icon {
    font-size: 14px;
    opacity: 0.5;
}

.panel-setting-chevron {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform .2s;
}

.panel-setting.open .panel-setting-chevron {
    transform: rotate(180deg);
}

.panel-setting-body {
    display: none;
    padding-top: 10px;
}

.panel-setting.open .panel-setting-body {
    display: block;
}

.panel-select {
    width: 100%;
    padding: 8px 10px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--text);
    outline: none;
    cursor: pointer;
    margin-bottom: 8px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23999' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.panel-select:focus {
    border-color: var(--orange);
}

.panel-setting-hint {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0 0 8px;
}

.panel-setting-error {
    font-size: 11px;
    color: #b42318;
    line-height: 1.45;
    margin: 0 0 8px;
    padding: 8px 10px;
    background: rgba(180, 35, 24, 0.08);
    border-radius: 6px;
}

.settings-project-prompt {
    width: 100%;
    box-sizing: border-box;
    min-height: 140px;
    max-height: min(280px, 42vh);
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.45;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--cream);
    color: var(--text);
    resize: vertical;
    outline: none;
    overflow-y: auto;
}

.settings-project-prompt:focus {
    border-color: var(--orange);
}

.settings-prompt-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 8px;
}

/* Текстовые кнопки в настройках (не 34×34 как + / ✎ в «Файлы») */
.settings-prompt-bar .repo-project-btn {
    width: 100%;
    height: auto;
    min-height: 40px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    white-space: normal;
    line-height: 1.3;
}

.settings-prompt-bar .repo-project-btn--primary {
    background: var(--orange);
    border-color: var(--orange);
    color: #fff;
}

.settings-prompt-bar .repo-project-btn--primary:hover {
    filter: brightness(1.05);
    border-color: var(--orange);
    color: #fff;
}

.settings-spec-row {
    margin-bottom: 12px;
}

.settings-inline-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.settings-radio-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-select-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin: 10px 0 6px;
    color: var(--text);
}

.settings-format-wrap {
    margin-bottom: 4px;
}

.panel-textarea {
    width: 100%;
    min-height: 180px;
    padding: 10px 12px;
    margin-bottom: 10px;
    box-sizing: border-box;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Inter', ui-monospace, monospace;
    font-size: 11px;
    line-height: 1.45;
    color: var(--text);
    resize: vertical;
    outline: none;
}

.panel-textarea:focus {
    border-color: var(--orange);
}

.panel-save-btn {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    background: var(--orange);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.panel-save-btn:hover {
    filter: brightness(1.05);
}

.panel-save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ══════════════════════════════
   AUTH PAGE
   ══════════════════════════════ */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cream);
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px 36px 36px;
    width: 100%;
    max-width: 380px;
    margin: 20px;
    box-shadow: 0 4px 24px rgba(180,140,100,0.1);
    text-align: center;
}

.auth-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--orange);
    margin-bottom: 8px;
}

.auth-title {
    font-family: 'Georgia', serif;
    font-size: 24px;
    font-weight: 700;
    font-style: italic;
    color: var(--text);
    margin-bottom: 28px;
}

.auth-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text);
    outline: none;
    text-align: center;
    letter-spacing: 2px;
    transition: border-color .2s, box-shadow .2s;
}

.auth-input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-glow);
}

.auth-input::placeholder {
    color: var(--text-muted);
    letter-spacing: 0;
}

.auth-btn {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 14px;
    background: var(--orange);
    color: #FFF;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s;
}

.auth-btn:hover { background: var(--orange-light); }

.auth-error {
    margin-top: 16px;
    font-size: 14px;
    color: #B83030;
}

.auth-hint {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

/* ══════════════════════════════
   RESPONSIVE
   ══════════════════════════════ */

@media (max-width: 1100px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-h) auto 1fr;
    }
    .app-product-tabs {
        grid-column: 1;
    }
    .sidebar, .app-panel-slot {
        display: none;
    }
    .chat {
        grid-column: 1;
        grid-row: 3;
    }
    .chat-messages {
        padding: 20px 16px;
    }
.chat-input-wrap {
    padding: 12px 16px 16px;
    }
}

/* ── PAYWALL (пробный запрос исчерпан) ── */
.chat-paywall {
    padding: 20px 24px 28px;
}

.chat-paywall-inner {
    max-width: 420px;
    margin: 0 auto;
    text-align: center;
    padding: 24px 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.chat-paywall-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.chat-paywall-text {
    font-size: 13px;
    color: var(--text-mid);
    line-height: 1.5;
    margin-bottom: 18px;
}

.chat-paywall-btn {
    display: inline-block;
    padding: 12px 28px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    color: #fff !important;
    background: var(--orange);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background .2s;
    text-decoration: none;
    text-align: center;
    box-sizing: border-box;
}

.chat-paywall-btn:hover {
    background: var(--orange-light);
}

/* ── ATTACHMENTS ── */
.chat-attach-preview {
    padding: 10px 14px 0;
}

.chat-attach-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-attach-design-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.chat-attach-design-card {
    min-width: 0;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.chat-attach-design-card:hover {
    transform: translateY(-1px);
    border-color: var(--orange-border);
    box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}

.chat-attach-design-media {
    position: relative;
    aspect-ratio: 1 / 1;
    background: rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-attach-design-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.chat-attach-design-meta {
    padding: 8px;
}

.chat-attach-design-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.chat-attach-design-sub {
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-attach-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 8px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-mid);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.chat-attach-file--design-ref {
    min-height: 58px;
    align-items: center;
}

.chat-attach-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.chat-attach-thumb-wrap {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.chat-attach-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-attach-remove {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-light);
    font-size: 12px;
    cursor: pointer;
    transition: all .15s;
}

.chat-attach-remove:hover {
    background: rgba(200,60,60,0.1);
    border-color: rgba(200,60,60,0.2);
    color: #C03030;
}

.chat-attach-remove--overlay {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255,255,255,0.92);
    border-color: rgba(0,0,0,0.06);
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

.design-ref-badge {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--orange-border);
    background: var(--orange-glow);
    color: var(--orange);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

/* ── TEMPLATES ── */
.chat-templates {
    padding: 8px 12px 12px;
    border-top: 1px solid var(--border-light);
}

.chat-templates-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 4px 4px 8px;
}

.chat-templates-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-templates-select {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--cream);
    color: var(--text);
}

.chat-templates-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.chat-templates-actions .repo-project-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.chat-template-insert-btn {
    display: block;
    width: 100%;
    padding: 10px 14px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--warm-light);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.chat-template-insert-btn:hover:not(:disabled) {
    background: var(--orange-glow);
    border-color: var(--orange-border);
    color: var(--text);
}

.chat-template-insert-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.scene-modal-box--idea-template {
    max-width: min(640px, 96vw);
}

.idea-template-modal-text {
    width: 100%;
    box-sizing: border-box;
    min-height: 180px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
    background: var(--cream);
    color: var(--text);
    resize: vertical;
}

.idea-template-modal-text:focus {
    outline: none;
    border-color: var(--orange);
}

/* ── Модальное окно: выбор проекта для сцены ── */
.scene-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.scene-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(26, 26, 26, 0.45);
}

.scene-modal-box {
    position: relative;
    z-index: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px 20px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
}

.scene-modal-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 14px;
    line-height: 1.35;
}

.scene-modal-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.scene-modal-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--cream);
    margin-bottom: 18px;
    color: var(--text);
}

.scene-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.scene-modal-btn {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
}

.scene-modal-btn--ghost {
    background: var(--warm-light);
    color: var(--text);
}

.scene-modal-btn--ghost:hover {
    filter: brightness(0.98);
}

.scene-modal-btn--primary {
    background: var(--orange);
    color: #fff;
}

.scene-modal-btn--primary:hover {
    filter: brightness(1.05);
}

.scene-modal-box--wide {
    max-width: 440px;
}

.scene-modal-box--sound-voice {
    max-width: 980px;
    width: min(980px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

.sound-voice-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.sound-voice-modal-header .scene-modal-title {
    margin: 0;
}

.sound-voice-modal-subtitle {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.sound-voice-modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.sound-voice-modal-close:hover {
    border-color: var(--orange);
}

.sound-voice-modal-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sound-voice-search {
    flex: 1 1 320px;
    min-width: 220px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--cream);
    color: var(--text);
    font: inherit;
    padding: 0 14px;
}

.sound-voice-tabs {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sound-voice-tab {
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.sound-voice-tab.is-active {
    border-color: var(--orange);
    background: rgba(255, 106, 0, 0.08);
    color: var(--orange);
}

.sound-voice-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sound-voice-filter {
    min-width: 140px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--cream);
    color: var(--text);
    font: inherit;
}

.sound-voice-filter-clear {
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text-mid);
    font: inherit;
    cursor: pointer;
}

.sound-voice-modal-note {
    font-size: 12px;
    color: var(--text-muted);
}

.sound-voice-list {
    overflow: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sound-voice-empty {
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--warm-light);
    padding: 20px;
    font-size: 14px;
    color: var(--text-mid);
}

.sound-voice-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sound-voice-card.is-selected {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.1);
}

.sound-voice-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.sound-voice-card-title {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
}

.sound-voice-card-desc {
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-mid);
}

.sound-voice-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sound-voice-icon-btn,
.sound-voice-select-btn {
    min-width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--warm-light);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.sound-voice-icon-btn.is-active {
    color: var(--orange);
    border-color: rgba(255, 106, 0, 0.32);
}

.sound-voice-select-btn {
    min-width: 48px;
    background: rgba(255, 106, 0, 0.08);
}

.sound-voice-select-btn.is-active {
    background: var(--orange);
    color: #fff;
    border-color: var(--orange);
}

.sound-voice-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sound-voice-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--warm-light);
    color: var(--text-mid);
    font-size: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.sound-voice-card audio {
    width: 100%;
}

.sound-voice-card-warning {
    font-size: 12px;
    color: #9d4b1f;
}

@media (max-width: 820px) {
    .scene-modal-box--sound-voice {
        width: min(100vw - 16px, 100%);
        max-height: calc(100vh - 16px);
        padding: 16px;
    }

    .sound-voice-modal-toolbar {
        align-items: stretch;
    }

    .sound-voice-tabs {
        width: 100%;
    }

    .sound-voice-tab {
        flex: 1 1 auto;
    }

    .sound-voice-filter {
        flex: 1 1 140px;
    }

    .sound-voice-card-title {
        font-size: 18px;
    }
}

.gallery-modal {
    position: fixed;
    inset: 0;
    z-index: 11000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.gallery-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 16, 12, 0.55);
}

.gallery-modal-box {
    position: relative;
    z-index: 1;
    width: fit-content;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.16);
    box-sizing: border-box;
}

.gallery-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
}

.gallery-modal-media {
    width: auto;
    max-width: 100%;
    background: transparent;
}

.gallery-modal-image,
.gallery-modal-video {
    width: auto;
    height: auto;
    max-width: calc(90vw - 72px);
    max-height: calc(90vh - 120px);
    display: block;
    object-fit: contain;
}

.gallery-modal-image {
    background: transparent;
}

.gallery-modal-video {
    background: #000;
}

.gallery-modal-dialog {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    width: fit-content;
    max-width: 100%;
}

.gallery-modal-refbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.gallery-modal-refitem {
    width: 96px;
}

.gallery-modal-refimg {
    width: 96px;
    height: 96px;
    object-fit: cover;
    display: block;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
}

.gallery-modal-reflabel {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-light);
    text-align: left;
}

.gallery-modal-file {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    padding: 12px;
    width: fit-content;
    max-width: 100%;
    box-sizing: border-box;
}

.gallery-modal-file--nav {
    position: relative;
}

.gallery-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 999px;
    background: rgba(255,255,255,0.94);
    color: var(--text);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.gallery-modal-nav:hover {
    border-color: var(--orange-border);
    color: var(--orange);
}

.gallery-modal-nav--prev {
    left: 18px;
}

.gallery-modal-nav--next {
    right: 18px;
}

.gallery-modal-counter {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 2;
    min-width: 62px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(20,16,12,0.74);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.gallery-modal-meta {
    margin-top: 8px;
}

.gallery-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.gallery-modal-sub {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-light);
}

.gallery-modal-actions {
    display: flex;
    gap: 6px;
    margin-top: 0;
    justify-content: flex-start;
}

.gallery-modal-actions--inline {
    margin-top: 0;
}

/* Проект: не обрезать низ — скролл в середине, кнопки снизу всегда видны */
#projectModal.scene-modal {
    align-items: flex-start;
    justify-content: center;
    padding-top: max(12px, 2vh);
    padding-bottom: max(12px, 2vh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.scene-modal-box--project {
    max-width: min(1280px, calc(100vw - 20px));
    width: 100%;
    max-height: calc(100vh - 24px);
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.scene-modal-box--project > .scene-modal-title {
    flex-shrink: 0;
}

.project-modal-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 8px;
    margin-right: -4px;
}

.scene-modal-box--project > .scene-modal-actions {
    flex-shrink: 0;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Редактирование сцены — широкое окно, как проект */
#sceneEditModal.scene-modal {
    align-items: flex-start;
    justify-content: center;
    padding-top: max(12px, 2vh);
    padding-bottom: max(12px, 2vh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.scene-modal-box--scene-edit {
    max-width: min(960px, calc(100vw - 20px));
    width: 100%;
    max-height: calc(100vh - 24px);
    padding: 22px 26px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.scene-modal-box--scene-edit > .scene-modal-title {
    flex-shrink: 0;
}

.scene-modal-box--scene-edit .project-modal-scroll {
    flex: 1 1 auto;
    min-height: 0;
}

.scene-modal-box--scene-edit > .scene-modal-actions--scene-edit {
    flex-shrink: 0;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.scene-modal-box--scene-edit .scene-edit-body,
.scene-modal-box--scene-edit .project-modal-prompt.scene-edit-body {
    min-height: min(420px, 52vh);
    max-height: min(640px, 65vh);
    font-family: 'Inter', ui-monospace, monospace;
    font-size: 13px;
}

.project-modal-prompt {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.45;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--cream);
    color: var(--text);
    resize: vertical;
    min-height: clamp(260px, 42vh, 560px);
    max-height: min(720px, 78vh);
}

.project-modal-format-row,
.project-modal-genre-row {
    margin-bottom: 0;
}

.project-modal-prompt:focus {
    outline: none;
    border-color: var(--accent, #c9a227);
    box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.15);
}

.project-modal-prompt-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
}

.project-modal-prompt-btn {
    font-size: 12px;
    padding: 6px 12px;
}

.scene-modal-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--cream);
    color: var(--text);
    margin-bottom: 14px;
}

.project-modal-spec {
    margin-bottom: 12px;
}

.project-modal-radio-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 4px;
}

.project-modal-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.35;
}

.project-modal-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 14px;
    line-height: 1.4;
}

.repo-project-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 8px;
    line-height: 1.4;
    min-height: 1.2em;
}
