/* Notebook cards (tab listing) */
.nb-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.nb-card:hover {
    background: var(--glass-bg);
}
.nb-card__icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.12);
    border-radius: 10px;
    color: var(--accent-primary, #818cf8);
}
.nb-card__body {
    flex: 1;
    min-width: 0;
}
.nb-card__title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nb-card__path {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nb-card__arrow {
    flex-shrink: 0;
    color: var(--text-dim);
}

/* Tab header extensions (back link, action link) */
.tab-header__back {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-primary, #818cf8);
    text-decoration: none;
}
.tab-header__back:hover {
    opacity: 0.8;
}
.tab-header__action {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-primary, #818cf8);
    text-decoration: none;
}
.tab-header__action:hover {
    opacity: 0.8;
}

/* Generate / create prompt bar */
.nb-generate {
    margin-bottom: 20px;
}
.nb-generate form {
    display: flex;
    gap: 8px;
}
.nb-generate__input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    background: var(--card-glass, rgba(255, 255, 255, 0.04));
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.nb-generate__input::placeholder {
    color: var(--text-muted);
}
.nb-generate__input:focus {
    border-color: var(--accent-primary, #818cf8);
}
.nb-generate__btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    background: var(--accent-primary, #818cf8);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}
.nb-generate__btn:hover {
    opacity: 0.85;
}

/* Run button — distinct from Create */
.nb-run__btn {
    padding: 10px 28px;
    border-radius: 10px;
    border: none;
    background: var(--color-primary, #1a5a94);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s, transform 0.15s;
}
.nb-run__btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Template gallery grid */
.nb-category {
    margin-bottom: 8px;
}
.nb-category__title,
.nb-section__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 24px 0 12px;
}
.nb-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.nb-template-card {
    display: block;
    padding: 16px;
    border-radius: 12px;
    background: var(--card-glass, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.15s;
}
.nb-template-card:hover {
    border-color: var(--accent-primary, #818cf8);
    transform: translateY(-2px);
}
/* Reports grid — icon cards for one-tap podcast generation */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 0 0 24px;
}
.report-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 12px 16px;
    border-radius: 14px;
    background: var(--card-glass, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    cursor: pointer;
    text-align: center;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
}
.report-card:hover {
    border-color: var(--color-primary, #1a5a94);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(26, 90, 148, 0.12);
}
.report-card:active {
    transform: translateY(0);
}
.report-card__icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--text-primary);
}
/* Icon color categories */
.report-card__icon--sunrise { background: rgba(251, 191, 36, 0.15); color: var(--color-warning); }
.report-card__icon--scale { background: rgba(99, 102, 241, 0.15); color: var(--purple); }
.report-card__icon--layers { background: rgba(168, 85, 247, 0.15); color: var(--pink); }
.report-card__icon--calculator { background: rgba(45, 106, 79, 0.15); color: var(--color-success); }
.report-card__icon--shield { background: rgba(192, 57, 43, 0.15); color: var(--color-error); }
.report-card__icon--database { background: rgba(6, 182, 212, 0.15); color: var(--teal); }
.report-card__icon--workflow { background: rgba(249, 115, 22, 0.15); color: var(--color-warning); }
.report-card__icon--file-text { background: rgba(99, 102, 241, 0.15); color: var(--purple); }
.report-card__icon--eye { background: rgba(236, 72, 153, 0.15); color: var(--pink); }
.report-card__icon--bar-chart { background: rgba(45, 106, 79, 0.15); color: var(--color-success); }
.report-card__icon--briefcase { background: rgba(168, 85, 247, 0.15); color: var(--pink); }
.report-card__icon--globe { background: rgba(59, 130, 246, 0.15); color: var(--cyan); }
.report-card__icon--users { background: rgba(251, 191, 36, 0.15); color: var(--color-warning); }

.report-card__body {
    flex: 1;
    min-width: 0;
}
.report-card__title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}
.report-card__desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.report-card__action {
    color: var(--color-primary, #1a5a94);
    opacity: 0;
    transition: opacity 0.15s;
}
.report-card:hover .report-card__action {
    opacity: 1;
}
/* Loading state */
.report-card__spinner {
    display: none;
    position: absolute;
    inset: 0;
    background: var(--surface-tabs);
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: var(--color-primary, #1a5a94);
}
.report-card--loading .report-card__spinner {
    display: flex;
}
.report-card--loading .report-card__spinner svg {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.nb-template-card__title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.nb-template-card__desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.nb-template-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.nb-template-card__tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary, #818cf8);
}

/* Template run form */
.nb-template-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}
.nb-template-form {
    margin-bottom: 24px;
}
.nb-template-form__field {
    margin-bottom: 14px;
}
.nb-template-form__field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.nb-template-form__hint {
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 6px;
}
.nb-template-form__input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    background: var(--card-glass, rgba(255, 255, 255, 0.04));
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.nb-template-form__input:focus {
    border-color: var(--accent-primary, #818cf8);
}

/* Template results */
.nb-template-results {
    margin-top: 20px;
}

/* Calc result blocks (returned by template runs) */
.calc-result {
    padding: 14px 16px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: var(--card-glass, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}
.calc-result__explanation {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 8px;
}
.calc-result__expr {
    display: block;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    overflow-x: auto;
}
.calc-result__value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.calc-result__value--rich {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    font-family: inherit;
}
.calc-result__value--rich p {
    margin: 0;
}
.calc-result__value--rich strong {
    color: var(--text-primary, #fff);
}
.calc-result__chart {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 8px;
}
.calc-result__error {
    font-size: 14px;
    color: var(--color-error-light);
    padding: 10px 14px;
    background: rgba(192, 57, 43, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(192, 57, 43, 0.15);
}

/* Notebook skeleton (ghost page) */
.nb-skeleton {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0;
}
.nb-skeleton__bar {
    border-radius: 8px;
    background: linear-gradient(90deg,
        var(--glass-bg) 25%,
        var(--glass-bg) 50%,
        var(--glass-bg) 75%
    );
    background-size: 200% 100%;
    animation: nb-shimmer 1.5s ease-in-out infinite;
}
.nb-skeleton__title {
    height: 1.8rem;
    width: 60%;
}
.nb-skeleton__subtitle {
    height: 1rem;
    width: 85%;
}
.nb-skeleton__section {
    height: 3.5rem;
    width: 100%;
    border-radius: 10px;
}
.nb-skeleton__block {
    height: 8rem;
    width: 100%;
    border-radius: 10px;
}
@keyframes nb-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.nb-skeleton--error .nb-skeleton__bar {
    animation: none;
    background: rgba(192, 57, 43, 0.08);
}
.nb-skeleton__error-msg {
    display: none;
    color: var(--color-error-light);
    font-size: 14px;
    padding: 12px 16px;
    background: rgba(192, 57, 43, 0.08);
    border: 1px solid rgba(192, 57, 43, 0.15);
    border-radius: 10px;
}
.nb-skeleton--error .nb-skeleton__error-msg {
    display: block;
}

/* Notebook view page */
.nb-view {
    max-width: 760px;
    margin: 0 auto;
    padding: 16px 16px 140px;
}
.nb-view__header {
    margin-bottom: 24px;
}
.nb-view__back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent-primary, #818cf8);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
}
.nb-view__back:hover {
    opacity: 0.8;
}
.nb-view__title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
    display: inline;
}
.nb-breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}
.nb-breadcrumb {
    font-size: 12px;
    color: var(--text-muted, rgba(255, 255, 255, 0.45));
    text-decoration: none;
}
a.nb-breadcrumb:hover {
    color: var(--accent-primary, #818cf8);
}
.nb-breadcrumb--active {
    color: var(--text-secondary, rgba(255, 255, 255, 0.65));
}
.nb-breadcrumb-sep {
    font-size: 12px;
    color: var(--text-muted, rgba(255, 255, 255, 0.3));
    user-select: none;
}

/* ================================================================
   Calc Report — ReasonSpring design-token adaptation
   Styles the HTML body returned by mari-calc-engine's render_html_body().
   Uses RS design tokens from reasonspring.css for consistency.
   ================================================================ */

.mckinsey-report {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-secondary, #4a5568);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

/* Headings — Space Grotesk for calc reports (sharp, technical) */
.mckinsey-report h1 {
    font-family: var(--font-display, 'Source Serif 4'), Georgia, serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #fff);
    letter-spacing: -0.02em;
    margin: 0 0 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--color-primary, #1a5a94);
}
.mckinsey-report h2 {
    font-family: var(--font-display, 'Source Serif 4'), Georgia, serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary, rgba(255, 255, 255, 0.9));
}
.mckinsey-report h3 {
    font-family: var(--font-display, 'Source Serif 4'), Georgia, serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-secondary, rgba(255, 255, 255, 0.7));
    margin: 1.25rem 0 0.5rem;
}
.mckinsey-report h4, .mckinsey-report h5, .mckinsey-report h6 {
    font-family: var(--font-display, 'Source Serif 4'), Georgia, serif;
    color: var(--text-muted, rgba(255, 255, 255, 0.45));
    margin: 1rem 0 0.4rem;
}
.mckinsey-report p { margin: 0.5rem 0; }
.mckinsey-report strong { color: var(--text-primary, #fff); font-weight: 600; }
.mckinsey-report em { color: var(--text-muted, rgba(255, 255, 255, 0.45)); }
.mckinsey-report a { color: var(--color-user, #a78bfa); text-decoration: none; border-bottom: 1px solid rgba(167, 139, 250, 0.3); }
.mckinsey-report a:hover { border-bottom-color: var(--color-user, #a78bfa); }

/* Code — JetBrains Mono (already loaded in base.html) */
.mckinsey-report code {
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background: var(--bg-secondary, #f3f4f6);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    color: var(--text-primary, #2d2d2d);
}
.mckinsey-report pre {
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    font-size: 0.82em;
    background: var(--bg-secondary, #f3f4f6);
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: var(--radius-sm, 10px);
    padding: 0.75rem 1rem;
    overflow-x: auto;
    margin: 0.75rem 0;
    line-height: 1.5;
}
.mckinsey-report pre code { background: none; padding: 0; font-size: inherit; }
/* Consecutive code blocks: merge into one visual unit */
.mckinsey-report .codehilite + .codehilite {
    margin-top: -1px;
}
.mckinsey-report .codehilite + .codehilite pre {
    margin-top: 0;
    border-radius: 0 0 var(--radius-sm, 10px) var(--radius-sm, 10px);
    padding-top: 0.5rem;
}
.mckinsey-report .codehilite:has(+ .codehilite) pre {
    margin-bottom: 0;
    border-radius: var(--radius-sm, 10px) var(--radius-sm, 10px) 0 0;
    padding-bottom: 0.5rem;
}
/* Middle blocks in a run: no radius at all */
.mckinsey-report .codehilite + .codehilite:has(+ .codehilite) pre {
    border-radius: 0;
}

/* Tables */
.mckinsey-report table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75rem 0;
    font-size: 0.88em;
    font-variant-numeric: tabular-nums;
}
.mckinsey-report thead th {
    font-weight: 600;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #718096);
    background: var(--bg-secondary, #f3f4f6);
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid var(--color-primary, #1a5a94);
    text-align: left;
    white-space: nowrap;
}
.mckinsey-report td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
    color: var(--text-secondary, #4a5568);
    vertical-align: top;
}
.mckinsey-report td:last-child, .mckinsey-report th:last-child { text-align: right; }
.mckinsey-report td:first-child, .mckinsey-report th:first-child {
    text-align: left;
    font-weight: 500;
    color: var(--text-secondary, #4a5568);
}
.mckinsey-report tbody tr:hover { background: rgba(26, 90, 148, 0.04); }

/* Blockquotes — result callouts (joined to preceding code block) */
.mckinsey-report blockquote {
    border-left: 3px solid var(--color-primary, #1a5a94);
    padding: 0.5rem 1rem;
    margin: 0;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 0 0 var(--radius-sm, 10px) var(--radius-sm, 10px);
    line-height: 1.5;
    color: var(--text-primary, #2d2d2d);
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    font-size: 0.88em;
    margin-bottom: 1rem;
}
/* Join blockquote to preceding code block (codehilite wraps pre) */
.mckinsey-report .codehilite + blockquote {
    margin-top: -1px;
    border-top: 1px solid var(--border-subtle, #e5e7eb);
}
.mckinsey-report .codehilite:has(+ blockquote) pre {
    margin-bottom: 0;
    border-radius: var(--radius-sm, 10px) var(--radius-sm, 10px) 0 0;
}
.mckinsey-report blockquote p {
    margin: 0.15rem 0;
}
.mckinsey-report blockquote strong {
    color: var(--color-user, #a78bfa);
    font-weight: 700;
}

/* Images (charts) */
.mckinsey-report img {
    max-width: 100%;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-sm, 10px);
    margin: 1rem 0;
    box-shadow: var(--shadow-md, 0 2px 6px rgba(0, 0, 0, 0.4));
}

/* Lists */
.mckinsey-report ul, .mckinsey-report ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.mckinsey-report li { margin: 0.2rem 0; }
.mckinsey-report hr { border: none; border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08)); margin: 2rem 0; }

/* Collapsible sections */
.mckinsey-report details {
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-sm, 10px);
    margin: 1rem 0;
    background: var(--card-glass, rgba(18, 18, 24, 0.6));
    overflow: hidden;
}
.mckinsey-report details > summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    background: var(--glass-bg, rgba(255, 255, 255, 0.04));
    font-family: var(--font-display, 'Source Serif 4'), Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    transition: background 0.15s ease;
}
.mckinsey-report details > summary::-webkit-details-marker { display: none; }
.mckinsey-report details > summary::before {
    content: '\25B8';
    font-size: 0.8em;
    color: var(--text-dim, rgba(255, 255, 255, 0.25));
    transition: transform 0.2s ease;
    display: inline-block;
    width: 1em;
}
.mckinsey-report details[open] > summary::before {
    transform: rotate(90deg);
    color: var(--color-primary, #1a5a94);
}
.mckinsey-report details > summary:hover { background: var(--glass-bg-hover, rgba(255, 255, 255, 0.08)); }
.mckinsey-report details > .section-body { padding: 1rem 1.25rem 1.25rem; }
.mckinsey-report details[open] > summary { border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06)); }

/* Toolbar (expand/collapse controls) */
.mckinsey-report .toolbar {
    display: flex;
    gap: 0.5rem;
    margin: 1.25rem 0;
}
.mckinsey-report .toolbar button {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary, rgba(255, 255, 255, 0.75));
    background: transparent;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-sm, 10px);
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.mckinsey-report .toolbar button:hover {
    background: rgba(26, 90, 148, 0.08);
    border-color: var(--color-primary, #1a5a94);
    color: var(--text-primary, #fff);
}

/* Timestamp */
.mckinsey-report .timestamp {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-dim, rgba(255, 255, 255, 0.25));
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
}

/* KaTeX dark mode */
.mckinsey-report .katex { color: var(--text-primary, rgba(255, 255, 255, 0.9)); }
.mckinsey-report .katex-display { margin: 1rem 0; overflow-x: auto; }

/* ── Notebook action buttons ── */
.nb-view__actions {
    display: inline-flex;
    gap: 6px;
    margin-left: 10px;
    vertical-align: middle;
}
.nb-view__actions .btn {
    flex: none;
    padding: 6px;
}

/* ── Inline editor zone ── */
.nb-inline-edit {
    margin: 0 0 16px;
}
.nb-editor-inline {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    background: var(--card-glass, rgba(255, 255, 255, 0.04));
    overflow: hidden;
}
.nb-editor-inline__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    background: var(--glass-bg, rgba(255, 255, 255, 0.04));
}
.nb-editor-inline__title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.nb-editor-inline__actions {
    display: flex;
    gap: 8px;
}
.nb-editor-inline__textarea {
    width: 100%;
    min-height: 400px;
    padding: 16px;
    background: transparent;
    color: var(--text-primary);
    border: none;
    resize: vertical;
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    outline: none;
    box-sizing: border-box;
}

/* ── Generation target in notebook view ── */
#nb-gen-target:not(:empty) {
    margin: 16px 0;
}

/* ── Inline edit with prompt ── */
.nb-edit-prompt-inline {
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    background: var(--card-glass, rgba(255, 255, 255, 0.04));
    padding: 16px;
}

.nb-edit-prompt-inline__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.nb-edit-prompt-inline__title {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.nb-edit-prompt-inline__form {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.nb-edit-prompt-inline__input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    background: var(--card-glass, rgba(255, 255, 255, 0.04));
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s;
}

.nb-edit-prompt-inline__input:focus {
    border-color: var(--accent-primary, #818cf8);
}

.nb-edit-prompt-inline__hint {
    font-size: 0.75rem;
    color: var(--text-muted, rgba(255, 255, 255, 0.45));
    margin: 0;
}

/* ── Tracked changes view ── */
.nb-tracked {
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
}

.nb-tracked__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    position: sticky;
    top: 0;
    background: var(--bg-card, #16213e);
    padding: 8px 0;
    z-index: 1;
}

.nb-tracked__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.nb-tracked__instruction {
    font-size: 0.8rem;
    color: var(--text-muted, #888);
    font-style: italic;
    flex: 1 1 100%;
}

.nb-tracked__actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.nb-tracked__diff {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.9rem;
    line-height: 1.8;
    word-wrap: break-word;
}

/* ── TextChange spans ── */
.tc {
    transition: opacity 0.15s, background 0.15s;
}

.tc--unchanged {
    color: var(--text-primary, #e0e0e0);
}

/* Inserted text — green */
.tc--inserted.tc--accepted {
    background: rgba(45, 106, 79, 0.2);
    color: var(--color-success);
    border-radius: 3px;
    padding: 1px 2px;
    cursor: pointer;
}

.tc--inserted.tc--rejected {
    opacity: 0.3;
    text-decoration: line-through;
    color: var(--color-success);
    cursor: pointer;
}

/* Deleted text — red */
.tc--deleted.tc--accepted {
    background: rgba(192, 57, 43, 0.2);
    color: var(--color-error);
    text-decoration: line-through;
    border-radius: 3px;
    padding: 1px 2px;
    cursor: pointer;
}

.tc--deleted.tc--rejected {
    background: none;
    color: var(--text-primary, #e0e0e0);
    text-decoration: none;
    cursor: pointer;
}

/* Modified text — orange */
.tc--modified.tc--accepted {
    background: rgba(251, 146, 60, 0.2);
    border-radius: 3px;
    padding: 1px 2px;
    cursor: pointer;
}

.tc--modified.tc--accepted del {
    color: var(--color-error);
    text-decoration: line-through;
    opacity: 0.6;
}

.tc--modified.tc--accepted ins {
    color: var(--color-warning);
    text-decoration: none;
    font-weight: 500;
}

.tc--modified.tc--rejected {
    cursor: pointer;
}

.tc--modified.tc--rejected del {
    color: var(--text-primary, #e0e0e0);
    text-decoration: none;
}

.tc--modified.tc--rejected ins {
    display: none;
}

/* Spinner for loading state */
.spin {
    animation: spin 0.8s linear infinite;
}

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

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-flex;
}