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

:root {
    --c-bg:       #f5f4f0;
    --c-surface:  #ffffff;
    --c-border:   #e2dfd8;
    --c-primary:  #4f46e5;
    --c-primary-h:#3730a3;
    --c-success:  #059669;
    --c-danger:   #dc2626;
    --c-text:     #1c1a2e;
    --c-muted:    #6b7280;
    --c-subtle:   #9ca3af;
    --radius:     12px;
    --radius-lg:  18px;
    --shadow:     0 2px 16px rgba(0,0,0,.07);
    --shadow-lg:  0 8px 40px rgba(0,0,0,.12);
    --footer-h:   84px;
    --header-h:   65px;
    --steps-row-h: 82px;
}

html {
    font-size: clamp(13.5px, calc(8px + 0.8vh), 16px);
    scroll-behavior: smooth;
}

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

/* ── Utility ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

body.ai-assist-busy,
body.ai-assist-busy * {
    cursor: wait !important;
}

.ai-assist-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .25);
    backdrop-filter: blur(1px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-assist-overlay-box {
    min-width: 320px;
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: .45rem;
    align-items: center;
    text-align: center;
}

.ai-assist-spinner {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid #d1d5db;
    border-top-color: var(--c-primary);
    animation: spin .75s linear infinite;
}

.ai-assist-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--c-text);
}

.ai-assist-detail {
    font-size: .84rem;
    color: var(--c-muted);
}

.center { text-align: center; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .85rem 2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s, opacity .15s;
    text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--c-primary);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--c-primary-h); }

.btn-ghost {
    background: transparent;
    color: var(--c-primary);
    border: 2px solid var(--c-primary);
}
.btn-ghost:hover:not(:disabled) { background: rgba(79,70,229,.06); }

.btn-xl {
    padding: 0.8rem 2rem;
    font-size: 1.2rem;
    border-radius: var(--radius-lg);
    min-width: 220px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--c-primary);
    font-size: .9rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    min-width: 0;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.a-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: var(--header-h);
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.a-topbar {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 0 1.25rem;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    z-index: 125;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
}

.a-logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--c-primary);
    letter-spacing: -.4px;
}

.a-logo-version {
    font-size: .65rem;
    color: var(--c-muted);
    margin-left: .35rem;
    font-weight: 500;
    opacity: .7;
    vertical-align: middle;
}

.topbar-working-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: .95rem;
    font-weight: 700;
    color: var(--c-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40%;
    pointer-events: none;
}

.a-user {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.a-user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .05rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#user-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--c-text);
    line-height: 1.25;
}

#user-email {
    font-size: .75rem;
    color: var(--c-muted);
    line-height: 1.25;
}

.a-menu {
    position: relative;
}

.a-menu-toggle {
    width: 38px;
    height: 38px;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: #fff;
    color: var(--c-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.a-menu-toggle:hover {
    background: #f7f5f1;
    border-color: #cfcabf;
}

.a-menu-toggle:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

.a-menu-icon,
.a-menu-icon::before,
.a-menu-icon::after {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    content: '';
}

.a-menu-icon {
    position: relative;
}

.a-menu-icon::before {
    position: absolute;
    top: -5px;
    left: 0;
}

.a-menu-icon::after {
    position: absolute;
    top: 5px;
    left: 0;
}

.a-menu-list {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 170px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
    padding: .35rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    z-index: 190;
}

.a-menu-item {
    border: none;
    background: transparent;
    color: var(--c-text);
    text-align: left;
    font-size: .9rem;
    font-weight: 600;
    padding: .55rem .65rem;
    border-radius: 8px;
    cursor: pointer;
}

.a-menu-item:hover {
    background: #f4f1ea;
}

.a-menu-item:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 1px;
}

#a-menu-item-signout {
    color: #b42318;
}

/* ── Step progress bar ──────────────────────────────────────────────────── */
.a-steps {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 1.25rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    cursor: pointer;
    position: relative;
}

.step-item:hover .step-circle {
    border-color: var(--c-primary);
}

.step-item:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 3px;
    border-radius: 8px;
}

.step-item:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 18px;
    left: calc(50% + 22px);
    width: calc(100% - 2px);
    height: 2px;
    background: var(--c-border);
    z-index: 0;
}

.step-item.done:not(:last-child)::after {
    background: var(--c-primary);
}

.step-connector {
    width: 60px;
    height: 2px;
    background: var(--c-border);
    margin-bottom: 24px;
    flex-shrink: 0;
    transition: background .3s;
}

.step-connector.done { background: var(--c-primary); }

.step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2.5px solid var(--c-border);
    background: var(--c-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    font-weight: 700;
    color: var(--c-muted);
    transition: all .25s;
    z-index: 1;
}

.step-item.active .step-circle {
    border-color: var(--c-primary);
    background: var(--c-primary);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(79,70,229,.15);
}

.step-item.done .step-circle {
    border-color: var(--c-success);
    background: var(--c-success);
    color: #fff;
}

.step-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--c-subtle);
    white-space: nowrap;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.step-item.active .step-label { color: var(--c-primary); }
.step-item.done  .step-label  { color: var(--c-success); }

/* ── Step progress row ──────────────────────────────────────────────────── */
.steps-row {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    padding: 1.25rem 1rem;
}

.steps-row {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    padding: 1.25rem 1rem;
    position: relative;
}

/* ── Main content area ──────────────────────────────────────────────────── */
.a-main {
    flex: 1;
    min-height: calc(100vh - var(--header-h));
    display: flex;
    flex-direction: column;
    padding-bottom: calc(var(--footer-h) + 1.5rem);
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    width: 100%;
    box-sizing: border-box;
}

/* ── Outline wide mode ──────────────────────────────────────────────────── */
.a-main--wide {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

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

.card-fill > #qa-body,
.card-fill > #align-body {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#qa-body .textarea-tools-wrap,
#align-body .textarea-tools-wrap,
.card-fill .textarea-tools-wrapped,
.my-desk-editor-card .textarea-tools-wrap,
.my-desk-editor-card .textarea-tools-wrapped,
.outline-qa-panel .textarea-tools-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* taWrap (the position:relative wrapper around the textarea) must also flex-fill */
#qa-body .textarea-tools-wrap > div:first-child,
#align-body .textarea-tools-wrap > div:first-child,
.card-fill .textarea-tools-wrapped > div:first-child,
.my-desk-editor-card .textarea-tools-wrap > div:first-child,
.my-desk-editor-card .textarea-tools-wrapped > div:first-child,
.outline-qa-panel .textarea-tools-wrap > div:first-child {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}

#qa-body .qa-answer-area,
#align-body .qa-answer-area,
.card-fill .generate-note,
.my-desk-editor-card .qa-answer-area,
.outline-qa-panel .qa-answer-area,
#qa-body .qa-answer-ce,
#align-body .qa-answer-ce,
.my-desk-editor-card .qa-answer-ce,
.outline-qa-panel .qa-answer-ce,
#qa-body .doc-analysis-overlay,
#align-body .doc-analysis-overlay,
.outline-qa-panel .doc-analysis-overlay {
    flex: 1;
    min-height: 7.25rem;
    height: 0;
}

@media (max-height: 900px) {
    .a-main {
        padding-top: 1.25rem;
        padding-bottom: calc(var(--footer-h) + 1rem);
    }
    .step-hero {
        margin-bottom: .8rem;
    }
}

@media (max-height: 760px) {
    .a-main {
        padding-top: .8rem;
        padding-bottom: calc(var(--footer-h) + .8rem);
    }
    .step-hero h1 {
        line-height: 1.1;
        margin-bottom: .35rem;
    }
    .step-hero p {
        line-height: 1.45;
    }
}

/* ── Step hero heading ──────────────────────────────────────────────────── */
.step-hero {
    text-align: center;
    margin-bottom: 1.5rem;
}

.step-hero h1 {
    font-size: 2.1rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--c-text);
    margin-bottom: .6rem;
}

.step-hero p {
    font-size: 1.1rem;
    color: var(--c-muted);
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ── Upload zone ────────────────────────────────────────────────────────── */
.upload-zone {
    border: 2.5px dashed var(--c-border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.25rem;
    text-align: center;
    background: #fafaf8;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--c-primary);
    background: rgba(79,70,229,.03);
}

.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.upload-zone h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: .4rem; }
.upload-zone p  { font-size: .9rem; color: var(--c-muted); }

.upload-zone input[type="file"] { display: none; }

/* ── Voice recorder ──────────────────────────────────────────────────────── */
.voice-record-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: none;
    background: var(--c-surface);
    border: 2.5px solid var(--c-border);
    color: var(--c-muted);
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
}

.voice-record-btn:hover { border-color: var(--c-danger); color: var(--c-danger); }
.voice-record-btn.recording {
    background: var(--c-danger);
    border-color: var(--c-danger);
    color: #fff;
    animation: pulse-ring 1.2s ease-out infinite;
}

@keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
    70%  { box-shadow: 0 0 0 14px rgba(220,38,38,0); }
    100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}

.voice-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}

.voice-wrap .voice-label {
    font-size: .8rem;
    color: var(--c-muted);
    font-weight: 500;
}

.voice-timer {
    font-size: .85rem;
    color: var(--c-danger);
    font-weight: 700;
    font-feature-settings: "tnum";
    min-height: 1.2em;
}

/* ── Source list ─────────────────────────────────────────────────────────── */
.source-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; }

.source-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: #f9f8f5;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: .7rem 1rem;
    font-size: .9rem;
}

.source-item .src-icon { font-size: 1.1rem; }
.source-item .src-title { flex: 1; font-weight: 600; color: var(--c-text); }
.source-item .src-type  { font-size: .75rem; color: var(--c-muted); background: #eee; padding: .15rem .45rem; border-radius: 4px; }

/* ── Q&A step ────────────────────────────────────────────────────────────── */
.qa-progress {
    text-align: left;
    font-size: .85rem;
    color: var(--c-muted);
    font-weight: 600;
    margin-bottom: .35rem;
    letter-spacing: .04em;
    background: rgba(0,0,0,.04);
    border-radius: 6px;
    padding: .25rem .5rem;
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    border: none;
    outline: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

/* ── Custom select dropdown (replaces native <select> for question nav) ──── */
div.cust-select.qa-progress {
    display: flex;
    align-items: center;
    gap: .3rem;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}
div.cust-select.qa-progress:focus {
    outline: 2px solid var(--c-primary);
    outline-offset: 1px;
}
.cust-select-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cust-select-arrow {
    flex-shrink: 0;
    font-size: .7rem;
    color: var(--c-muted);
    line-height: 1;
}
.cust-select-arrow::after { content: '▾'; }
.cust-select-list {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    z-index: 120;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,.12);
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .25rem 0;
    list-style: none;
    margin: 0;
}
.cust-select-option {
    padding: .45rem .75rem;
    font-size: .82rem;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--c-text);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.cust-select-option:hover {
    background: var(--c-bg);
    color: var(--c-primary);
}

.qa-bar-wrap {
    height: 5px;
    background: var(--c-border);
    border-radius: 99px;
    margin-bottom: .6rem;
}

.qa-bar {
    height: 100%;
    background: var(--c-primary);
    border-radius: 99px;
    transition: width .4s ease;
}

.qa-question {
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.25;
    color: var(--c-text);
    margin-bottom: .55rem;
}

.qa-answer-area {
    width: 100%;
    min-height: 112px;
    padding: .8rem .95rem;
    border: 2px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 1.05rem;
    font-family: inherit;
    color: var(--c-text);
    background: #fff;
    resize: none;
    transition: border-color .2s;
    line-height: 1.6;
    box-sizing: border-box;
}

.qa-answer-area:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

/* Copy / Erase overlay buttons inside textarea wrapper */
.ta-overlay-btn {
    position: absolute;
    top: .4rem;
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(0,0,0,.1);
    border-radius: 5px;
    cursor: pointer;
    font-size: .7rem;
    font-family: inherit;
    font-weight: 700;
    color: #888;
    padding: .15rem .32rem;
    line-height: 1;
    backdrop-filter: blur(4px);
    transition: background .15s, color .15s, opacity .15s;
    opacity: .55;
    z-index: 2;
}
.ta-overlay-btn:hover { opacity: 1; background: rgba(255,255,255,.92); color: #333; }

/* ── Ghostwriter button ─────────────────────────────────────────────────────── */
.btn-ghostwriter {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .85rem;
    border: 1.5px solid var(--c-primary);
    border-radius: 8px;
    background: transparent;
    color: var(--c-primary);
    font-size: .85rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.btn-ghostwriter:hover:not(:disabled) { background: rgba(79,70,229,.07); }
.btn-ghostwriter:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghostwriter.gw-btn--active {
    background: var(--c-primary);
    color: #fff;
}

.gw-stuck-wrap {
    position: relative;
}

.gw-stuck-popover {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    width: min(360px, calc(100vw - 2rem));
    max-width: 360px;
    padding: .35rem;
    border: 1px solid rgba(15, 23, 42, .1);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .16);
}

.gw-stuck-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .35rem .45rem .15rem;
}

.gw-stuck-menu-header .gw-stuck-menu-title {
    padding: 0;
}

.gw-stuck-close-x {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--c-muted);
    padding: .1rem .25rem;
    border-radius: 4px;
    transition: color .15s, background .15s;
}
.gw-stuck-close-x:hover { color: var(--c-text); background: rgba(0,0,0,.06); }

.gw-stuck-menu,
.gw-stuck-card {
    display: flex;
    flex-direction: column;
    gap: .55rem;
}

.gw-stuck-menu-title,
.gw-stuck-card-title {
    padding: .35rem .45rem .15rem;
    font-size: .82rem;
    font-weight: 800;
    color: var(--c-text);
    letter-spacing: .01em;
}

.gw-stuck-option {
    width: 100%;
    border: 1px solid var(--c-border);
    border-radius: 11px;
    background: #fff;
    padding: .7rem .8rem;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .15s;
}

.gw-stuck-option:hover {
    border-color: rgba(79,70,229,.35);
    background: rgba(79,70,229,.05);
    transform: translateY(-1px);
}

.gw-stuck-option-title {
    font-size: .9rem;
    font-weight: 700;
    color: var(--c-text);
    line-height: 1.35;
}

.gw-stuck-option-detail,
.gw-stuck-card-text,
.gw-stuck-detail-text {
    font-size: .82rem;
    line-height: 1.5;
    color: var(--c-muted);
}

.gw-stuck-option-detail {
    margin-top: .22rem;
}

.gw-stuck-card {
    padding: .35rem;
}

.gw-stuck-detail {
    padding: .55rem .6rem;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid rgba(15, 23, 42, .06);
}

.gw-stuck-detail-label {
    margin-bottom: .16rem;
    font-size: .74rem;
    font-weight: 800;
    color: var(--c-primary);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.gw-stuck-footer {
    display: flex;
    justify-content: flex-end;
    gap: .45rem;
    padding-top: .2rem;
}

/* ── Ghostwriter suggestions panel ─────────────────────────────────────────── */
/* ── Contenteditable answer area (replaces <textarea> in wrapTextareaWithTools) */
.qa-answer-ce {
    width: 100%;
    min-height: 112px;
    padding: .8rem .95rem;
    border: 2px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 1.05rem;
    font-family: inherit;
    color: var(--c-text);
    background: #fff;
    transition: border-color .2s;
    line-height: 1.6;
    box-sizing: border-box;
    cursor: text;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    outline: none;
}

.qa-answer-ce:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

/* Placeholder via data-placeholder attribute */
.qa-answer-ce:not(.ce-has-content):before {
    content: attr(data-placeholder);
    color: #bbb;
    pointer-events: none;
    display: block;
}

/* ── Inline suggestion block inside CE div ─────────────────────────────── */
.gw-suggestion-inline {
    background: #f3f2ff;
    border: 1.5px solid rgba(79,70,229,.25);
    border-radius: 10px;
    padding: .55rem .75rem .65rem;
    margin: .6rem 0 .2rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
    /* prevent this block from being edited */
    -webkit-user-select: none;
    user-select: none;
}

/* ── Old panel styles (no longer needed, kept for safety) ─────────────── */
.gw-suggestions-panel { display: none; }
.gw-inline-panel      { display: none; }

/* When active, flatten the textarea's bottom edge to connect to inline panel */
.gw-active textarea,
.gw-active .qa-answer-area {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-color: var(--c-primary);
    border-bottom-color: transparent;
}

.gw-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .15rem;
}

.gw-panel-title {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--c-muted);
}

.gw-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: .8rem;
    color: var(--c-subtle);
    padding: .1rem .3rem;
    border-radius: 4px;
    line-height: 1;
}
.gw-panel-close:hover { color: var(--c-text); background: rgba(0,0,0,.05); }

.gw-empty {
    font-size: .85rem;
    color: var(--c-muted);
    text-align: center;
    padding: .5rem 0;
}

.gw-suggestion-card {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    padding: .65rem .8rem .7rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.gw-suggestion-label {
    font-size: .9rem;
    font-weight: 700;
    color: var(--c-text);
    line-height: 1.3;
}

.gw-suggestion-desc {
    font-size: .8rem;
    color: var(--c-muted);
    line-height: 1.5;
}

.gw-suggestion-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .1rem;
}

/* Small action buttons inside suggestion cards */
.btn-sm {
    display: inline-flex;
    align-items: center;
    padding: .3rem .75rem;
    border-radius: 7px;
    font-size: .8rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .15s, opacity .15s;
}
.btn-sm:disabled { opacity: .45; cursor: not-allowed; }

.btn-sm--primary {
    background: var(--c-primary);
    color: #fff;
}
.btn-sm--primary:hover:not(:disabled) { background: var(--c-primary-h); }

.btn-sm--ghost {
    background: transparent;
    color: var(--c-primary);
    border: 1.5px solid var(--c-primary);
}
.btn-sm--ghost:hover:not(:disabled) { background: rgba(79,70,229,.07); }

.btn-sm--muted {
    background: transparent;
    color: var(--c-muted);
    border: 1.5px solid var(--c-border);
}
.btn-sm--muted:hover:not(:disabled) { background: rgba(0,0,0,.04); }

.gw-auto-toggle {
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    color: var(--c-muted);
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .01em;
    cursor: pointer;
    user-select: none;
}

.gw-auto-toggle input {
    margin: 0;
    accent-color: var(--c-primary);
}

/* Input area revealed when author needs to provide detail */
.gw-input-area {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin-top: .3rem;
    padding-top: .45rem;
    border-top: 1px solid var(--c-border);
}

.gw-input-textarea {
    width: 100%;
    min-height: 80px;
    padding: .6rem .75rem;
    border: 1.5px solid var(--c-border);
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    color: var(--c-text);
    background: #fff;
    resize: none;
    line-height: 1.55;
    box-sizing: border-box;
    transition: border-color .2s;
}
.gw-input-textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(79,70,229,.08); }

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

.gw-mini-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.35rem;
    opacity: .7;
    transition: opacity .15s;
    padding: 0;
    line-height: 1;
}
.gw-mini-icon-btn:hover:not(:disabled) { opacity: 1; }
.gw-mini-icon-btn:disabled { opacity: .35; }

/* ── I'm Stuck example boxes ─────────────────────────────────────────────── */
.gw-loading-row {
    display: flex;
    justify-content: center;
    padding: .75rem 0;
}

.gw-example-box {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    padding: .65rem .8rem .7rem;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.gw-example-label {
    font-size: .8rem;
    font-weight: 700;
    color: var(--c-primary);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.gw-example-hint {
    font-size: .82rem;
    color: var(--c-muted);
    line-height: 1.45;
}

.gw-example-preview {
    background: #f3f2ff;
    border: 1px solid rgba(79,70,229,.15);
    border-radius: 7px;
    padding: .6rem .75rem;
    font-size: .87rem;
    line-height: 1.6;
    color: var(--c-text);
    white-space: pre-wrap;
    font-style: italic;
}

.gw-wizard-note {
    font-size: .78rem;
    color: var(--c-muted);
    margin-top: -.1rem;
}

.gw-wizard-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}



#qa-body,
#align-body {
    padding-bottom: 10px;
    min-width: 0;
    overflow: visible;
}

/* ── Align intro card (multi-field, before single Q flow) ──────────────────── */
.align-intro-card {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    padding: .25rem 0 .5rem;
}

.align-intro-lead {
    font-size: .92rem;
    color: var(--c-muted);
    margin: 0;
}

.align-intro-fields {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.align-intro-field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.align-intro-label {
    font-size: .82rem;
    font-weight: 700;
    color: var(--c-text);
}

.align-intro-input {
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: .48rem .72rem;
    font-size: .93rem;
    color: var(--c-text);
    background: #fff;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.align-intro-input:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, .12);
}

.align-voice-row {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.align-intro-inline-select {
    flex: 1;
}

.align-voice-preview-btn {
    white-space: nowrap;
    padding: .42rem .8rem !important;
    font-size: .8rem !important;
}

.align-intro-input::placeholder {
    color: #bbb;
}

.align-intro-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .75rem;
    padding-top: .2rem;
}

/* ── Align quick-start card (first-four questions, one card) ──────────────── */
.align-qs-card {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    padding: .25rem 0 .5rem;
}

.align-qs-fields {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.align-qs-field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.align-qs-hint {
    font-size: .74rem;
    color: var(--c-muted);
    margin: 0 0 .15rem;
    font-style: italic;
}

.align-qs-input {
    /* inherits align-intro-input styles */
}

.align-choice-list {
    display: flex;
    flex-direction: column;
    gap: .65rem;
    margin-top: .5rem;
    flex: 1;
    min-height: 0;
}

.align-choice-option {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .75rem .85rem;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    cursor: pointer;
    background: #fff;
}

.align-choice-radio {
    margin-top: .2rem;
}

.align-choice-copy {
    display: block;
}

.align-choice-label {
    display: block;
    font-weight: 700;
    color: var(--c-text);
}

.align-choice-description {
    display: block;
    font-size: .85rem;
    color: var(--c-muted);
}

.align-controls-anchor {
    margin-top: .65rem;
    min-height: 2.5rem;
    border-top: 1px solid var(--c-border);
    padding-top: .65rem;
    margin-top: auto;
}

.align-controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    min-height: 2.25rem;
}

.qa-chevron-btn {
    background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
    border: 1px solid var(--c-border);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    color: var(--c-text);
    padding: .42rem .78rem;
    min-height: 2.1rem;
    border-radius: 9px;
    font-family: inherit;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    transition: color .15s, background .15s, border-color .15s, box-shadow .15s, transform .05s;
    user-select: none;
}

.qa-chevron-btn:hover:not(:disabled) {
    border-color: rgba(79, 70, 229, .45);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .10);
    background: #fff;
}

.qa-chevron-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.qa-chevron-btn:disabled {
    opacity: .42;
    cursor: default;
}

.qa-chevron-btn:focus-visible {
    outline: 2px solid rgba(79, 70, 229, .45);
    outline-offset: 2px;
}

.qa-chevron { font-size: 1.08rem; line-height: 1; }
.qa-chevron-label { font-size: .8rem; font-weight: 700; letter-spacing: .01em; }

.qa-save-btn {
    background: linear-gradient(180deg, #4f46e5 0%, #4338ca 100%);
    border: 1px solid #4338ca;
    color: #fff;
    border-radius: 9px;
    padding: .42rem 1rem;
    min-height: 2.1rem;
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .01em;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 8px 18px rgba(79, 70, 229, .18);
    transition: border-color .15s, color .15s, background .15s, box-shadow .15s, transform .05s;
}

.qa-save-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #5b53ea 0%, #4c43d5 100%);
    box-shadow: 0 10px 22px rgba(79, 70, 229, .24);
}

.qa-save-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.qa-save-btn:disabled {
    opacity: .58;
    cursor: default;
}

.qa-save-btn:focus-visible {
    outline: 2px solid rgba(79, 70, 229, .45);
    outline-offset: 2px;
}

.qa-save-btn--dirty {
    border-color: #16a34a;
    background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
    box-shadow: 0 8px 18px rgba(22, 163, 74, .20);
}

.qa-save-btn--dirty:hover:not(:disabled) {
    background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 10px 22px rgba(22, 163, 74, .26);
}

.qa-undo-btn {
    background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
    border: 1px solid var(--c-border);
    color: var(--c-text);
    border-radius: 9px;
    padding: .42rem .9rem;
    min-height: 2.1rem;
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .01em;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    transition: border-color .15s, color .15s, background .15s, box-shadow .15s, transform .05s;
}

.qa-undo-btn:hover:not(:disabled) {
    border-color: rgba(79, 70, 229, .45);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .10);
}

.qa-undo-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.qa-undo-btn:disabled {
    opacity: .58;
    cursor: default;
}

.qa-undo-btn:focus-visible {
    outline: 2px solid rgba(79, 70, 229, .45);
    outline-offset: 2px;
}

.qa-save-status {
    font-size: .8rem;
    color: var(--c-muted);
    text-align: center;
    min-height: 1.1em;
    margin-top: .15rem;
}

.qa-skip {
    font-size: .85rem;
    color: var(--c-subtle);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}
.qa-skip:hover { color: var(--c-muted); }

/* ── Outline step ────────────────────────────────────────────────────────── */

.outline-step-topbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .45rem 1.1rem;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface);
    min-height: 0;
}

.outline-step-label {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--c-muted);
}

.outline-two-col {
    display: grid;
    grid-template-columns: 240px 1fr;
    height: calc(100vh - var(--header-h) - var(--steps-row-h) - var(--footer-h) - 64px);
    min-height: 320px;
    overflow: hidden;
}

/* ── Persistent step actions (Steps 3/4) ───────────────────────────────── */
.step-action-shell {
    position: sticky;
    top: 0;
    z-index: 8;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    padding: .75rem 1rem;
}

.step-action-bar {
    display: flex;
    gap: .6rem;
    align-items: center;
}

.step-run-card {
    margin-top: .55rem;
    padding: .45rem .65rem;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    display: flex;
    gap: .6rem;
    align-items: center;
    flex-wrap: wrap;
    background: var(--c-surface);
}

.step-run-badge {
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: .15rem .45rem;
    border-radius: 999px;
    border: 1px solid currentColor;
}

.step-run-msg {
    font-size: .82rem;
    color: var(--c-muted);
    min-width: 0;
}

.step-run-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
}

.step-run-action-btn {
    font-size: .76rem !important;
    padding: .3rem .62rem !important;
    line-height: 1.1;
}

.step-run-hint {
    font-size: .76rem;
    color: var(--c-muted);
    white-space: nowrap;
}

.step-run-card--idle .step-run-badge {
    color: var(--c-muted);
}
.step-run-card--running .step-run-badge {
    color: var(--c-primary);
}
.step-run-card--success .step-run-badge {
    color: var(--c-success);
}
.step-run-card--error .step-run-badge {
    color: var(--c-danger);
}
.step-run-card--stopped .step-run-badge {
    color: #b45309;
}

@media (max-width: 680px) {
    .outline-two-col {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.outline-left-col {
    border-right: 1px solid var(--c-border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--c-surface);
}

.outline-left-col .chapter-list {
    padding: .15rem .35rem;
    gap: .1rem;
}

.outline-right-col {
    overflow: hidden;
    background: var(--c-bg);
    display: flex;
    flex-direction: column;
}

.outline-right-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 2rem;
    color: var(--c-muted);
    font-size: .92rem;
    flex: 1;
}

/* ── Generate step right-panel actions block ────────────────────────────── */
.generate-actions-panel {
    padding: 2rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.generate-actions-panel .btn-xl {
    align-self: stretch;
}

/* ── Chapter brief panel ────────────────────────────────────────────────── */
.chapter-brief-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 1.8rem 2rem 2rem;
}

.chapter-brief-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ── Editable brief fields ─────────────────────────────────────────────── */
.brief-edit-title-wrap {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    margin-bottom: 1.1rem;
}

.brief-edit-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--c-text);
    line-height: 1.3;
    flex: 1;
    outline: none;
    border-bottom: 2px dashed var(--c-border);
    padding-bottom: .15rem;
    transition: border-color .15s;
    cursor: text;
}
.brief-edit-title:focus { border-bottom-color: var(--c-primary); }
.brief-edit-title:not(:focus):empty:before {
    content: attr(data-placeholder);
    color: #bbb;
    pointer-events: none;
}

.brief-title-pencil {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: var(--c-muted);
    opacity: .55;
    pointer-events: none;
    margin-bottom: 1px;
}

.brief-save-status {
    font-size: .75rem;
    color: var(--c-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

.brief-edit-section {
    margin-bottom: 1.1rem;
}

.brief-edit-body {
    font-size: .95rem;
    line-height: 1.75;
    color: var(--c-text);
    outline: none;
    border: 1.5px solid var(--c-border);
    border-radius: 6px;
    padding: .35rem .5rem;
    margin-top: .25rem;
    transition: border-color .15s, background .15s;
    min-height: 2.5em;
    white-space: pre-wrap;
    word-break: break-word;
    background: #fff;
    cursor: text;
}
.brief-edit-body:focus {
    border-color: var(--c-primary);
    background: rgba(79,70,229,.03);
}
.brief-edit-body:not(:focus):empty:before {
    content: attr(data-placeholder);
    color: #bbb;
    pointer-events: none;
    display: block;
}

.chapter-brief-body {
    font-size: .95rem;
    line-height: 1.75;
    color: var(--c-text);
    white-space: pre-wrap;
}

.brief-section-heading {
    font-size: .8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--c-primary);
    margin: 1.1rem 0 .15rem;
    padding: 0;
}

.brief-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--c-text);
}

.chapter-brief-body br + br {
    display: block;
    content: '';
    margin-top: .35rem;
}

.chapter-brief-actions {
    margin-top: 1.2rem;
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Chapter draft panel ────────────────────────────────────────────────── */
.chapter-draft-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 1.4rem 2rem 2rem;
}

.chapter-draft-header {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.chapter-draft-header .btn-draft-narrate {
    margin-left: auto;
}

.chapter-draft-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--c-muted);
}

.chapter-draft-meta {
    font-size: .78rem;
    color: var(--c-muted);
}

.chapter-draft-tools {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.draft-tool-btn {
    width: 1.9rem;
    height: 1.9rem;
    border: 1px solid var(--c-border);
    border-radius: 7px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: var(--c-text);
    font-size: .92rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.draft-tool-btn--text {
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .02em;
}

.draft-tool-btn:hover {
    border-color: rgba(79, 70, 229, .45);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .10);
    background: #fff;
}

.draft-tool-btn:focus-visible {
    outline: 2px solid rgba(79, 70, 229, .45);
    outline-offset: 2px;
}

.chapter-draft-body {
    font-size: .95rem;
    line-height: 1.8;
    color: var(--c-text);
    white-space: pre-wrap;
    flex: 1;
    outline: none;
}

.chapter-draft-body:focus {
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .28);
    border-radius: 8px;
}

.draft-comment {
    background: #fff4bf;
    border-bottom: 2px dotted #f59e0b;
    padding: 0 .08em;
}

.draft-comment-popover {
    position: fixed;
    z-index: 1400;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .22);
    padding: .3rem;
    display: inline-flex;
    gap: .25rem;
}

.draft-comment-popover-btn {
    border: 1px solid var(--c-border);
    background: #fff;
    color: var(--c-text);
    border-radius: 6px;
    font-size: .74rem;
    font-weight: 700;
    padding: .2rem .5rem;
    cursor: pointer;
}

.draft-comment-popover-btn:hover {
    border-color: rgba(79, 70, 229, .45);
    color: var(--c-primary);
}

.draft-comment-popover-btn--danger:hover {
    border-color: rgba(220, 38, 38, .45);
    color: #b91c1c;
}

.chapter-draft-body--rendered {
    white-space: normal;
}

.chapter-draft-body--rendered h1,
.chapter-draft-body--rendered h2,
.chapter-draft-body--rendered h3 {
    font-weight: 700;
    margin: 1.25rem 0 .5rem;
    line-height: 1.3;
}
.chapter-draft-body--rendered h1 { font-size: 1.2rem; }
.chapter-draft-body--rendered h2 { font-size: 1.05rem; }
.chapter-draft-body--rendered h3 { font-size: .97rem; }
.chapter-draft-body--rendered p  { margin: 0 0 .9rem; }
.chapter-draft-body--rendered blockquote {
    border-left: 3px solid var(--c-border);
    margin: .75rem 0;
    padding: .25rem 0 .25rem 1rem;
    color: var(--c-muted);
    font-style: italic;
}
.chapter-draft-body--rendered hr { border: none; border-top: 1px solid var(--c-border); margin: 1rem 0; }
.chapter-draft-body--rendered .md-needs {
    background: #fef9c3;
    color: #854d0e;
    padding: .1em .35em;
    border-radius: 4px;
    font-size: .88em;
    font-style: normal;
}

.chapter-draft-body--rendered .narration-active-block {
    transition: background-color .2s ease;
    background: rgba(251, 191, 36, .28);
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(251, 191, 36, .22);
}

.outline-qa-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.2rem 1.5rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.outline-qa-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .4rem;
    min-width: 0;
    overflow: visible;
}

.outline-qa-header .qa-progress {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.outline-qa-chapter-label {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--c-primary);
}

.outline-qa-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: .75rem;
    gap: .5rem;
}

.outline-qa-btn {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--c-primary) !important;
    padding: 0 !important;
    font-size: .92rem !important;
    font-weight: 700 !important;
    cursor: pointer;
}
.outline-qa-btn:hover { text-decoration: underline; }

.outline-qa-save-status {
    font-size: .8rem;
    color: var(--c-muted);
    min-height: 1.2em;
}

/* Chapter cards – compact single-row style for left col */
.chapter-list { display: flex; flex-direction: column; gap: .1rem; }

.chapter-card,
.assignment-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: .05rem .35rem;
    display: flex;
    gap: .2rem;
    align-items: center;
    min-height: 24px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}

/* Keep Step 2 assignment cards aligned even when only some have delete icons. */
.assignment-card {
    position: relative;
    padding-right: 1.35rem;
}

.assignment-card-remove {
    position: absolute;
    right: .18rem;
    bottom: .08rem;
    font-size: .64rem;
    line-height: 1;
    padding: .05rem .15rem;
    background: transparent;
    color: var(--c-muted);
    border: none;
    cursor: pointer;
}

.assignment-card-remove:hover {
    color: var(--c-danger);
}

.assignment-additional-actions {
    display: flex;
    justify-content: center;
    margin-top: .55rem;
}

.assignment-additional-btn {
    font-size: .72rem;
    padding: .26rem .6rem;
    line-height: 1.1;
}

.chapter-card:hover,
.assignment-card:hover {
    border-color: var(--c-primary);
    box-shadow: var(--shadow);
}

.chapter-card--active,
.assignment-card--active {
    border-color: var(--c-primary);
    background: rgba(79,70,229,.07);
    box-shadow: 0 0 0 2px rgba(79,70,229,.15);
}

.chapter-num {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(79,70,229,.1);
    color: var(--c-primary);
    font-size: .56rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chapter-num--started {
    background: #2563eb;
    color: #fff;
}

.chapter-num--complete {
    background: #16a34a;
    color: #fff;
}

.chapter-body {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.chapter-title {
    font-size: .72rem;
    font-weight: 700;
    color: var(--c-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    margin-bottom: 0;
}

.chapter-desc { display: none; }

.chapter-card-arrow,
.assignment-card-arrow {
    font-size: .95rem;
    color: var(--c-muted);
    flex-shrink: 0;
}

.assignment-card-arrow {
    margin-right: .75rem;
}

.chapter-card--active .chapter-card-arrow,
.assignment-card--active .assignment-card-arrow {
    color: var(--c-primary);
}

.chapter-progress-txt,
.assignment-progress-txt {
    font-size: .58rem;
    color: var(--c-muted);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    padding-left: .2rem;
}

/* Chat below the two-col (normal width) */
/* ── Strategy carousel ──────────────────────────────────────────────────── */
.strategy-carousel {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    height: calc(100vh - var(--header-h) - var(--steps-row-h) - var(--footer-h) - 64px);
    min-height: 340px;
    box-sizing: border-box;
}

.strategy-carousel-header {
    flex-shrink: 0;
    margin-bottom: 1rem;
}

.strategy-carousel-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: stretch;
}

/* The card itself */
.strategy-card {
    flex: 1;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Arrow | content | arrow row inside the card */
.strategy-card-nav {
    flex: 1;
    display: flex;
    align-items: stretch;
    min-height: 0;
}

.strat-nav-btn {
    flex-shrink: 0;
    width: 3.2rem;
    height: 3.2rem;
    background: none;
    border: none;
    border-radius: 0;
    font-size: 0;
    color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.strat-nav-btn::before {
    content: '';
    display: block;
    width: 1.1rem;
    height: 1.1rem;
    border-top: 2px solid var(--c-muted);
    border-right: 2px solid var(--c-muted);
    transition: border-color .15s;
}

#strat-prev::before {
    transform: rotate(-135deg) translate(-1px, 1px);
}

#strat-next::before,
.strat-nav-btn--next::before {
    transform: rotate(45deg) translate(-1px, 1px);
}

.strat-nav-btn:hover:not(:disabled)::before {
    border-color: var(--c-accent);
}

.strat-nav-btn:disabled {
    opacity: .2;
    cursor: default;
}

/* prev/next flanking the dots */
.strat-nav-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.strategy-card-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.8rem 2rem 2rem;
}
.strat-counter {
    font-size: .78rem;
    color: var(--c-muted);
    margin: .1rem 0 .8rem;
}

.strategy-carousel-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 680px) {
    .strategy-carousel-cols {
        grid-template-columns: 1fr;
    }
}

.strategy-carousel-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    margin-top: .5rem;
}

.strat-dots {
    display: flex;
    gap: .4rem;
    align-items: center;
}

.strat-dot {
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    background: var(--c-muted);
    opacity: .3;
    cursor: pointer;
    transition: opacity .15s, background .15s;
    flex-shrink: 0;
}

.strat-dot--active {
    background: #22c55e;
    opacity: 1;
}

/* ── Outline strategy header ─────────────────────────────────────────────── */
.outline-strategy-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .2rem;
    padding: 1rem 1.25rem .85rem;
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}

.outline-strategy-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--c-muted);
}

.outline-strategy-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--c-text);
    line-height: 1.25;
}

.outline-strategy-change-btn {
    font-size: .78rem;
    padding: .25rem .7rem;
    margin-top: .35rem;
}

.strategy-preview-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--c-muted);
    margin: 0 0 .3rem;
}

.strategy-preview-title {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0 0 .4rem;
    color: var(--c-text);
}

.strategy-preview-desc {
    font-size: .9rem;
    color: var(--c-muted);
    line-height: 1.6;
    margin: 0 0 1.3rem;
}

.strategy-preview-chapters h4,
.strategy-carousel-cols h4 {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--c-muted);
    margin: 0 0 .5rem;
}

.strategy-preview-chapters {
    margin-bottom: 1.3rem;
}

.strategy-ch-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.strategy-ch-list li {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: .9rem;
    line-height: 1.5;
    color: var(--c-text);
}

.strat-ch-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--c-muted);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.strategy-plan-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .4rem;
}

.strategy-plan-tag {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    color: var(--c-text);
    font-size: .78rem;
    padding: .2rem .6rem;
    border-radius: 20px;
}

.strategy-change-btn {
    background: none;
    border: none;
    padding: .25rem .3rem;
    font-size: .75rem;
    color: var(--c-muted);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: color .15s, text-decoration-color .15s;
}

.strategy-change-btn:hover {
    color: var(--c-accent);
    text-decoration-color: var(--c-accent);
}

.outline-book-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: .25rem;
    color: var(--c-text);
}

.outline-subtitle {
    font-size: .95rem;
    color: var(--c-muted);
    margin-bottom: 1.25rem;
}

.outline-title-card {
    margin-bottom: 1rem;
    padding: .9rem 1.1rem .7rem;
}

/* ── Generate step ────────────────────────────────────────────────────────── */
.generate-note {
    width: 100%;
    min-height: 120px;
    padding: 1rem 1.2rem;
    border: 2px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 1.05rem;
    font-family: inherit;
    color: var(--c-text);
    background: #fff;
    resize: none;
    margin-bottom: 1rem;
    transition: border-color .2s;
}

.generate-note:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

.generate-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ── Write My Book – chapter by chapter ─────────────────────────────────── */
.generate-chapters-section {
    margin-top: .5rem;
    margin-bottom: 2rem;
}

.generate-chapters-divider {
    text-align: center;
    margin: 0 0 1.25rem;
    color: var(--c-muted);
    font-size: .9rem;
    font-weight: 600;
    letter-spacing: .02em;
}

.generate-chapter-cols {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 55vh;
    min-height: 380px;
    overflow: hidden;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
}

@media (max-width: 680px) {
    .generate-chapter-cols {
        grid-template-columns: 1fr;
        height: auto;
    }
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem 1rem;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

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

.spinner-wrap p {
    font-size: 1rem;
    color: var(--c-muted);
}

/* ── Manuscript reader ────────────────────────────────────────────────────── */
.manuscript-ready {
    text-align: center;
    padding: 1rem 0 2rem;
}

.manuscript-ready .success-icon { font-size: 3rem; margin-bottom: .75rem; }
.manuscript-ready h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: .5rem; }
.manuscript-ready p  { color: var(--c-muted); margin-bottom: 1.5rem; }

.chapter-read-list { display: flex; flex-direction: column; gap: .6rem; text-align: left; }

.chapter-read-item {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: .85rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
}

.chapter-read-item:hover {
    border-color: var(--c-primary);
    box-shadow: var(--shadow);
}

.chapter-read-item .ch-num {
    font-size: .8rem;
    font-weight: 700;
    color: var(--c-muted);
    min-width: 28px;
}

.chapter-read-item .ch-title {
    flex: 1;
    font-weight: 600;
    font-size: .95rem;
}

.chapter-read-item .ch-arrow { color: var(--c-subtle); font-size: .85rem; }

/* Chapter reader overlay */
.chapter-reader {
    position: fixed;
    inset: 0;
    background: rgba(28,26,46,.5);
    backdrop-filter: blur(4px);
    z-index: 220;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.reader-box {
    background: #fff;
    border-radius: var(--radius-lg);
    max-width: 700px;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.reader-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.reader-header h3 { font-size: 1.05rem; font-weight: 700; }

.reader-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--c-muted);
    cursor: pointer;
    padding: .25rem .5rem;
    border-radius: 4px;
    line-height: 1;
}
.reader-close:hover { background: #f0ede8; }

.reader-body {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    flex: 1;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--c-text);
    word-break: break-word;
}

.reader-body h1 { font-size: 1.6rem; font-weight: 800; margin: 1.4rem 0 .6rem; }
.reader-body h2 { font-size: 1.25rem; font-weight: 700; margin: 1.2rem 0 .5rem; border-bottom: 1px solid var(--c-border); padding-bottom: .25rem; }
.reader-body h3 { font-size: 1.05rem; font-weight: 700; margin: 1rem 0 .4rem; }
.reader-body p  { margin: 0 0 1rem; }
.reader-body p.reader-paragraph-highlight {
    background: #fff3cd;
    border-left: 4px solid #f59e0b;
    padding: .35rem .55rem;
    border-radius: 6px;
    box-shadow: 0 0 0 1px rgba(245, 158, 11, .25) inset;
}
.reader-body blockquote {
    border-left: 3px solid var(--c-primary);
    margin: 1rem 0;
    padding: .5rem 1rem;
    background: #f5f3ef;
    color: var(--c-muted);
    font-style: italic;
}
.reader-body hr { border: none; border-top: 1px solid var(--c-border); margin: 1.5rem 0; }
.md-needs {
    background: #fff3cd;
    color: #856404;
    border-radius: 3px;
    padding: .1em .3em;
    font-size: .9em;
    font-style: italic;
}

/* ── Step nav footer ────────────────────────────────────────────────────── */
.step-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--footer-h);
    margin-top: 0;
    padding: .8rem 1rem;
    padding-left: 5.4rem;
    border-top: 1px solid var(--c-border);
    background: rgba(255,255,255,.93);
    backdrop-filter: blur(8px);
    flex-wrap: wrap;
    gap: 1rem;
}

/* ── Empty / waiting state ────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: .5rem; }
.empty-state p  { color: var(--c-muted); font-size: .95rem; max-width: 400px; margin: 0 auto; }

/* ── Alert / flash ────────────────────────────────────────────────────────── */
.alert {
    padding: .8rem 1.1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
}

.alert-success { background: rgba(5,150,105,.1); color: #065f46; border: 1px solid rgba(5,150,105,.25); }
.alert-error   { background: rgba(220,38,38,.09); color: #991b1b; border: 1px solid rgba(220,38,38,.2); }
.alert-info    { background: rgba(79,70,229,.08); color: #3730a3; border: 1px solid rgba(79,70,229,.2); }

/* ── Auth / login page ────────────────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: var(--c-bg);
}

.auth-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 2.75rem 2.25rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--c-primary);
    letter-spacing: -.5px;
    margin-bottom: .2rem;
}

.auth-sub {
    font-size: .85rem;
    color: var(--c-muted);
    margin-bottom: 2.25rem;
}

.auth-field {
    width: 100%;
    padding: .85rem 1rem;
    border: 2px solid var(--c-border);
    border-radius: var(--radius);
    background: #fafaf8;
    color: var(--c-text);
    font-size: 1rem;
    margin-bottom: .85rem;
    transition: border-color .2s;
}

.auth-field:focus {
    outline: none;
    border-color: var(--c-primary);
    background: #fff;
}

.auth-card .btn { width: 100%; }

.auth-error {
    color: var(--c-danger);
    font-size: .85rem;
    margin-top: .5rem;
    min-height: 1.2em;
}

.auth-sent-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.auth-sent p    { color: var(--c-muted); font-size: .92rem; line-height: 1.6; margin-bottom: .75rem; }
.auth-sent strong { color: var(--c-text); }

.my-desk-panel {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--header-h);
    bottom: 0;
    width: 100vw;
    height: calc(100vh - var(--header-h));
    background: #e8dcc0;
    border: none;
    border-radius: 0;
    box-shadow: var(--shadow-lg);
    z-index: 130;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.my-desk-head {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .95rem 1.1rem;
    border-bottom: 1px solid var(--c-border);
    background: #ddd0b5;
    position: relative;
}

.my-desk-head h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--c-text);
    text-align: center;
    flex: 1;
}

.my-desk-head-actions {
    position: absolute;
    right: 1.1rem;
    display: flex;
    align-items: center;
    gap: .35rem;
}

.my-desk-actions-row {
    display: flex;
    gap: .55rem;
    padding: 0 .45rem;
}

.my-desk-action-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: .7rem .5rem;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.my-desk-action-card:hover {
    border-color: var(--c-primary);
    box-shadow: var(--shadow);
}
.my-desk-action-icon { font-size: 1.5rem; line-height: 1; }
.my-desk-action-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--c-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.my-desk-body {
    flex: 1;
    display: grid;
    grid-template-columns: 360px 1fr;
    min-height: 0;
}

.my-desk-list-wrap {
    border-right: 1px solid var(--c-border);
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.my-desk-editor-wrap {
    padding: .85rem;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.my-desk-editor-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    padding: .9rem;
}

.my-desk-editor-card .auth-field {
    margin-bottom: 0;
}

.my-desk-editor-card .qa-answer-area {
    min-height: 220px;
    flex: 1;
    margin: 0;
}

.my-desk-sub {
    font-size: .78rem;
    color: var(--c-muted);
    margin: .65rem .8rem;
    letter-spacing: .03em;
    text-transform: uppercase;
    font-weight: 600;
}

.my-desk-list {
    overflow-y: auto;
    padding: 0 .45rem .45rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.my-desk-item {
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: #fff;
    padding: .45rem .6rem;
    cursor: pointer;
}

.my-desk-item:hover {
    border-color: var(--c-primary);
    box-shadow: var(--shadow);
}

.my-desk-item--new {
    border-style: dashed;
}

.my-desk-item.active {
    border-color: var(--c-primary);
    background: rgba(79,70,229,.08);
}

.my-desk-item.hidden-item {
    opacity: .72;
}

.my-desk-hidden-folder {
    margin-top: .35rem;
    border: 1px dashed var(--c-border);
    border-radius: 10px;
    background: #f8f7f3;
    padding: .45rem;
}

.my-desk-hidden-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .15rem .25rem .45rem;
}

.my-desk-hidden-title {
    font-size: .78rem;
    font-weight: 700;
    color: var(--c-muted);
}

.my-desk-hidden-list {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.doc-row-top {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .1rem;
    min-width: 0;
}

.doc-kind-badge {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #3f3f46;
    background: #eceff3;
    border-radius: 999px;
    padding: .12rem .45rem;
}

.doc-title {
    font-size: .83rem;
    font-weight: 700;
    color: var(--c-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.doc-visibility-toggle {
    margin-left: auto;
    font-size: .72rem;
    color: var(--c-primary);
    text-decoration: underline;
    flex-shrink: 0;
}

.doc-preview {
    font-size: .75rem;
    color: var(--c-muted);
    line-height: 1.35;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.doc-meta {
    font-size: .69rem;
    color: var(--c-subtle);
    line-height: 1.25;
    margin-bottom: .15rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.doc-meta-link-row {
    display: flex;
    justify-content: flex-end;
    margin-top: -.35rem;
}

.doc-meta-link {
    font-size: .74rem;
    color: var(--c-primary);
    text-decoration: underline;
    cursor: pointer;
}

/* ── View toggle (Original / Analyzed) ─────────────────────────────────── */
.view-toggle-group {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .3rem;
    margin-left: auto;
    flex-shrink: 0;
}

.view-toggle {
    display: inline-flex;
    align-items: center;
    background: #e4e4e8;
    border: 1px solid #c8c8d0;
    border-radius: 6px;
    overflow: hidden;
    height: 26px;
    flex-shrink: 0;
}

.view-toggle__btn {
    display: inline-block;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0 .75rem;
    font-size: .75rem;
    line-height: 26px;
    height: 26px;
    cursor: pointer;
    color: #888;
    font-weight: 500;
    white-space: nowrap;
    transition: background .12s, color .12s;
}

.view-toggle__btn--active {
    background: #fff;
    color: #1a1a2e;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px #c0c0c8;
    border-radius: 5px;
}

.view-toggle__btn:not(.view-toggle__btn--active):hover {
    color: #444;
    background: rgba(0,0,0,.06);
}

.doc-analysis-overlay {
    display: none;
    background: #fff;
    border: 1px solid var(--c-border, #ddd);
    border-radius: 8px;
    overflow-y: auto;
    font-size: .82rem;
    color: var(--c-text);
    line-height: 1.5;
}

.doc-analysis-overlay.visible {
    display: block;
}

/* ── Spreadsheet-style analysis layout ───────────────────────────────────── */
.ana-meta {
    font-size: .72rem;
    color: var(--c-muted);
    padding: .45rem .65rem .25rem;
    border-bottom: 1px solid var(--c-border, #e8e8ee);
}

.ana-section {
    border-bottom: 1px solid var(--c-border, #e8e8ee);
}

.ana-section:last-child {
    border-bottom: none;
}

.ana-section-head {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--c-muted);
    padding: .35rem .65rem .2rem;
    background: #f6f6f9;
    border-bottom: 1px solid var(--c-border, #e8e8ee);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.ana-table {
    width: 100%;
    border-collapse: collapse;
}

.ana-table tr {
    border-bottom: 1px solid #ebebf0;
}

.ana-table tr:last-child {
    border-bottom: none;
}

.ana-table td,
.ana-table th {
    padding: .3rem .65rem;
    font-size: .8rem;
    line-height: 1.45;
    vertical-align: top;
    text-align: left;
}

.ana-table th {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--c-muted);
    background: #fafafe;
    border-bottom: 1px solid var(--c-border, #e8e8ee);
    padding: .25rem .65rem;
}

.ana-row-num {
    color: var(--c-muted);
    font-size: .72rem;
    width: 1.6rem;
    min-width: 1.6rem;
    text-align: right;
    padding-right: .5rem;
    user-select: none;
}

.ana-table--two-col td:first-child {
    width: 55%;
    border-right: 1px solid #ebebf0;
}

.ana-gap {
    color: #c0392b;
    font-size: .78rem;
}

.ana-prose {
    padding: .4rem .65rem;
    font-size: .8rem;
    line-height: 1.5;
    color: var(--c-text);
    white-space: pre-wrap;
}

.doc-meta-structured {
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: #fff;
    padding: .55rem .7rem;
    margin-top: .25rem;
    max-height: 180px;
    overflow-y: auto;
}

.doc-meta-grid {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.doc-meta-row {
    display: grid;
    grid-template-columns: minmax(110px, 170px) 1fr;
    gap: .45rem;
    align-items: start;
}

.doc-meta-key {
    font-size: .7rem;
    color: var(--c-subtle);
    text-transform: uppercase;
    letter-spacing: .03em;
    font-weight: 700;
}

.doc-meta-val {
    font-size: .78rem;
    color: var(--c-text);
    line-height: 1.35;
    word-break: break-word;
    white-space: pre-wrap;
}

.doc-meta-empty {
    font-size: .78rem;
    color: var(--c-muted);
}

.doc-analysis-summary {
    font-size: .76rem;
    color: var(--c-muted);
    margin-bottom: .45rem;
}

.doc-meta-section {
    margin-bottom: .55rem;
}

.doc-meta-heading {
    font-size: .72rem;
    color: var(--c-text);
    font-weight: 700;
    margin-bottom: .18rem;
}

.doc-meta-bullets {
    margin: 0;
    padding-left: 1.1rem;
}

.doc-meta-bullets li {
    font-size: .78rem;
    line-height: 1.35;
    color: var(--c-text);
    margin: .1rem 0;
}

.doc-meta-subline {
    margin-top: .2rem;
    font-size: .74rem;
    color: var(--c-muted);
}

.my-desk-empty {
    margin: auto;
    color: var(--c-muted);
    font-size: .9rem;
}

.my-desk-empty.book-audit-host {
    margin: 0;
    width: 100%;
    height: 100%;
    color: inherit;
    font-size: inherit;
}

.book-audit-report-host {
    width: 100%;
    height: 100%;
    overflow: auto;
}

.book-audit-report {
    height: 100%;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: .95rem;
}

.audit-loading,
.audit-empty {
    border: 1px dashed var(--c-border);
    border-radius: 10px;
    background: #fcfbf7;
    color: var(--c-muted);
    text-align: center;
    padding: 1rem;
}

.audit-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .9rem;
    margin-bottom: .7rem;
}

.audit-eyebrow {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    color: var(--c-primary);
}

.audit-hero h2 {
    font-size: 1.2rem;
    font-weight: 800;
    margin: .1rem 0 .2rem;
}

.audit-sub {
    color: var(--c-muted);
    font-size: .84rem;
    max-width: 58ch;
}

.audit-hero-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(74px, 1fr));
    gap: .45rem;
}

.audit-hero-meta > div {
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: #faf9f6;
    padding: .35rem .45rem;
    text-align: center;
}

.audit-hero-meta strong {
    display: block;
    font-size: 1rem;
    line-height: 1.05;
}

.audit-hero-meta span {
    display: block;
    font-size: .67rem;
    color: var(--c-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.audit-meta-line {
    font-size: .72rem;
    color: var(--c-muted);
    margin-bottom: .55rem;
}

.audit-section {
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: #fff;
    padding: .65rem;
    margin-bottom: .65rem;
}

.audit-section h3 {
    font-size: .86rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--c-muted);
    margin-bottom: .5rem;
}

.audit-issues-grid {
    display: grid;
    gap: .55rem;
}

.audit-issue-card {
    border: 1px solid var(--c-border);
    border-radius: 10px;
    background: #faf9f6;
    padding: .55rem .6rem;
}

.audit-issue-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .3rem;
}

.audit-cat {
    font-size: .67rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--c-muted);
    font-weight: 700;
}

.audit-issue-card h4 {
    font-size: .9rem;
    margin-bottom: .2rem;
}

.audit-issue-card p,
.audit-fix,
.audit-ref {
    font-size: .78rem;
    color: var(--c-text);
    line-height: 1.45;
    margin-bottom: .25rem;
}

.audit-ref {
    color: var(--c-muted);
}

.audit-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: .3rem;
}

.audit-nav-btn {
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: #fff;
    color: var(--c-primary);
    padding: .28rem .5rem;
    font-size: .72rem;
    font-weight: 700;
    cursor: pointer;
}

.audit-nav-btn:hover {
    border-color: var(--c-primary);
}

.audit-ref-link {
    border: none;
    background: transparent;
    color: var(--c-primary);
    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}

.audit-ref-link:hover {
    color: var(--c-primary-h);
}

.audit-table-wrap {
    overflow: auto;
}

.audit-table {
    width: 100%;
    border-collapse: collapse;
}

.audit-table th,
.audit-table td {
    border-bottom: 1px solid #ebe7de;
    text-align: left;
    vertical-align: top;
    font-size: .76rem;
    line-height: 1.4;
    padding: .36rem .42rem;
}

.audit-table th {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--c-muted);
    background: #f8f7f3;
}

.audit-sev {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .04em;
    border-radius: 999px;
    padding: .16rem .42rem;
    border: 1px solid transparent;
}

.audit-sev--critical {
    background: #fee2e2;
    color: #7f1d1d;
    border-color: #fecaca;
}

.audit-sev--high {
    background: #ffedd5;
    color: #9a3412;
    border-color: #fed7aa;
}

.audit-sev--medium {
    background: #fef9c3;
    color: #854d0e;
    border-color: #fde68a;
}

.audit-sev--low {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.my-desk-coming-soon {
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.my-desk-coming-soon-inner {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
}

.my-desk-coming-soon-icon {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: .25rem;
}

.my-desk-coming-soon-inner h3 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--c-text);
    margin: 0;
}

.my-desk-coming-soon-inner p {
    font-size: .88rem;
    color: var(--c-muted);
    margin: 0;
}

@media (max-width: 900px) {
    .my-desk-body {
        grid-template-columns: 1fr;
        grid-template-rows: 46% 54%;
    }

    .my-desk-list-wrap {
        border-right: none;
        border-bottom: 1px solid var(--c-border);
    }

    .audit-hero {
        flex-direction: column;
    }

    .audit-hero-meta {
        width: 100%;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    :root { --footer-h: 74px; }

    .a-main { padding: 1.25rem 1rem; }
    .step-hero h1 { font-size: 1.6rem; }
    .qa-question { font-size: 1.35rem; }
    .btn-xl { min-width: 160px; padding: .9rem 1.75rem; font-size: 1.05rem; }
    .step-label { font-size: .65rem; }
    .a-topbar { padding: 0 1rem; }
    .topbar-working-title { display: none; }
    .steps-row { padding: 1rem .5rem; }

    .a-user-info {
        display: none;
    }
}

/* ── Text Dialog (general-purpose modal with full toolbar) ───────────────── */
.text-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.text-dialog {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    padding: 1.4rem 1.5rem 1.2rem;
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    gap: .85rem;
    max-height: 90vh;
    overflow-y: auto;
}

.text-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
}

.text-dialog-question {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--c-text);
    line-height: 1.4;
    flex: 1;
    margin: 0;
}

.text-dialog-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--c-muted);
    cursor: pointer;
    padding: 0 .2rem;
    flex-shrink: 0;
    margin-top: -.1rem;
}

.text-dialog-close:hover { color: var(--c-text); }

.text-dialog-sub {
    font-size: .8rem;
    color: var(--c-muted);
    margin-top: -.55rem;
}

.text-dialog .qa-answer-area {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    border: 1px solid var(--c-border);
    border-radius: 7px;
    padding: .65rem .75rem;
    font-size: .9rem;
    line-height: 1.6;
    font-family: inherit;
    background: var(--c-bg);
    color: var(--c-text);
    box-sizing: border-box;
}

.text-dialog .qa-answer-area:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 2px rgba(79,70,229,.12);
}

.text-dialog .textarea-tools-row {
    border-top: 1px solid var(--c-border);
    padding-top: .65rem;
    margin-top: .1rem;
}

/* ── Ana-gap action buttons ─────────────────────────────────────────────── */
.ana-gap-actions {
    display: flex;
    gap: .4rem;
    margin-top: .4rem;
}

.ana-gap-btn {
    font-size: .68rem;
    font-weight: 600;
    padding: .2rem .6rem;
    border-radius: 5px;
    border: 1px solid var(--c-border);
    cursor: pointer;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.5;
    transition: background .12s, border-color .12s;
}

.ana-gap-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.ana-gap-btn--answer { border-color: var(--c-primary); color: var(--c-primary); }
.ana-gap-btn--answer:hover { background: rgba(79,70,229,.07); }

.ana-gap-skipped {
    font-size: .73rem;
    color: var(--c-muted);
    font-style: italic;
    margin-top: .3rem;
}

.ana-gap-answered {
    font-size: .78rem;
    color: var(--c-text);
    background: rgba(79,70,229,.06);
    border-left: 2px solid var(--c-primary);
    padding: .3rem .55rem;
    border-radius: 0 4px 4px 0;
    margin-top: .35rem;
    line-height: 1.4;
}

.ana-unskip-btn {
    font-size: .68rem;
    font-weight: 600;
    padding: .15rem .55rem;
    border-radius: 5px;
    border: 1px solid var(--c-border);
    cursor: pointer;
    background: var(--c-bg);
    color: var(--c-muted);
    margin-left: auto;
    transition: border-color .12s, color .12s;
}
.ana-unskip-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
