/* ── Reset & base ─────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-bg: #0c0e16;
    --color-surface: #161926;
    --color-surface2: #1e2235;
    --color-border: rgba(255, 255, 255, .08);
    --color-primary: #6c63ff;
    --color-primary-h: #8a83ff;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-text: #e8e8f0;
    --color-muted: #858599;
    --radius: 8px;
    --radius-lg: 12px;
    --max-width: 900px;
    --shadow: 0 4px 24px rgba(0, 0, 0, .4);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.container {
    width: 92%;
    max-width: var(--max-width);
    margin-inline: auto;
}

.hstack {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}

.vstack {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

main {
    flex: 1;
}

.project-main {
    padding-block: 2rem 4rem;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding-block: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* ── Hamburger menu ──────────────────────────────────────────────────── */
.hamburger-wrap {
    position: relative;
}
.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    padding: 7px 8px;
    transition: background .15s;
}
.hamburger-btn:hover { background: var(--color-surface2); }
.hamburger-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: background .15s;
}
.hamburger-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    z-index: 200;
    overflow: hidden;
    padding: 4px 0;
}
.hamburger-menu.open { display: block; }
.hamburger-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .6rem 1rem;
    background: transparent;
    border: none;
    color: var(--color-text);
    font-size: .9rem;
    text-align: left;
    cursor: pointer;
    transition: background .12s;
}
.hamburger-item:hover { background: var(--color-surface2); }
.hamburger-item--danger { color: #ff6b6b; }
.hamburger-item--danger:hover { background: rgba(255,107,107,.1); }
.hamburger-divider {
    height: 1px;
    background: var(--color-border);
    margin: 4px 0;
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: -.02em;
}

.logo-sub {
    font-size: .8rem;
    color: var(--color-muted);
    margin-left: .5rem;
}

.logo-version {
    font-size: .7rem;
    color: var(--color-muted);
    margin-left: .4rem;
    font-weight: 500;
    opacity: .7;
}

/* ── Stage pills ──────────────────────────────────────────────────────────── */
.stage-pills {
    gap: .25rem;
}

.stage-pill {
    font-size: .72rem;
    font-weight: 600;
    padding: .25rem .65rem;
    border-radius: 99px;
    background: var(--color-surface2);
    color: var(--color-muted);
    border: 1px solid var(--color-border);
    white-space: nowrap;
}

.stage-pill.active {
    background: var(--color-primary);
    color: #fff;
    border-color: transparent;
}

.stage-pill.done-step {
    background: #16312a;
    color: var(--color-success);
    border-color: #1e4a39;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.25rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, transform .1s, opacity .15s;
    white-space: nowrap;
    user-select: none;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none !important;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-h);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--color-success);
    color: #000;
}

.btn-success:hover:not(:disabled) {
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(108, 99, 255, .1);
}

.btn-ghost {
    background: var(--color-surface2);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
    background: #252840;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-sm {
    padding: .35rem .85rem;
    font-size: .8rem;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.field label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.field input,
.field textarea,
.field select {
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    padding: .6rem .85rem;
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
    resize: vertical;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--color-primary);
}

.field textarea {
    min-height: 90px;
}

.required {
    color: var(--color-danger);
}

.error-text {
    color: var(--color-danger);
    font-size: .85rem;
    margin-top: .5rem;
}

/* ── Q&A Session ──────────────────────────────────────────────────────────── */
.session-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.session-badge {
    font-size: .7rem;
    font-weight: 700;
    padding: .2rem .6rem;
    border-radius: 99px;
    background: rgba(108, 99, 255, .2);
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.question-item {
    margin-bottom: 1.5rem;
}

.question-num {
    font-size: .72rem;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .3rem;
}

.question-text {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: .5rem;
    line-height: 1.5;
}

.question-hint {
    font-size: .8rem;
    color: var(--color-muted);
    margin-bottom: .5rem;
    font-style: italic;
}

.question-item textarea {
    width: 100%;
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    padding: .65rem .85rem;
    font-size: .9rem;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color .15s;
}

.question-item textarea:focus {
    border-color: var(--color-primary);
}

/* ── Completed session collapsible ───────────────────────────────────────── */
.past-session-toggle {
    font-size: .82rem;
    color: var(--color-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .75rem;
    user-select: none;
}

.past-session-toggle:hover {
    color: var(--color-text);
}

.past-session-content {
    display: none;
}

.past-session-content.open {
    display: block;
}

.past-qa-item {
    margin-bottom: .75rem;
    padding: .75rem;
    background: var(--color-surface2);
    border-radius: var(--radius);
}

.past-qa-q {
    font-size: .8rem;
    color: var(--color-muted);
    margin-bottom: .25rem;
}

.past-qa-a {
    font-size: .88rem;
}

/* ── Outline ──────────────────────────────────────────────────────────────── */
.outline-meta {
    margin-bottom: 1.5rem;
}

.book-title-input {
    font-size: 1.4rem;
    font-weight: 800;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--color-border);
    color: var(--color-text);
    width: 100%;
    padding: .25rem 0;
    outline: none;
    font-family: inherit;
    margin-bottom: .5rem;
    transition: border-color .15s;
}

.book-title-input:focus {
    border-color: var(--color-primary);
}

.tagline-input {
    font-size: .95rem;
    color: var(--color-muted);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border);
    width: 100%;
    padding: .2rem 0;
    outline: none;
    font-family: inherit;
    font-style: italic;
    transition: border-color .15s;
}

.tagline-input:focus {
    border-color: var(--color-primary);
    color: var(--color-text);
}

.outline-chapter {
    display: flex;
    gap: 1rem;
    padding: .9rem 1rem;
    border-radius: var(--radius);
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    margin-bottom: .6rem;
    align-items: flex-start;
}

.outline-chapter-num {
    font-size: .78rem;
    font-weight: 800;
    color: var(--color-primary);
    width: 1.8rem;
    flex-shrink: 0;
    padding-top: .15rem;
}

.outline-chapter-body {
    flex: 1;
    min-width: 0;
}

.outline-chapter-title {
    font-weight: 700;
    font-size: .95rem;
    margin-bottom: .3rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    color: var(--color-text);
    font-family: inherit;
    width: 100%;
    outline: none;
    padding: 0;
    transition: border-color .15s;
}

.outline-chapter-title:focus {
    border-color: var(--color-primary);
}

.outline-chapter-desc {
    font-size: .83rem;
    color: var(--color-muted);
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    color: var(--color-muted);
    font-family: inherit;
    width: 100%;
    outline: none;
    padding: 0;
    resize: none;
    min-height: 2.5em;
    transition: border-color .15s;
}

.outline-chapter-desc:focus {
    border-color: var(--color-border);
    color: var(--color-text);
}

/* ── Chapter cards ────────────────────────────────────────────────────────── */
.chapter-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    overflow: hidden;
    transition: border-color .2s;
}

.chapter-card.open {
    border-color: rgba(108, 99, 255, .3);
}

.chapter-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
}

.chapter-header:hover {
    background: rgba(255, 255, 255, .02);
}

.chapter-num-badge {
    font-size: .72rem;
    font-weight: 800;
    color: var(--color-primary);
    background: rgba(108, 99, 255, .12);
    border-radius: 99px;
    padding: .25rem .65rem;
    white-space: nowrap;
}

.chapter-title-label {
    font-weight: 700;
    font-size: .95rem;
    flex: 1;
}

.chapter-desc-label {
    font-size: .8rem;
    color: var(--color-muted);
    margin-top: .15rem;
}

.status-badge {
    font-size: .7rem;
    font-weight: 700;
    padding: .2rem .65rem;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}

.status-pending {
    background: rgba(255, 255, 255, .06);
    color: var(--color-muted);
}

.status-drafting {
    background: rgba(245, 158, 11, .15);
    color: var(--color-warning);
}

.status-drafted {
    background: rgba(108, 99, 255, .15);
    color: var(--color-primary);
}

.status-needs_input {
    background: rgba(245, 158, 11, .15);
    color: var(--color-warning);
}

.status-approved {
    background: rgba(34, 197, 94, .15);
    color: var(--color-success);
}

.chapter-body {
    display: none;
    border-top: 1px solid var(--color-border);
    padding: 1.25rem;
}

.chapter-card.open .chapter-body {
    display: block;
}

.chapter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-bottom: 1rem;
}

.draft-box {
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    font-size: .88rem;
    line-height: 1.8;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.draft-needs {
    color: var(--color-warning);
    font-style: italic;
}

.draft-word-count {
    font-size: .75rem;
    color: var(--color-muted);
    margin-bottom: .5rem;
}

.draft-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .5rem;
}

.draft-word-count-text {
    font-size: .75rem;
    color: var(--color-muted);
}

.draft-tts-btn {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    color: var(--color-muted);
    transition: color .15s, border-color .15s, background .15s;
}

.draft-tts-btn:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: rgba(108, 99, 255, .08);
}

.draft-tts-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Quality scores panel ─────────────────────────────────────────────────── */
.quality-scores-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .65rem .85rem;
    margin-bottom: .75rem;
    font-size: .78rem;
}

.qs-banner {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .78rem;
    font-weight: 600;
    margin-bottom: .5rem;
    padding: .3rem .5rem;
    border-radius: 4px;
}

.qs-banner-ok {
    color: #22c55e;
    background: rgba(34, 197, 94, .08);
    border: 1px solid rgba(34, 197, 94, .2);
}

.qs-banner-warn {
    color: var(--color-warning);
    background: rgba(245, 158, 11, .08);
    border: 1px solid rgba(245, 158, 11, .2);
}

.qs-row {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .4rem;
}

.qs-item {
    display: flex;
    align-items: center;
    gap: .3rem;
}

.qs-label {
    color: var(--color-muted);
    font-size: .72rem;
}

.qs-pip {
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1;
}

.qs-high {
    background: rgba(34, 197, 94, .18);
    color: #22c55e;
}

.qs-mid {
    background: rgba(251, 191, 36, .18);
    color: #f59e0b;
}

.qs-low {
    background: rgba(239, 68, 68, .18);
    color: #ef4444;
}

.qs-tags {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    margin-top: .2rem;
}

.qs-tag {
    font-size: .68rem;
    color: var(--color-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: .15rem .5rem;
    display: flex;
    align-items: center;
    gap: .25rem;
}

.gaps-section {
    margin-bottom: 1rem;
}

.gaps-title {
    font-size: .82rem;
    font-weight: 700;
    color: var(--color-warning);
    margin-bottom: .5rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.gap-item {
    font-size: .83rem;
    color: var(--color-muted);
    padding: .35rem .75rem;
    border-left: 2px solid var(--color-warning);
    margin-bottom: .35rem;
    background: rgba(245, 158, 11, .05);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.summary-note {
    font-size: .83rem;
    color: var(--color-muted);
    font-style: italic;
    margin-bottom: 1rem;
}

/* ── Project cards (home) ─────────────────────────────────────────────────── */
.project-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: .85rem;
    cursor: pointer;
    transition: border-color .2s, transform .15s, box-shadow .15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.project-card:hover {
    border-color: rgba(108, 99, 255, .4);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.project-card-main {
    flex: 1;
    min-width: 0;
}

.project-card-name {
    font-weight: 700;
    font-size: 1rem;
}

.project-card-sub {
    font-size: .82rem;
    color: var(--color-muted);
    margin-top: .2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-card-meta {
    text-align: right;
    flex-shrink: 0;
}

.project-stage-pill {
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    padding: .2rem .65rem;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.stage-intake {
    background: rgba(108, 99, 255, .15);
    color: var(--color-primary);
}

.stage-outline_review {
    background: rgba(245, 158, 11, .15);
    color: var(--color-warning);
}

.stage-writing {
    background: rgba(34, 197, 94, .15);
    color: var(--color-success);
}

.stage-done {
    background: rgba(34, 197, 94, .25);
    color: var(--color-success);
}

.project-card-date {
    font-size: .75rem;
    color: var(--color-muted);
    margin-top: .4rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--color-muted);
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: .5rem;
    color: var(--color-text);
}

/* ── Loading overlay ──────────────────────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 14, 22, .85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    z-index: 999;
    color: var(--color-text);
}

.loading-overlay.hidden {
    display: none;
}

.loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, .12);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    flex-shrink: 0;
}

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

#loading-msg {
    font-size: .9rem;
    color: var(--color-muted);
    max-width: 420px;
    text-align: center;
}

.loading-sub {
    font-size: .78rem;
    color: var(--color-muted);
    opacity: .7;
    max-width: 420px;
    text-align: center;
    min-height: 1.2em;
    letter-spacing: .02em;
}

.loading-wisdom {
    margin-top: 1.4rem;
    max-width: 380px;
    background: rgba(108, 99, 255, .08);
    border: 1px solid rgba(108, 99, 255, .2);
    border-radius: var(--radius);
    padding: .7rem 1rem;
    text-align: center;
    font-size: .8rem;
    color: var(--color-text);
    line-height: 1.65;
    animation: wisdomFadeIn .6s ease;
}

.loading-wisdom.hidden {
    display: none;
}

.loading-wisdom-label {
    display: block;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-primary);
    margin-bottom: .35rem;
    opacity: .85;
}

@keyframes wisdomFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading-block {
    padding: 3rem;
    text-align: center;
    color: var(--color-muted);
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast-area {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    z-index: 1000;
}

.toast {
    padding: .75rem 1.25rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    max-width: 360px;
    animation: slideUp .2s ease;
    box-shadow: var(--shadow);
}

.toast-error {
    background: #3b100e;
    border: 1px solid var(--color-danger);
    color: #fca5a5;
}

.toast-success {
    background: #052e16;
    border: 1px solid var(--color-success);
    color: #86efac;
}

.toast-info {
    background: #1e1b4b;
    border: 1px solid var(--color-primary);
    color: #c4b5fd;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ── Section headings ─────────────────────────────────────────────────────── */
.section-heading {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: .35rem;
}

.section-sub {
    font-size: .85rem;
    color: var(--color-muted);
    margin-bottom: 1.5rem;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding-block: 1rem;
    text-align: center;
    color: var(--color-muted);
    font-size: .82rem;
}


/* ═══════════════════════════════════════════════════════════════════════════
   TWO-PANEL WORKSPACE  (project.html)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Full-screen workspace body */
.workspace-body {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── App Header ────────────────────────────────────────────────────────────── */
.app-header {
    flex-shrink: 0;
    height: 52px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
}

.app-header-inner {
    width: 100%;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
}

.app-header-left .logo {
    font-size: 1rem;
    font-weight: 800;
    color: var(--color-primary);
    text-decoration: none;
    white-space: nowrap;
}

.header-sep {
    color: var(--color-border);
    font-size: 1.2rem;
}

.header-project-name {
    font-size: .85rem;
    color: var(--color-text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.app-header-actions {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-shrink: 0;
}

/* ── Header info button ──────────────────────────────────────────── */
.header-info-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--color-muted);
    padding: .2rem .35rem;
    border-radius: var(--radius);
    line-height: 1;
    transition: color .15s, background .15s;
    flex-shrink: 0;
    margin-left: .25rem;
}

.header-info-btn:hover {
    color: var(--color-primary);
    background: rgba(108, 99, 255, .1);
}

/* ── Help dialog ─────────────────────────────────────────────── */
.help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 14, 22, .75);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.help-overlay.hidden {
    display: none;
}

.help-dialog {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    width: min(560px, 92vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .5);
}

.help-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem .9rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.help-dialog-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.help-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    color: var(--color-muted);
    line-height: 1;
    padding: .1rem .3rem;
    border-radius: var(--radius);
    transition: color .15s, background .15s;
}

.help-close-btn:hover {
    color: var(--color-text);
    background: var(--color-surface2);
}

.help-dialog-body {
    overflow-y: auto;
    padding: 1.2rem 1.4rem 1.4rem;
}

.help-list {
    display: grid;
    gap: 0;
    margin: 0;
}

.help-list dt {
    font-size: .8rem;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: 1rem;
}

.help-list dt:first-child {
    margin-top: 0;
}

.help-list dd {
    margin: .25rem 0 0 0;
    font-size: .83rem;
    color: var(--color-muted);
    line-height: 1.55;
}

/* ── Deep eval results dialog ────────────────────────────────────────── */
.deepeval-summary {
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: 1.1rem;
    padding-bottom: .85rem;
    border-bottom: 1px solid var(--color-border);
}

.deepeval-summary span {
    font-weight: 400;
}

.deepeval-section-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-muted);
    margin: 1rem 0 .4rem;
}

.deepeval-row {
    padding: .45rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
}

.deepeval-row:last-of-type {
    border-bottom: none;
}

.deepeval-row-title {
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: .15rem;
}

.deepeval-row-scores {
    font-size: .78rem;
    color: var(--color-muted);
}

.deepeval-row-notes {
    font-size: .75rem;
    color: var(--color-muted);
    margin-top: .2rem;
    opacity: .8;
}

.deepeval-explain {
    margin-top: 1.2rem;
    font-size: .75rem;
    color: var(--color-muted);
    border-top: 1px solid var(--color-border);
    padding-top: .85rem;
    line-height: 1.5;
}

/* ── Workspace two-panel split ─────────────────────────────────────────────── */
.workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* ── Left nav rail ──────────────────────────────────────────────────────────── */
.nav-rail {
    width: 188px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    overflow: hidden;
    user-select: none;
}

.nav-rail-heading {
    padding: .75rem 1rem .6rem;
    font-size: .69rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.nav-steps {
    overflow-y: auto;
    padding: .4rem 0;
}

.nav-steps::-webkit-scrollbar {
    width: 3px;
}

.nav-steps::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .07);
    border-radius: 2px;
}

.nav-step {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    padding: .6rem .85rem .6rem .75rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background .12s, border-color .15s;
    position: relative;
}

.nav-step:hover {
    background: rgba(255, 255, 255, .04);
}

.nav-step.ns-active {
    border-left-color: var(--color-primary);
    background: rgba(108, 99, 255, .08);
}

.ns-bubble {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .67rem;
    font-weight: 700;
    color: var(--color-muted);
    flex-shrink: 0;
    margin-top: .1rem;
    transition: background .15s, border-color .15s, color .15s;
    line-height: 1;
}

.nav-step.ns-active .ns-bubble {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.nav-step.ns-complete .ns-bubble {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
    font-size: .7rem;
}

.nav-step.ns-inprogress .ns-bubble {
    border-color: var(--color-warning);
    color: var(--color-warning);
}

.ns-info {
    flex: 1;
    min-width: 0;
}

.ns-name {
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--color-text);
}

.nav-step.ns-active .ns-name {
    color: var(--color-primary);
}

.ns-sub {
    font-size: .67rem;
    color: var(--color-muted);
    margin-top: .13rem;
    line-height: 1.35;
}

.nav-step-divider {
    height: 1px;
    background: var(--color-border);
    margin: .15rem .85rem .15rem 2.45rem;
    opacity: .4;
}

/* ── Content section (below journey steps) ─────────────────────────────────── */
.nav-content-section {
    border-top: 2px solid var(--color-border);
    padding-top: .25rem;
    flex-shrink: 0;
}

.nav-content-heading {
    padding: .6rem 1rem .4rem;
    font-size: .69rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
}

.ns-bubble-icon {
    font-size: .75rem;
}

/* ── Questionnaire canvas ───────────────────────────────────────────────────── */
.quest-wrap {
    max-width: 700px;
    padding-bottom: 3rem;
}

/* ── Stories canvas ─────────────────────────────────────────────────────────── */
.stories-wrap {
    max-width: 720px;
    padding-bottom: 4rem;
}

.story-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1rem;
}

.story-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color .15s;
}

.story-card:focus-within {
    border-color: rgba(108, 99, 255, .45);
}

.story-card-header {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .75rem 1rem;
    background: rgba(255, 255, 255, .03);
    border-bottom: 1px solid var(--color-border);
}

.story-card-num {
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-primary);
    flex-shrink: 0;
    white-space: nowrap;
}

.story-title-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: .92rem;
    font-weight: 700;
    color: var(--color-text);
    font-family: inherit;
    min-width: 0;
}

.story-title-input::placeholder {
    color: var(--color-muted);
    font-weight: 400;
}

.story-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--color-muted);
    line-height: 1;
    padding: .1rem .3rem;
    border-radius: 4px;
    transition: color .12s, background .12s;
    flex-shrink: 0;
}

.story-remove-btn:hover {
    color: var(--color-danger);
    background: rgba(239, 68, 68, .08);
}

.story-field {
    padding: .85rem 1rem .5rem;
    border-bottom: 1px solid var(--color-border);
}

.story-field:last-of-type {
    border-bottom: none;
}

.story-field-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-muted);
    margin-bottom: .4rem;
}

.story-textarea {
    width: 100%;
    background: none;
    border: none;
    outline: none;
    resize: none;
    font-size: .87rem;
    line-height: 1.7;
    color: var(--color-text);
    font-family: inherit;
    overflow: hidden;
    display: block;
}

.story-textarea::placeholder {
    color: var(--color-muted);
    opacity: .65;
}

.story-card-footer {
    padding: .6rem 1rem;
    border-top: 1px solid var(--color-border);
    background: rgba(255, 255, 255, .02);
    min-height: 2.6rem;
}

.story-add-row {
    display: flex;
    justify-content: flex-start;
    margin-top: 1.5rem;
}

.quest-intro {
    font-size: .85rem;
    color: var(--color-muted);
    line-height: 1.65;
    margin-bottom: 1.75rem;
    padding: 1rem 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.quest-section {
    margin-bottom: 2rem;
}

.quest-section-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--color-border);
}

.quest-section-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.quest-section-title {
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-muted);
}

.quest-section-count {
    font-size: .72rem;
    color: var(--color-border);
    margin-left: auto;
}

.quest-question {
    margin-bottom: 1.35rem;
}

.quest-q-text {
    font-size: .87rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.55;
    margin-bottom: .45rem;
}

.quest-q-text .q-num {
    color: var(--color-muted);
    font-weight: 400;
    font-size: .8rem;
    margin-right: .3rem;
}

.quest-textarea {
    width: 100%;
    min-height: 72px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: .83rem;
    line-height: 1.6;
    padding: .65rem .85rem;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color .15s;
    font-family: inherit;
}

.quest-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.quest-textarea.has-answer {
    border-color: rgba(34, 197, 94, .35);
    background: rgba(34, 197, 94, .03);
}

/* ── STT mic button ───────────────────────────────────────────────────────── */
.stt-textarea-wrap {
    position: relative;
    display: block;
}

.stt-textarea-wrap textarea {
    padding-bottom: 2.2rem;
    /* make room for mic btn */
}

.stt-mic-btn {
    position: absolute;
    bottom: .45rem;
    right: .5rem;
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    transition: color .15s, background .15s;
    padding: 0;
    line-height: 1;
}

.stt-mic-btn:hover {
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb, 99, 102, 241), .08);
}

.stt-wand-btn {
    position: absolute;
    bottom: .45rem;
    right: 2.3rem;
    /* sits left of the mic btn */
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    transition: color .15s, background .15s;
    padding: 0;
    line-height: 1;
}

.stt-wand-btn:hover {
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb, 99, 102, 241), .08);
}

.stt-wand-btn.stt-wand-busy {
    color: var(--color-muted);
    animation: stt-wand-spin .8s linear infinite;
}

@keyframes stt-wand-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.stt-mic-btn.stt-recording {
    color: var(--color-danger);
    background: rgba(239, 68, 68, .1);
    animation: stt-pulse 1.2s ease-in-out infinite;
}

@keyframes stt-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, .4);
    }

    50% {
        box-shadow: 0 0 0 5px rgba(239, 68, 68, 0);
    }
}

.quest-footer {
    position: sticky;
    bottom: 0;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    padding: 1rem 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.quest-progress-text {
    font-size: .78rem;
    color: var(--color-muted);
}

/* ── Align step: book-type choice cards ───────────────────────────────────── */
.align-choices {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .65rem;
    margin-top: .35rem;
}

.align-choice-card {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: .75rem 1rem;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, background .15s;
}

.align-choice-card:hover {
    border-color: var(--color-primary);
    background: rgba(108, 99, 255, .06);
}

.align-choice-card.selected {
    border-color: var(--color-primary);
    background: rgba(108, 99, 255, .1);
}

.align-choice-label {
    font-size: .85rem;
    font-weight: 700;
    color: var(--color-text);
}

.align-choice-card.selected .align-choice-label {
    color: var(--color-primary);
}

.align-choice-desc {
    font-size: .75rem;
    color: var(--color-muted);
    line-height: 1.4;
}

/* ── Left canvas ────────────────────────────────────────────────────────────── */
.canvas-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-bg);
}

.canvas-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem 1.25rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
    min-height: 50px;
}

.canvas-toolbar-title {
    font-size: .85rem;
    font-weight: 700;
    color: var(--color-text);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.canvas-toolbar-actions {
    display: flex;
    gap: .5rem;
    flex-shrink: 0;
}

.canvas-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    min-height: 0;
}

.canvas-body::-webkit-scrollbar {
    width: 6px;
}

.canvas-body::-webkit-scrollbar-track {
    background: transparent;
}

.canvas-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .1);
    border-radius: 3px;
}

/* ── Resize handle ──────────────────────────────────────────────────────────── */
.resize-handle {
    width: 4px;
    flex-shrink: 0;
    background: var(--color-border);
    cursor: col-resize;
    transition: background .15s;
}

.resize-handle:hover,
.resize-handle.dragging {
    background: var(--color-primary);
}

/* ── Right todo rail ────────────────────────────────────────────────────────── */
.todo-rail {
    width: 320px;
    min-width: 240px;
    max-width: 440px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    overflow: hidden;
}

.rail-header {
    flex-shrink: 0;
    padding: .85rem 1rem .65rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: .65rem;
}

.rail-title {
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-muted);
    flex: 1;
}

.rail-progress {
    width: 60px;
    height: 5px;
    background: rgba(255, 255, 255, .08);
    border-radius: 3px;
    overflow: hidden;
}

.rail-progress-bar {
    height: 100%;
    background: var(--color-success);
    border-radius: 3px;
    transition: width .4s ease;
    width: 0%;
}

.rail-score {
    font-size: .75rem;
    font-weight: 700;
    color: var(--color-success);
    min-width: 2.5rem;
    text-align: right;
}

.rail-body {
    flex: 1;
    overflow-y: auto;
    padding: .5rem 0;
}

.rail-body::-webkit-scrollbar {
    width: 4px;
}

.rail-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .08);
    border-radius: 2px;
}

.rail-loading {
    padding: 2rem;
    text-align: center;
    color: var(--color-muted);
    font-size: .85rem;
}

.rail-footer {
    flex-shrink: 0;
    padding: .6rem 1rem;
    border-top: 1px solid var(--color-border);
}

/* ── Todo group heading ─────────────────────────────────────────────────────── */
.todo-group-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
    padding: .75rem 1rem .3rem;
}

/* ── Todo item ──────────────────────────────────────────────────────────────── */
.todo-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem 1rem;
    cursor: pointer;
    border-radius: 0;
    transition: background .12s;
    border-left: 3px solid transparent;
    position: relative;
}

.todo-item:hover {
    background: rgba(255, 255, 255, .03);
}

.todo-item.selected {
    background: rgba(108, 99, 255, .08);
    border-left-color: var(--color-primary);
}

/* Status dot */
.todo-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background .2s;
}

.dot-not_started {
    background: rgba(255, 255, 255, .18);
}

.dot-in_progress {
    background: var(--color-warning);
    box-shadow: 0 0 6px rgba(245, 158, 11, .4);
}

.dot-needs_attention {
    background: var(--color-danger);
    box-shadow: 0 0 6px rgba(239, 68, 68, .5);
}

.dot-ready {
    background: var(--color-success);
    box-shadow: 0 0 6px rgba(34, 197, 94, .4);
}

.dot-complete {
    background: var(--color-success);
    box-shadow: 0 0 8px rgba(34, 197, 94, .6);
}

.todo-label {
    flex: 1;
    font-size: .83rem;
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.3;
    min-width: 0;
}

.todo-score-pill {
    font-size: .68rem;
    font-weight: 700;
    padding: .15rem .45rem;
    border-radius: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}

.score-not_started {
    background: rgba(255, 255, 255, .06);
    color: var(--color-muted);
}

.score-in_progress {
    background: rgba(245, 158, 11, .15);
    color: var(--color-warning);
}

.score-needs_attention {
    background: rgba(239, 68, 68, .15);
    color: #fc8181;
}

.score-ready {
    background: rgba(34, 197, 94, .15);
    color: var(--color-success);
}

.score-complete {
    background: rgba(34, 197, 94, .2);
    color: var(--color-success);
}

/* ── Source list (canvas) ───────────────────────────────────────────────────── */
.source-grid {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.source-card {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .15s;
}

.source-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-muted);
    font-size: .75rem;
    padding: .2rem .3rem;
    border-radius: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .15s, color .15s, background .15s;
    margin-right: .15rem;
}

.source-card:hover {
    border-color: rgba(108, 99, 255, .4);
}

.source-card:hover .source-edit-btn {
    opacity: 1;
}

.source-edit-btn:hover {
    color: var(--color-primary);
    background: rgba(108, 99, 255, .1);
}

.source-card.selected {
    border-color: var(--color-primary);
    background: rgba(108, 99, 255, .05);
}

.source-icon {
    width: 22px;
    height: 22px;
    border-radius: var(--radius);
    background: rgba(108, 99, 255, .12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    color: var(--color-primary);
    flex-shrink: 0;
    font-weight: 700;
}

.source-card-body {
    flex: 1;
    min-width: 0;
}

.source-card-title {
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-card-meta {
    font-size: .72rem;
    font-weight: 400;
    color: var(--color-muted);
}

.source-status-badge {
    font-size: .68rem;
    font-weight: 700;
    padding: .15rem .5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
    flex-shrink: 0;
}

.src-raw {
    background: rgba(255, 255, 255, .06);
    color: var(--color-muted);
}

.src-normalized {
    background: rgba(34, 197, 94, .12);
    color: var(--color-success);
    padding: .15rem .35rem;
    letter-spacing: 0;
    font-size: .8rem;
}

.src-dismissed {
    background: rgba(239, 68, 68, .08);
    color: #fc8181;
    opacity: .6;
}

/* ── Canvas forms (add source, etc.) ────────────────────────────────────────── */
.canvas-form {
    max-width: 760px;
}

.canvas-form-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: .25rem;
}

.canvas-form-sub {
    font-size: .85rem;
    color: var(--color-muted);
    margin-bottom: 1.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .field {
    flex: 1;
    min-width: 180px;
}

.source-type-select {
    width: 100%;
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    padding: .6rem .85rem;
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    appearance: none;
}

.source-type-select:focus {
    border-color: var(--color-primary);
}

.big-textarea {
    width: 100%;
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    padding: .85rem 1rem;
    font-size: .88rem;
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
    line-height: 1.65;
    min-height: 260px;
    resize: vertical;
    outline: none;
    transition: border-color .15s;
}

.big-textarea:focus {
    border-color: var(--color-primary);
}

/* ── Todo detail panel (canvas) ──────────────────────────────────────────────── */
.todo-detail {
    max-width: 760px;
}

.todo-detail-header {
    margin-bottom: 1.5rem;
}

.todo-detail-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: .3rem;
}

.todo-detail-desc {
    font-size: .88rem;
    color: var(--color-muted);
}

.todo-section {
    margin-bottom: 1.75rem;
}

.todo-section-title {
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-muted);
    margin-bottom: .65rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--color-border);
}

.evidence-box {
    background: rgba(34, 197, 94, .05);
    border: 1px solid rgba(34, 197, 94, .15);
    border-radius: var(--radius);
    padding: 1rem;
    font-size: .85rem;
    line-height: 1.7;
    color: var(--color-text);
    white-space: pre-wrap;
}

.evidence-textarea {
    width: 100%;
    min-height: 220px;
    background: rgba(34, 197, 94, .05);
    border: 1px solid rgba(34, 197, 94, .25);
    border-radius: var(--radius);
    padding: 1rem;
    font-size: .85rem;
    line-height: 1.7;
    color: var(--color-text);
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
    white-space: pre-wrap;
}

.evidence-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(108, 99, 255, .15);
}

.evidence-empty {
    color: var(--color-muted);
    font-style: italic;
}

.gap-list,
.inconsistency-list,
.action-list {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.gap-item-pill,
.inconsistency-pill,
.action-pill {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .5rem .75rem;
    border-radius: var(--radius);
    font-size: .82rem;
    line-height: 1.5;
}

.gap-item-pill {
    background: rgba(239, 68, 68, .06);
    border-left: 3px solid var(--color-danger);
    color: var(--color-text);
}

.inconsistency-pill {
    background: rgba(245, 158, 11, .06);
    border-left: 3px solid var(--color-warning);
    color: var(--color-text);
}

.action-pill {
    background: rgba(108, 99, 255, .06);
    border-left: 3px solid var(--color-primary);
    color: var(--color-text);
    cursor: pointer;
}

.action-pill:hover {
    background: rgba(108, 99, 255, .12);
}

/* ── Context panel resolution cards ─────────────────────────────────────────── */
.ctx-resolution-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .65rem .85rem;
    margin-bottom: .5rem;
    font-size: .83rem;
}

.ctx-resolution-card.ctx-resolved {
    border-color: rgba(34, 197, 94, .3);
    background: rgba(34, 197, 94, .04);
}

.ctx-res-label {
    font-weight: 600;
    margin-bottom: .4rem;
    line-height: 1.45;
}

.ctx-res-values {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin-bottom: .5rem;
    font-size: .79rem;
}

.ctx-val-a {
    color: var(--color-danger);
    background: rgba(239, 68, 68, .08);
    border-radius: 3px;
    padding: 2px 6px;
}

.ctx-val-b {
    color: var(--color-warning);
    background: rgba(245, 158, 11, .08);
    border-radius: 3px;
    padding: 2px 6px;
}

.ctx-val-sep {
    font-size: .72rem;
    color: var(--color-muted);
    font-style: italic;
}

.ctx-val-sources {
    width: 100%;
    font-size: .72rem;
    color: var(--color-muted);
    margin-top: .15rem;
}

.ctx-res-answer {
    font-size: .82rem;
    color: var(--color-text);
    display: flex;
    align-items: flex-start;
    gap: .4rem;
    padding: .35rem 0;
}

.ctx-res-textarea {
    width: 100%;
    padding: .45rem .6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: .82rem;
    resize: vertical;
    box-sizing: border-box;
    margin-top: .35rem;
}

/* ── Inline Q&A in todo detail ───────────────────────────────────────────────── */
.question-cards {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.question-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    transition: border-color .15s;
}

.question-card.answered {
    border-color: rgba(34, 197, 94, .25);
    opacity: .75;
}

.question-card.open {
    border-color: rgba(108, 99, 255, .25);
}

.q-category-tag {
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-primary);
    margin-bottom: .3rem;
}

.q-text {
    font-size: .88rem;
    font-weight: 500;
    margin-bottom: .3rem;
    line-height: 1.5;
}

.q-rationale {
    font-size: .77rem;
    color: var(--color-muted);
    font-style: italic;
    margin-bottom: .65rem;
}

.q-answer-given {
    font-size: .83rem;
    color: var(--color-success);
    font-style: italic;
    padding: .35rem .6rem;
    background: rgba(34, 197, 94, .05);
    border-radius: 4px;
}

.q-answer-textarea {
    width: 100%;
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    padding: .55rem .75rem;
    font-size: .88rem;
    font-family: inherit;
    min-height: 70px;
    resize: vertical;
    outline: none;
    transition: border-color .15s;
}

.q-answer-textarea:focus {
    border-color: var(--color-primary);
}

/* ── Inline answer cards (missing data / contradictions / actions / suggestions) ── */
.inline-answer-card {
    transition: border-color .15s, background .15s;
}

.inline-type-tag {
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .28rem;
}

/* ── Contradiction value-picker chips ────────────────────────────────────────── */
.conflict-picker {
    margin-top: .7rem;
}

.conflict-picker-label {
    font-size: .75rem;
    color: var(--color-muted);
    margin-bottom: .45rem;
}

.conflict-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.conflict-chip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .15rem;
    padding: .45rem .8rem;
    border-radius: var(--radius);
    border: 1.5px solid var(--chip-color, var(--color-primary));
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background .13s, transform .1s;
    min-width: 80px;
}

.conflict-chip:hover {
    background: rgba(108, 99, 255, .1);
    transform: translateY(-1px);
}

.chip-value {
    font-size: .88rem;
    font-weight: 700;
    color: var(--chip-color, var(--color-primary));
    line-height: 1.2;
}

.chip-source {
    font-size: .68rem;
    color: var(--color-muted);
    font-style: italic;
    line-height: 1.2;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Context view ───────────────────────────────────────────────────────────── */
.context-section {
    margin-bottom: 2rem;
}

.context-block-title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-primary);
    margin-bottom: .6rem;
}

.context-text {
    font-size: .88rem;
    line-height: 1.75;
    color: var(--color-text);
    white-space: pre-wrap;
}

.context-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .5rem;
}

.context-tag {
    font-size: .78rem;
    padding: .2rem .65rem;
    border-radius: 99px;
    background: rgba(108, 99, 255, .12);
    color: var(--color-primary);
    border: 1px solid rgba(108, 99, 255, .2);
}

.context-story-card {
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    margin-bottom: .6rem;
}

.story-title {
    font-size: .9rem;
    font-weight: 700;
    margin-bottom: .25rem;
}

.story-summary {
    font-size: .82rem;
    color: var(--color-muted);
}

.story-richness {
    display: inline-block;
    font-size: .67rem;
    font-weight: 700;
    padding: .1rem .45rem;
    border-radius: 4px;
    margin-top: .35rem;
    text-transform: uppercase;
}

.rich-rich {
    background: rgba(34, 197, 94, .12);
    color: var(--color-success);
}

.rich-medium {
    background: rgba(245, 158, 11, .12);
    color: var(--color-warning);
}

.rich-thin {
    background: rgba(239, 68, 68, .12);
    color: #fc8181;
}

/* ── Context inline-edit controls ──────────────────────────────────────────── */
.ctx-section-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: .4rem;
}

.ctx-inline-edit-btn {
    font-size: .72rem;
    padding: .15rem .55rem;
    opacity: .65;
    transition: opacity .15s;
}

.ctx-inline-edit-btn:hover {
    opacity: 1;
}

.ctx-inline-form {
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .75rem;
}

.ctx-inline-textarea {
    width: 100%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: .85rem;
    line-height: 1.6;
    padding: .5rem .65rem;
    resize: vertical;
    box-sizing: border-box;
}

.ctx-inline-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.ctx-inline-input {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: .85rem;
    padding: .4rem .65rem;
    box-sizing: border-box;
}

.ctx-inline-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.ctx-inline-btn-row {
    display: flex;
    gap: .5rem;
    margin-top: .5rem;
}

.ctx-tag-remove {
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    font-size: .9rem;
    line-height: 1;
    padding: 0 .2rem;
    border-radius: 3px;
    transition: color .12s;
}

.ctx-tag-remove:hover {
    color: var(--color-danger);
}

.context-tag {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
}


.outline-chapter-row {
    display: flex;
    gap: 1rem;
    padding: .85rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: .5rem;
    align-items: flex-start;
    transition: border-color .15s;
}

.outline-chapter-row:hover {
    border-color: rgba(108, 99, 255, .3);
}

.outline-ch-num {
    font-size: .72rem;
    font-weight: 800;
    color: var(--color-primary);
    background: rgba(108, 99, 255, .12);
    border-radius: 4px;
    padding: .2rem .5rem;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: .1rem;
}

.outline-ch-body {
    flex: 1;
    min-width: 0;
}

.outline-ch-title {
    font-size: .9rem;
    font-weight: 700;
    margin-bottom: .2rem;
}

.outline-ch-purpose {
    font-size: .8rem;
    color: var(--color-muted);
}

.outline-ch-actions {
    flex-shrink: 0;
    position: relative;
}

.ch-menu-btn {
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s, border-color .15s;
}

.ch-menu-btn:hover {
    background: var(--color-border);
    color: var(--color-text);
    border-color: var(--color-primary);
}

.ch-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + .3rem);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .35);
    z-index: 200;
    min-width: 130px;
    overflow: hidden;
}

.ch-dd-item {
    display: block;
    width: 100%;
    padding: .5rem .9rem;
    background: none;
    border: none;
    text-align: left;
    font-size: .83rem;
    color: var(--color-text);
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s;
}

.ch-dd-item:hover {
    background: rgba(108, 99, 255, .12);
    color: var(--color-primary);
}

/* ── Chapter plan ────────────────────────────────────────────────────────────── */
.plan-section {
    margin-bottom: 1.5rem;
}

.plan-section-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-muted);
    margin-bottom: .5rem;
}

.plan-text {
    font-size: .88rem;
    line-height: 1.7;
    color: var(--color-text);
}

.plan-section-list {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.plan-section-item {
    padding: .5rem .75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .82rem;
}

.plan-section-item b {
    color: var(--color-primary);
    display: block;
    margin-bottom: .15rem;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.plan-missing {
    font-size: .82rem;
    color: var(--color-warning);
    padding: .35rem .6rem;
    border-left: 2px solid var(--color-warning);
    background: rgba(245, 158, 11, .05);
    border-radius: 0 4px 4px 0;
    margin-bottom: .35rem;
}

/* ── Chapter draft ───────────────────────────────────────────────────────────── */
.draft-markdown {
    font-size: .91rem;
    line-height: 1.85;
    color: var(--color-text);
    max-width: 680px;
}

.draft-markdown h1,
.draft-markdown h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 1.5rem 0 .5rem;
    color: var(--color-text);
}

.draft-markdown h3 {
    font-size: .95rem;
    font-weight: 700;
    margin: 1.2rem 0 .4rem;
    color: var(--color-text);
}

.draft-markdown p {
    margin-bottom: .85rem;
}

.draft-markdown blockquote {
    border-left: 3px solid var(--color-primary);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--color-muted);
    font-style: italic;
}

.draft-markdown em {
    font-style: italic;
}

.draft-markdown strong {
    font-weight: 700;
}

.draft-needs {
    color: var(--color-warning);
    font-weight: 600;
}

.draft-word-count {
    font-size: .75rem;
    color: var(--color-muted);
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--color-border);
}

/* ── Draft annotations ───────────────────────────────────────────────────────── */
.draft-annotation {
    border-radius: 2px;
    cursor: help;
    position: relative;
}

.ann-strikeout {
    text-decoration: line-through;
    background: rgba(239, 68, 68, .15);
    color: var(--color-danger);
}

.ann-replace {
    background: rgba(245, 158, 11, .18);
    border-bottom: 2px solid var(--color-warning);
}

.ann-insert {
    background: rgba(108, 99, 255, .12);
}

.ann-todo {
    background: rgba(217, 119, 6, .18);
    border-bottom: 2px dashed #d97706;
}

.ann-comment {
    background: rgba(99, 102, 241, .12);
    border-bottom: 2px dashed #6366f1;
}

.ann-badge {
    font-size: .7rem;
    font-weight: 700;
    background: var(--color-warning);
    color: #000;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.ann-insert-marker {
    font-size: .72rem;
    font-weight: 700;
    color: var(--color-primary);
    background: rgba(108, 99, 255, .15);
    border-radius: 3px;
    padding: 1px 5px;
    margin-left: 2px;
}

.ann-hint {
    font-size: .75rem;
    color: var(--color-muted);
    margin: .4rem 0 .75rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}

/* Annotation panel */
.ann-panel {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    padding: .75rem 1rem;
    margin: 1rem 0;
}

.ann-panel-title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-muted);
    margin-bottom: .55rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.ann-group-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-muted);
    margin: .5rem 0 .3rem;
    opacity: .7;
}

.ann-chip {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .35rem .5rem;
    border-radius: 4px;
    font-size: .8rem;
    border: 1px solid var(--color-border);
    margin-bottom: .3rem;
    background: var(--color-bg);
}

.ann-chip-type {
    white-space: nowrap;
    font-weight: 700;
    font-size: .75rem;
    flex-shrink: 0;
}

.ann-chip-body {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: .4rem;
    flex-wrap: wrap;
}

.ann-chip-sel {
    color: var(--color-muted);
    font-size: .78rem;
}

.ann-chip-note {
    color: var(--color-text);
}

.ann-chip-del {
    margin-left: auto;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-muted);
    padding: 0 2px;
    font-size: .8rem;
    line-height: 1;
}

.ann-chip-del:hover {
    color: var(--color-danger);
}

/* Right-click context menu */
.draft-ctx-menu {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    padding: .3rem 0;
    min-width: 200px;
    font-size: .84rem;
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    padding: .5rem .85rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    text-align: left;
    transition: background .1s;
}

.ctx-item:hover {
    background: rgba(108, 99, 255, .08);
}

.ctx-item i {
    width: 14px;
    text-align: center;
    color: var(--color-muted);
}

/* ── Empty states ────────────────────────────────────────────────────────────── */
.empty-state-large {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--color-muted);
}

.empty-state-large h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: .5rem;
}

.empty-state-large p {
    font-size: .88rem;
    max-width: 380px;
    margin: 0 auto .75rem;
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

/* ── Score indicator in context view ────────────────────────────────────────── */
.readiness-meter {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.readiness-bar-wrap {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, .08);
    border-radius: 3px;
    overflow: hidden;
}

.readiness-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .4s;
}

.readiness-label {
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ── Analyse button pulse animation ─────────────────────────────────────────── */
.btn-pulse {
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(108, 99, 255, 0);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(108, 99, 255, .25);
    }
}

/* ── Gating lock ─────────────────────────────────────────────────────────────── */
.gate-warning {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .85rem 1rem;
    background: rgba(245, 158, 11, .06);
    border: 1px solid rgba(245, 158, 11, .2);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .83rem;
    color: var(--color-text);
}

.gate-warning b {
    color: var(--color-warning);
}

/* ── Confidence badge ─────────────────────────────────────────────────────────── */
.conf-badge {
    font-size: .68rem;
    font-weight: 700;
    padding: .12rem .45rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.conf-high {
    background: rgba(34, 197, 94, .12);
    color: var(--color-success);
}

.conf-medium {
    background: rgba(245, 158, 11, .12);
    color: var(--color-warning);
}

.conf-low {
    background: rgba(239, 68, 68, .12);
    color: #fc8181;
}

/* ── Scrollable prose areas ──────────────────────────────────────────────────── */
.prose-scroll {
    max-height: 340px;
    overflow-y: auto;
    padding-right: .3rem;
}

.prose-scroll::-webkit-scrollbar {
    width: 4px;
}

.prose-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .1);
    border-radius: 2px;
}

/* ── Edit inline title ──────────────────────────────────────────────────────── */
.inline-title-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--color-border);
    color: var(--color-text);
    font-size: 1.25rem;
    font-weight: 800;
    font-family: inherit;
    width: 100%;
    outline: none;
    padding: .2rem 0;
    transition: border-color .15s;
}

.inline-title-input:focus {
    border-color: var(--color-primary);
}

/* ── Spinning on buttons ─────────────────────────────────────────────────────── */
.btn-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ── Helper ─────────────────────────────────────────────────────────────────── */
.btn-copied {
    background: var(--color-success) !important;
    color: #fff !important;
    border-color: var(--color-success) !important;
    transition: background .15s, color .15s;
}

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

.text-success {
    color: var(--color-success);
}

.text-warning {
    color: var(--color-warning);
}

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

.text-primary {
    color: var(--color-primary);
}

.flex-center {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.mt-1 {
    margin-top: .5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: .5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 1.25rem 0;
}

/* ── Project card action buttons ─────────────────────────────────────────── */
.project-card-actions {
    display: flex;
    align-items: center;
    gap: .15rem;
    flex-shrink: 0;
}

.project-card-settings-btn,
.project-card-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.05rem;
    color: var(--color-muted);
    padding: .3rem .4rem;
    border-radius: var(--radius);
    transition: color .15s, background .15s;
    line-height: 1;
    flex-shrink: 0;
}

.project-card-manuscript-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: .9rem;
    color: var(--color-primary);
    padding: .3rem .4rem;
    border-radius: var(--radius);
    transition: color .15s, background .15s;
    line-height: 1;
    flex-shrink: 0;
    opacity: .8;
}

.project-card-settings-btn:hover,
.project-card-edit-btn:hover {
    color: var(--color-primary);
    background: rgba(108, 99, 255, .1);
}

.project-card-manuscript-btn:hover {
    opacity: 1;
    background: rgba(108, 99, 255, .1);
}

/* ── Admin project table ──────────────────────────────────────────────────── */
.proj-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.proj-table th {
    text-align: left;
    padding: .4rem .6rem;
    border-bottom: 2px solid var(--color-border);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
    white-space: nowrap;
}

.proj-row-main td {
    padding: .5rem .6rem .1rem;
    vertical-align: top;
    border-top: 1px solid var(--color-border);
}

.proj-row-sub td {
    padding: .1rem .6rem .5rem;
    vertical-align: top;
    font-size: .78rem;
    color: var(--color-muted);
}

.proj-row-main:hover td,
.proj-row-main:hover + .proj-row-sub td {
    background: var(--color-surface);
}

.proj-tbl-name {
    font-weight: 600;
    white-space: nowrap;
}

.proj-tbl-title {
    font-style: italic;
}

.btn-tbl {
    display: inline-block;
    padding: .2rem .55rem;
    font-size: .78rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    color: inherit;
    line-height: 1.5;
}

.btn-tbl:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.btn-tbl + .btn-tbl {
    margin-left: .3rem;
}

/* ── Edit / delete modal ──────────────────────────────────────────────────── */
.edit-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.edit-modal-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: min(560px, calc(100vw - 2rem));
    box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}

.settings-modal-box {
    width: min(600px, calc(100vw - 2rem));
}

.settings-section-header {
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: .35rem;
    color: var(--color-text);
}

.settings-section-desc {
    font-size: .82rem;
    color: var(--color-muted);
    margin-bottom: 1rem;
}

.settings-field-hint {
    font-size: .8rem;
    color: var(--color-muted);
    margin-top: .4rem;
    line-height: 1.45;
}

.settings-field-hint a {
    color: var(--color-primary);
    text-decoration: underline;
}

/* ── Source drop zone ─────────────────────────────────────────────────────── */
.drop-zone {
    position: relative;
    border-radius: var(--radius);
}

.drop-zone-idle {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    pointer-events: none;
    z-index: 1;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface2);
    transition: border-color .15s, background .15s;
}

.drop-zone-icon {
    font-size: 2rem;
    color: var(--color-muted);
    line-height: 1;
}

.drop-zone-msg {
    font-size: .85rem;
    color: var(--color-muted);
}

.drop-browse-link {
    color: var(--color-primary);
    cursor: pointer;
    pointer-events: all;
    text-decoration: underline;
}

.drop-zone-hint {
    font-size: .72rem;
    color: var(--color-muted);
    opacity: .7;
}

.drop-zone-over .drop-zone-idle,
.drop-zone:focus-within .drop-zone-idle {
    border-color: var(--color-primary);
    background: rgba(108, 99, 255, .25);
}

.drop-zone-over .drop-zone-icon {
    color: var(--color-primary);
}

/* Keep textarea on top so user can type; idle layer hides once it has content */
.drop-zone .big-textarea,
.drop-zone .stt-textarea-wrap {
    position: relative;
    z-index: 2;
    background: transparent;
    min-height: 180px;
}

.drop-zone:has(.big-textarea:not(:placeholder-shown)) .drop-zone-idle,
.drop-zone:has(.big-textarea:focus) .drop-zone-idle {
    display: none !important;
}

/* ── Todo item restructure (body + top row) ───────────────────────────────── */
.todo-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .28rem;
}

.todo-item-top {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ── Todo mini-badges (gaps / conflicts / questions) ──────────────────────── */
.todo-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
}

.todo-badge {
    font-size: .62rem;
    font-weight: 700;
    padding: .1rem .38rem;
    border-radius: 3px;
    letter-spacing: .01em;
    white-space: nowrap;
}

.badge-gap {
    background: rgba(245, 158, 11, .18);
    color: #fbbf24;
}

.badge-conflict {
    background: rgba(239, 68, 68, .18);
    color: #fc8181;
}

.badge-question {
    background: rgba(108, 99, 255, .2);
    color: var(--color-primary-h);
}

/* ── Header Book Readiness badge ──────────────────────────────────────────── */
.header-readiness-badge {
    font-size: .75rem;
    font-weight: 700;
    padding: .28rem .75rem;
    border-radius: 99px;
    border: 1px solid var(--color-border);
    color: var(--color-muted);
    white-space: nowrap;
    margin-right: .25rem;
    transition: color .3s, border-color .3s, background .3s;
}

.header-readiness-badge.hr-green {
    background: rgba(34, 197, 94, .1);
    border-color: rgba(34, 197, 94, .35);
    color: var(--color-success);
}

.header-readiness-badge.hr-yellow {
    background: rgba(245, 158, 11, .1);
    border-color: rgba(245, 158, 11, .35);
    color: var(--color-warning);
}

.header-readiness-badge.hr-red {
    background: rgba(239, 68, 68, .1);
    border-color: rgba(239, 68, 68, .35);
    color: var(--color-danger);
}

/* ── Unified content (landing + sources) ──────────────────────────────────── */
.content-wrap {
    width: 100%;
}

.content-header {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: .75rem;
}

.content-title {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0 0 .2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.content-sub {
    color: var(--color-muted);
    font-size: .85rem;
    margin: 0;
}

.content-stats-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
    flex-wrap: wrap;
}

.content-chips {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    flex: 1;
}

.ov-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .72rem;
    font-weight: 600;
    padding: .22rem .6rem;
    border-radius: 99px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    white-space: nowrap;
    cursor: default;
}

.ov-chip[onclick] {
    cursor: pointer;
}

.ov-chip[onclick]:hover {
    border-color: rgba(108, 99, 255, .4);
}

.content-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--color-muted);
    opacity: 0;
    padding: .25rem .4rem;
    border-radius: var(--radius);
    transition: opacity .15s, color .15s, background .15s;
    line-height: 1;
    flex-shrink: 0;
}

.content-header:hover .content-edit-btn,
.content-edit-btn:focus {
    opacity: 1;
}

.content-edit-btn:hover {
    color: var(--color-primary);
    background: rgba(108, 99, 255, .1);
}

.ov-chip-sub {
    font-weight: 400;
    color: var(--color-muted);
    margin-left: .15rem;
}

.ov-chip-warn {
    background: rgba(245, 158, 11, .1);
    border-color: rgba(245, 158, 11, .35);
    color: var(--color-warning);
}

.ov-chip-green {
    background: rgba(34, 197, 94, .1);
    border-color: rgba(34, 197, 94, .35);
    color: var(--color-success);
}

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

.content-readiness {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
}

/* content-actions kept for reference but replaced by drop zone */
.content-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
}

/* ── Content mini drop zone ───────────────────────────────────────────────── */
.content-source-actions {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: .65rem;
}

.content-drop-zone {
    position: relative;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface2);
    padding: .65rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.content-drop-zone:hover,
.content-drop-zone-over {
    border-color: var(--color-primary);
    background: rgba(108, 99, 255, .25);
}

.content-drop-inner {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex: 1;
    pointer-events: none;
}

.content-drop-inner * {
    pointer-events: none;
}

.content-drop-btn {
    pointer-events: all !important;
}

.content-drop-icon {
    font-size: 1.1rem;
    color: var(--color-muted);
    line-height: 1;
}

.content-drop-msg {
    font-size: .8rem;
    color: var(--color-muted);
}

.content-drop-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.content-drop-btn:hover {
    opacity: .8;
}

.content-drop-hint {
    font-size: .7rem;
    color: var(--color-muted);
    opacity: .7;
}

.content-drop-pending {
    font-size: .72rem;
    font-weight: 700;
    color: var(--color-primary);
    background: rgba(108, 99, 255, .1);
    border: 1px solid rgba(108, 99, 255, .25);
    border-radius: 99px;
    padding: .2rem .6rem;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
}

.content-drop-pending:hover {
    background: rgba(108, 99, 255, .18);
}

/* ── Library canvas ─────────────────────────────────────────────────────────── */
.lib-subnav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

.lib-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: .65rem 1.25rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--color-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .45rem;
    transition: color .12s;
    white-space: nowrap;
}

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

.lib-tab-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.lib-tab-count {
    background: var(--color-border);
    color: var(--color-muted);
    border-radius: 99px;
    font-size: .67rem;
    font-weight: 700;
    padding: .05rem .42rem;
    min-width: 1.2rem;
    text-align: center;
}

.lib-tab-active .lib-tab-count {
    background: rgba(108, 99, 255, .15);
    color: var(--color-primary);
}

.lib-wrap {
    max-width: 820px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.lib-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.lib-section-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .85rem 1.1rem;
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-muted);
    cursor: pointer;
    list-style: none;
    border-bottom: 1px solid var(--color-border);
    user-select: none;
}

.lib-section-header::-webkit-details-marker {
    display: none;
}

.lib-section-header::before {
    content: '▾';
    font-size: .7rem;
    transition: transform .15s;
    color: var(--color-muted);
    flex-shrink: 0;
}

details.lib-section:not([open]) .lib-section-header::before {
    transform: rotate(-90deg);
}

.lib-section-icon {
    font-size: 1rem;
}

.lib-badge {
    margin-left: auto;
    background: var(--color-border);
    color: var(--color-muted);
    border-radius: 99px;
    font-size: .68rem;
    padding: .1rem .5rem;
    font-weight: 600;
}

.lib-section-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Per-source collapsible block inside a section */
.lib-source-block {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: .75rem;
    background: var(--color-surface);
}

.lib-source-block:last-child {
    margin-bottom: 0;
}

.lib-source-title {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .7rem 1.1rem;
    font-size: .84rem;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.lib-source-title::-webkit-details-marker {
    display: none;
}

.lib-source-title::before {
    content: '▾';
    font-size: .65rem;
    color: var(--color-muted);
    flex-shrink: 0;
    transition: transform .12s;
}

details.lib-source-block:not([open]) .lib-source-title::before {
    transform: rotate(-90deg);
}

.lib-source-badge {
    margin-left: auto;
    font-size: .65rem;
    font-weight: 700;
    padding: .1rem .45rem;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.lib-badge-extracted {
    background: rgba(34, 197, 94, .12);
    color: var(--color-success);
}

.lib-badge-raw {
    background: rgba(234, 179, 8, .12);
    color: var(--color-warning);
}

/* Text content blocks */
.lib-text-block {
    padding: .75rem 1.1rem 1rem 1.1rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

.lib-text-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-muted);
    margin-bottom: .4rem;
}

.lib-pre {
    font-family: inherit;
    font-size: .82rem;
    line-height: 1.65;
    color: var(--color-text);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

/* Nested "Original Content" sub-toggle for file sources */
.lib-raw-details {
    border-top: 1px solid var(--color-border);
}

.lib-raw-summary {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-muted);
    padding: .5rem 1.1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.lib-raw-summary::-webkit-details-marker {
    display: none;
}

.lib-empty-note {
    padding: .65rem 1.1rem;
    font-size: .8rem;
    color: var(--color-muted);
    font-style: italic;
    margin: 0;
}

.lib-keyfacts-list {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    margin-top: .3rem;
}

.lib-keyfact-row {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    font-size: .8rem;
    padding: .28rem .55rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.lib-keyfact-text {
    flex: 1;
    line-height: 1.5;
    color: var(--color-text);
}

/* ── Guided Flow ───────────────────────────────────────────────────────────── */
.guided-flow-rail-btn:hover {
    filter: brightness(1.12);
}
.guided-flow-rail-btn:active {
    transform: scale(.98);
}
.guided-wrap {
    max-width: 680px;
    padding: 1.5rem 0;
}

/* Labeled STT wrap — buttons flow below the textarea, not absolutely positioned */
.stt-labeled-wrap textarea {
    padding-bottom: unset;
}
.stt-labeled-wrap .stt-mic-btn,
.stt-labeled-wrap .stt-wand-btn {
    position: static;
    width: auto;
    height: auto;
    border-radius: var(--radius);
    font-size: .95rem;
    padding: .7rem 1rem;
    line-height: 1.4;
    color: inherit;
    background: inherit;
}
