/* Preserve the HTML hidden contract against component flex/grid rules. */
[hidden] {
    display: none !important;
}

:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --bg-accent: radial-gradient(circle at top left, rgba(76, 119, 255, 0.14), transparent 32%), radial-gradient(circle at top right, rgba(95, 67, 204, 0.12), transparent 28%), linear-gradient(180deg, #f8fbff 0%, #f4f7fb 36%, #eef3f9 100%);
    --surface: rgba(255, 255, 255, 0.94);
    --surface-strong: #ffffff;
    --surface-alt: #f5f8ff;
    --surface-muted: #eef3fb;
    --border: #d7e1f0;
    --border-strong: #c5d2e6;
    --text: #182235;
    --muted: #617189;
    --primary: #3562f4;
    --primary-strong: #2548bc;
    --primary-soft: #e6edff;
    --success-soft: #e8f8ee;
    --success-text: #1f6a43;
    --warning-soft: #fff6dd;
    --warning-text: #915f00;
    --danger-soft: #fff0f0;
    --danger-text: #b43c3c;
    --info-soft: #edf4ff;
    --info-text: #2f59c3;
    --shadow-sm: 0 10px 24px rgba(22, 34, 60, 0.06);
    --shadow-md: 0 18px 40px rgba(22, 34, 60, 0.1);
    --shadow-lg: 0 26px 56px rgba(22, 34, 60, 0.14);
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-pill: 999px;
    --control-height: 48px;
    --control-height-sm: 36px;
    --control-radius: 12px;
    --control-padding-x: 15px;
    --focus-ring: 0 0 0 4px rgba(53, 98, 244, 0.12);
    --sticky-offset: 88px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    height: 100%;
}

html:has(body.novel-editor-body) {
    overflow: auto;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg-accent);
    line-height: 1.55;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

img,
video {
    max-width: 100%;
    display: block;
}

code {
    padding: 0.12rem 0.45rem;
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--primary-strong);
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-size: 0.92em;
}

pre code,
.result-block code {
    display: inline;
    padding: 0;
    background: transparent;
    color: inherit;
}

h1,
h2,
h3,
p,
ul {
    margin-top: 0;
}

h1,
h2,
h3,
strong {
    overflow-wrap: anywhere;
}

.shell {
    width: min(1440px, calc(100% - 32px));
    margin: 0 auto;
}

.app-body {
    display: flex;
    flex-direction: column;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 64px;
    background: rgba(244, 247, 251, 0.82);
    border-bottom: 1px solid rgba(215, 225, 240, 0.95);
    backdrop-filter: blur(18px);
}

.shell-header,
.shell-subnav,
.site-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.shell-header {
    min-height: 64px;
    padding: 8px 0;
    flex-wrap: nowrap;
}

.brand-block {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.brand {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.brand-caption,
.shell-subnav {
    display: none;
}

.header-project-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--muted);
    font-size: 0.95rem;
    white-space: nowrap;
}

.header-project-label {
    color: var(--muted);
}

.header-project-title {
    color: var(--text);
    font-size: 0.98rem;
}

.project-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-sm);
}

.project-chip-label {
    color: var(--muted);
    font-size: 0.9rem;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    flex: 1 1 auto;
    gap: 10px;
}

.site-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0.62rem 0.95rem;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    color: var(--muted);
    font-weight: 600;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.site-nav a:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(197, 210, 230, 0.8);
    transform: translateY(-1px);
}

.site-nav a.is-active {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: rgba(107, 137, 255, 0.28);
    box-shadow: inset 0 0 0 1px rgba(107, 137, 255, 0.08);
}

.page-shell {
    flex: 1;
    padding: 20px 0 32px;
}

.novel-editor-body {
    min-height: 100vh;
    overflow: auto;
}

.novel-editor-body .site-footer {
    display: none;
}

.novel-editor-body .page-shell {
    height: auto;
    min-height: calc(100vh - 64px);
    padding: 24px 0 40px;
    overflow: visible;
}

.flash-stack {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.hero-card,
.panel {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid rgba(215, 225, 240, 0.96);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
}

.hero-card::before,
.panel::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, rgba(53, 98, 244, 0.22), rgba(95, 67, 204, 0.08), transparent);
}

.hero-card {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.95fr);
    gap: 26px;
    padding: 30px;
    margin-bottom: 24px;
}

.panel {
    padding: 24px;
    margin-bottom: 24px;
}

.grid {
    display: grid;
    gap: 20px;
}

.workbench-layout {
    display: grid;
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.workbench-sidebar,
.workbench-main {
    min-width: 0;
}

.sticky-stack {
    position: sticky;
    top: var(--sticky-offset);
    display: grid;
    gap: 16px;
}

.header-status-meta {
    flex: 0 0 auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.novel-workbench {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 340px;
    gap: 20px;
    height: auto;
    min-height: auto;
    align-items: start;
}

.chapter-sidebar,
.editor-column,
.ai-sidebar {
    min-width: 0;
    min-height: 0;
}

.chapter-sidebar-panel,
.ai-sidebar-panel {
    margin-bottom: 0;
}

.chapter-panel,
.editor-panel,
.ai-panel {
    min-height: 0;
}

.chapter-sidebar-head,
.chapter-sidebar-toolbar,
.editor-panel-head,
.editor-panel-kicker,
.editor-title-row,
.editor-inline-meta,
.editor-footnote,
.editor-primary-actions,
.ai-sidebar-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-footer-note {
    padding: 0 4px;
    text-align: center;
}

.chapter-sidebar-head,
.editor-panel-head,
.editor-title-row {
    align-items: center;
    justify-content: space-between;
}

.chapter-sidebar-head h1 {
    margin-bottom: 0;
    font-size: 1.4rem;
}

.chapter-sidebar-copy {
    margin-bottom: 12px;
}

.chapter-sidebar-toolbar {
    flex-direction: column;
    margin-bottom: 16px;
}

.chapter-search-field {
    display: block;
}

.chapter-search-field input {
    min-height: 42px;
}

.chapter-card-list {
    display: grid;
    gap: 10px;
    min-height: 0;
}

.chapter-create-disclosure {
    display: grid;
    gap: 12px;
}

.chapter-create-disclosure summary {
    list-style: none;
    cursor: pointer;
}

.chapter-create-disclosure summary::-webkit-details-marker {
    display: none;
}

.chapter-create-form {
    padding-top: 8px;
}

.chapter-create-disclosure:not([open]) .chapter-create-form {
    display: none;
}

.editor-panel {
    height: auto;
    min-height: calc(100vh - 112px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 0;
}

.editor-panel-head {
    align-items: flex-start;
}

.editor-panel-title {
    display: grid;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
}

.editor-panel-kicker {
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.editor-title-row {
    gap: 14px;
}

.editor-title-input {
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: clamp(1.55rem, 2.2vw, 2rem);
    font-weight: 800;
}

.editor-title-input:focus {
    outline: none;
    box-shadow: none;
}

.editor-inline-meta,
.editor-footnote {
    flex-wrap: wrap;
    align-items: center;
    color: var(--muted);
    font-size: 0.94rem;
}

.editor-primary-actions {
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.editor-primary-actions .primary-btn,
.editor-primary-actions .success-btn,
.editor-primary-actions .action-menu > summary {
    min-height: 46px;
    padding: 0 18px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 15px;
    font-weight: 800;
    box-sizing: border-box;
    white-space: nowrap;
}

.editor-primary-actions #cinematicRewriteBtn {
    min-width: 176px;
}

.editor-primary-actions #saveChapterBtn {
    min-width: 112px;
}

/* UI-B.1.1 — save/cinematic CTA hierarchy (novel editor only).
   Clean editor: save = neutral secondary, cinematic = primary CTA enabled.
   Dirty editor: save = emphasized primary, cinematic = disabled. */
.novel-editor-body .editor-primary-actions #saveChapterBtn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: none;
}
.novel-editor-body .editor-primary-actions #saveChapterBtn:hover {
    transform: translateY(-1px);
}
.novel-editor-body .editor-primary-actions #saveChapterBtn.is-emphasized {
    background: linear-gradient(180deg, #4a75ff 0%, var(--primary) 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 12px 24px rgba(53, 98, 244, 0.22);
}

.editor-primary-actions .action-menu {
    display: inline-flex;
    align-items: center;
}

.editor-primary-actions .action-menu > summary {
    list-style: none;
    cursor: pointer;
}

.editor-primary-actions .action-menu > summary::-webkit-details-marker {
    display: none;
}

.editor-outline-field,
.editor-content-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.editor-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: visible;
}

.outline-textarea {
    height: 72px;
    min-height: 72px;
    resize: vertical;
}

.editor-content-field {
    min-height: auto;
}

.editor-textarea {
    height: 68vh;
    min-height: 620px;
    max-height: none;
    line-height: 1.9;
    font-size: 17px;
    padding: 18px 20px;
    resize: vertical;
    overflow-y: auto;
}

.export-panel {
    margin-bottom: 0;
}

.ai-sidebar-stack {
    flex-direction: column;
    min-height: 0;
}

.ai-sidebar-panel {
    position: sticky;
    top: var(--sticky-offset);
    max-height: calc(100vh - 112px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-card {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(245, 248, 255, 0.98) 100%);
}

.compact-head h3 {
    margin-bottom: 4px;
}

.compact-head p {
    margin-bottom: 0;
}

.ai-tab-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.ai-tab {
    min-height: 40px;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
}

.ai-tab.is-active {
    border-color: rgba(53, 98, 244, 0.35);
    background: var(--primary-soft);
    color: var(--primary);
}

.ai-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

/* UI-B.1.1 — AI primary action footer: always visible at the bottom of the
   AI card, never compressed by the internal .ai-scroll (no fixed positioning,
   plain flex column).  Only .ai-scroll scrolls. */
.novel-editor-body .ai-primary-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 12px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.novel-editor-body .ai-primary-footer .ai-primary-action {
    width: 100%;
    min-height: 46px;
}

.ai-tab-panel[hidden] {
    display: none;
}

.ai-button-cluster > * {
    flex: 1 1 120px;
}

.action-menu {
    position: relative;
}

.action-menu summary {
    list-style: none;
    cursor: pointer;
}

.action-menu summary::-webkit-details-marker {
    display: none;
}

.action-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 8;
    display: grid;
    gap: 8px;
    min-width: 190px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-md);
}

.action-menu:not([open]) .action-menu-panel {
    display: none;
}

.primary-action {
    background: var(--primary);
    color: #ffffff;
}

.ghost-action {
    background: transparent;
    border-color: var(--border);
    color: var(--muted);
    box-shadow: none;
}

.danger-action {
    border-color: #f0caca;
    color: var(--danger-text);
    background: var(--danger-soft);
    box-shadow: none;
}

.two-up {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.four-up {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-grid {
    gap: 12px;
    margin-top: 18px;
}

.project-form,
.placeholder-box,
.metric-list,
.project-list,
.stacked-form,
.media-selection-list,
.media-task-list,
.storyboard-shot-list {
    display: grid;
    gap: 12px;
}

.placeholder-box,
.metric,
.project-item,
.list-row,
.chapter-card,
.media-card,
.storyboard-shot-card {
    background: linear-gradient(180deg, var(--surface-alt) 0%, var(--surface-muted) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.placeholder-box {
    align-content: start;
    padding: 18px;
    color: var(--muted);
}

.panel-subtle {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(245, 248, 255, 0.96) 100%);
}

.toolbar-card {
    display: grid;
    gap: 16px;
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(197, 210, 230, 0.96);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(18px);
}

.toolbar-row,
.toolbar-meta,
.toolbar-actions,
.stat-pills,
.info-grid,
.summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.toolbar-row {
    justify-content: space-between;
}

.toolbar-info-card {
    margin-bottom: 12px;
}

.toolbar-sticky-bar {
    position: sticky;
    top: var(--sticky-offset);
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 40px;
    margin-bottom: 16px;
    padding: 1px 6px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(197, 210, 230, 0.96);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(18px);
}

.toolbar-meta {
    color: var(--muted);
}

.toolbar-meta-compact {
    flex: 0 0 auto;
}

.toolbar-actions {
    justify-content: flex-end;
}

.toolbar-actions-slim {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
}

.toolbar-actions-slim > * {
    flex: 0 0 auto;
}

.toolbar-action-btn {
    min-height: 32px;
    padding: 0.4rem 0.72rem;
    white-space: nowrap;
    box-shadow: none;
}

.summary-strip {
    gap: 12px;
    align-items: stretch;
}

.summary-card,
.info-card {
    flex: 1 1 180px;
    min-width: 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #ffffff 0%, #f6f8fd 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.summary-card strong,
.info-card strong {
    display: block;
    margin-bottom: 4px;
    font-size: 1rem;
}

.summary-card span,
.info-card span {
    color: var(--muted);
    font-size: 0.92rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.info-card {
    display: grid;
    gap: 4px;
}

.action-pill,
.mini-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 0.32rem 0.72rem;
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.action-pill.is-success,
.mini-status.is-success {
    background: var(--success-soft);
    color: var(--success-text);
}

.action-pill.is-warning,
.mini-status.is-warning {
    background: var(--warning-soft);
    color: var(--warning-text);
}

.action-pill.is-error,
.mini-status.is-error {
    background: var(--danger-soft);
    color: var(--danger-text);
}

.form-helper {
    margin: -2px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.cinematic-policy-note {
    margin: 10px 0;
    padding: 10px 12px;
    border-left: 3px solid var(--primary);
    background: var(--surface-alt);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.5;
}

.cinematic-policy-note strong {
    display: block;
    margin-bottom: 2px;
}

/* PHASE UI-B.2 — cinematic task strategy card (advanced page only). */
.cinematic-task-strategy {
    margin: 4px 0 12px;
}
.cinematic-strategy-card {
    padding: 14px 16px;
    border: 1px solid rgba(53, 98, 244, 0.25);
    border-radius: var(--radius-md);
    background: var(--primary-soft);
}
.cinematic-strategy-card > strong {
    display: block;
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 0.95rem;
}
.cinematic-strategy-card p {
    display: flex;
    gap: 8px;
    margin: 5px 0;
    font-size: 0.9rem;
    line-height: 1.5;
}
.cinematic-strategy-card p > span {
    flex: 0 0 auto;
    min-width: 56px;
    font-weight: 700;
    color: var(--muted);
}
.cinematic-strategy-card .cinematic-strategy-helper {
    color: var(--muted);
    font-size: 0.84rem;
    margin: 2px 0 8px;
}

/* PHASE UI-B.2 §44 — task-mode scoped polish (advanced page only). */
.page-novel-advanced.is-cinematic-task-mode .review-source-textarea {
    background: var(--surface-muted);
    cursor: not-allowed;
}
.page-novel-advanced.is-cinematic-task-mode .advanced-console .panel-subtle {
    margin-bottom: 4px;
}

.cinematic-workflow-prompts {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.82rem;
    line-height: 1.4;
}

/* PHASE UI-B.3 — cinematic failure UX & retry card (minimal). */
.cinematic-failure-card {
    border-left: 4px solid #c0392b;
}
.cinematic-failure-card h3 {
    margin: 4px 0 6px;
}
.cinematic-failure-actions {
    margin-top: 10px;
}
.cinematic-failure-details {
    margin-top: 12px;
}
.cinematic-failure-detail-body {
    margin-top: 8px;
}
.cinematic-failure-detail-body pre {
    max-height: 220px;
    overflow: auto;
}

.panel-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.result-surface {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #ffffff 0%, #f6f8fd 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.result-surface + .result-surface {
    margin-top: 14px;
}

.result-surface h3 {
    margin-bottom: 6px;
}

.button-cluster {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.button-cluster > * {
    flex: 1 1 160px;
}

.page-link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
}

.page-link-row .secondary-link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
}

.inline-checkbox {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #ffffff 0%, #f6f8fd 100%);
    color: var(--text);
}

.inline-checkbox input {
    width: 18px;
    min-height: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    accent-color: var(--primary);
}

.inline-checkbox span {
    color: var(--text);
    font-size: 0.94rem;
    font-weight: 600;
}

.memory-grid {
    display: grid;
    gap: 12px;
}

.memory-text {
    min-height: 64px;
    max-height: 320px;
    overflow-y: auto;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    line-height: 1.65;
    font-size: 0.95rem;
}

.prompt-editor-textarea {
    min-height: 320px;
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-size: 0.92rem;
    line-height: 1.6;
}

.page-storyboard-workbench {
    --storyboard-page-width: 1560px;
    background:
        radial-gradient(circle at top left, rgba(53, 98, 244, 0.08), transparent 24%),
        linear-gradient(180deg, #f7f9fe 0%, #eef3fb 100%);
}

.page-storyboard-workbench .page-shell {
    display: grid;
    gap: 16px;
    padding-top: 14px;
}

.page-storyboard-workbench .shell {
    width: min(var(--storyboard-page-width), calc(100% - 32px));
}

.storyboard-status-bar,
.storyboard-workbench-layout {
    width: min(var(--storyboard-page-width), 100%);
    justify-self: center;
}

.storyboard-status-bar {
    padding: 16px 18px;
    margin-bottom: 0;
}

.storyboard-status-copy {
    display: grid;
    gap: 10px;
}

.storyboard-status-copy .eyebrow {
    margin-bottom: 0;
}

.storyboard-status-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.storyboard-status-head h1 {
    margin: 0 0 4px;
    font-size: 1.55rem;
}

.storyboard-status-head .muted {
    margin: 0;
    font-size: 0.94rem;
}

.storyboard-status-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.storyboard-status-metrics .metric {
    min-height: 64px;
    padding: 12px 14px;
}

.storyboard-workbench-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 20px;
    align-items: start;
}

.storyboard-main-column,
.storyboard-side-column,
.storyboard-input-rail,
.storyboard-side-sticky {
    min-width: 0;
}

.storyboard-main-column {
    display: grid;
    gap: 18px;
}

.storyboard-input-shell,
.storyboard-results-panel {
    margin-bottom: 0;
}

.storyboard-editor-toolbar {
    position: static;
    top: auto;
    z-index: auto;
    display: grid;
    gap: 10px;
    padding: 0 0 14px;
    margin: 0 0 14px;
    border-bottom: 1px solid rgba(197, 210, 230, 0.86);
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.storyboard-toolbar-copy,
.storyboard-toolbar-meta,
.storyboard-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.storyboard-toolbar-copy h2 {
    margin-bottom: 4px;
}

.storyboard-toolbar-copy p {
    margin-bottom: 0;
}

.storyboard-toolbar-meta {
    justify-content: flex-start;
}

.storyboard-toolbar-actions {
    justify-content: flex-start;
}

.storyboard-input-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 16px;
    align-items: start;
}

.storyboard-source-field,
.storyboard-requirement-field {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

.storyboard-source-field textarea {
    min-height: 520px;
    line-height: 1.88;
    font-size: 16px;
    padding: 18px 20px;
}

.storyboard-input-rail {
    display: grid;
    gap: 14px;
}

.storyboard-input-stats {
    grid-template-columns: 1fr;
}

.storyboard-requirement-field textarea {
    min-height: 160px;
    line-height: 1.75;
}

.storyboard-results-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.page-storyboard-workbench .storyboard-shot-head {
    position: static;
    top: auto;
    z-index: auto;
}

.storyboard-side-column {
    align-self: start;
}

.storyboard-side-sticky {
    position: sticky;
    top: var(--sticky-offset);
    display: grid;
    gap: 16px;
    max-height: calc(100vh - var(--sticky-offset) - 20px);
    overflow-y: auto;
    padding-right: 4px;
}

.storyboard-side-sticky > .panel {
    margin-bottom: 0;
}

.page-storyboard-workbench .section-head {
    margin-bottom: 14px;
}

.page-storyboard-workbench .storyboard-shot-grid textarea[data-field="dialogue"],
.page-storyboard-workbench .storyboard-shot-grid textarea[data-field="narration"] {
    min-height: 96px;
    line-height: 1.65;
}

.page-novel-advanced {
    --advanced-page-width: 1560px;
    background:
        radial-gradient(circle at top right, rgba(53, 98, 244, 0.08), transparent 26%),
        linear-gradient(180deg, #f7f9fe 0%, #eef3fb 100%);
}

.page-novel-advanced .page-shell {
    display: grid;
    gap: 14px;
    padding-top: 14px;
}

.page-novel-advanced .shell {
    width: min(1560px, calc(100% - 32px));
}

.advanced-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
    gap: 20px;
    align-items: start;
}

.page-novel-advanced .advanced-hero,
.page-novel-advanced .advanced-step-panel,
.page-novel-advanced .advanced-review-layout {
    width: min(var(--advanced-page-width), 100%);
    justify-self: center;
}

.page-novel-advanced .advanced-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 14px 18px;
    margin-bottom: 0;
}

.page-novel-advanced .advanced-hero .eyebrow {
    display: none;
}

.page-novel-advanced .advanced-hero h1 {
    margin: 0 0 6px;
    font-size: 1.55rem;
}

.page-novel-advanced .advanced-hero .muted {
    margin: 0;
    font-size: 0.94rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-novel-advanced .advanced-hero .metric-list {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    margin-top: 10px;
    overflow-x: auto;
}

.page-novel-advanced .advanced-hero .metric {
    min-height: 52px;
    min-width: 140px;
    padding: 10px 12px;
}

.page-novel-advanced .advanced-hero .metric span {
    font-size: 0.82rem;
}

.page-novel-advanced .advanced-hero .metric strong {
    font-size: 0.95rem;
}

.page-novel-advanced .advanced-hero .placeholder-box {
    min-width: 360px;
    padding: 12px 14px;
}

.page-novel-advanced .advanced-hero .placeholder-box > span,
.page-novel-advanced .advanced-hero .placeholder-box strong {
    display: none;
}

.page-novel-advanced .advanced-hero .page-link-row {
    margin-top: 0;
}

.advanced-step-panel {
    overflow-x: auto;
    padding: 14px 16px;
}

.page-novel-advanced .advanced-step-panel {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 0;
}

.page-novel-advanced .advanced-step-panel .section-head {
    margin-bottom: 0;
    align-items: center;
}

.advanced-step-track {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 8px;
    min-width: max-content;
}

.page-novel-advanced .advanced-step-track {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
}

.advanced-step-card {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #ffffff 0%, #f6f8fd 100%);
    color: var(--muted);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.page-novel-advanced .advanced-step-card {
    min-height: 46px;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    padding: 8px 10px;
    align-content: center;
}

.advanced-step-card strong {
    color: var(--text);
    font-size: 0.92rem;
}

.page-novel-advanced .advanced-step-card strong {
    font-size: 0.86rem;
    white-space: nowrap;
}

.page-novel-advanced .advanced-step-index {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
}

.page-novel-advanced .advanced-step-panel .section-head h2 {
    margin: 0;
    font-size: 1.1rem;
}

.page-novel-advanced .advanced-step-panel .section-head p {
    display: none;
}

.page-novel-advanced .advanced-step-panel .section-head .mini-status {
    margin-left: auto;
}

.advanced-step-card > span:not(.advanced-step-index) {
    display: none;
}

.advanced-step-card.is-current {
    border-color: rgba(53, 98, 244, 0.38);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(232, 240, 255, 0.98) 100%);
    box-shadow: 0 12px 24px rgba(53, 98, 244, 0.12);
    color: var(--text);
}

.advanced-step-card.is-complete {
    border-color: rgba(27, 164, 117, 0.28);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(236, 249, 243, 0.98) 100%);
}

.advanced-step-card.is-pending {
    opacity: 0.8;
}

.advanced-step-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(53, 98, 244, 0.1);
    color: var(--primary);
    font-size: 0.88rem;
    font-weight: 700;
}

.advanced-review-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 20px;
    align-items: stretch;
}

.advanced-review-main,
.advanced-console-sticky,
.reading-stack,
.review-tab-panel {
    display: grid;
    gap: 16px;
}

.advanced-review-main,
.advanced-console,
.review-reader-panel {
    min-width: 0;
}

.page-novel-advanced .advanced-console {
    align-self: stretch;
    min-height: 100%;
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.62);
    box-shadow: var(--shadow-md);
    overflow: visible;
}

.review-reader-panel {
    display: grid;
    gap: 16px;
    min-height: auto;
}

.page-novel-advanced .review-toolbar {
    position: sticky;
    top: var(--sticky-offset);
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    margin: -4px 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}

.review-tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.page-novel-advanced .review-tab-bar {
    flex: 1 1 auto;
    gap: 8px;
    min-width: 0;
}

.page-novel-advanced .review-primary-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

.page-novel-advanced .review-primary-actions .primary-btn,
.page-novel-advanced .review-primary-actions .secondary-btn {
    min-height: 38px;
    padding: 0.56rem 0.9rem;
    white-space: nowrap;
}

.review-tab {
    min-height: 38px;
    padding: 0.56rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
    box-shadow: none;
}

.review-tab.is-active {
    border-color: rgba(53, 98, 244, 0.32);
    background: rgba(53, 98, 244, 0.1);
    color: var(--primary);
}

.review-tab-panels {
    min-height: 0;
    overflow: visible;
    padding-right: 0;
}

.review-tab-panel[hidden] {
    display: none !important;
}

.page-novel-advanced .review-reader-panel {
    min-height: auto;
}

.page-novel-advanced .reading-stack label {
    display: grid;
    gap: 8px;
    width: 100%;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
}

.page-novel-advanced .reading-stack input,
.page-novel-advanced .reading-stack textarea {
    width: 100%;
    padding: 0.82rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
    color: var(--text);
    box-shadow: none;
}

.page-novel-advanced #editorTitle {
    min-height: 52px;
    font-size: 1.25rem;
    font-weight: 800;
}

.page-novel-advanced #editorOutline {
    min-height: 96px;
    resize: vertical;
    line-height: 1.7;
}

.review-source-textarea,
.page-novel-advanced .result-surface textarea {
    min-height: 280px;
    line-height: 1.72;
}

.page-novel-advanced .result-surface {
    width: 100%;
}

.page-novel-advanced .result-surface textarea {
    width: 100%;
    display: block;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
    color: var(--text);
    box-sizing: border-box;
}

.page-novel-advanced #draftResultTextarea,
.page-novel-advanced #finalResultTextarea {
    min-height: 720px;
    height: 72vh;
    font-size: 17px;
    line-height: 1.9;
    resize: vertical;
    overflow-y: auto;
}

.page-novel-advanced #projectScriptText {
    min-height: 260px;
}

.page-novel-advanced #compareOriginalTextarea,
.page-novel-advanced #compareFinalTextarea {
    min-height: 680px;
    height: 68vh;
    font-size: 16px;
    line-height: 1.85;
    resize: vertical;
    overflow-y: auto;
}

.review-source-textarea {
    min-height: 680px;
    height: 70vh;
    font-size: 17px;
    line-height: 1.9;
    padding: 18px 20px;
    resize: vertical;
    overflow-y: auto;
}

.review-text-surface {
    min-height: 320px;
}

.review-text-block {
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.78;
}

.compare-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.advanced-console-sticky {
    position: sticky;
    top: var(--sticky-offset);
    width: 100%;
    height: calc(100vh - var(--sticky-offset) - 20px);
    max-height: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    padding: 14px;
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.advanced-console-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.page-novel-advanced .advanced-console-scroll > .panel {
    margin-bottom: 14px;
}

.page-novel-advanced .advanced-console-scroll > .panel:last-child {
    margin-bottom: 0;
}

.advanced-console-actions > * {
    flex: 1 1 calc(50% - 10px);
}

.advanced-summary-card {
    position: static;
    padding: 16px 18px;
}

.page-novel-advanced .advanced-summary-card .toolbar-row {
    margin-bottom: 10px;
}

.page-novel-advanced .summary-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.page-novel-advanced .summary-card {
    padding: 12px 14px;
}

.page-novel-advanced .source-editor-card {
    display: grid;
    gap: 14px;
}

.page-novel-advanced .source-editor-grid {
    display: grid;
    grid-template-columns: minmax(240px, 0.45fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.page-novel-advanced .source-title-field,
.page-novel-advanced .source-outline-field,
.page-novel-advanced .source-content-field {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
}

.page-novel-advanced .source-title-field input,
.page-novel-advanced .source-outline-field textarea,
.page-novel-advanced .source-content-field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
}

.page-novel-advanced .source-title-field input {
    min-height: 52px;
    padding: 0.8rem 0.95rem;
    font-size: 1.2rem;
    font-weight: 800;
}

.page-novel-advanced .source-outline-field textarea {
    min-height: 96px;
    padding: 0.82rem 0.95rem;
    line-height: 1.7;
    resize: vertical;
}

.page-novel-advanced .source-content-field textarea {
    min-height: 720px;
    height: 72vh;
    padding: 18px 20px;
    font-size: 17px;
    line-height: 1.9;
    resize: vertical;
    overflow-y: auto;
}

@media (max-width: 1180px) {
    .page-storyboard-workbench .storyboard-workbench-layout,
    .page-storyboard-workbench .storyboard-input-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .page-storyboard-workbench .storyboard-side-sticky {
        position: static;
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .advanced-review-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .page-novel-advanced .advanced-hero,
    .page-novel-advanced .advanced-step-panel {
        grid-template-columns: minmax(0, 1fr);
    }

    .page-novel-advanced .advanced-hero .muted {
        white-space: normal;
    }

    .page-novel-advanced .advanced-hero .placeholder-box {
        min-width: 0;
    }

    .page-novel-advanced .review-toolbar {
        position: static;
        align-items: stretch;
        flex-direction: column;
    }

    .page-novel-advanced .review-primary-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .advanced-console-sticky {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .advanced-console-scroll {
        overflow: visible;
        padding-right: 0;
    }
}

@media (max-width: 900px) {
    .advanced-hero,
    .compare-grid,
    .page-novel-advanced .source-editor-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .advanced-step-track {
        grid-template-columns: repeat(6, minmax(150px, 1fr));
    }
}

@media (max-width: 640px) {
    .advanced-console-actions > * {
        flex-basis: 100%;
    }

    .review-reader-panel {
        min-height: auto;
    }

    .advanced-summary-card {
        position: static;
    }
}

.stacked-form {
    gap: 14px;
}

.stacked-form label,
.project-form label,
.form-field {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

.form-label {
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 500;
}

.form-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.project-form input,
.project-form textarea,
.project-form select,
.stacked-form input,
.stacked-form textarea,
.stacked-form select,
.storyboard-shot-grid input,
.storyboard-shot-grid textarea,
.storyboard-shot-grid select,
.form-control {
    width: 100%;
    min-height: var(--control-height);
    padding: 0.82rem var(--control-padding-x);
    border: 1px solid var(--border);
    border-radius: var(--control-radius);
    background: var(--surface-strong);
    color: var(--text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.project-form textarea,
.stacked-form textarea,
.storyboard-shot-grid textarea,
textarea.form-control,
.form-textarea {
    resize: vertical;
    min-height: 108px;
    line-height: 1.65;
}

.form-control-sm {
    width: auto;
    min-height: var(--control-height-sm);
    height: var(--control-height-sm);
    padding: 0.42rem 0.72rem;
    border: 1px solid var(--border);
    border-radius: var(--control-radius);
    background: var(--surface-strong);
    color: var(--text);
    font-size: 0.86rem;
}

.form-control:disabled,
.form-control-sm:disabled {
    cursor: not-allowed;
    background: var(--surface-muted);
    color: var(--muted);
    opacity: 0.78;
}

input::placeholder,
textarea::placeholder {
    color: #91a0b6;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgba(53, 98, 244, 0.5);
    box-shadow: var(--focus-ring);
    background: #ffffff;
}

textarea[readonly],
input[readonly] {
    background: #f8fbff;
}

button,
.btn,
.primary-btn,
.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

button:hover,
.btn:hover,
.primary-btn:hover,
.secondary-btn:hover {
    transform: translateY(-1px);
}

button:disabled,
.btn:disabled,
.primary-btn:disabled,
.secondary-btn:disabled,
.secondary-btn[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.62;
    transform: none;
    box-shadow: none;
}

.project-form button,
.project-form > button {
    width: 100%;
}

button,
.btn-primary,
.primary-btn {
    background: linear-gradient(180deg, #4a75ff 0%, var(--primary) 100%);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(53, 98, 244, 0.22);
}

.btn-secondary,
.secondary-btn {
    background: var(--surface);
    color: var(--text);
    box-shadow: none;
}

.btn-sm {
    min-height: var(--control-height-sm);
    padding: 0.42rem 0.72rem;
    font-size: 0.86rem;
}

.subpanel {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-alt);
    box-shadow: none;
}

.form-row,
.control-row {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.form-row .form-field {
    flex: 1 1 240px;
    min-width: 0;
}

.compact-control-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.86rem;
}

.compact-control-group > span {
    white-space: nowrap;
}

.panel-compact {
    padding: 10px 18px;
}

.page-context-row,
.entity-card-head,
.media-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.page-context-title {
    font-size: 1.05rem;
}

.page-context-switcher {
    margin-left: auto;
}

.chapter-picker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--muted);
}

.inline-checkbox-spaced {
    margin-right: 12px;
}

.status-note,
.control-offset,
.secondary-link-offset {
    margin-left: 8px;
}

.btn-inline-edit {
    min-height: 28px;
    margin-left: 6px;
    padding: 2px 8px;
    font-size: 0.8rem;
}

.form-control-xs {
    min-height: 28px;
    height: 28px;
    padding-block: 0.2rem;
    font-size: 0.82rem;
}

.flow-arrow {
    padding: 0 2px;
    color: var(--muted);
    font-size: 1.2rem;
    line-height: 1;
}

.disclosure-spaced,
.form-spaced,
.import-single-row {
    margin-top: 8px;
}

.import-single-row {
    margin-top: 12px;
}

.inline-meta-tight {
    gap: 6px;
}

.result-block-compact {
    min-height: 80px;
    margin-top: 6px;
}

.debug-note {
    margin: 0 0 8px;
    font-size: 0.82rem;
}

.import-target-select {
    display: none;
    margin-left: 8px;
}

.import-title-control {
    width: 200px;
    margin-left: 8px;
}

.entity-card-head {
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.no-shrink {
    flex-shrink: 0;
}

.visual-style-form {
    align-items: end;
}

.visual-style-field {
    min-width: 280px;
}

.success-btn {
    min-height: 52px;
    border: 1px solid rgba(31, 122, 74, 0.2);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #34c77b 0%, #22a35f 100%);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 14px 28px rgba(34, 163, 95, 0.18);
    cursor: pointer;
}

.success-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.warning-btn {
    min-height: 52px;
    border: 1px solid rgba(200, 140, 20, 0.25);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #f0a020 0%, #d4880f 100%);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 14px 28px rgba(212, 136, 15, 0.18);
    cursor: pointer;
}

.warning-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.secondary-link {
    color: var(--primary);
    font-weight: 700;
}

.secondary-link:hover {
    color: var(--primary-strong);
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.muted,
.stacked-row span,
.project-item span,
.list-row span,
.media-meta {
    color: var(--muted);
}

.plain-list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--muted);
}

.project-item,
.list-row,
.chapter-card,
.media-card {
    display: grid;
    gap: 6px;
    padding: 16px;
}

.project-item {
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.project-showcase {
    gap: 16px;
}

.project-item-head,
.hero-heading,
.workflow-step-head,
.workflow-step-meta,
.project-item-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.project-item-head strong,
.hero-heading h1 {
    margin: 0;
}

.project-item-desc,
.workflow-step-card p {
    margin-bottom: 0;
}

.project-item-desc {
    color: var(--muted);
}

.project-item-action {
    min-width: 168px;
}

.project-item:hover,
.chapter-card:hover,
.media-card-selectable:hover,
.nav-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.metric {
    display: grid;
    gap: 8px;
    padding: 16px;
}

.metric span {
    color: var(--muted);
    font-size: 0.9rem;
}

.metric strong {
    font-size: 1rem;
}

.nav-card {
    min-height: 180px;
    align-content: start;
}

.overview-stack,
.hero-aside,
.mini-flow-list,
.workflow-step-card {
    display: grid;
    gap: 16px;
}

.hero-aside {
    align-content: start;
}

.hero-aside.panel,
.workflow-step-card.panel {
    margin-bottom: 0;
}

.hero-lead {
    margin: 0;
    color: var(--muted);
    font-size: 1.02rem;
}

.project-form-intro h2 {
    margin-bottom: 6px;
}

.mini-flow-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mini-flow-item {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(240, 245, 255, 0.96) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.mini-flow-item strong {
    font-size: 0.96rem;
}

.mini-flow-item span {
    color: var(--muted);
    font-size: 0.92rem;
}

.workflow-overview {
    margin-bottom: 24px;
}

.workflow-step-card {
    min-height: 100%;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.workflow-step-card.is-complete {
    border-color: rgba(117, 203, 151, 0.7);
    background: linear-gradient(180deg, rgba(244, 255, 248, 0.96) 0%, rgba(232, 248, 238, 0.98) 100%);
}

.workflow-step-card.is-next {
    border-color: rgba(53, 98, 244, 0.45);
    box-shadow: 0 18px 36px rgba(53, 98, 244, 0.14);
}

.workflow-step-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 800;
}

.workflow-step-meta {
    justify-content: flex-start;
    color: var(--muted);
    font-size: 0.92rem;
}

.workflow-step-action {
    color: var(--primary);
    font-weight: 700;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.section-head h2,
.panel h2,
.hero-card h1 {
    margin-bottom: 6px;
}

.inline-actions,
.inline-meta,
.media-card-head,
.media-status-row,
.media-option,
.storyboard-shot-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.media-option {
    align-items: flex-start;
}

.media-option input,
.media-checkbox {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
}

.media-card-select-control {
    display: inline-flex;
    align-items: center;
}

.media-shot-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.media-clear-menu {
    position: relative;
}

/* 展开菜单必须高于后续分镜卡片，避免最后一个危险操作被遮挡。 */
.media-asset-card:has(.media-clear-menu[open]) {
    position: relative;
    z-index: 24;
}

.media-shots-panel {
    overflow: visible;
}
.media-clear-menu summary {
    list-style: none;
    cursor: pointer;
}

.media-clear-menu summary::-webkit-details-marker {
    display: none;
}

.media-clear-menu-options {
    position: absolute;
    z-index: 20;
    right: 0;
    top: calc(100% + 6px);
    display: grid;
    gap: 6px;
    min-width: 132px;
    padding: 8px;
    border: 1px solid var(--border-color, #d9dfeb);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(26, 39, 73, 0.15);
}

.media-clear-menu:not([open]) .media-clear-menu-options {
    display: none;
}

.media-clear-menu-options .secondary-btn {
    width: 100%;
    text-align: left;
}
.media-clear-menu-divider {
    height: 1px;
    margin: 2px 0;
    background: var(--border-color, #d9dfeb);
}

.media-delete-shot-btn {
    font-weight: 800;
}
.media-shot-editor {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-alt);
}

.media-shot-editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.media-shot-editor-grid label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 0.88rem;
}

.media-shot-editor-grid input,
.media-shot-editor-grid textarea,
.media-shot-editor-grid select {
    width: 100%;
}

.media-shot-editor-span-2 {
    grid-column: span 2;
}

@media (max-width: 640px) {
    .media-shot-editor-grid {
        grid-template-columns: 1fr;
    }

    .media-shot-editor-span-2 {
        grid-column: span 1;
    }
}

.media-upload-actions,
.media-scene-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}

.media-source-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface-alt);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.media-upload-input[hidden] {
    display: none;
}


.media-scene-editor {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-alt);
}

.media-scene-editor[hidden] {
    display: none;
}

.media-scene-editor label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 0.88rem;
}

.media-scene-editor input,
.media-scene-editor textarea {
    width: 100%;
}

.media-scene-editor-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.notice-box {
    display: block;
    margin-bottom: 16px;
    padding: 14px 16px;
    white-space: pre-wrap;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-alt);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.notice-box.is-success {
    background: var(--success-soft);
    border-color: #bfe2cc;
    color: var(--success-text);
}

.notice-box.is-error {
    background: var(--danger-soft);
    border-color: #f0c0c0;
    color: var(--danger-text);
}

.notice-box.is-info {
    background: var(--info-soft);
    border-color: #c6d8ff;
    color: var(--info-text);
}

.notice-box.is-loading {
    background: var(--warning-soft);
    border-color: #f2d48b;
    color: var(--warning-text);
}

.notice-box.is-soft {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(197, 210, 230, 0.86);
    color: var(--muted);
}

.empty-state {
    margin: 0;
    padding: 18px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.58);
    color: var(--muted);
}

.chapter-card {
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.chapter-card strong {
    font-size: 0.98rem;
}

.chapter-card span {
    font-size: 0.9rem;
    color: var(--muted);
}

.chapter-card-meta {
    font-size: 0.82rem;
}

.chapter-panel {
    display: flex;
    flex-direction: column;
}

.chapter-sidebar-panel {
    position: sticky;
    top: var(--sticky-offset);
    max-height: calc(100vh - 112px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chapter-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.chapter-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(215, 225, 240, 0.86);
}

.chapter-footer-actions > * {
    flex: 1 1 120px;
}

.inline-preview {
    display: grid;
    gap: 10px;
}

.inline-preview summary {
    cursor: pointer;
}

.editor-outline-disclosure {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: #fff;
}

.editor-outline-disclosure summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--muted);
}

.editor-outline-disclosure .editor-outline-field {
    margin-top: 10px;
}

.novel-workbench.is-focus-mode {
    grid-template-columns: minmax(0, 960px);
    justify-content: center;
}

.novel-workbench.is-focus-mode .chapter-sidebar,
.novel-workbench.is-focus-mode .ai-sidebar {
    display: none;
}

.novel-workbench.is-focus-mode .editor-textarea {
    height: calc(100vh - 260px);
    min-height: 680px;
}

.chapter-card.is-active {
    border-color: rgba(53, 98, 244, 0.7);
    background: linear-gradient(180deg, #e6edff 0%, #dae7ff 100%);
    box-shadow: 0 0 0 4px rgba(53, 98, 244, 0.12), 0 10px 24px rgba(53, 98, 244, 0.06);
    transform: translateY(-2px);
}

.chapter-card.is-dirty,
.storyboard-shot-card.is-dirty {
    border-color: rgba(255, 177, 53, 0.58);
    box-shadow: 0 0 0 4px rgba(255, 177, 53, 0.12);
}

.editor-empty-state {
    padding: 40px 24px;
    text-align: center;
}

.editor-empty-state .empty-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.98rem;
}

.editor-empty-state .empty-hint strong {
    color: var(--text);
    font-weight: 600;
}

.result-block {
    margin: 0;
    min-height: 180px;
    padding: 18px;
    border: 1px solid rgba(15, 23, 42, 0.2);
    border-radius: var(--radius-md);
    background: #0f172a;
    color: #e2e8f0;
    overflow-x: auto;
    white-space: pre-wrap;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.storyboard-shot-card {
    padding: 18px;
    gap: 16px;
}

.storyboard-shot-head {
    position: static;
    top: auto;
    z-index: auto;
    justify-content: space-between;
    padding: 12px 14px;
    margin: 0 0 14px;
    border: 1px solid rgba(215, 225, 240, 0.9);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    min-height: 76px;
}

.storyboard-shot-title {
    min-width: 0;
    display: grid;
    gap: 6px;
}

.storyboard-shot-title strong {
    font-size: 1.03rem;
}

.toggle-shot-editor-btn,
.save-shot-btn {
    min-height: 38px;
    padding: 0.56rem 0.85rem;
}

.storyboard-shot-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.storyboard-summary-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0.3rem 0.72rem;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(197, 210, 230, 0.95);
    background: rgba(245, 248, 255, 0.9);
    color: #44556d;
    font-size: 0.85rem;
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.storyboard-shot-editor[hidden] {
    display: none !important;
}

.storyboard-shot-card.is-expanded .storyboard-shot-summary {
    margin-bottom: 10px;
}

.storyboard-shot-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.shot-status-text {
    color: var(--muted);
    font-size: 0.9rem;
}

.shot-status-text.is-dirty {
    color: var(--warning-text);
    font-weight: 700;
}

.shot-status-text.is-saved {
    color: var(--success-text);
    font-weight: 700;
}

.storyboard-span-2 {
    grid-column: span 2;
}

.media-form {
    margin-bottom: 18px;
}

.media-summary-strip,
.media-selection-toolbar,
.media-inline-list {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.media-summary-strip {
    margin-top: 16px;
}

.media-selection-toolbar {
    justify-content: space-between;
    margin-bottom: 16px;
}

.media-mini-btn {
    min-height: 40px;
    padding: 0.72rem 0.9rem;
}

.media-card-selectable {
    cursor: pointer;
}

.media-asset-card.is-selected {
    border-color: rgba(53, 98, 244, 0.36);
    box-shadow: 0 0 0 4px rgba(53, 98, 244, 0.08);
}

.media-asset-card.is-active {
    border-color: rgba(53, 98, 244, 0.56);
    background: linear-gradient(180deg, #eef3ff 0%, #e9f0ff 100%);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0.25rem 0.72rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: #eef2f7;
    color: #44556d;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-done,
.status-succeeded,
.status-success {
    background: var(--success-soft);
    border-color: #bfe2cc;
    color: var(--success-text);
}

.status-auto {
    background: #eef3ff;
    border-color: #cbd6ff;
    color: #3554c7;
}

.status-failed,
.status-error {
    background: var(--danger-soft);
    border-color: #f0c0c0;
    color: var(--danger-text);
}

.status-generating,
.status-running,
.status-queued,
.status-polling,
.status-warning {
    background: var(--warning-soft);
    border-color: #f2d48b;
    color: var(--warning-text);
}

.status-pending,
.status-submitted,
.status-draft,
.status-idle {
    background: #eef2f7;
    border-color: #d7e1eb;
    color: #516176;
}

.status-skipped {
    background: #f0f3ff;
    border-color: #cbd6ff;
    color: #3554c7;
}

.media-timing-meta {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.5;
}

.media-timing-meta.timing-aligned {
    color: #28784a;
}

.media-timing-meta.timing-blocked,
.media-timing-meta.timing-warning {
    color: #9b5c00;
}
.media-error {
    color: var(--danger-text);
    font-size: 0.92rem;
}

.media-preview-shell,
.render-progress-panel {
    display: grid;
    gap: 14px;
}

.media-preview-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.media-preview-stage,
.render-preview-box {
    min-height: 260px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(241, 246, 255, 0.95) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.media-preview-stage {
    display: grid;
    place-items: center;
}

.media-preview-stage img,
.media-preview-stage video,
.render-preview-box video {
    width: 100%;
    border-radius: var(--radius-md);
    object-fit: contain;
    background: #000000;
}

.media-preview-stage audio {
    width: 100%;
}

.media-result-summary {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.72);
}

.media-preview-stage {
    min-height: 140px;
    max-height: 260px;
}

.media-preview-stage img,
.media-preview-stage video {
    max-height: 240px;
    object-fit: contain;
    cursor: pointer;
}

.media-preview-stage img:hover,
.media-preview-stage video:hover {
    opacity: 0.92;
}

/* 全屏遮罩 lightbox */
.media-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.media-lightbox-overlay img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* 卡片缩略图 */
.media-card-thumb {
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.media-failure-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.media-subhead {
    margin-top: 18px;
    margin-bottom: 14px;
}

.media-subhead h3 {
    margin: 0;
    font-size: 1.05rem;
}

.progress-track {
    position: relative;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: #e6ebf5;
    border: 1px solid rgba(167, 181, 206, 0.35);
}

.progress-value {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #4a75ff 0%, #6f9bff 100%);
    box-shadow: 0 8px 18px rgba(53, 98, 244, 0.25);
}

.render-preview-grid {
    align-items: start;
}

#finalVideoPlayer {
    width: 100%;
    border-radius: var(--radius-md);
    background: #000000;
    box-shadow: var(--shadow-sm);
}

.site-footer {
    border-top: 1px solid rgba(215, 225, 240, 0.95);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px);
}

.site-footer-inner {
    min-height: 64px;
    font-size: 0.94rem;
}

@media (max-width: 980px) {
    .page-storyboard-workbench .storyboard-status-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-storyboard-workbench .storyboard-editor-toolbar,
    .page-storyboard-workbench .storyboard-shot-head {
        position: static;
    }

    .storyboard-shot-head {
        min-height: auto;
    }

    .hero-card,
    .two-up,
    .four-up,
    .storyboard-shot-grid,
    .workbench-layout,
    .novel-workbench,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .storyboard-span-2 {
        grid-column: span 1;
    }

    .sticky-stack,
    .novel-side-sticky,
    .storyboard-shot-head {
        position: static;
    }

    .shell-header,
    .shell-subnav,
    .site-footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .shell-header {
        padding: 16px 0;
        gap: 12px;
    }

    .site-nav {
        justify-content: flex-start;
    }

    .header-project-summary,
    .header-status-meta {
        width: 100%;
    }

    .editor-panel {
        min-height: auto;
    }

    .editor-textarea {
        min-height: 420px;
    }

    .media-selection-toolbar,
    .media-preview-head {
        flex-direction: column;
        align-items: flex-start;
    }


    .mini-flow-list {
        grid-template-columns: 1fr;
    }
}

/* ===== Standard Novel Editor: Chapter Sidebar Polish ===== */
.novel-editor-body .chapter-sidebar-head {
    text-align: left;
    align-items: flex-start;
}

.novel-editor-body .chapter-sidebar-head h1 {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
}

.novel-editor-body .chapter-sidebar-head .eyebrow {
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 2px;
}

.novel-editor-body .chapter-sidebar-head .mini-status {
    margin-top: 0;
}

.novel-editor-body .chapter-search-field input {
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: #fff;
    font-size: 0.92rem;
    color: var(--text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.novel-editor-body .chapter-search-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(53, 98, 244, 0.14);
    outline: none;
}

.novel-editor-body .chapter-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    min-height: 64px;
    height: auto;
    overflow: hidden;
    box-shadow: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.novel-editor-body .chapter-card strong {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    margin-bottom: 2px;
    word-break: break-word;
}

.novel-editor-body .chapter-card span {
    display: block;
    font-size: 0.84rem;
    color: var(--muted);
    line-height: 1.35;
}

.novel-editor-body .chapter-card .chapter-card-meta {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 4px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.72;
}

.novel-editor-body .chapter-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.novel-editor-body .chapter-card.is-active {
    border-color: rgba(53, 98, 244, 0.6);
    background: linear-gradient(180deg, #eef3ff 0%, #e3eafa 100%);
    box-shadow: 0 0 0 3px rgba(53, 98, 244, 0.1);
    transform: translateY(-1px);
}

.novel-editor-body .chapter-card.is-active strong {
    color: #16264a;
}

.novel-editor-body .chapter-card.is-active span,
.novel-editor-body .chapter-card.is-active .chapter-card-meta {
    color: #3a4f7a;
    opacity: 1;
}

.novel-editor-body .chapter-card.is-active:hover {
    border-color: var(--primary-strong);
}

.novel-editor-body .chapter-card.is-dirty {
    border-color: rgba(255, 177, 53, 0.52);
    box-shadow: 0 0 0 3px rgba(255, 177, 53, 0.08);
}

.novel-editor-body .chapter-footer-actions > * {
    flex: 1 1 auto;
    font-size: 0.84rem;
    padding: 6px 10px;
    min-height: 34px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    transition: background 0.18s ease, color 0.18s ease;
}

.novel-editor-body .chapter-footer-actions > *:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.novel-editor-body .chapter-create-disclosure summary {
    width: 100%;
}

.novel-editor-body .chapter-card-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.novel-editor-body .chapter-create-disclosure[open] {
    max-height: 55vh;
    overflow-y: auto;
}

.novel-editor-body .chapter-create-disclosure[open] .chapter-create-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== End Chapter Sidebar Polish ===== */

@media (min-width: 721px) {
    .novel-editor-body .editor-panel-head {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        gap: 18px;
    }

    .novel-editor-body .editor-panel-title {
        flex: 1 1 auto;
        min-width: 0;
        text-align: left;
    }

    .novel-editor-body .editor-panel-kicker {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
    }

    .novel-editor-body .editor-title-row {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 14px;
        width: 100%;
    }

    .novel-editor-body .editor-title-input {
        width: auto;
        max-width: 680px;
        text-align: left;
    }

    .novel-editor-body .editor-inline-meta,
    .novel-editor-body .editor-footnote {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
    }

    .novel-editor-body .editor-primary-actions {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        gap: 10px;
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .novel-editor-body .editor-primary-actions > * {
        width: auto;
    }
}

@media (max-width: 768px) {
    html,
    body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .page-shell {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: visible;
    }

    .site-header {
        position: static;
        height: auto;
    }

    .shell-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 0;
        min-height: auto;
    }

    .header-project-summary {
        white-space: normal;
        width: 100%;
    }

    .header-status-meta {
        width: 100%;
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    .site-nav {
        display: flex;
        flex-direction: row !important;
        flex-wrap: nowrap;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        gap: 8px;
        padding: 4px 0 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .site-nav::-webkit-scrollbar {
        display: none;
    }

    .site-nav a {
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: max-content;
        padding: 10px 16px;
        justify-content: center;
        border-radius: 999px;
    }

    .page-storyboard-workbench .storyboard-status-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero-card,
    .two-up,
    .four-up,
    .storyboard-shot-grid,
    .workbench-layout,
    .novel-workbench,
    .info-grid,
    .compare-grid,
    .mini-flow-list,
    .advanced-hero,
    .advanced-review-layout,
    .page-novel-advanced .summary-strip {
        grid-template-columns: 1fr;
    }

    .chapter-sidebar-panel,
    .ai-sidebar-panel,
    .advanced-console-sticky,
    .storyboard-side-sticky,
    .sticky-stack,
    .media-preview-sidebar,
    .novel-side-sticky {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .page-novel-advanced .advanced-hero .placeholder-box {
        min-width: 0;
    }

    .storyboard-span-2 {
        grid-column: span 1;
    }

    .inline-actions,
    .inline-meta,
    .toolbar-actions {
        flex-wrap: wrap;
    }

    .hero-card,
    .panel {
        padding: 18px;
    }

    .shell {
        width: min(100%, calc(100% - 24px));
        overflow-x: hidden;
    }
}

@media (max-width: 720px) {
    .page-storyboard-workbench .storyboard-status-head,
    .page-storyboard-workbench .storyboard-toolbar-copy,
    .page-storyboard-workbench .storyboard-toolbar-meta,
    .page-storyboard-workbench .storyboard-toolbar-actions,
    .page-storyboard-workbench .storyboard-results-meta {
        flex-direction: column;
        align-items: stretch;
    }

    .storyboard-shot-head,
    .storyboard-shot-head .inline-actions {
        align-items: stretch;
    }

    .toggle-shot-editor-btn,
    .save-shot-btn {
        width: 100%;
    }

    .page-storyboard-workbench .storyboard-status-metrics {
        grid-template-columns: 1fr;
    }

    .shell {
        width: min(100%, calc(100% - 24px));
    }

    .page-shell {
        padding: 22px 0 36px;
    }

    .hero-card,
    .panel {
        padding: 20px;
        border-radius: 20px;
    }

    .section-head {
        flex-direction: column;
    }

    .inline-actions,
    .inline-meta {
        width: 100%;
    }

    .editor-panel-head,
    .editor-title-row,
    .editor-inline-meta,
    .editor-footnote,
    .editor-primary-actions,
    .editor-panel-kicker {
        flex-direction: column;
        align-items: stretch;
    }

    .editor-title-input {
        font-size: 1.4rem;
    }

    .action-menu {
        width: 100%;
    }

    .action-menu-panel {
        position: static;
        min-width: 0;
        margin-top: 8px;
    }

    .inline-actions > *,
    .inline-meta > *,
    .toolbar-actions > *,
    .toolbar-actions-slim > *,
    .button-cluster > *,
    .editor-primary-actions > * {
        width: 100%;
    }

    .toolbar-row,
    .toolbar-meta,
    .toolbar-meta-compact,
    .summary-strip {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-sticky-bar {
        position: static;
        min-height: auto;
        padding: 14px 16px;
        border-radius: var(--radius-lg);
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions-slim {
        flex-wrap: wrap;
        overflow: visible;
    }

    .hero-heading,
    .project-item-head,
    .workflow-step-head,
    .workflow-step-meta,
    .project-item-meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .site-nav {
        gap: 8px;
        flex-direction: row !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        padding: 4px 0 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .site-nav::-webkit-scrollbar {
        display: none;
    }

    .site-nav a {
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: max-content;
        justify-content: center;
    }

    .project-chip {
        width: 100%;
        justify-content: center;
    }

    .project-item-action {
        width: 100%;
    }
}

/* ===== 页面布局优化 ===== */
.compact-action { min-height: 32px; padding: 2px 10px; font-size: 0.82rem; }

/* PHASE ONECLICK-A.1 — global cross-page one-click job bar.
   Sticky under the site header on every project page; shows the server-owned
   one-click job status and never cancels on navigation/reload. */
.oneclick-job-bar {
    position: sticky;
    top: 64px;
    z-index: 25;
    background: rgba(255, 251, 235, 0.95);
    border-bottom: 1px solid rgba(224, 185, 92, 0.65);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
}

.oneclick-job-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 6px 0;
}

.oneclick-job-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: #f2b544;
    box-shadow: 0 0 0 3px rgba(242, 181, 68, 0.25);
    animation: oneclick-pulse 1.6s ease-in-out infinite;
}

@keyframes oneclick-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.oneclick-job-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1 1 auto;
}

.oneclick-job-body strong {
    font-size: 0.9rem;
    color: var(--text);
}

.oneclick-job-meta {
    display: flex;
    gap: 8px;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.oneclick-job-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.chapter-select {
    min-height: 34px; padding: 4px 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: #fff; font-size: 0.88rem; color: var(--text);
}
.render-first-screen { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
.render-action-row { flex-wrap: wrap; }
.storyboard-input-disclosure { margin-bottom: 14px; }
.storyboard-input-disclosure summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.media-workbench-layout {
    display: grid;
    grid-template-columns: minmax(240px, 0.9fr) minmax(320px, 1.2fr) 360px;
    gap: 16px;
}
.media-asset-sidebar {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    gap: 16px;
    align-content: start;
}

.media-characters-panel,
.media-scenes-panel {
    grid-column: auto;
    grid-row: auto;
}

.media-shots-panel {
    grid-column: 2;
    grid-row: 1;
}

.media-preview-sidebar {
    grid-column: 3;
    grid-row: 1;
}

.media-preview-sidebar {
    position: sticky;
    top: var(--sticky-offset);
    max-height: calc(100vh - 112px);
    overflow-y: auto;
}

/* AI 折叠 */
@media (min-width: 961px) {
    .novel-editor-body.ai-collapsed .novel-right-rail .ai-sidebar {
        display: none;
    }
}

/* 右侧栏容器 */
.novel-right-rail {
    min-width: 0;
    display: grid;
    gap: 16px;
    align-self: start;
}
.novel-right-rail .ai-sidebar { min-width: 0; min-height: 0; }

/* 素材页响应式 */
@media (max-width: 1280px) {
    .media-workbench-layout { grid-template-columns: minmax(0, 1fr) 340px; }
    .media-asset-sidebar { grid-column: 1 / -1; grid-row: auto; }
    .media-shots-panel,
    .media-preview-sidebar {
        grid-column: auto;
        grid-row: auto;
    }

}
@media (max-width: 720px) {
    .render-first-screen { grid-template-columns: 1fr; }
    .media-workbench-layout { grid-template-columns: 1fr; }
    .media-preview-sidebar { position: static; max-height: none; }
}
/* ===== TXT 导入弹窗 ===== */
.import-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 100;
    display: flex; align-items: center; justify-content: center;
}
.import-modal-overlay[hidden] { display: none; }
.import-modal-panel {
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    max-width: 780px; width: 95%; max-height: 85vh; display: flex; flex-direction: column;
    overflow: hidden;
}
.import-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.import-modal-header h2 { margin: 0; font-size: 1.2rem; }
.import-modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.import-modes { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 10px; }
.import-preview-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.88rem; }
.import-preview-table th, .import-preview-table td {
    border: 1px solid var(--border); padding: 8px 10px; text-align: left;
}
.import-preview-table th { background: var(--surface-muted); font-weight: 600; }
.import-warning { color: #b43c3c; font-size: 0.86rem; margin-top: 4px; }
.import-summary { font-size: 0.9rem; color: var(--muted); margin-bottom: 8px; }
.import-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
/* ===== 品牌双语顶栏 ===== */
.brand-bilingual { display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand-en { font-size: 0.7em; font-weight: 600; opacity: 0.7; letter-spacing: 0.04em; }
/* ===== END ===== */
/* ===== Unified component responsive rules ===== */
@media (max-width: 768px) {
    .page-context-row {
        align-items: flex-start;
    }

    .page-context-switcher {
        width: 100%;
        margin-left: 0;
    }

    .visual-style-field {
        width: 100%;
        min-width: 0;
    }

    .visual-style-form > button {
        width: 100%;
    }

    .chapter-picker {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .chapter-picker .form-control-sm,
    .page-context-switcher .form-control-sm {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .form-row,
    .control-row {
        align-items: stretch;
        flex-direction: column;
    }

    .compact-control-group.control-offset {
        width: 100%;
        margin-left: 0;
    }

    .compact-control-group.control-offset .form-control-sm,
    .import-title-control {
        width: 100%;
        margin-left: 0;
    }

    .flow-arrow {
        display: none;
    }
}

/* Storyboard coverage audit */
.storyboard-audit-panel {
    display: grid;
    gap: 14px;
    padding: 16px 18px;
}

.storyboard-audit-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.storyboard-audit-head .eyebrow,
.storyboard-audit-head h2,
.storyboard-audit-head .muted {
    margin-bottom: 4px;
}

.storyboard-audit-head h2 {
    font-size: 1.08rem;
}

.storyboard-audit-status {
    flex: 0 0 auto;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 800;
    color: var(--muted);
    background: var(--surface-soft);
}

.storyboard-audit-status.is-passed {
    color: #1f7a45;
    border-color: #a8ddb9;
    background: #effbf3;
}

.storyboard-audit-status.is-stale,
.storyboard-audit-status.is-failed {
    color: #9a5d05;
    border-color: #f4cf88;
    background: #fff8e8;
}

.storyboard-audit-status.is-running {
    color: #3564d9;
    border-color: #b9cbff;
    background: #f1f5ff;
}

.storyboard-audit-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.storyboard-audit-metrics article {
    display: grid;
    gap: 4px;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-soft);
}

.storyboard-audit-metrics span,
.storyboard-audit-chunks {
    color: var(--muted);
    font-size: 0.85rem;
}

.storyboard-audit-metrics strong {
    color: var(--ink);
    font-size: 1rem;
}

.storyboard-audit-chunks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.storyboard-audit-chunks span {
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(83, 110, 255, 0.07);
}

.storyboard-audit-error {
    margin: 0;
    color: #a04343;
    font-size: 0.9rem;
}

@media (max-width: 760px) {
    .storyboard-audit-head {
        display: grid;
    }

    .storyboard-audit-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Storyboard analysis live progress */
.storyboard-analysis-progress[hidden] {
    display: none;
}

.storyboard-analysis-progress {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    padding: 15px 16px;
    border: 1px solid #b9cbff;
    border-radius: 14px;
    background: linear-gradient(135deg, #f5f8ff, #fbfcff);
}

.storyboard-analysis-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #244ca9;
}

.storyboard-analysis-progress-head span {
    font-size: 1.05rem;
    font-weight: 800;
}

.storyboard-progress-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe7fb;
}

.storyboard-progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #4d71ff, #7192ff);
    transition: width .35s ease;
}

.storyboard-progress-batch,
.storyboard-progress-message,
.storyboard-progress-tip {
    margin: 0;
}

.storyboard-progress-batch {
    color: var(--ink);
    font-weight: 750;
}

.storyboard-progress-message {
    color: #3861bd;
}

.storyboard-progress-checklist {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .72);
    color: var(--muted);
    font-size: .9rem;
}

.storyboard-progress-checklist .is-done { color: #22804a; }
.storyboard-progress-checklist .is-current { color: #315fe2; font-weight: 800; }
.storyboard-progress-checklist .is-error { color: #b23d3d; font-weight: 800; }
.storyboard-progress-tip { color: var(--muted); font-size: .86rem; }
/* ============ MATERIAL-OVERRIDE-A.1R PART B.2 — editor Drawer ============ */
/* The material editors live in their compact cards; opening one detaches it
   into a fixed Drawer workspace so the Card never grows/gets squeezed. */
.v4-editor-root {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
}
.v4-editor-root.v4-editor-open { display: block; }
.v4-editor-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 40, 0.45);
}
.v4-editor-drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(820px, 68vw);
    min-width: 640px;
    max-width: 100vw;
    background: #fff;
    border-left: 1px solid #d7dee8;
    box-shadow: -12px 0 32px rgba(16, 24, 40, 0.18);
    display: flex;
    flex-direction: column;
}
.v4-editor-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid #e3e8ef;
    background: #f7f9fc;
    position: sticky;
    top: 0;
}
.v4-editor-drawer-title { font-weight: 700; color: #14213d; }
#mediaDrawerNotice { flex: 0 0 auto; margin: 12px 18px 0; max-height: 160px; overflow: auto; white-space: pre-wrap; }
.v4-editor-drawer-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 18px;
}
.v4-editor-drawer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 18px;
    border-top: 1px solid #e3e8ef;
    background: #f7f9fc;
    position: sticky;
    bottom: 0;
}
.v4-editor-close {
    font-size: 20px;
    line-height: 1;
    border: 0;
    background: transparent;
    color: #5a6b8c;
    cursor: pointer;
    padding: 2px 8px;
}
.v4-editor-close:hover { color: #14213d; }
@media (max-width: 1100px) {
    .v4-editor-drawer { width: 100vw; min-width: 0; }
}
/* Detached source editors: never let the collapsed card show them expanded */
.v4-asset-editor.in-drawer,
.v4-dialogue-editor.in-drawer {
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
}
.v4-asset-editor.in-drawer > summary,
.v4-dialogue-editor.in-drawer > summary { display: none; }
.v4-asset-editor.in-drawer .v4-asset-editor-body,
.v4-dialogue-editor.in-drawer .v4-dialogue-editor-body { padding: 0; }
/* Drawer editing layout: roomy, readable */
.v4-editor-drawer .v4-edit-modes { display: flex; gap: 6px; margin: 4px 0 14px; }
.v4-editor-drawer .v4-mode-btn {
    border: 1px solid #c9d4e4; background: #fff; color: #3c4b66;
    border-radius: 6px; padding: 5px 14px; cursor: pointer;
}
.v4-editor-drawer .v4-mode-btn.is-active {
    background: #1b66e0; border-color: #1b66e0; color: #fff;
}
.v4-editor-drawer .v4-asset-field { display: block; margin-bottom: 10px; }
.v4-editor-drawer .v4-asset-field label { display: block; font-weight: 600; margin-bottom: 4px; }
.v4-editor-drawer input.v4-char-field,
.v4-editor-drawer input.v4-shot-field,
.v4-editor-drawer input.v4-scene-field {
    width: 100%; box-sizing: border-box; padding: 6px 8px;
    border: 1px solid #ccd6e4; border-radius: 6px;
}
.v4-editor-drawer .v4-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}
.v4-editor-drawer .v4-form-grid .v4-asset-field-wide { grid-column: 1 / -1; }
.v4-prompt-readonly,
.v4-editor-drawer .v4-base-pre {
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: #f2f5fa;
    border: 1px solid #dbe2ec;
    border-radius: 6px;
    padding: 10px;
    margin: 6px 0 10px;
    font-size: 13px;
    line-height: 1.6;
}
.v4-editor-drawer textarea.v4-char-full,
.v4-editor-drawer textarea.v4-shot-full,
.v4-editor-drawer textarea.v4-turn-text {
    width: 100%;
    box-sizing: border-box;
    min-height: 240px;
    resize: vertical;
    padding: 8px 10px;
    border: 1px solid #ccd6e4;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
}
.v4-editor-drawer textarea.v4-turn-text { min-height: 150px; }
.v4-editor-drawer textarea.v4-char-extra,
.v4-editor-drawer textarea.v4-shot-extra { width: 100%; box-sizing: border-box; }
.v4-editor-drawer .v4-dialogue-editor-body .v4-turn-editor {
    border: 1px solid #e0e6ef;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 14px;
    background: #fff;
}
.v4-editor-drawer .v4-asset-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.v4-editor-drawer .v4-asset-actions .primary-btn { margin-left: auto; }
.v4-editor-drawer .v4-editor-drawer-footer .v4-editor-footer-danger { margin-right: auto; }
body.v4-editor-open { overflow: hidden; }
@media (max-width: 1100px) { .v4-editor-drawer .v4-form-grid { grid-template-columns: 1fr; } }
/* PART C.1 — SHOT 成片调整 three-tab layout + motion pane */
.v4-shot-tabs { display: flex; gap: 6px; margin: 2px 0 12px; }
.v4-shot-tab {
    border: 1px solid #c9d4e4; background: #fff; color: #3c4b66;
    border-radius: 6px; padding: 6px 16px; cursor: pointer; font-weight: 600;
}
.v4-shot-tab.is-active {
    background: #1b66e0; border-color: #1b66e0; color: #fff;
}
.v4-editor-drawer textarea.v4-shot-motion {
    width: 100%; box-sizing: border-box; min-height: 180px; resize: vertical;
    padding: 8px 10px; border: 1px solid #ccd6e4; border-radius: 6px;
    font-size: 13px; line-height: 1.6;
}
.v4-editor-drawer .v4-asset-actions .primary-btn { margin-left: auto; }
.v4-shot-tab-dialogue .v4-turn-editor { margin-bottom: 12px; }
/* The active dialog owns feedback; restore the page notice when it closes. */
body.v4-editor-open #mediaNotice {
    display: none;
}
/* PART C.1.3a - default placeholder must never be visible; #mediaNotice is a
   dynamic container only (showNotice() removes [hidden]). */
#mediaNotice[hidden] {
    display: none !important;
}
/* ONECLICK-UX-C.1.1 - hard guard: author CSS (.primary-btn/.secondary-btn)
   display rules must never override the one-click bar action `hidden` state. */
.oneclick-job-actions [hidden] {
    display: none !important;
}

/* ------------------------------------------------------------------ *
 * MATERIALS UI PRODUCT POLISH — Voice Casting panel + Prop materials
 * Presentation only; keeps the existing nzst visual system.
 * ------------------------------------------------------------------ */
.voice-casting-panel .vc-subtitle { margin: 2px 0 0; }
.voice-casting-panel .vc-summary {
    margin: 6px 0 0; font-size: 13px; color: var(--muted,#6b7280);
    font-weight: 500;
}
.vc-actions { gap: 10px; align-items: center; flex-wrap: wrap; }
.vc-provider-disabled {
    margin: 10px 0 14px; padding: 12px 14px; border-radius: 12px;
    background: #f8fafc; border: 1px dashed #d0d7e2;
    display: flex; flex-direction: column; gap: 2px;
}
.vc-provider-disabled strong { font-size: 14px; font-weight: 600; }
.vc-provider-disabled .muted { font-size: 12px; }
.vc-section { margin: 20px 0 0; }
.vc-section-title {
    margin: 0 0 12px; font-size: 15px; font-weight: 600; color: #374151;
    letter-spacing: .2px;
}
.vc-list { display: flex; flex-direction: column; gap: 14px; }
.vc-empty { margin: 4px 0 8px; }

.voice-casting-card {
    border: 1px solid #e5e7eb; border-radius: 14px; padding: 16px 18px;
    background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.voice-casting-card.vc-action-card {
    border-color: #c7d2fe; box-shadow: 0 2px 6px rgba(79,70,229,.06);
}
.vc-card-title-row {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; margin-bottom: 8px;
}
.vc-name { font-size: 16px; font-weight: 600; color: #111827; }
.vc-meta { font-size: 12px; color: #6b7280; margin-top: 2px; }
.vc-status { flex: 0 0 auto; }
.vc-recommendation {
    margin: 8px 0 12px; padding: 10px 12px; border-radius: 10px;
    background: #f5f7ff; border: 1px solid #eef2ff;
}
.vc-recommendation-label {
    display: block; font-size: 12px; font-weight: 600; color: #4f46e5;
    margin-bottom: 2px;
}
.vc-recommendation p { margin: 0; font-size: 13px; color: #374151; }
.vc-prompt-label {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 10px; margin: 10px 0 6px;
}
.vc-prompt-label > span:first-child { font-size: 13px; font-weight: 600; }
.vc-ai-hint { font-size: 12px; }
.vc-prompt-textarea {
    width: 100%; min-height: 76px; max-height: 150px; resize: vertical;
    padding: 12px 14px; border-radius: 10px; border: 1px solid #e5e7eb;
    background: #fafbfc; font: 14px/1.5 inherit; color: #111827;
    box-sizing: border-box;
}
.vc-prompt-textarea[readonly] { background: #f3f4f6; color: #4b5563; }
.voice-casting-card .vc-actions { margin-top: 12px; justify-content: flex-start; }
.vc-preview-audio { max-width: 240px; height: 36px; }

.voice-casting-card.vc-confirmed-card {
    padding: 12px 16px; border-color: #e5e7eb; background: #fafbfc;
}
.vc-confirmed-card .vc-name { font-size: 15px; }
.vc-confirmed-card .vc-actions { margin-top: 6px; }
.vc-locked { font-size: 12px; }
/* PHASE VOICE-CASTING-VISIBILITY-1 — an ACCEPTED identity with an outstanding
   recast request is still the CURRENT production voice; it must stay visible. */
.vc-locked.vc-recasting {
    background: #fff7ed; color: #b45309; border: 1px solid #fed7aa;
}
.vc-error-line {
    margin: 6px 0 0; padding: 8px 10px; border-radius: 8px;
    background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
    font-size: 12px;
}
/* PHASE VOICE-CASTING-VISIBILITY-1 (B) — demoted-but-paid candidates. */
.vc-history {
    margin: 10px 0 0; padding: 10px 12px; border-radius: 10px;
    background: #f8fafc; border: 1px dashed #cbd5e1;
}
.vc-history-title {
    font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 8px;
}
.vc-history-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    padding: 6px 0;
}
.vc-history-row + .vc-history-row { border-top: 1px solid #e2e8f0; }
.vc-history-meta { font-size: 12px; flex: 1 1 220px; }
.vc-history-audio { max-width: 200px; }
/* PHASE VOICE-CASTING-RECAST-WORKFLOW-1 — the ONE shared candidate workflow
   (used by the un-ACCEPTED card AND the ACCEPTED+recasting card). */
.vc-candidate-workspace {
    margin-top: 12px; padding: 12px 14px; border-radius: 12px;
    background: #f8fafc; border: 1px solid #e2e8f0;
}
.vc-workspace-title {
    font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 8px;
}
.vc-candidate-workspace .vc-prompt-textarea { background: #fff; }
.vc-prompt-hint { margin: 6px 0 0; font-size: 12px; color: #b45309; }
.vc-current-voice-actions { margin-bottom: 2px; }
button.tertiary-btn, .tertiary-btn {
    border: 0; background: transparent; color: #4f46e5; cursor: pointer;
    font-size: 13px; padding: 6px 10px; border-radius: 8px;
}
button.tertiary-btn:hover { background: #eef2ff; }

/* Prop materials */
.v4-props-panel .media-selection-list { display: flex; flex-wrap: wrap; gap: 14px; }
.v4-prop-card {
    width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 8px;
    border: 1px solid #e5e7eb; border-radius: 14px; padding: 12px;
}
.prop-thumb {
    height: 110px; border-radius: 10px; display: flex; align-items: center;
    justify-content: center; font-size: 13px; color: #9ca3af;
    background: linear-gradient(135deg,#f3f4f6,#eef2ff);
}
.prop-body .media-card-head { gap: 8px; align-items: center; }
.v4-prop-card .prop-body strong { font-size: 15px; }
.prop-anchor { margin: 4px 0 0; font-size: 12px; }
.prop-evidence { font-size: .85rem; overflow-wrap: anywhere; }
.prop-evidence summary { cursor: pointer; }
.prop-evidence .inline-actions { flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.prop-evidence button { padding: 5px 8px; font-size: .8rem; }
.props-empty {
    padding: 18px; border: 1px dashed #d0d7e2; border-radius: 12px;
    display: flex; flex-direction: column; gap: 4px; width: 100%;
}

/* UI-3: action semantics and editor controls. */
.secondary-btn.danger-action { color: #a52222; background: #fff4f3; border: 1px solid #cf6a65; }
.secondary-btn.danger-action:hover:not(:disabled) { color: #851b1b; background: #ffe3e0; border-color: #a52222; }
.secondary-btn.danger-action:disabled { opacity: .5; cursor: not-allowed; }
.secondary-btn.danger-action:focus-visible { outline: 3px solid #a52222; outline-offset: 2px; }
#mediaPage .media-mini-btn { border-radius: 12px; font-weight: 700; padding: 10px 14px; min-height: 40px; }
.v4-editor-drawer-title { overflow-wrap: anywhere; }
.v4-editor-drawer-header, .v4-editor-close { flex-shrink: 0; }
.v4-editor-drawer .v4-asset-actions { position: sticky; bottom: 0; z-index: 2; padding: 10px 0; background: #fff; }
.novel-editor-body.ai-collapsed .novel-right-rail { display: none; }
@media (min-width: 981px) {
    .novel-editor-body.ai-collapsed .novel-workbench:not(.is-focus-mode) { grid-template-columns: 260px minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .page-novel-advanced .advanced-step-track { grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; }
    .page-novel-advanced .advanced-step-card strong { white-space: normal; overflow-wrap: anywhere; }
}

/* UI-4: bound each long list; keep batch controls inside its scroll area. */
.media-workspace-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
#mediaPage .media-workbench-layout { grid-template-columns: minmax(220px, .9fr) minmax(350px, 1.3fr) minmax(260px, .9fr); align-items: start; }
#mediaPage .media-asset-sidebar { grid-column: 1; grid-row: 1; }
#mediaPage .media-shots-panel { grid-column: 2; grid-row: 1; }
#mediaPage .media-preview-sidebar { grid-column: 3; grid-row: 1; position: static; }
#mediaPage .media-asset-sidebar, #mediaPage .media-shots-panel, #mediaPage .media-preview-sidebar {
    min-width: 0; max-height: min(900px, 78vh); overflow: auto; overscroll-behavior: contain; scroll-margin-top: 90px;
}
.media-shots-controls { position: sticky; top: -24px; z-index: 4; background: #fff; padding: 12px 0; border-bottom: 1px solid var(--border); }
.media-shots-controls .section-head { display: block; margin-bottom: 8px; }
.media-shots-controls h2 { font-size: 1.05rem; margin: 0 0 8px; }
.media-shots-controls .flow-arrow, .media-shots-controls .section-head p,
.media-shots-controls .media-selection-toolbar > .muted { display: none; }
.media-shots-controls .section-head > .inline-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.media-shots-controls .section-head > .inline-actions > .status-pill { grid-column: 1 / -1; justify-self: start; }
.media-shots-controls #toggleAllShotsBtn { grid-column: 1 / -1; justify-self: start; }
#mediaPage .media-shots-controls .media-mini-btn { width: 100%; min-width: 0; font-size: .82rem; padding: 7px 5px; }
.media-shots-controls .media-selection-toolbar { margin: 6px 0; }
.media-shot-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.media-shot-filters input, .media-shot-filters select { width: 100%; min-width: 0; padding: 7px; }
.media-filter-summary { font-size: .85rem; }
.media-shots-panel .media-asset-card { scroll-margin-top: 310px; }
.media-empty-filter { padding: 16px; }
@media (max-width: 1100px) {
    #mediaPage .media-workbench-layout { grid-template-columns: minmax(0, 1fr); }
    #mediaPage .media-shots-panel { grid-column: 1; grid-row: 1; }
    #mediaPage .media-preview-sidebar { grid-column: 1; grid-row: 2; }
    #mediaPage .media-asset-sidebar { grid-column: 1; grid-row: 3; }
    #mediaPage .media-shots-panel { max-height: 85vh; }
    #mediaPage .media-preview-sidebar { max-height: 60vh; }
    .media-workspace-nav { position: sticky; top: 0; z-index: 5; background: #f3f6ff; padding: 8px 0; }
}
