* {
    box-sizing: border-box;
}

:root {
    --ink: #1d2939;
    --muted: #64748b;
    --brand: #146579;
    --brand-dark: #12273a;
    --brand-soft: #edf6f8;
    --line: #dce4e9;
    --surface: #ffffff;
    --surface-soft: #f7f9fb;
    --success: #237a52;
    --success-soft: #edf8f2;
    --warning: #9a6318;
    --warning-soft: #fff6df;
    --danger: #a32d20;
    --danger-soft: #fff0ed;
    --book-width: 720px;
}

body {
    margin: 0;
    background: #f4f6f8;
    color: var(--ink);
    font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
    padding: 15px max(20px, calc((100vw - 1240px) / 2));
    background: var(--brand-dark);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header a {
    color: #ffffff;
    text-decoration: none;
}

header nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.brand {
    font-size: 20px;
    font-weight: 750;
}

main {
    max-width: 1240px;
    margin: 35px auto;
    padding: 0 20px 90px;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.2;
    margin: 5px 0;
}

h2 {
    font-size: 21px;
}

h3 {
    line-height: 1.3;
}

.eyebrow {
    color: #397488;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.15em;
}

.muted {
    color: var(--muted);
}

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

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 15px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px #152a3a08;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 18px;
}

.linkcard {
    text-decoration: none;
    color: inherit;
}

.linkcard:hover {
    border-color: #1b7285;
}

.columns {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
}

.chapter-link {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 0;
    border-bottom: 1px solid #e6ebef;
    color: inherit;
    text-decoration: none;
}

.chapter-link:hover {
    color: #12657a;
}

button,
.button {
    border: 0;
    border-radius: 9px;
    background: var(--brand);
    color: #ffffff;
    font: inherit;
    font-weight: 650;
    padding: 10px 15px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button:hover,
.button:hover {
    filter: brightness(0.96);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

button.quiet {
    background: transparent;
    padding: 0;
}

button.secondary,
.button.secondary {
    background: #edf3f5;
    color: #255164;
}

a {
    color: var(--brand);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #cbd6df;
    border-radius: 8px;
    padding: 10px;
    font: inherit;
    color: var(--ink);
}

textarea {
    min-height: 130px;
    resize: vertical;
}

label {
    font-weight: 700;
    display: block;
    margin: 10px 0 4px;
}

.editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.editor-grid textarea {
    min-height: 440px;
}

.meta {
    display: grid;
    grid-template-columns: 80px 1fr 100px 1fr;
    align-items: center;
    gap: 12px;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.actions form {
    margin: 0;
}

.notice {
    padding: 10px 16px;
    border-radius: 8px;
    background: #e5f2f5;
    margin-bottom: 18px;
}

.notice.error,
.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.notice.warning {
    background: #fff3d6;
}

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

.narrow {
    max-width: 490px;
    margin: auto;
}

audio {
    width: 100%;
    max-width: 360px;
}

/* Stage 1 + private reader */
.structure-row {
    border-top: 1px solid #e6ebef;
    padding: 18px 0;
}

.structure-row h3 {
    margin: 5px 0 8px;
}

.structure-row p {
    white-space: pre-line;
}

.manuscript-raw {
    max-height: 420px;
    overflow: auto;
    padding: 18px;
    white-space: pre-wrap;
    background: #f4f6f8;
    border-radius: 8px;
}

.inline-checkbox {
    width: auto;
    margin-right: 8px;
}

.reader-cover {
    margin: 0 auto 25px;
    max-width: 800px;
    text-align: center;
    padding: 60px 24px;
    background: #eaf0f2;
    border-radius: 15px;
}

.reader-section {
    max-width: 800px;
    margin: 30px auto;
    padding: clamp(24px, 6vw, 70px);
}

.reader-text {
    font: 18px/1.85 Georgia, "Times New Roman", serif;
    overflow-wrap: anywhere;
}

.reader-section audio {
    width: 100%;
    max-width: 100%;
}

summary {
    cursor: pointer;
    font-weight: 700;
}

/* =========================================================
   BOOK PRODUCTION STUDIO
   ========================================================= */

.chapter-studio-heading {
    margin-bottom: 24px;
}

.status-pill,
.source-badge,
.segment-status,
.stage-ready,
.stage-waiting {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.status-draft,
.source-badge {
    background: #eef2f6;
    color: #475467;
}

.status-review,
.stage-waiting {
    background: var(--warning-soft);
    color: var(--warning);
}

.status-approved,
.stage-ready,
.source-badge-live {
    background: var(--success-soft);
    color: var(--success);
}

.production-roadmap {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 18px;
}

.roadmap-step {
    position: relative;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    color: #7b8794;
}

.roadmap-step strong,
.roadmap-step small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.roadmap-step strong {
    color: #475467;
    font-size: 13px;
}

.roadmap-step small {
    margin-top: 2px;
    font-size: 11px;
}

.roadmap-number {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #eef2f6;
    color: #667085;
    font-size: 12px;
    font-weight: 850;
}

.roadmap-step.is-complete {
    border-color: #cbe8d8;
    background: #fbfefc;
}

.roadmap-step.is-complete .roadmap-number {
    background: var(--success);
    color: #ffffff;
}

.roadmap-step.is-current {
    border-color: #98cad5;
    background: #f4fbfc;
    box-shadow: 0 0 0 2px #dff2f5 inset;
}

.roadmap-step.is-current .roadmap-number {
    background: var(--brand);
    color: #ffffff;
}

.current-step-card {
    margin-bottom: 22px;
    padding: 22px 24px;
    border: 1px solid #bcdbe2;
    border-radius: 15px;
    background: linear-gradient(135deg, #f3fafc 0%, #ffffff 72%);
}

.current-step-card h2 {
    margin: 3px 0 7px;
    font-size: 24px;
}

.current-step-card p:not(.eyebrow) {
    max-width: 850px;
    margin-top: 0;
    color: #526172;
}

.studio-tabs {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    gap: 6px;
    padding: 8px;
    margin: 0 0 20px;
    overflow-x: auto;
    background: rgba(244, 246, 248, 0.96);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 13px;
}

.studio-tab {
    flex: 1 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 130px;
    padding: 11px 13px;
    background: transparent;
    color: #526172;
    border-radius: 9px;
}

.studio-tab span {
    opacity: 0.55;
    font-size: 11px;
    letter-spacing: 0.08em;
}

.studio-tab.is-active {
    background: var(--brand-dark);
    color: #ffffff;
}

.tab-badge {
    min-width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    padding: 0 5px;
    border-radius: 999px;
    background: #d92d20;
    color: #ffffff;
    font-size: 11px;
}

.studio-tab-panel {
    display: none;
}

.studio-tab-panel.is-active {
    display: block;
}

.ai-editorial-panel {
    border-color: #bfd8df;
    background: linear-gradient(180deg, #f8fcfd 0%, #ffffff 100%);
}

.panel-title-row,
.editor-heading,
.review-list-heading,
.segment-heading,
.production-status-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.panel-title-row h2,
.panel-title-row p,
.editor-heading h2,
.editor-heading p {
    margin-top: 0;
    margin-bottom: 4px;
}

.ai-status {
    max-width: 440px;
    text-align: right;
    font-size: 13px;
}

.primary-action {
    padding: 12px 18px;
    font-weight: 800;
}

.chapter-settings-panel {
    padding-top: 18px;
    padding-bottom: 18px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 110px minmax(220px, 1.4fr) minmax(180px, 0.7fr) minmax(180px, 0.8fr);
    gap: 12px 16px;
    margin-top: 18px;
    align-items: end;
}

.toggle-field {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 30px;
}

.toggle-field input {
    width: auto;
}

.toggle-field label {
    margin: 0;
}

.editor-workspace {
    display: grid;
    grid-template-columns: minmax(300px, 0.78fr) minmax(560px, 1.35fr);
    gap: 20px;
    align-items: start;
    margin-bottom: 20px;
}

.book-source-panel,
.publication-editor-panel {
    min-width: 0;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 2px 10px #152a3a06;
}

.source-scroll {
    height: 820px;
    overflow: hidden;
    border: 1px solid #e2e8ef;
    border-radius: 10px;
    background: #f8fafb;
}

.source-column textarea {
    width: 100%;
    height: 100%;
    min-height: 820px;
    border: 0;
    border-radius: 0;
    padding: 24px;
    resize: none;
    outline: none;
    background: #f8fafb;
    color: #596575;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 16px;
    line-height: 1.75;
}

.editor-impact {
    display: grid;
    grid-template-columns: repeat(3, minmax(95px, 1fr));
    gap: 10px;
    margin: 14px 0 16px;
}

.editor-impact > div {
    padding: 11px 13px;
    border-radius: 10px;
    background: var(--surface-soft);
    border: 1px solid #e7ebef;
}

.editor-impact span,
.editor-impact small,
.editor-impact strong {
    display: block;
}

.editor-impact span,
.editor-impact small {
    color: #667085;
    font-size: 11px;
}

.editor-impact strong {
    margin: 1px 0;
    font-size: 18px;
}

.impact-warning {
    grid-column: 1 / -1;
    margin: 0;
    padding: 10px 12px;
    border-radius: 9px;
    background: var(--warning-soft);
    color: #80511a;
    font-size: 13px;
    font-weight: 650;
}

.ebook-page-shell {
    overflow: hidden;
    border: 1px solid #d6dde3;
    border-radius: 12px;
    background: #ece8df;
    box-shadow: inset 0 0 28px #493e2e0d;
}

.ebook-page-header {
    max-width: var(--book-width);
    margin: 0 auto;
    padding: 18px 72px 0;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    color: #928a80;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 11px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.ebook-title-preview {
    max-width: var(--book-width);
    margin: 0 auto;
    padding: 52px 72px 8px;
    background: #fffefa;
    color: #1d1c1a;
    font: 700 31px/1.2 Georgia, "Times New Roman", serif;
}

.ql-toolbar.ql-snow {
    border-color: #cbd6df;
    border-radius: 9px 9px 0 0;
    background: #f8fafb;
}

.ebook-page-shell > .ql-toolbar.ql-snow {
    max-width: var(--book-width);
    margin: 0 auto;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    background: #fbfbf8;
}

.ql-container.ql-snow {
    border-color: #cbd6df;
    border-radius: 0 0 9px 9px;
}

.rich-editor {
    min-height: 560px;
    background: #ffffff;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 17px;
    line-height: 1.75;
}

.ebook-editor.ql-container.ql-snow {
    max-width: var(--book-width);
    min-height: 820px;
    margin: 0 auto;
    border: 0;
    border-radius: 0;
    background: #fffefa;
}

.ebook-editor .ql-editor,
.ebook-rendered-content {
    color: #292722;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 18px;
    line-height: 1.78;
}

.ebook-editor .ql-editor {
    min-height: 820px;
    padding: 42px 72px 90px;
}

.ebook-editor .ql-editor p,
.ebook-rendered-content p {
    margin: 0 0 1.15em;
}

.ebook-editor .ql-editor h2,
.ebook-rendered-content h2 {
    margin: 2.4em 0 0.9em;
    font-size: 1.55rem;
    line-height: 1.28;
}

.ebook-editor .ql-editor h3,
.ebook-rendered-content h3 {
    margin: 2em 0 0.75em;
    font-size: 1.25rem;
    line-height: 1.3;
}

.ebook-editor .ql-editor blockquote,
.ebook-rendered-content blockquote {
    margin: 1.55em 1.8em;
    padding: 0 0 0 1.25em;
    border-left: 2px solid #c9c1b4;
    color: #4a4640;
}

.ebook-editor .ql-editor ul,
.ebook-editor .ql-editor ol,
.ebook-rendered-content ul,
.ebook-rendered-content ol {
    margin: 1.1em 0 1.4em;
    padding-left: 1.6em;
}

.editor-help {
    margin-top: 10px;
    color: #667085;
    font-size: 13px;
}

.edit-tools-panel {
    margin-top: 20px;
}

.notes-field {
    margin-top: 18px;
}

.diff-view {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    border: 1px solid var(--line);
    padding: 15px;
    border-radius: 8px;
    max-height: 340px;
    overflow: auto;
    background: #f8fafb;
}

.sticky-save-actions {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid #e4e7ec;
}

/* Review */
.stage-intro-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 28px;
    align-items: start;
}

.stage-intro-grid h2 {
    margin: 4px 0 8px;
    font-size: 25px;
}

.stage-action-box {
    padding: 16px;
    border: 1px solid #e0e6eb;
    border-radius: 12px;
    background: #f8fafb;
}

.stage-action-box p {
    margin: 8px 0 0;
    color: #667085;
    font-size: 13px;
}

.review-flag {
    border-left: 4px solid #bc8751;
    background: #fff9f1;
    border-radius: 8px;
    padding: 17px;
    margin: 14px 0;
}

.review-flag.resolved {
    border-left-color: #33845d;
    background: #f3faf5;
}

.review-flag blockquote {
    margin: 12px 0;
    padding: 12px 15px;
    border-left: 3px solid #dec6a5;
    background: #ffffffa6;
}

.inline-control {
    display: flex;
    align-items: center;
    gap: 7px;
}

.empty-state {
    padding: 26px;
    border: 1px dashed #cfd8df;
    border-radius: 12px;
    background: #fafbfc;
    text-align: center;
    color: #667085;
}

.empty-state strong {
    color: #344054;
}

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

.manual-flag-details,
.revision-details {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #e7ebef;
}

.revision-preview {
    margin: 14px 0;
    padding: 26px;
    max-height: 520px;
    overflow: auto;
    background: #fffefa;
    border: 1px solid #e6e0d6;
    border-radius: 8px;
}

/* Narration */
.narration-editor {
    min-height: 520px;
}

.narration-editor .ql-editor {
    min-height: 520px;
    padding: 32px 40px 60px;
    font: 18px/1.85 Georgia, "Times New Roman", serif;
}

.narration-next-step {
    margin-top: 18px;
    padding: 15px 17px;
    border-radius: 10px;
    background: #f1f7f9;
    color: #405566;
}

.narration-next-step p {
    margin: 5px 0 0;
}

/* Audio */
.audio-process-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.audio-process-card {
    position: relative;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #ffffff;
}

.audio-process-card.is-next {
    border-color: #8fc4d0;
    box-shadow: 0 0 0 2px #dff2f5 inset;
}

.process-number {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--brand-dark);
    color: #ffffff;
    font-size: 13px;
    font-weight: 850;
}

.audio-process-card h3 {
    margin: 15px 0 6px;
}

.audio-process-card p {
    min-height: 96px;
    color: #667085;
}

.audio-process-card form {
    margin-top: 16px;
}

.production-status-panel {
    align-items: flex-start;
}

.production-status-panel h2 {
    margin: 3px 0;
}

.segment-card {
    padding: 18px 0;
    border-top: 1px solid #e3eaf0;
}

.segment-card p {
    white-space: pre-wrap;
}

.segment-status {
    background: #eef2f6;
    color: #475467;
}

/* Digital preview */
.preview-mode-switch {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.preview-mode-switch .is-selected {
    background: var(--brand-dark);
    color: #ffffff;
}

.digital-preview-frame {
    max-width: 930px;
    margin: 0 auto;
    padding: 40px;
    border-radius: 20px;
    background: #ded9cf;
    transition: max-width 180ms ease;
}

.digital-preview-frame.is-mobile {
    max-width: 430px;
    padding: 12px;
    border-radius: 26px;
    background: #1e242b;
}

.digital-reader-page {
    min-height: 900px;
    padding: 48px 76px 86px;
    border-radius: 9px;
    background: #fffefa;
    box-shadow: 0 12px 35px #2520181f;
}

.digital-reader-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 58px;
    color: #928a80;
    font: 11px/1.4 Georgia, "Times New Roman", serif;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.digital-reader-page > h1 {
    max-width: var(--book-width);
    margin: 0 auto 42px;
    color: #1d1c1a;
    font: 700 36px/1.18 Georgia, "Times New Roman", serif;
}

.digital-reader-page .ebook-rendered-content {
    max-width: var(--book-width);
    margin: 0 auto;
}

.reader-audio-card {
    max-width: var(--book-width);
    margin: 50px auto 0;
    padding-top: 22px;
    border-top: 1px solid #ddd5ca;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.reader-audio-card span,
.reader-audio-card strong {
    display: block;
}

.digital-preview-frame.is-mobile .digital-reader-page {
    min-height: 760px;
    padding: 32px 24px 58px;
    border-radius: 18px;
}

.digital-preview-frame.is-mobile .digital-reader-meta {
    margin-bottom: 40px;
}

.digital-preview-frame.is-mobile .digital-reader-page > h1 {
    margin-bottom: 32px;
    font-size: 30px;
}

.digital-preview-frame.is-mobile .ebook-rendered-content {
    font-size: 17px;
    line-height: 1.72;
}

.digital-preview-frame.is-mobile .reader-audio-card {
    display: block;
}

.digital-preview-frame.is-mobile .reader-audio-card audio {
    margin-top: 12px;
    max-width: 100%;
}

@media (max-width: 1100px) {
    .production-roadmap {
        grid-template-columns: repeat(4, 1fr);
    }

    .editor-workspace {
        grid-template-columns: 1fr;
    }

    .source-scroll,
    .source-column textarea {
        height: 520px;
        min-height: 520px;
    }

    .audio-process-grid {
        grid-template-columns: 1fr;
    }

    .audio-process-card p {
        min-height: auto;
    }
}

@media (max-width: 760px) {
    .columns,
    .editor-grid,
    .meta,
    .stage-intro-grid,
    .settings-grid {
        display: block;
    }

    .chapter-link {
        display: block;
    }

    .heading {
        align-items: flex-start;
        flex-direction: column;
    }

    header {
        padding: 12px 20px;
    }

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

    .roadmap-step {
        padding: 10px;
    }

    .studio-tabs {
        margin-left: -4px;
        margin-right: -4px;
    }

    .studio-tab {
        min-width: 118px;
    }

    .toggle-field {
        padding-top: 10px;
    }

    .panel-title-row,
    .editor-heading,
    .production-status-panel,
    .reader-audio-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .ai-status {
        text-align: left;
    }

    .book-source-panel,
    .publication-editor-panel,
    .panel {
        padding: 18px;
    }

    .ebook-page-header {
        padding: 16px 24px 0;
    }

    .ebook-title-preview {
        padding: 38px 24px 8px;
        font-size: 27px;
    }

    .ebook-editor .ql-editor {
        padding: 32px 24px 60px;
        font-size: 17px;
    }

    .editor-impact {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .digital-preview-frame {
        padding: 12px;
    }

    .digital-reader-page {
        min-height: 760px;
        padding: 32px 24px 58px;
    }

    .digital-reader-meta {
        margin-bottom: 40px;
    }

    .digital-reader-page > h1 {
        margin-bottom: 32px;
        font-size: 30px;
    }
}

@media (max-width: 520px) {
    .production-roadmap {
        grid-template-columns: 1fr;
    }

    .editor-impact {
        grid-template-columns: 1fr;
    }

    .impact-warning {
        grid-column: auto;
    }
}


/* --------------------------------------------------------------------------
   Live workflow / HTMX production states
   -------------------------------------------------------------------------- */

.studio-process-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: start center;
    padding: 88px 22px 22px;
    background: rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(2px);
}

.studio-process-overlay[hidden] {
    display: none;
}

.studio-process-card {
    width: min(560px, 100%);
    display: flex;
    gap: 18px;
    align-items: center;
    padding: 22px 24px;
    border: 1px solid #d7e0e8;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 22px 70px rgba(15, 23, 42, 0.22);
}

.studio-process-card strong {
    display: block;
    margin-bottom: 5px;
    color: #182230;
    font-size: 17px;
}

.studio-process-card p {
    margin: 0;
    color: #667085;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    border: 3px solid #d5dde6;
    border-top-color: currentColor;
    border-radius: 999px;
    animation: studio-spin 0.72s linear infinite;
}

.spinner-large {
    width: 34px;
    height: 34px;
    color: var(--brand-dark);
    border-width: 4px;
}

.spinner-small,
.spinner-inline,
.spinner-button {
    width: 15px;
    height: 15px;
    border-width: 2px;
}

.spinner-button {
    margin-right: 7px;
    vertical-align: -2px;
}

.spinner-inline {
    margin-right: 6px;
    vertical-align: -2px;
}

@keyframes studio-spin {
    to {
        transform: rotate(360deg);
    }
}

.studio-action-result {
    display: flex;
    gap: 11px;
    align-items: center;
    margin: 0 0 14px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #d7e0e8;
    background: #f8fafc;
}

.studio-action-result-success {
    border-color: #a7d7ba;
    background: #f0faf4;
    color: #17603a;
}

.studio-action-result-error {
    border-color: #f3b7b2;
    background: #fff4f3;
    color: #9c2b22;
}

.status-icon {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 999px;
    color: #ffffff;
    font-weight: 800;
}

.status-icon-success {
    background: #24945a;
}

.status-icon-error {
    background: #c23b32;
}

.audio-progress-panel {
    overflow: hidden;
}

.audio-progress-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.audio-progress-heading h2 {
    margin-top: 2px;
}

.audio-progress-number {
    color: var(--brand-dark);
    font-size: 26px;
    white-space: nowrap;
}

.progress-track {
    height: 13px;
    margin: 20px 0 14px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8edf2;
}

.progress-fill {
    height: 100%;
    min-width: 0;
    border-radius: inherit;
    background: var(--brand-dark);
    transition: width 300ms ease;
}

.audio-progress-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    color: #667085;
    font-size: 14px;
}

.audio-progress-stats b {
    color: #344054;
}

.audio-progress-stats .has-errors,
.audio-progress-stats .has-errors b {
    color: #b42318;
}

.live-refresh-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0 0;
    color: #475467;
    font-size: 13px;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #24945a;
    box-shadow: 0 0 0 0 rgba(36, 148, 90, 0.38);
    animation: live-pulse 1.5s ease-out infinite;
}

@keyframes live-pulse {
    70% {
        box-shadow: 0 0 0 8px rgba(36, 148, 90, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(36, 148, 90, 0);
    }
}

.stage-processing,
.stage-error {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 7px;
    font-weight: 800;
}

.stage-processing {
    color: #175cd3;
}

.stage-error {
    color: #b42318;
}

.production-error-box,
.segment-error {
    margin-top: 16px;
    padding: 13px 15px;
    border: 1px solid #f3b7b2;
    border-radius: 10px;
    background: #fff4f3;
    color: #912018;
}

.production-error-box p,
.segment-error p {
    margin: 5px 0 0;
}

.segment-working {
    border-left: 3px solid #2e6fd1;
    padding-left: 14px;
}

.segment-error {
    border-left-color: #c23b32;
}

.segment-status-working {
    background: #eef4ff;
    color: #175cd3;
}

.segment-status-ready {
    background: #ecfdf3;
    color: #067647;
}

.segment-status-error {
    background: #fef3f2;
    color: #b42318;
}

.production-complete-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-color: #a7d7ba;
    background: #f8fffa;
}

.ai-status.is-processing {
    color: #175cd3;
    font-weight: 700;
}

@media (max-width: 760px) {
    .studio-process-overlay {
        padding-top: 72px;
    }

    .studio-process-card,
    .production-complete-panel,
    .audio-progress-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .audio-progress-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

/* Narration profile + OpenAI voice lab */
.narration-settings-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, .8fr);
    gap: 22px;
    align-items: start;
}

.narration-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.narration-field-grid label,
.voice-preview-panel label {
    display: block;
    margin-bottom: 7px;
    font-weight: 800;
    color: #182230;
}

.narration-field-grid select,
.narration-field-grid input,
#narration-settings-form textarea,
.voice-preview-panel textarea {
    width: 100%;
}

.field-help {
    margin: 7px 0 0;
    color: #667085;
    font-size: 13px;
    line-height: 1.45;
}

.voice-preview-panel {
    position: sticky;
    top: 22px;
}

.voice-preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin: 14px 0;
}

.voice-preview-button {
    justify-content: flex-start;
    width: 100%;
}

#voice-preview-player {
    width: 100%;
    margin-top: 12px;
}

.segment-kind-badge {
    display: inline-flex;
    margin-left: 9px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #475467;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

@media (max-width: 900px) {
    .narration-settings-layout,
    .narration-field-grid {
        grid-template-columns: 1fr;
    }

    .voice-preview-panel {
        position: static;
    }
}


.danger-action {
    border-color: #fda29b !important;
    color: #b42318 !important;
    background: #fff !important;
}

.danger-action:hover {
    border-color: #f04438 !important;
    background: #fef3f2 !important;
}

/* Publication workspace */
.publication-shell {
    display: grid;
    gap: 22px;
}

.publication-heading {
    margin-bottom: 0;
}

.publication-readiness {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.readiness-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 1px solid #e4e7ec;
    border-radius: 14px;
    background: #fff;
}

.readiness-card div {
    display: grid;
    gap: 2px;
}

.readiness-card span:not(.readiness-dot) {
    color: #667085;
    font-size: 13px;
}

.readiness-dot {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: #d0d5dd;
}

.readiness-card.is-ready .readiness-dot {
    background: #12b76a;
}

.publication-grid {
    display: grid;
    grid-template-columns: minmax(300px, .72fr) minmax(0, 1.7fr);
    gap: 22px;
    align-items: start;
}

.panel-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.cover-stage {
    display: grid;
    place-items: center;
    min-height: 420px;
    margin: 18px 0;
    padding: 18px;
    border-radius: 16px;
    background: #f2f4f7;
}

.cover-stage img {
    display: block;
    width: min(100%, 290px);
    max-height: 430px;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 18px 45px rgba(16, 24, 40, .2);
}

.cover-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: min(100%, 280px);
    aspect-ratio: 2 / 3;
    padding: 36px 28px;
    background: #101828;
    color: #fff;
    box-shadow: 0 18px 45px rgba(16, 24, 40, .2);
}

.cover-placeholder span {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 32px;
    line-height: 1.05;
}

.cover-picker {
    width: 100%;
    text-align: center;
}

.publication-status {
    min-height: 20px;
    margin-top: 10px;
}

.metadata-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 18px 0;
}

.metadata-field.wide {
    grid-column: 1 / -1;
}

.metadata-field label {
    display: block;
    margin-bottom: 7px;
    font-weight: 800;
}

.metadata-field input,
.metadata-field textarea,
.metadata-field select {
    width: 100%;
}

.field-error {
    margin: 5px 0 0;
    color: #b42318;
    font-size: 13px;
}

.publication-section-list {
    display: grid;
    margin-top: 15px;
}

.publication-section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 15px 0;
    border-top: 1px solid #eaecf0;
}

.publication-section-row > div:first-child {
    display: grid;
    gap: 3px;
}

.publication-section-row > div:first-child span {
    color: #667085;
    font-size: 13px;
}

.section-output-status {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.status-pill {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #475467;
    font-size: 11px;
    font-weight: 800;
}

.status-pill.status-ready {
    background: #ecfdf3;
    color: #067647;
}

.output-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 15px;
}

.output-card {
    padding: 17px;
    border: 1px solid #e4e7ec;
    border-radius: 13px;
    background: #f9fafb;
}

.output-card.is-active {
    background: #fff;
    border-color: #b7cbea;
}

.output-card p {
    min-height: 54px;
    color: #667085;
    font-size: 13px;
}

/* Finished-book reader */
.book-reader-shell {
    max-width: 1360px;
    margin: -10px auto 0;
}

.reader-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 58px;
    padding: 0 12px;
    border-bottom: 1px solid #eaecf0;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(10px);
}

.reader-toolbar > :last-child {
    text-align: right;
}

.reader-brand {
    max-width: 440px;
    overflow: hidden;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-landing {
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(0, 620px);
    justify-content: center;
    gap: 70px;
    padding: 70px 30px 50px;
}

.reader-cover-art img,
.reader-cover-fallback {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    box-shadow: 0 24px 60px rgba(16, 24, 40, .24);
}

.reader-cover-fallback {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 55px 40px;
    background: #101828;
    color: #fff;
}

.reader-cover-fallback h1 {
    color: inherit;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 44px;
}

.reader-landing-copy {
    align-self: center;
}

.reader-landing-copy > h1 {
    margin-bottom: 7px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(42px, 5vw, 68px);
    line-height: 1;
}

.reader-landing-copy > h2 {
    margin-top: 0;
    color: #475467;
    font-weight: 500;
}

.reader-byline {
    margin: 20px 0;
    font-size: 18px;
}

.reader-description {
    color: #475467;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 17px;
    line-height: 1.65;
}

.reader-start-actions {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    margin-top: 28px;
}

.reader-toc {
    max-width: 900px;
    margin: 30px auto 80px;
    padding: 40px 28px;
}

.reader-toc > h2 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 32px;
}

.reader-toc-list {
    border-top: 1px solid #d0d5dd;
}

.reader-toc-list a {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 18px;
    padding: 15px 0;
    border-bottom: 1px solid #eaecf0;
    color: inherit;
}

.reader-toc-list span {
    color: #667085;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.reader-page-wrap {
    display: grid;
    grid-template-columns: 250px minmax(0, 780px);
    justify-content: center;
    gap: 45px;
    padding: 40px 24px 90px;
}

.reader-side-toc {
    position: sticky;
    top: 84px;
    align-self: start;
    max-height: calc(100vh - 110px);
    overflow: auto;
}

.reader-cover-mini {
    display: block;
    margin-bottom: 20px;
}

.reader-cover-mini img {
    width: 105px;
    max-height: 160px;
    object-fit: cover;
    box-shadow: 0 8px 24px rgba(16, 24, 40, .16);
}

.reader-cover-mini > span {
    display: block;
    padding: 20px 14px;
    background: #101828;
    color: #fff;
    font-family: Georgia, 'Times New Roman', serif;
}

.reader-side-toc nav {
    display: grid;
    gap: 4px;
}

.reader-side-toc nav a {
    display: grid;
    gap: 2px;
    padding: 9px 10px;
    border-radius: 8px;
    color: #475467;
    font-size: 13px;
}

.reader-side-toc nav a.active {
    background: #f2f4f7;
    color: #101828;
    font-weight: 800;
}

.reader-side-toc small {
    color: #98a2b3;
    font-size: 10px;
    text-transform: uppercase;
}

.reader-page {
    min-width: 0;
}

.reader-mode-switch {
    display: inline-flex;
    gap: 4px;
    margin-bottom: 50px;
    padding: 4px;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    background: #f9fafb;
}

.reader-mode-switch a {
    padding: 7px 12px;
    border-radius: 7px;
    color: #475467;
    font-size: 13px;
    font-weight: 800;
}

.reader-mode-switch a.active {
    background: #fff;
    color: #101828;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
}

.reader-section-heading {
    margin-bottom: 42px;
    text-align: center;
}

.reader-section-heading h1 {
    max-width: 690px;
    margin: 8px auto 0;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(35px, 5vw, 52px);
    font-weight: 500;
    line-height: 1.12;
}

.reader-book-text {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 19px;
    line-height: 1.78;
    color: #292524;
}

.reader-book-text p {
    margin: 0 0 1.2em;
}

.reader-book-text blockquote {
    margin: 1.7em 2em;
    padding-left: 1.2em;
    border-left: 2px solid #d0d5dd;
    font-style: italic;
}

.reader-book-text h2,
.reader-book-text h3 {
    margin: 2.2em 0 1em;
    font-family: Georgia, 'Times New Roman', serif;
}

.reader-audio-panel {
    position: sticky;
    top: 68px;
    z-index: 10;
    margin: -20px 0 35px;
    padding: 16px 18px;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .08);
}

.reader-audio-panel p {
    margin: 0 0 8px;
}

.reader-audio-panel audio {
    width: 100%;
}

.mode-listen .reader-section-heading {
    margin-top: 60px;
}

.reader-section-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 15px;
    margin-top: 70px;
    padding-top: 24px;
    border-top: 1px solid #eaecf0;
    font-size: 13px;
}

.reader-next-link {
    text-align: right;
}

@media (max-width: 980px) {
    .publication-readiness,
    .output-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .publication-grid,
    .reader-landing,
    .reader-page-wrap {
        grid-template-columns: 1fr;
    }

    .reader-landing {
        gap: 35px;
    }

    .reader-cover-art {
        width: min(360px, 90%);
        margin: 0 auto;
    }

    .reader-side-toc {
        position: static;
        display: none;
    }
}

@media (max-width: 680px) {
    .publication-readiness,
    .output-grid,
    .metadata-grid {
        grid-template-columns: 1fr;
    }

    .metadata-field.wide {
        grid-column: auto;
    }

    .publication-section-row,
    .panel-heading-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-output-status {
        justify-content: flex-start;
    }

    .reader-toolbar {
        grid-template-columns: auto 1fr auto;
        gap: 10px;
        font-size: 12px;
    }

    .reader-brand {
        text-align: center;
    }

    .reader-landing {
        padding: 35px 10px;
    }

    .reader-toc {
        padding: 30px 8px;
    }

    .reader-toc-list a {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .reader-page-wrap {
        padding: 28px 8px 70px;
    }

    .reader-book-text {
        font-size: 18px;
        line-height: 1.72;
    }

    .reader-mode-switch {
        display: flex;
        width: 100%;
    }

    .reader-mode-switch a {
        flex: 1;
        text-align: center;
    }

    .reader-section-nav {
        grid-template-columns: 1fr 1fr;
    }

    .reader-section-nav > a {
        display: none;
    }
}

/* Publication · EPUB compiler */
.output-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.epub-checklist {
    display: grid;
    gap: 0.55rem;
    margin: 0.9rem 0;
}

.epub-checklist > div {
    display: grid;
    grid-template-columns: 1.25rem 1fr;
    gap: 0.45rem;
    align-items: start;
    font-size: 0.92rem;
    line-height: 1.4;
}

.epub-blockers {
    padding: 0.8rem;
    border: 1px solid rgba(180, 50, 50, 0.26);
    border-radius: 10px;
    background: rgba(180, 50, 50, 0.06);
}

.epub-blockers > div > span {
    font-weight: 800;
}

.epub-warnings {
    margin: 0.8rem 0;
}

.epub-warnings summary {
    cursor: pointer;
    font-weight: 700;
}

.audiobook-output-actions {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.audiobook-opening-option {
    align-items: center;
    display: flex;
    gap: 0.55rem;
    margin-bottom: 0.7rem;
}

/* Publication audiobook background jobs */
.publication-export-jobs {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.publication-export-job {
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 14px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.72);
}

.publication-export-job.is-running {
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.06);
}

.publication-export-job.is-ready {
    border-color: rgba(22, 163, 74, 0.28);
}

.publication-export-job.is-error {
    border-color: rgba(220, 38, 38, 0.35);
}

.publication-export-job-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.publication-export-job-head strong,
.publication-export-job-head span {
    display: block;
}

.publication-export-job-head > div > span {
    margin-top: 4px;
    color: var(--muted, #64748b);
    font-size: 0.9rem;
}

.publication-job-state,
.publication-job-working {
    display: inline-flex !important;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.publication-job-state {
    font-size: 0.84rem;
    font-weight: 700;
}

.publication-job-state.is-ready {
    color: #15803d;
}

.publication-job-state.is-error {
    color: #b91c1c;
}

.publication-job-spinner {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
    animation: publication-job-spin 0.75s linear infinite;
}

@keyframes publication-job-spin {
    to {
        transform: rotate(360deg);
    }
}

.publication-job-progress {
    width: 100%;
    height: 10px;
    margin-top: 15px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.08);
}

.publication-job-progress > span {
    display: block;
    height: 100%;
    min-width: 1%;
    border-radius: inherit;
    background: currentColor;
    color: #2563eb;
    transition: width 0.3s ease;
}

.publication-job-current {
    margin: 9px 0 0;
    font-size: 0.9rem;
    color: var(--muted, #64748b);
}

.publication-job-error {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(220, 38, 38, 0.07);
    color: #991b1b;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.publication-job-message {
    margin: 12px 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(37, 99, 235, 0.07);
}

.publication-job-message-error {
    background: rgba(220, 38, 38, 0.07);
    color: #991b1b;
}

@media (max-width: 700px) {
    .publication-export-job-head {
        flex-direction: column;
    }
}

/* ================================================================
   PREMIUM APPLICATION SHELL · 2026 UI PASS
   Visual-only overrides. No workflow or model behavior changes.
   ================================================================ */
:root {
    --app-bg: #f5f6f8;
    --app-surface: #ffffff;
    --app-surface-strong: #ffffff;
    --app-sidebar: #171c24;
    --app-sidebar-soft: #252d38;
    --app-ink: #202733;
    --app-muted: #697384;
    --app-line: #e3e7ed;
    --app-line-soft: #eef1f5;
    --app-accent: #a68052;
    --app-accent-soft: #f5f0e8;
    --app-success: #2f6c52;
    --app-success-soft: #e9f3ed;
    --app-danger: #9b3f3f;
    --app-danger-soft: #faecea;
    --app-warning: #916a27;
    --app-warning-soft: #fbf3df;
    --sidebar-width: 244px;
    --topbar-height: 68px;
    --radius-lg: 12px;
    --radius-md: 9px;
    --shadow-soft: 0 3px 18px rgba(24, 34, 50, .035);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--app-bg);
}

body {
    margin: 0;
    background: var(--app-bg);
    color: var(--app-ink);
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background:
        radial-gradient(circle at 20% 0%, rgba(255, 255, 255, .035), transparent 38%),
        var(--app-sidebar);
    color: #f7f2e7;
    padding: 22px 16px 18px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    border-right: 1px solid rgba(255,255,255,.06);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: #fff;
    text-decoration: none;
    padding: 3px 8px 22px;
}

.app-brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #c5a26f, #8f6937);
    color: #171918;
    font-family: Georgia, serif;
    font-weight: 800;
    box-shadow: 0 8px 24px rgba(0,0,0,.22);
}

.app-brand-copy strong {
    display: block;
    font-size: 15px;
    letter-spacing: .01em;
}

.app-brand-copy span {
    display: block;
    margin-top: 2px;
    color: rgba(255,255,255,.48);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.sidebar-section {
    margin-top: 14px;
}

.sidebar-label {
    padding: 0 11px 8px;
    color: rgba(255,255,255,.36);
    font-size: 10px;
    letter-spacing: .15em;
    text-transform: uppercase;
    font-weight: 700;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
}

.sidebar-link,
.sidebar-link-disabled {
    min-height: 42px;
    border-radius: 11px;
    padding: 10px 11px;
    display: flex;
    align-items: center;
    gap: 11px;
    color: rgba(255,255,255,.72);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background .16s ease, color .16s ease, transform .16s ease;
}

.sidebar-link:hover,
.sidebar-link.is-active {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.sidebar-link:hover {
    transform: translateX(2px);
}

.sidebar-link svg,
.sidebar-link-disabled svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    opacity: .82;
}

.sidebar-link-disabled {
    color: rgba(255,255,255,.28);
    cursor: default;
}

.sidebar-soon {
    margin-left: auto;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: rgba(255,255,255,.28);
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 10px 2px;
    border-top: 1px solid rgba(255,255,255,.08);
    color: rgba(255,255,255,.42);
    font-size: 11px;
    line-height: 1.5;
}

.app-content-shell {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.app-topbar {
    height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 30px;
    background: rgba(250,248,242,.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(104,100,90,.12);
}

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

.topbar-product {
    font-size: 13px;
    font-weight: 700;
    color: var(--app-muted);
    letter-spacing: .02em;
    white-space: nowrap;
}

.topbar-context {
    color: #a29c91;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.mobile-menu-button {
    display: none;
    border: 0;
    background: transparent;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    color: var(--app-ink);
}

.profile-menu {
    position: relative;
}

.profile-menu > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 5px 9px 5px 6px;
    border: 1px solid var(--app-line);
    background: rgba(255,255,255,.76);
    border-radius: 999px;
    user-select: none;
}

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

.profile-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--app-sidebar);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
}

.profile-name {
    font-size: 12px;
    font-weight: 700;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-popover {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: 230px;
    background: #fff;
    border: 1px solid var(--app-line);
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(22,22,20,.16);
    padding: 8px;
}

.profile-popover-head {
    padding: 10px 11px 12px;
    border-bottom: 1px solid var(--app-line-soft);
    margin-bottom: 6px;
}

.profile-popover-head strong,
.profile-popover-head span {
    display: block;
}

.profile-popover-head span {
    font-size: 11px;
    color: var(--app-muted);
    margin-top: 3px;
}

.profile-popover-item,
.profile-popover-disabled {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: var(--app-ink);
    padding: 9px 10px;
    border-radius: 9px;
    font-size: 13px;
    border: 0;
    background: transparent;
    text-align: left;
}

.profile-popover-item:hover {
    background: #f5f2ec;
}

.profile-popover-disabled {
    color: #a6a39b;
}

.app-main {
    width: min(1500px, calc(100% - 48px));
    margin: 0 auto;
    padding: 34px 0 72px;
}

.app-main > .notice {
    border-radius: 12px;
    box-shadow: none;
    border: 1px solid var(--app-line);
    background: #fff;
}

.heading {
    margin-bottom: 24px;
    align-items: flex-start;
}

.heading h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 600;
    letter-spacing: -.025em;
    line-height: 1.08;
}

.eyebrow {
    letter-spacing: .13em;
    font-size: 10px;
    font-weight: 800;
    color: #8a7657;
}

.panel {
    background: var(--app-surface-strong);
    border: 1px solid var(--app-line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.panel h2,
.panel h3 {
    letter-spacing: -.015em;
}

button,
.button,
.primary-action {
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: -.005em;
    transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
}

button:hover:not(:disabled),
.button:hover,
.primary-action:hover {
    transform: translateY(-1px);
}

button.primary,
.button.primary,
.primary-action,
button:not(.secondary):not(.quiet) {
    box-shadow: 0 6px 16px rgba(28,29,27,.11);
}

input,
textarea,
select {
    border-radius: 10px;
    border-color: #d8d4ca;
    background: #fff;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #b59564;
    box-shadow: 0 0 0 3px rgba(168,132,79,.12);
    outline: 0;
}

/* Book-context navigation */
.book-context-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 13px 16px;
    margin: -8px 0 26px;
    border: 1px solid var(--app-line);
    border-radius: 14px;
    background: rgba(255,255,255,.75);
    box-shadow: 0 8px 32px rgba(25,24,21,.035);
}

.book-context-cover {
    width: 38px;
    height: 52px;
    border-radius: 5px;
    overflow: hidden;
    background: #242725;
    flex: 0 0 auto;
}

.book-context-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-context-copy {
    min-width: 140px;
    max-width: 260px;
}

.book-context-copy strong,
.book-context-copy span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-context-copy strong {
    font-size: 13px;
}

.book-context-copy span {
    color: var(--app-muted);
    font-size: 11px;
    margin-top: 2px;
}

.book-context-tabs {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    overflow-x: auto;
    scrollbar-width: none;
}

.book-context-tabs::-webkit-scrollbar {
    display: none;
}

.book-context-tabs a {
    text-decoration: none;
    color: #686b68;
    padding: 8px 10px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.book-context-tabs a:hover,
.book-context-tabs a.is-active {
    background: #ede7dc;
    color: #403524;
}

/* Dashboard */
.library-hero {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    gap: 24px;
    align-items: end;
    margin-bottom: 28px;
}

.library-hero h1 {
    font-family: Georgia, serif;
    font-size: clamp(34px,4vw,54px);
    margin: 5px 0 8px;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.library-card {
    text-decoration: none;
    color: inherit;
    display: grid;
    grid-template-columns: 74px minmax(0,1fr);
    gap: 16px;
    min-height: 158px;
    padding: 16px;
    border: 1px solid var(--app-line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 34px rgba(24,24,21,.045);
    transition: transform .16s ease, box-shadow .16s ease, border .16s ease;
}

.library-card:hover {
    transform: translateY(-2px);
    border-color: #cfc6b8;
    box-shadow: 0 18px 42px rgba(24,24,21,.08);
}

.library-card-cover {
    width: 74px;
    height: 110px;
    border-radius: 7px;
    overflow: hidden;
    background: linear-gradient(145deg, #232624, #393c38);
    box-shadow: 0 8px 24px rgba(0,0,0,.14);
}

.library-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.library-card-cover-placeholder {
    height: 100%;
    display: grid;
    place-items: center;
    padding: 8px;
    color: rgba(255,255,255,.7);
    font-family: Georgia, serif;
    font-size: 10px;
    text-align: center;
}

.library-card h2 {
    margin: 3px 0 6px;
    font-size: 18px;
}

/* Publication tabs */
.publication-shell {
    max-width: 1400px;
}

.publication-tabs {
    position: sticky;
    top: calc(var(--topbar-height) + 8px);
    z-index: 35;
    display: flex;
    gap: 4px;
    padding: 6px;
    margin: 0 0 22px;
    border: 1px solid var(--app-line);
    border-radius: 13px;
    background: rgba(255,253,248,.94);
    backdrop-filter: blur(14px);
    box-shadow: 0 10px 30px rgba(26,25,22,.045);
    overflow-x: auto;
}

.publication-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--app-muted);
    padding: 10px 14px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: none !important;
}

.publication-tab:hover {
    transform: none !important;
    background: #f1ede5;
}

.publication-tab.is-active {
    background: var(--app-sidebar);
    color: #fff;
}

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

.publication-tab-panel {
    animation: premiumFade .18s ease;
}

@keyframes premiumFade {
    from { opacity: .55; transform: translateY(3px); }
    to { opacity: 1; transform: none; }
}

.publication-overview-hero {
    display: grid;
    grid-template-columns: minmax(0,1.5fr) minmax(240px,.5fr);
    gap: 18px;
    margin-bottom: 18px;
}

.publication-summary-card {
    padding: 24px;
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, #1d201e, #272b28);
    color: #fff;
    box-shadow: 0 22px 60px rgba(22,24,22,.16);
}

.publication-summary-card .eyebrow {
    color: #c9ad80;
}

.publication-summary-card h2 {
    color: #fff;
    font-family: Georgia, serif;
    font-size: clamp(26px,3vw,38px);
    margin: 6px 0 8px;
}

.publication-summary-card p {
    color: rgba(255,255,255,.62);
}

.publication-cover-mini {
    min-height: 260px;
    padding: 18px;
    display: grid;
    place-items: center;
    border: 1px solid var(--app-line);
    background: #fff;
    border-radius: var(--radius-lg);
}

.publication-cover-mini img {
    max-height: 250px;
    max-width: 100%;
    border-radius: 7px;
    box-shadow: 0 14px 32px rgba(0,0,0,.16);
}

.publication-cover-panel,
.publication-metadata-panel,
.publication-sections-panel,
.publication-outputs-panel {
    margin-bottom: 18px;
}

.publication-metadata-panel {
    max-width: none;
}

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

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

.output-card {
    border-radius: 14px;
    background: #fbfaf7;
    border-color: var(--app-line);
}

/* Editorial studio: bounded workspaces instead of endless page growth. */
.editor-workspace {
    align-items: stretch;
}

.book-source-panel,
.publication-editor-panel {
    min-width: 0;
}

.book-source-panel .source-scroll {
    height: min(66vh, 720px);
    min-height: 460px;
    overflow: auto;
    border-radius: 12px;
    background: #fbfaf7;
    border: 1px solid var(--app-line-soft);
}

.book-source-panel textarea {
    min-height: 100% !important;
    height: auto !important;
    border: 0 !important;
    background: transparent !important;
    resize: none;
    box-shadow: none !important;
}

.ebook-page-shell {
    height: min(66vh, 720px);
    min-height: 460px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ebook-page-shell .ebook-page-header,
.ebook-page-shell .ebook-title-preview {
    flex: 0 0 auto;
}

#edited-editor.rich-editor,
#narration-editor.rich-editor {
    min-height: 0 !important;
}

#edited-editor .ql-editor,
#narration-editor .ql-editor {
    overflow-y: auto;
    max-height: min(54vh, 590px);
    min-height: 360px;
}

.narration-editor {
    max-height: min(62vh, 680px);
    overflow: hidden;
}

.narration-editor .ql-editor {
    max-height: min(58vh, 630px);
}

.diff-view,
.revision-body,
.flag-copy {
    max-height: 440px;
    overflow: auto;
}

/* Production / status language */
.status-pill {
    border-radius: 999px;
    font-weight: 800;
    font-size: 10px;
    letter-spacing: .04em;
}

.status-ready,
.status-approved,
.is-ready .status-pill {
    background: var(--app-success-soft);
    color: var(--app-success);
}

.production-roadmap,
.current-step-card,
.studio-tabs {
    border-color: var(--app-line);
    box-shadow: none;
}

.studio-tabs {
    position: sticky;
    top: calc(var(--topbar-height) + 8px);
    z-index: 34;
    background: rgba(255,253,248,.95);
    backdrop-filter: blur(12px);
}

.studio-tab {
    box-shadow: none !important;
}

/* HTMX: standard visible activity treatment. */
.htmx-indicator {
    opacity: 0;
    transition: opacity .15s ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}

.premium-working {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    color: var(--app-warning);
}

.premium-spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(145,106,39,.18);
    border-top-color: currentColor;
    animation: premiumSpin .75s linear infinite;
}

@keyframes premiumSpin {
    to { transform: rotate(360deg); }
}

/* Streamline cleanup */
.streamline-pipeline {
    padding: 6px;
    background: #f6f3ed;
    border-radius: 14px;
    border: 1px solid var(--app-line-soft);
}

.chapter-link {
    border-radius: 12px;
    transition: background .14s ease, border .14s ease;
}

.chapter-link:hover {
    background: #faf8f3;
}

/* General responsive behavior */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 1100px) {
    :root {
        --sidebar-width: 218px;
    }

    .app-main {
        width: min(100% - 34px, 1400px);
    }

    .profile-name {
        display: none;
    }

    .book-context-copy {
        display: none;
    }

    .publication-overview-hero {
        grid-template-columns: 1fr 280px;
    }
}

@media (max-width: 820px) {
    :root {
        --sidebar-width: 264px;
        --topbar-height: 62px;
    }

    .app-sidebar {
        transform: translateX(-102%);
        transition: transform .22s ease;
        box-shadow: 18px 0 60px rgba(0,0,0,.28);
    }

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

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 95;
        background: rgba(0,0,0,.36);
        backdrop-filter: blur(2px);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .app-content-shell {
        margin-left: 0;
    }

    .mobile-menu-button {
        display: grid;
        place-items: center;
    }

    .app-topbar {
        padding: 0 15px;
    }

    .topbar-product {
        display: none;
    }

    .app-main {
        width: min(100% - 24px, 1400px);
        padding-top: 22px;
    }

    .library-hero,
    .publication-overview-hero,
    .publication-grid,
    .columns {
        grid-template-columns: 1fr !important;
    }

    .metadata-grid,
    .output-grid {
        grid-template-columns: 1fr;
    }

    .book-context-bar {
        padding: 10px;
        gap: 9px;
    }

    .book-context-cover {
        width: 31px;
        height: 42px;
    }

    .book-context-tabs {
        margin-left: 0;
    }

    .publication-tabs {
        top: calc(var(--topbar-height) + 4px);
    }

    .studio-tabs {
        top: calc(var(--topbar-height) + 4px);
    }

    .editor-workspace {
        grid-template-columns: 1fr !important;
    }

    .book-source-panel .source-scroll,
    .ebook-page-shell {
        height: 58vh;
        min-height: 390px;
    }

    #edited-editor .ql-editor,
    #narration-editor .ql-editor {
        max-height: 48vh;
        min-height: 320px;
    }
}

@media (max-width: 560px) {
    .app-main {
        width: min(100% - 18px, 1400px);
    }

    .heading h1 {
        font-size: 30px;
    }

    .library-grid {
        grid-template-columns: 1fr;
    }

    .library-card {
        grid-template-columns: 62px minmax(0,1fr);
    }

    .library-card-cover {
        width: 62px;
        height: 92px;
    }

    .publication-tabs {
        margin-inline: -2px;
    }

    .profile-popover {
        width: min(230px, calc(100vw - 26px));
    }
}

.app-content-shell.is-auth-screen {
    margin-left: 0;
}

.global-activity {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: 6px;
    color: var(--app-warning);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.global-activity[hidden] {
    display: none;
}

.global-process-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(20,22,20,.35);
    backdrop-filter: blur(4px);
}

.global-process-overlay[hidden] {
    display: none;
}

.global-process-card {
    width: min(480px, 100%);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 24px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--app-line);
    box-shadow: 0 24px 80px rgba(0,0,0,.22);
}

.global-process-card strong,
.global-process-card span {
    display: block;
}

.global-process-card strong {
    margin-bottom: 4px;
    font-size: 15px;
}

.global-process-card > div > span {
    color: var(--app-muted);
    font-size: 12px;
}

.global-process-spinner {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    border-width: 3px;
}


/* PORTAL DESIGN SYSTEM V2 — neutral graphite + refined, compact UI */
:root {
    --brand: #354d69;
    --brand-dark: #202935;
    --brand-soft: #f0f3f7;
    --ink: #202733;
    --muted: #697384;
    --line: #e3e7ed;
    --surface: #ffffff;
    --surface-soft: #f8f9fb;
    --app-bg: #f5f6f8;
    --app-surface: #ffffff;
    --app-surface-strong: #ffffff;
    --app-sidebar: #171c24;
    --app-sidebar-soft: #252d38;
    --app-ink: #202733;
    --app-muted: #697384;
    --app-line: #e3e7ed;
    --app-line-soft: #eef1f5;
    --app-accent: #a68052;
    --app-accent-soft: #f5f0e8;
    --radius-lg: 12px;
    --radius-md: 9px;
    --shadow-soft: 0 3px 18px rgba(24,34,50,.035);
}
html, body, .app-shell, .app-content-shell { background: var(--app-bg); }
body { color: var(--app-ink); font-size: 14px; line-height: 1.52; }
.app-sidebar { background: var(--app-sidebar); border-right: 1px solid #2a303b; }
.app-brand-mark { background: #b99870; border-radius: 8px; box-shadow: none; }
.app-main { padding-top: 24px; }
.app-topbar { background: #fff; border-bottom: 1px solid var(--app-line); }
.panel, .card, .linkcard, .publication-summary-card, .library-card,
.publication-export-job, .source-panel, .production-panel, .book-context-bar {
    background: #fff;
    border-color: var(--app-line);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(25,34,49,.035);
}
.panel { padding: clamp(17px,2vw,23px); }
.heading { margin-bottom: 19px; }
.heading h1 { font-size: clamp(26px,2.6vw,35px); letter-spacing: -.03em; }
.heading .muted, .premium-panel-intro .muted { max-width: 72ch; }
.eyebrow, .sidebar-label { letter-spacing: .105em; font-weight: 650; }
.eyebrow { color: #8a7254; }
/* Controls stay compact, understated, and consistent across ALL templates. */
button, .button, a.button, input[type=submit], .primary-action,
.action-button, .btn, .profile-menu > summary {
    min-height: 34px;
    padding: 7px 12px;
    font-size: 12.5px;
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: 0;
    border-radius: 7px;
    box-shadow: none !important;
    transform: none !important;
    transition: background-color .13s ease, border-color .13s ease, color .13s ease;
}
button:hover:not(:disabled), .button:hover, a.button:hover, .primary-action:hover {
    transform: none !important;
    box-shadow: none !important;
}
button:disabled, .button[aria-disabled=true] { opacity: .52; cursor: not-allowed; }
button.secondary, .button.secondary, .button.quiet, .button.outline {
    background: #fff;
    color: #3d4859;
    border: 1px solid #dce2e9;
}
button.secondary:hover, .button.secondary:hover { background: #f5f7fa; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
    min-height: 36px;
    padding: 8px 10px;
    font-size: 13.5px;
    border: 1px solid #dae0e8;
    border-radius: 7px;
    box-shadow: none;
    color: var(--app-ink);
    background: #fff;
}
textarea { line-height: 1.55; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(94,125,163,.17); outline-offset: 0; border-color: #91a6bc; box-shadow: none; }
label { font-size: 12px; font-weight: 650; color: #445065; }
.field-help { color: var(--app-muted); font-size: 12px; }
.source-badge, .segment-kind-badge, .publication-job-state, .badge, .pill,
.status-pill, .sidebar-soon, .publication-status, .production-state-pill {
    min-height: 0;
    padding: 3px 7px;
    font-size: 10px;
    line-height: 1.3;
    font-weight: 650;
    letter-spacing: .015em;
    border-radius: 5px;
    box-shadow: none;
}
.sidebar-link, .sidebar-link-disabled { min-height: 35px; border-radius: 7px; padding-block: 7px; font-size: 12.5px; }
.book-context-bar { gap: 12px; padding: 10px 14px; }
.book-context-cover { border-radius: 5px; }
.book-context-tabs a, .publication-tab, .studio-tabs a,
.reader-mode-switch a, .profile-popover-item, .profile-popover-disabled {
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 6px;
}
.book-context-tabs a { padding: 7px 10px; }
.publication-tabs { background: #fff; border: 1px solid var(--app-line); border-radius: 10px; padding: 4px; }
.publication-tab { padding: 8px 13px; }
.publication-tab.is-active { background: #f1f4f7; color: #27374c; }
/* Narration page: same workspace identity, quieter hierarchy and compact voice lab. */
.premium-narration-page { grid-template-columns: minmax(0,1.5fr) minmax(290px,.85fr); gap: 16px; align-items: start; }
.premium-narration-page .panel { min-width: 0; }
.premium-panel-intro { padding-bottom: 15px; margin-bottom: 17px; border-bottom: 1px solid var(--app-line-soft); }
.premium-panel-intro h2 { margin: 4px 0 5px; font-size: 20px; letter-spacing: -.02em; }
.premium-panel-intro p { margin: 0; }
.premium-narration-page .narration-field-grid { gap: 15px 18px; }
.premium-narration-page label { font-weight: 650; color: #445065; }
.premium-narration-page .section-divider { border: 0; border-top: 1px solid var(--app-line-soft); margin-block: 20px; }
.premium-voice-lab { position: sticky; top: calc(var(--topbar-height) + 14px); }
.premium-voice-lab h2 { font-size: 19px; margin: 7px 0; }
.premium-voice-lab .voice-preview-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.premium-voice-lab .voice-preview-button { min-width: 0; justify-content: flex-start; white-space: nowrap; }
.premium-voice-lab #preview-text { min-height: 120px; max-height: 210px; resize: vertical; }
.premium-voice-lab #voice-preview-player { width: 100%; }
.sticky-save-actions { background: #fff; border-top: 1px solid var(--app-line-soft); padding-top: 12px; gap: 12px; }
/* Every production/status surface receives the same visual priority. */
.production-progress, .production-working, .publication-export-job.is-running,
.publication-job-working, .audio-progress-panel, .studio-action-result:not([hidden]),
.production-complete-panel, .production-error-box {
    border-radius: 9px;
    box-shadow: none;
}
.publication-export-job.is-running, .publication-job-working { background: #f4f7fb; border-color: #ccd9ea; }
.publication-job-progress, progress { accent-color: #5d7591; }
/* Editor and manuscript preparation must scroll inside the work surface. */
.book-source-panel .source-scroll, .ebook-page-shell { max-height: min(66vh,740px); overflow-y: auto; }
#edited-editor .ql-editor, #narration-editor .ql-editor { min-height: 300px; max-height: min(60vh,680px); overflow-y: auto; }
#narration-settings-form textarea { max-height: 230px; resize: vertical; }
/* Keyboard + mobile polish without sacrificing desktop density. */
:focus-visible { outline: 2px solid #8da9c5; outline-offset: 2px; }
@media (max-width: 1120px) {
    .premium-narration-page { grid-template-columns: minmax(0,1fr); }
    .premium-voice-lab { position: static; }
}
@media (max-width: 760px) {
    .app-main { width: calc(100% - 28px); padding-top: 18px; }
    .panel { padding: 16px; }
    .book-context-bar { padding: 10px; }
    .premium-narration-page .narration-field-grid { grid-template-columns: 1fr; }
    .premium-voice-lab .voice-preview-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .publication-tabs, .book-context-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
