/* ── 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;
    /* Default bar height; author.js sets the same token on <html> from measured .a-topbar when #app is visible */
    --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: 250;
    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: 260;
}

.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: minmax(268px, 22rem) minmax(0, 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;
    /* Below fixed .a-topbar (same inset as .a-wrap padding; --header-h synced from measured topbar in JS) */
    top: var(--header-h);
    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;
    }
}

/* Step 2 — chapter headings above assignment groups */
.assignment-chapter-group {
    margin-bottom: .48rem;
}

.sidelist-chapter-heading {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--c-muted);
    margin: 0 0 .2rem .06rem;
    line-height: 1.2;
}

.sidelist-card-stack {
    display: flex;
    flex-direction: column;
    gap: .22rem;
}

.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: .08rem .28rem .12rem;
    gap: .22rem;
}

.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 .md-needs-actions {
    display: inline-flex;
    gap: .25rem;
    margin-left: .35rem;
    vertical-align: middle;
}
.chapter-draft-body--rendered .md-needs-btn {
    border: 1px solid rgba(133, 77, 14, .25);
    background: rgba(255, 255, 255, .62);
    color: #854d0e;
    border-radius: 4px;
    font-size: .72rem;
    line-height: 1.2;
    padding: .08rem .33rem;
    cursor: pointer;
}
.chapter-draft-body--rendered .md-needs-btn--fix {
    font-weight: 700;
}
.chapter-draft-body--rendered .md-needs-btn--dismiss,
.chapter-draft-body--rendered .md-needs-btn--undo {
    opacity: .82;
}
.chapter-draft-body--rendered .md-needs-dismissed {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: rgba(133, 77, 14, .75);
    font-size: .82em;
    background: rgba(254, 249, 195, .45);
    border-radius: 4px;
    padding: .05em .3em;
}
.chapter-draft-body--rendered .md-needs-dismissed-label {
    opacity: .75;
}
.chapter-draft-body--rendered .md-needs-fixed-flag {
    display: inline-block;
    margin-left: .35rem;
    color: rgba(5, 150, 105, .82);
    font-size: .75em;
    border: 1px solid rgba(5, 150, 105, .22);
    border-radius: 4px;
    padding: .02em .28em;
    vertical-align: middle;
}

.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;
}

/* Left sidebar cards — shared base (My Assignments, Outline, Write) */
.chapter-list { display: flex; flex-direction: column; gap: .22rem; }

.chapter-card,
.assignment-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: .22rem .32rem .22rem .28rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .38rem;
    min-height: 2.35rem;
    box-sizing: border-box;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}

.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;
}

/* My Assignments — unassigned group: text pill instead of numbered badge */
.assignment-unassigned-pill {
    flex: 1;
    min-width: 0;
    align-self: center;
    border-radius: 999px;
    padding: .2rem .5rem;
    font-size: .58rem;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    color: var(--c-primary);
    background: rgba(79, 70, 229, 0.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

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

.chapter-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: .06rem;
}

.chapter-title {
    font-size: .74rem;
    font-weight: 700;
    color: var(--c-text);
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.15;
    margin-bottom: 0;
}

.chapter-meta {
    font-size: .58rem;
    color: var(--c-muted);
    line-height: 1.15;
}

/* Fixed-width column so progress (step 2) or action buttons (outline/write) never resize the card */
.sidelist-card-trail {
    flex: 0 0 5.35rem;
    width: 5.35rem;
    min-width: 5.35rem;
    max-width: 5.35rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    box-sizing: border-box;
}

.chapter-action-btn--sidelist {
    appearance: none;
    font-family: inherit;
    font-size: .56rem;
    font-weight: 700;
    line-height: 1.15;
    padding: .14rem .26rem;
    margin: 0;
    border: 1px solid rgba(79, 70, 229, 0.38);
    border-radius: 5px;
    background: rgba(79, 70, 229, 0.06);
    color: var(--c-primary);
    cursor: pointer;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-action-btn--sidelist:hover {
    background: rgba(79, 70, 229, 0.11);
}

.chapter-action-btn--sidelist:disabled {
    opacity: 0.65;
    cursor: default;
}

.chapter-card--active .chapter-action-btn--sidelist,
.assignment-card--active .chapter-action-btn--sidelist {
    border-color: rgba(79, 70, 229, 0.55);
}

.chapter-actions {
    display: flex;
    align-items: center;
    margin-top: .02rem;
}

.chapter-action-btn {
    font-size: .58rem;
    line-height: 1.1;
    padding: .16rem .4rem;
}

.chapter-desc { display: none; }

.chapter-card-arrow,
.assignment-card-arrow {
    font-size: .95rem;
    color: var(--c-muted);
    flex-shrink: 0;
    width: 1rem;
    text-align: center;
    line-height: 1;
}

.assignment-card-arrow {
    margin-right: 0;
}

.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: 600;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: right;
    width: 100%;
}

/* 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: auto;
    width: 100vw;
    height: calc(100vh - var(--header-h));
    background: #e8dcc0;
    border: none;
    border-radius: 0;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    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: grid;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    gap: .55rem;
    padding: 0 .45rem;
    width: 100%;
    box-sizing: border-box;
}

.my-desk-action-card {
    width: 100%;
    min-width: 0;
    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-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: .6rem;
}

.my-desk-settings-section-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: .28rem;
    padding: .95rem 1rem;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
    cursor: pointer;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}

.my-desk-settings-section-card:hover,
.my-desk-settings-section-card:focus-visible {
    border-color: var(--c-primary);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.my-desk-settings-section-title {
    font-size: .96rem;
    font-weight: 700;
    color: var(--c-text);
}

.my-desk-settings-section-desc {
    font-size: .82rem;
    color: var(--c-muted);
}

.my-desk-settings-section-cta {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-top: .35rem;
    font-size: .78rem;
    font-weight: 700;
    color: var(--c-primary);
    letter-spacing: .01em;
}

.my-desk-body {
    flex: 1;
    display: block;
    min-height: 0;
}

.my-desk-body.my-desk-body--workspace {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

/* Full workspace below app topbar (same for every Admin Desk tool) */
.my-desk-panel.my-desk-panel--workspace {
    top: var(--header-h);
    height: calc(100dvh - var(--header-h));
    bottom: auto;
    overflow: clip;
}

.my-desk-panel.my-desk-panel--workspace .my-desk-head {
    display: none;
}

.my-desk-body.my-desk-body--workspace .my-desk-list-wrap {
    display: none;
}

.my-desk-body.my-desk-body--workspace .my-desk-editor-wrap {
    display: flex;
    padding: 0;
    height: 100%;
    min-height: 0;
    overflow: clip;
}

.my-desk-panel.my-desk-panel--workspace .my-desk-body {
    height: 100%;
    min-height: 0;
    overflow: clip;
}

/* Admin Desk workspace content — full bleed column under topbar */
.desk-workspace-shell {
    flex: 1;
    min-width: 0;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    background: var(--c-surface);
    overflow: hidden;
    border-radius: 0;
}
.desk-workspace-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
    padding: 0.45rem 0.75rem;
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface);
}
.desk-workspace-head .reader-close {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    min-width: 2.25rem;
    min-height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.desk-workspace-head h3 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--c-text);
}
.desk-workspace-intro {
    flex-shrink: 0;
    margin: 0;
    padding: 0.32rem 0.75rem;
    font-size: 0.74rem;
    color: var(--c-muted);
    line-height: 1.45;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-bg);
}
.desk-workspace-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0.45rem 0.75rem;
}
.desk-workspace-body--flush {
    padding: 0;
}
.desk-workspace-body--scroll {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.desk-workspace-foot {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    flex-wrap: wrap;
    padding: 0.4rem 0.75rem;
    border-top: 1px solid var(--c-border);
    background: var(--c-bg);
}
.desk-workspace-foot--spread {
    justify-content: space-between;
}
.desk-workspace-iframe-wrap {
    flex: 1;
    min-height: 0;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.desk-workspace-iframe-wrap iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    display: block;
}

.desk-workspace-status {
    font-size: 0.76rem;
    min-height: 1.1em;
    color: var(--c-muted);
}
.desk-workspace-foot--spread .desk-workspace-status {
    margin-right: auto;
}

.desk-workspace-shell--audit {
    min-height: 0;
}
.desk-workspace-shell--audit .book-audit-report-host {
    flex: 1;
    min-height: 0;
    min-width: 0;
}

.desk-print-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.desk-print-options {
    display: flex;
    flex-direction: column;
    gap: 0.38rem;
}
.desk-print-option {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
}
.desk-print-option input {
    margin: 0;
    flex-shrink: 0;
}
.desk-print-option strong {
    font-size: 0.8rem;
    color: var(--c-text);
}

.desk-ai-prompts-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
}
.desk-ai-prompts-iframe {
    flex: 1;
    min-height: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
}

.desk-users-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0.35rem;
    overflow: hidden;
}
/* Shared grid: last column is fixed width so separate grids (add row vs list rows)
   resolve fr tracks identically; `auto` per grid used different widths for button vs icon. */
.desk-users-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr 0.8fr 0.9fr minmax(5.5rem, 0.75fr) 7.75rem;
    gap: 0.32rem;
    align-items: center;
}
.desk-users-grid.desk-users-grid--add {
    flex-shrink: 0;
}

/* Reset global `.auth-field` / `.btn` inside user admin grids (login-sized fields
   and default button padding were winning over compact row styles). */
.desk-users-body .desk-users-grid .auth-field {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border-width: 1px !important;
    line-height: 1.2 !important;
}
.desk-users-body .desk-users-grid input.auth-field.desk-users-field-tight,
.desk-users-body .desk-users-grid select.auth-field.desk-users-field-tight {
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
}
.desk-users-body .desk-users-grid .btn.desk-users-add {
    margin: 0 !important;
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    line-height: 1.15 !important;
    font-size: 0.72rem !important;
    padding: 0 0.45rem !important;
    box-sizing: border-box !important;
    align-self: center;
}
.desk-users-body .desk-users-grid .btn.desk-users-delete-btn {
    margin: 0 !important;
    flex-shrink: 0;
    align-self: center;
}

.desk-users-field {
    font-size: 0.75rem !important;
    padding: 0.3rem 0.45rem !important;
    border-radius: 4px;
    height: 32px;
    box-sizing: border-box;
}
.desk-users-field-tight {
    font-size: 0.8rem !important;
    padding: 0.38rem 0.5rem !important;
    border-radius: 4px;
    height: 32px;
    box-sizing: border-box;
}
.desk-users-admin-cell {
    display: flex;
    align-items: center;
    align-self: center;
    min-height: 32px;
}
.desk-users-role.auth-field {
    margin-bottom: 0 !important;
    width: 100%;
    min-width: 0;
    cursor: pointer;
    line-height: 1.2;
}
select.desk-users-role.desk-users-field {
    padding: 0.28rem 0.4rem !important;
    font-size: 0.75rem !important;
}
select.desk-users-role.desk-users-field-tight {
    padding: 0.28rem 0.35rem !important;
    font-size: 0.78rem !important;
}
.desk-users-delete-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    align-self: center;
}
.desk-users-delete-btn {
    font-size: 1.05rem;
    line-height: 1;
    height: 32px;
    width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    color: var(--c-danger);
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 4px;
}
.desk-users-delete-btn:hover:not(:disabled) {
    background: rgba(220, 53, 69, 0.12);
}
.desk-users-add {
    font-size: 0.72rem !important;
    padding: 0 0.45rem !important;
    height: 32px;
    box-sizing: border-box;
    border-radius: 4px;
    align-self: center;
    width: 100%;
    min-width: 0;
    white-space: nowrap;
    line-height: 1.15 !important;
}
.desk-users-status {
    margin: 0 !important;
    flex-shrink: 0;
}
.desk-users-list {
    flex: 1;
    min-height: 0;
    overflow: auto;
    scrollbar-gutter: stable;
}
.desk-users-list-row {
    padding: 0.06rem 0;
}

.desk-settings-body-wrap {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
}
#my-desk-settings-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.4rem 0.75rem;
}

.desk-settings-subview {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 0.3rem;
}
.desk-settings-subview--iframe {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.desk-settings-subnav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    flex-shrink: 0;
}
.desk-settings-back {
    padding: 0.25rem 0.48rem !important;
    font-size: 0.76rem !important;
}
.desk-settings-subtitle {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--c-text);
}
.desk-settings-subnav-spacer {
    width: 64px;
    flex-shrink: 0;
}
.desk-settings-subcopy {
    margin: 0;
    font-size: 0.75rem;
    color: var(--c-muted);
}
.desk-strategy-list {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    padding-right: 0.15rem;
}
.desk-settings-iframe {
    flex: 1;
    min-height: 0;
}

.desk-app-requests-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    gap: 0.28rem;
}
.desk-app-requests-textarea {
    flex: 1;
    min-height: 160px;
    resize: vertical;
    margin: 0;
}
.desk-app-requests-tip {
    margin: 0;
    font-size: 0.66rem;
    color: var(--c-muted);
    flex-shrink: 0;
}
.desk-app-requests-attachment-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
    margin: 0.2rem 0 0;
}
.desk-app-requests-attachment-label .desk-workspace-field-label {
    margin: 0;
}
.desk-app-requests-attachment-label input[type="file"] {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.72rem;
    color: var(--c-muted);
}
.desk-app-requests-attachment-hint {
    margin: 0;
    font-size: 0.66rem;
    color: var(--c-muted);
    flex-shrink: 0;
}
.desk-app-requests-attachment-summary {
    margin: 0;
    font-size: 0.7rem;
    color: var(--c-text);
    flex-shrink: 0;
}
.desk-workspace-field-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--c-muted);
    flex-shrink: 0;
}

.desk-revisions-main {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 0 !important;
}
.desk-revisions-toolbar {
    display: flex;
    align-items: center;
    gap: 0.32rem;
    flex-wrap: wrap;
    flex-shrink: 0;
    padding: 0.15rem 0.75rem 0;
}
.desk-revisions-toolbar-btn {
    font-size: 0.72rem !important;
    padding: 0.25rem 0.48rem !important;
    min-height: 28px;
    line-height: 1.1;
    border-radius: 6px;
}
.desk-revisions-toolbar-status {
    font-size: 0.74rem;
    min-height: 1em;
    color: var(--c-muted);
    margin-left: auto;
}
.desk-revisions-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.2fr);
    gap: 0.45rem;
    flex: 1;
    min-height: 0;
    padding: 0 0.75rem 0.45rem;
    overflow: hidden;
}
.desk-revisions-list-pane {
    overflow: auto;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 0.35rem;
    background: #fff;
    min-height: 0;
}
.desk-revisions-preview-pane {
    overflow: hidden;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 0.4rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.desk-revisions-find-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.28rem;
    margin-bottom: 0.32rem;
    flex-shrink: 0;
}
.desk-revisions-find-input {
    max-width: 220px;
    height: 28px;
    font-size: 0.72rem !important;
    padding: 0.18rem 0.4rem !important;
    border-radius: 6px;
    margin-bottom: 0 !important;
}
.desk-revisions-find-btn {
    font-size: 0.68rem !important;
    padding: 0.2rem 0.42rem !important;
    min-height: 28px;
    line-height: 1.1;
    border-radius: 6px;
}
.desk-revisions-find-status {
    font-size: 0.68rem;
    color: var(--c-muted);
    min-height: 1em;
}
.desk-revisions-preview-inner {
    overflow: auto;
    flex: 1;
    min-height: 0;
    padding: 0.08rem;
}
.desk-revisions-preview-placeholder {
    color: var(--c-muted);
    font-size: 0.76rem;
    margin: 0;
}

.desk-revision-card {
    cursor: pointer;
}
.desk-revision-card--selected {
    box-shadow: inset 0 0 0 2px var(--c-primary);
    background: rgba(79, 70, 229, 0.08);
}
.book-revision-delete {
    border: none;
    background: transparent;
    padding: 0.1rem 0.22rem;
    margin: 0;
    line-height: 0;
    color: var(--c-danger);
    cursor: pointer;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.book-revision-delete svg {
    display: block;
}
.book-revision-delete:hover {
    background: rgba(220, 38, 38, 0.12);
}
.book-revision-delete:focus-visible {
    outline: 2px solid var(--c-danger);
    outline-offset: 2px;
}

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

.my-desk-editor-wrap {
    padding: .85rem;
    min-height: 0;
    display: none;
    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%;
    min-height: 0;
    display: flex;
    color: inherit;
    font-size: inherit;
}

/* Question Editor — full panel shell (fills workspace under topbar) */
.qe-panel-root {
    flex: 1;
    min-width: 0;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    background: var(--c-surface);
    overflow: hidden;
    border-radius: 0;
}
.qe-panel-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface);
}
.qe-panel-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: var(--c-text);
}
.qe-panel-intro {
    flex-shrink: 0;
    margin: 0;
    padding: 0.5rem 1rem 0.65rem;
    color: var(--c-muted);
    font-size: 0.82rem;
    line-height: 1.45;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-bg);
}
.qe-panel-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(420px, 1fr);
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    overflow: hidden;
    box-sizing: border-box;
}
.qe-panel-actions {
    flex-shrink: 0;
    display: flex;
    gap: 0.55rem;
    align-items: center;
    justify-content: flex-end;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--c-border);
    background: var(--c-bg);
}
.qe-panel-column {
    padding: 0.65rem 0.75rem !important;
    overflow: auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Question Editor — admin compact shell */
.qe-panel-root--compact .qe-panel-head {
    padding: 0.45rem 0.75rem;
    gap: 0.55rem;
}
.qe-panel-root--compact .qe-panel-head h3 {
    font-size: 1rem;
    font-weight: 800;
}
.qe-panel-root--compact .qe-panel-intro {
    font-size: 0.62rem;
    line-height: 1.35;
    padding: 0.22rem 0.55rem;
}
.qe-panel-grid--compact {
    gap: 0.38rem;
    padding: 0.38rem 0.55rem;
}
.qe-panel-grid--compact > .qe-panel-column {
    padding: 0.35rem 0.45rem !important;
}
.qe-panel-root--compact .qe-panel-actions {
    padding: 0.35rem 0.55rem;
    gap: 0.35rem;
}
.qe-panel-root--compact .qe-panel-actions .btn {
    padding: 0.28rem 0.65rem;
    font-size: 0.72rem;
}
.qe-panel-status {
    font-size: 0.65rem;
    min-height: 1em;
    color: var(--c-muted);
    margin-right: auto;
}

/* Question Editor — dense right column (admin) */
.qe-editor-right {
    font-size: 0.7rem;
    line-height: 1.32;
}
.qe-right-stack {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
}
.qe-right-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--c-muted);
    margin: 0.08rem 0 0;
    letter-spacing: 0.02em;
}
.qe-right-hint {
    font-size: 0.58rem;
    line-height: 1.35;
    color: var(--c-muted);
    margin: 0;
}
.qe-right-hint--tight {
    margin-top: 0.12rem;
}
.qe-editor-right .auth-field,
.qe-editor-right .qe-right-input,
.qe-editor-right .qe-right-select {
    font-size: 0.68rem !important;
    padding: 0.18rem 0.35rem !important;
    line-height: 1.32;
    border-radius: 5px;
    min-height: 0;
}
.qe-editor-right .qe-right-textarea,
.qe-editor-right .qa-answer-area {
    font-size: 0.68rem !important;
    padding: 0.2rem 0.35rem !important;
    line-height: 1.32;
    border-radius: 5px;
    min-height: 0;
}
.qe-right-divider {
    border: none;
    border-top: 1px solid var(--c-border);
    margin: 0.28rem 0;
}
.qe-right-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    margin-top: 0.05rem;
}
.qe-right-section-title {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--c-text);
}
.qe-right-btn-sm {
    padding: 0.12rem 0.38rem !important;
    font-size: 0.62rem !important;
    font-weight: 600;
    min-height: 0;
    border-radius: 5px;
}
.qe-question-list {
    display: grid;
    gap: 2px;
    margin-top: 0.12rem;
}
.qe-question-card {
    padding: 0.22rem 0.32rem !important;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
    background: #fefce8;
    border-color: rgba(234, 179, 8, 0.28);
}
.qe-question-main-row {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
}
.qe-question-main-row .qe-question-text {
    flex: 1;
    min-width: 0;
    align-self: stretch;
}
.qe-question-main-row .qe-question-text.qe-question-text--readonly {
    cursor: pointer;
    resize: none;
    background: rgba(255, 255, 255, 0.72);
}
.qe-question-main-row .qe-question-text.qe-question-text--readonly:focus {
    outline: 2px solid rgba(59, 130, 246, 0.35);
    outline-offset: 1px;
}
/* Auto-derived display number for each question (e.g. 1.1, 0.2). Not persisted —
   recomputed on every render from the question's index inside its chapter bucket. */
.qe-question-number {
    flex: 0 0 auto;
    align-self: flex-start;
    margin-top: 0.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.85rem;
    padding: 0.12rem 0.32rem;
    border-radius: 999px;
    background: rgba(234, 179, 8, 0.18);
    border: 1px solid rgba(234, 179, 8, 0.35);
    color: #92400e;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    user-select: none;
}
.qe-assignment-numbers {
    color: var(--c-primary, #6c63ff);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.qe-drag-cluster-inline {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    max-width: 5.5rem;
    min-width: 2.25rem;
    gap: 0.12rem !important;
    padding-top: 0.12rem;
}
.qe-question-main-row .qe-drag-hint-label {
    white-space: normal;
    text-align: center;
    font-size: 0.52rem;
    line-height: 1.15;
    max-width: 5rem;
}
.qe-editor-right .qe-drag-handle {
    font-size: 1.35rem;
    line-height: 1;
    padding: 0.14rem 0.2rem;
}
.qe-editor-right .qe-drag-hint-label {
    font-size: 0.58rem;
}
.qe-editor-right .qe-remove-question {
    min-width: 22px !important;
    min-height: 22px !important;
    padding: 0.06rem 0.2rem !important;
}
.qe-editor-right .qe-remove-question .fa-trash-can {
    font-size: 0.72rem;
}
.qe-question-main-row .qe-remove-question--in-row {
    flex: 0 0 auto;
    align-self: center;
    margin: 0;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}
.qe-question-main-row .qe-remove-question--in-row:hover:not(:disabled) {
    background: rgba(185, 28, 28, 0.1) !important;
}
.qe-example-toggle {
    display: flex;
    align-items: center;
    gap: 0.32rem;
    width: 100%;
    justify-content: flex-start;
    margin-top: 0.2rem;
    padding: 0.15rem 0.35rem !important;
    font-size: 0.62rem !important;
    font-weight: 600;
    color: var(--c-primary);
    border: 1px dashed var(--c-border);
    border-radius: 5px;
    text-align: left;
    cursor: pointer;
}
.qe-example-toggle--beside-text {
    width: auto;
    min-width: 5rem;
    max-width: 7.25rem;
    margin-top: 0;
    flex-direction: column;
    align-self: stretch;
    justify-content: center;
    text-align: center;
    gap: 0.18rem;
    padding: 0.22rem 0.28rem !important;
}
.qe-example-toggle--beside-text span {
    line-height: 1.15;
}
.qe-example-toggle .qe-example-chevron {
    font-size: 0.55rem;
    transition: transform 0.15s ease;
    width: 0.65rem;
    text-align: center;
}
.qe-example-toggle--open .qe-example-chevron {
    transform: rotate(90deg);
}
.qe-example-drawer {
    margin-top: 0.22rem;
    padding-top: 0.22rem;
    border-top: 1px dashed var(--c-border);
}
.qe-example-drawer.hidden {
    display: none !important;
}
.qe-example-drawer-hint {
    font-size: 0.58rem;
    color: var(--c-muted);
    margin: 0 0 0.18rem;
    line-height: 1.35;
}
.qe-example-tools {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.22rem;
}
.qe-example-append-label {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    font-size: 0.58rem;
    color: var(--c-muted);
}
.qe-editor-right .qe-example-status {
    font-size: 0.58rem;
    color: var(--c-muted);
    min-height: 1em;
}
.qe-right-empty {
    color: var(--c-muted);
    font-size: 0.65rem;
    margin: 0;
}

/* Question Editor — tighter left list in compact mode */
.qe-panel-grid--compact .qe-assignment-toolbar {
    margin-bottom: 0.28rem;
}
.qe-panel-grid--compact .qe-assignment-toolbar .btn {
    font-size: 0.62rem;
    padding: 0.22rem 0.4rem;
}
.qe-panel-grid--compact .qe-assignment-btn {
    padding: 0.28rem 0.38rem 0.25rem;
    gap: 0.12rem;
}
.qe-panel-grid--compact .qe-assignment-label {
    font-size: 0.68rem;
}
.qe-panel-grid--compact .qe-assignment-count {
    font-size: 0.58rem;
    padding-left: calc(1rem + 0.35rem);
}
.qe-panel-grid--compact .qe-assignment-index {
    width: 1rem;
    height: 1rem;
    font-size: 0.62rem;
}
.qe-panel-grid--compact .qe-assignment-row {
    margin: 0.08rem 0;
}

@media (max-width: 720px) {
    .qe-panel-grid {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(120px, 35vh) 1fr;
    }
}

/* Question Editor — reorder chapter questions (assignment block) */
.qe-question-row {
    position: relative;
}
.qe-drag-handle-cluster {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    max-width: 100%;
}
.qe-drag-hint-label {
    font-size: 0.72rem;
    line-height: 1.2;
    color: var(--c-muted);
    opacity: 0.75;
    white-space: nowrap;
}
.qe-drag-handle-cluster--hint-dismissed .qe-drag-hint-label {
    display: none;
}
.qe-drag-tooltip-pop {
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    z-index: 6;
    font-size: 0.72rem;
    line-height: 1.25;
    padding: 0.28rem 0.45rem;
    border-radius: 6px;
    background: var(--c-text, #1f2937);
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.17s ease;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
}
.qe-drag-handle-cluster--hint-dismissed:hover .qe-drag-tooltip-pop,
.qe-drag-handle-cluster--hint-dismissed:focus-within .qe-drag-tooltip-pop {
    opacity: 0.95;
}
.qe-drag-handle-cluster.qe-drag-tooltip--press .qe-drag-tooltip-pop {
    opacity: 0.95;
}
.qe-drag-handle {
    cursor: grab;
    flex-shrink: 0;
    user-select: none;
    font-size: 1rem;
    line-height: 1;
    color: var(--c-subtle);
    padding: .1rem .15rem;
    border-radius: 4px;
}
.qe-drag-handle:hover {
    color: var(--c-primary);
    background: rgba(79, 70, 229, 0.08);
}
.qe-drag-handle:active {
    cursor: grabbing;
}
.qe-question-row--dragging .qe-drag-handle {
    cursor: grabbing;
}
.qe-question-row--dragging > .card {
    opacity: 0.65;
    transform: scale(1.01);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.qe-question-row--drop-target > .card {
    outline: 2px dashed var(--c-primary);
    outline-offset: 2px;
    background: rgba(79, 70, 229, 0.04);
}

.qe-assignment-btn.qe-assignment-btn--drop-target {
    outline: 2px dashed var(--c-primary);
    outline-offset: 1px;
    background: rgba(79, 70, 229, 0.08);
}

.qe-assignment-btn {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    width: 100%;
    justify-content: flex-start;
    padding: 0.45rem 0.55rem 0.4rem;
    text-align: left;
}
.qe-assignment-btn-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
}
.qe-assignment-count {
    font-size: 0.7rem;
    color: var(--c-muted);
    line-height: 1.25;
    padding-left: calc(1.2rem + 0.5rem);
    padding-bottom: 0.05rem;
}
.qe-assignment-count--missing {
    color: #b45309;
    font-weight: 600;
}
.qe-assignment-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--c-primary-10, rgba(108, 99, 255, 0.18));
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}
.qe-assignment-index--empty {
    background: transparent;
}
.qe-assignment-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.qe-assignment-btn .qe-delete-assignment {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 0.2rem 0.35rem;
    border-radius: 6px;
    color: var(--c-danger, #b91c1c);
    cursor: pointer;
    line-height: 1;
}
.qe-assignment-btn .qe-delete-assignment:hover {
    background: rgba(185, 28, 28, 0.1);
}
.qe-assignment-btn .qe-delete-assignment:focus-visible {
    outline: 2px solid var(--c-danger, #b91c1c);
    outline-offset: 1px;
}
.qe-assignment-btn .qe-delete-assignment .fa-trash-can {
    font-size: 0.85rem;
}

.qe-remove-question {
    flex-shrink: 0;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.35rem !important;
    min-width: 28px;
    min-height: 28px;
    color: var(--c-danger, #b91c1c) !important;
    border-radius: 6px;
}
.qe-remove-question:hover {
    background: rgba(185, 28, 28, 0.1);
    color: var(--c-danger, #b91c1c) !important;
}
.qe-remove-question:focus-visible {
    outline: 2px solid var(--c-danger, #b91c1c);
    outline-offset: 1px;
}
.qe-remove-question .fa-trash-can {
    font-size: 0.85rem;
}

.qe-assignment-toolbar {
    margin-bottom: 0.45rem;
}
.qe-assignment-toolbar .btn {
    width: 100%;
    justify-content: center;
    font-size: 0.78rem;
    padding: 0.32rem 0.5rem;
}
.qe-assignment-row {
    margin: 0.15rem 0;
}

.book-audit-report-host {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.book-audit-frame {
    flex: 1;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.book-audit-actions {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .75rem .85rem;
    background: #f4ecd9;
    border-bottom: 1px solid var(--c-border);
}

.book-audit-actions-meta {
    font-size: .8rem;
    color: var(--c-muted);
}

.book-audit-close {
    margin-left: auto;
}

.book-audit-content {
    flex: 1;
    min-height: 0;
    overflow: visible;
    padding: .8rem;
}

.book-audit-report {
    height: auto;
    overflow: visible;
    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 {
        display: block;
    }

    .my-desk-body.my-desk-body--workspace {
        display: grid;
        grid-template-rows: 1fr;
    }

    .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); }
