@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Source+Serif+4:opsz,wght@8..60,400..700&display=swap');

/* P12 semantic tokens. Public landing pages retain their bounded environment
   styling; the authenticated workspace consumes this platform layer. */
:root {
    --color-canvas: #F6F8FB;
    --color-surface: #FFFFFF;
    --color-surface-subtle: #EEF2F7;
    --color-surface-elevated: #FFFFFF;
    --color-text-primary: #172033;
    --color-text-secondary: #536174;
    --color-text-tertiary: #5F6B7A;
    --color-border: #D7DEE8;
    --color-divider: #E7ECF2;
    --color-accent: #315EFB;
    --color-on-accent: #FFFFFF;
    --color-accent-soft: #E8EEFF;
    --color-focus-ring: #315EFB;
    --color-success: #18794E;
    --color-on-success: #FFFFFF;
    --color-success-soft: #E8F5EE;
    --color-warning: #946200;
    --color-on-warning: #FFFFFF;
    --color-warning-soft: #FFF4D6;
    --color-danger: #B42318;
    --color-on-danger: #FFFFFF;
    --color-danger-soft: #FDECEA;
    --color-info: #2563EB;
    --color-info-soft: #E8F1FF;
    --color-generated-foreground: #445B70;
    --color-generated-background-subtle: #EEF3F6;
    --color-generated-border: #748694;
    --color-unresolved-foreground: #5C4B82;
    --color-unresolved-background-subtle: #F3EFF9;
    --color-unresolved-border: #917DAF;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --radius-control: 6px;
    --radius-panel: 10px;
    --motion-instant: 80ms;
    --motion-micro: 120ms;
    --motion-standard: 180ms;
    --motion-pane: 240ms;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-canvas: #0E141D;
        --color-surface: #151D28;
        --color-surface-subtle: #1C2633;
        --color-surface-elevated: #202C3A;
        --color-text-primary: #EDF2F7;
        --color-text-secondary: #B6C1CF;
        --color-text-tertiary: #8F9CAE;
        --color-border: #334155;
        --color-divider: #263445;
        --color-accent: #7AA2FF;
        --color-on-accent: #0E141D;
        --color-accent-soft: #1C2D59;
        --color-focus-ring: #8FB1FF;
        --color-success: #5FD19A;
        --color-on-success: #0E141D;
        --color-success-soft: #16382A;
        --color-warning: #F4C152;
        --color-on-warning: #0E141D;
        --color-warning-soft: #3A2E14;
        --color-danger: #FF8A80;
        --color-on-danger: #0E141D;
        --color-danger-soft: #421F23;
        --color-info: #8CB4FF;
        --color-info-soft: #1B3153;
        --color-generated-foreground: #B2C3D2;
        --color-generated-background-subtle: #1D2A34;
        --color-generated-border: #617584;
        --color-unresolved-foreground: #D0BDF2;
        --color-unresolved-background-subtle: #2A2238;
        --color-unresolved-border: #846B9F;
    }
}

:root {
    --bg: #f7f4ec;
    --cl-canvas: #faf9f6;
    --cl-parchment: #f6f1e8;
    --cl-card: #ffffff;
    --cl-text-primary: #2e2a26;
    --cl-text-secondary: #5f5a54;
    --cl-text-muted: #8c867f;
    --cl-blue: #1e6fdb;
    --cl-blue-hover: #295cb5;
    --cl-blue-soft: #e6effc;
    --cl-border: #d8d2c8;
    --cl-ink: #cfc7bc;
    --public-shell-max-width: 1140px;
    --public-shell-padding: 40px 20px 72px;
    --border-light: rgba(70, 50, 30, 0.15);
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
}

/* The authenticated shell still contains established components that consume
   the legacy aliases below. Keep those aliases mapped to the frozen P12
   semantic pairs so dark mode never falls back to the former parchment
   palette. */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: var(--color-canvas);
        --cl-canvas: var(--color-canvas);
        --cl-parchment: var(--color-surface-subtle);
        --cl-card: var(--color-surface);
        --cl-text-primary: var(--color-text-primary);
        --cl-text-secondary: var(--color-text-secondary);
        --cl-text-muted: var(--color-text-tertiary);
        --cl-blue: var(--color-accent);
        --cl-blue-hover: #A9C2FF;
        --cl-blue-soft: var(--color-accent-soft);
        --cl-border: var(--color-border);
        --cl-ink: var(--color-divider);
        --border-light: var(--color-divider);
    }
}

html, body {
    /* update-id: swb-2025-11-17-1 */
    height: 100%;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Layout stabilized for pinned chat  collapsible research workspace */
body {
    font-family: "Open Sans", "Inter", "Segoe UI", Arial, sans-serif;
    background: #f7f4ec;
    color: #3a2f23;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}
.landing-page,
body.tos-page {
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    height: auto;
    min-height: 100vh;
}
html:has(body.landing-page),
html:has(body.tos-page) {
    overflow: auto;
    height: auto;
}

.hidden {
    display: none !important;
}

.library-surface { padding: 24px; border: 1px solid var(--border-color, #d7d2c8); border-radius: 18px; background: var(--surface, #fffdf8); }
.library-surface__header { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.library-surface__home, .library-surface__detail { display: grid; gap: 12px; }
.library-card { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--border-color, #d7d2c8); border-radius: 12px; background: color-mix(in srgb, var(--surface, #fffdf8) 90%, #6d5c45 10%); }
.library-card button { flex: 0 0 auto; }
.library-card label { display: grid; gap: 6px; width: 100%; }
.library-card input, .library-card textarea, .library-card select { width: 100%; box-sizing: border-box; }
@media (max-width: 700px) { .library-surface { padding: 16px; } .library-surface__header { flex-direction: column; } .library-card { align-items: flex-start; flex-direction: column; } }

body.landing-page {
    background: var(--cl-canvas);
    color: var(--cl-text-primary);
    font-family: "Open Sans", "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    margin: 0;
}

.landing-page h1,
.landing-page h2,
.landing-page h3,
.landing-page h4 {
    font-family: "Open Sans", "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-weight: 700;
    color: var(--cl-text-primary);
    line-height: 1.2;
}

.landing-page p,
.landing-page li {
    color: var(--cl-text-secondary);
    line-height: 1.6;
}

.landing-shell {
    max-width: var(--public-shell-max-width);
    width: 100%;
    margin: 0 auto;
    padding: var(--public-shell-padding);
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-height: 100vh;
    box-sizing: border-box;
}

.landing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.landing-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.landing-brand--home {
    text-decoration: none;
    color: inherit;
}

.landing-brand--home:hover .brand-mark {
    border-color: rgba(43, 99, 194, 0.5);
}

.landing-brand--home:hover h1 {
    color: #2b63c2;
}

.landing-brand h1 {
    margin: 0;
    font-size: 26px;
    white-space: nowrap;
    line-height: 1.1;
}

.landing-tagline {
    margin: 0;
    font-size: 14px;
    color: var(--cl-text-muted);
    line-height: 1.2;
    letter-spacing: 0.2px;
}

.landing-brand__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: calc(100vw - 150px);
}

.brand-mark {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    border: 1px solid var(--cl-border);
    background: var(--cl-parchment);
    color: var(--cl-text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.landing-nav {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.landing-nav a {
    color: var(--cl-text-secondary);
    text-decoration: none;
    font-size: 14px;
}

.landing-nav__link {
    text-decoration: underline;
    opacity: 0.8;
}

.landing-nav__cta {
    border: 1px solid var(--cl-border);
    border-radius: 999px;
    padding: 6px 16px;
    background: var(--cl-card);
    color: var(--cl-text-primary);
}

/* ── Locale toggle (app header + landing nav) ─────────────────────────── */
.locale-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

.locale-btn {
    background: none;
    border: none;
    padding: 3px 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #8b7a68;
    cursor: pointer;
    border-radius: 4px;
    text-decoration: none;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

.locale-btn:hover {
    color: #3a2f23;
    background: rgba(70, 50, 30, 0.07);
}

.locale-btn--active {
    color: #3a2f23;
    background: rgba(70, 50, 30, 0.1);
}

.locale-sep {
    font-size: 11px;
    color: #c5b9a3;
    user-select: none;
}

.locale-toggle--landing .locale-btn {
    font-size: 13px;
}

.about-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.landing-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.landing-hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 36px;
    background: var(--cl-parchment);
    border-radius: 28px;
    border: 1px solid var(--cl-border);
    padding: 40px;
    box-shadow: 0 25px 60px rgba(46, 42, 38, 0.08);
}

.hero-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--cl-text-muted);
    font-size: 12px;
    margin: 0 0 6px;
}

.landing-hero__text {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.landing-hero__text h2 {
    font-size: 36px;
    margin: 0;
}

.landing-hero__text p {
    margin: 0;
}

.hero-points {
    list-style: disc;
    padding-left: 20px;
    margin: 0;
    color: var(--cl-text-secondary);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hero-cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 6px;
}

.hero-micro {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--cl-text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 11px 24px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

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

.btn--primary:hover {
    background: var(--cl-blue-hover);
}

.btn--ghost {
    border: 1px solid var(--cl-border);
    color: var(--cl-text-primary);
    background: var(--cl-card);
}

.btn--ghost:hover {
    border-color: var(--cl-blue);
    color: var(--cl-blue-hover);
}

.landing-hero__visual {
    border: 1px solid rgba(70, 50, 30, 0.25);
    border-radius: 20px;
    padding: 0;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at top, rgba(247,244,236,0.95), rgba(240,230,208,0.7));
    display: flex;
    align-items: stretch;
    min-height: 360px;
}

.landing-hero__visual::before,
.landing-hero__visual::after {
    content: '';
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    opacity: 0.32;
    animation: grandManFade 16s ease-in-out infinite;
    z-index: 0;
    mix-blend-mode: multiply;
}

.landing-hero__visual::before {
    background-image: url('/swedenborg/pics/swedenbor_02.png');
    animation-delay: 0s;
}

.landing-hero__visual::after {
    background-image: url('/swedenborg/pics/swedenbor_03.png');
    animation-delay: 8s;
}

.correspondence-field {
    position: relative;
    width: 100%;
    min-height: 340px;
    height: 100%;
    overflow: hidden;
    border-radius: 20px;
    z-index: 1;
    flex: 1 1 auto;
}

.correspondence-field::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(247,244,236,0) 50%, rgba(247,244,236,0.35) 100%);
    z-index: 0;
}

.correspondence-field__overlay {
    position: absolute;
    inset: 0;
    padding: 24px;
    z-index: 1;
}

.correspondence-field__figure {
    width: 100%;
    height: auto;
    opacity: 0.75;
}

.correspondence-field__labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
    font-size: 12px;
    color: rgba(58,47,35,0.65);
}

.correspondence-field__labels .label {
    position: absolute;
    background: rgba(255, 255, 255, 0.68);
    padding: 2px 7px;
    border-radius: 12px;
    border: 1px solid rgba(58,47,35,0.12);
    font-size: 12px;
    color: rgba(58,47,35,0.7);
}

.correspondence-field__watermark {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    letter-spacing: 2px;
    color: rgba(58,47,35,0.35);
    text-transform: uppercase;
    z-index: 2;
}

.landing-highlights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.landing-highlights > header {
    grid-column: 1 / -1;
}

.landing-note {
    font-size: 13px;
    color: var(--cl-text-muted);
    margin-top: 6px;
}

@media (min-width: 960px) {
    .landing-highlights {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .landing-highlights > header {
        grid-column: 1 / -1;
    }
}

.feature-card {
    background: var(--cl-card);
    padding: 22px;
    border-radius: 20px;
    border: 1px solid var(--cl-border);
    box-shadow: 0 15px 25px rgba(46, 42, 38, 0.06);
}

.feature-card h4 {
    margin: 0 0 8px;
    font-size: 18px;
}

.feature-card p {
    margin: 0;
}

.landing-panel {
    background: var(--cl-card);
    border: 1px solid var(--cl-border);
    border-radius: 24px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 20px 40px rgba(46, 42, 38, 0.05);
}

.landing-panel--split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 28px;
}

.panel-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--cl-text-muted);
    font-size: 12px;
    margin: 0 0 8px;
}

.panel-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--cl-text-secondary);
}

.panel-list li {
    position: relative;
    padding-left: 18px;
}

.panel-list li::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 6px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--cl-blue);
}

.landing-panel--sources .sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.swedenborg-context {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--cl-border);
}

.swedenborg-context h2 {
    margin-top: 0;
    margin-bottom: 8px;
}

.landing-panel--sources h4 {
    margin: 0 0 6px;
}

.landing-panel--sources p {
    margin: 0;
}

.landing-panel--cta {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--cl-parchment);
}

.panel-cta-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.landing-ai-notice {
    border-radius: 22px;
    border: 1px solid var(--cl-border);
    background: var(--cl-card);
    padding: 24px;
    box-shadow: 0 12px 30px rgba(46, 42, 38, 0.05);
}

.landing-footer {
    text-align: center;
    font-size: 13px;
    color: var(--cl-text-muted);
    line-height: 1.5;
}

.landing-footer a {
    color: var(--cl-blue);
}

.public-legal-footer {
    margin-top: auto;
    border: 1px solid rgba(70, 50, 30, 0.22);
    background: #2f261d;
    color: #e8deca;
    border-radius: 16px;
    padding: 18px 20px;
    text-align: center;
    font-size: 13px;
    line-height: 1.6;
}

.public-legal-footer p {
    margin: 6px 0;
}

.public-legal-footer a {
    color: #b5d0ff;
    text-decoration: none;
}

.public-legal-footer a:hover {
    text-decoration: underline;
}

.cookie-banner {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    border: 1px solid rgba(70, 50, 30, 0.25);
    padding: 12px 18px;
    display: flex;
    gap: 12px;
    align-items: center;
    max-width: 420px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    font-size: 13px;
    color: #3a2f23;
}

.cookie-banner button {
    border: none;
    background: #2b63c2;
    color: #fff;
    border-radius: 999px;
    padding: 6px 16px;
    cursor: pointer;
    font-size: 13px;
}

.about-page {
    background: #f7f4ec;
    color: #3a2f23;
    font-family: "Open Sans", "Inter", "Segoe UI", Arial, sans-serif;
    margin: 0;
    min-height: 100vh;
    overflow-y: auto;
}

.about-shell {
    max-width: var(--public-shell-max-width);
    width: 100%;
    margin: 0 auto;
    padding: var(--public-shell-padding);
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-height: 100vh;
    box-sizing: border-box;
}

.about-hero {
    position: relative;
    min-height: 420px;
    padding: 40px 24px;
    background-color: #f8f1df;
    background-image: url('/swedenborg/pics/swedenborg_web.png');
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 50%;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(70, 50, 30, 0.1);
}

.about-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(247, 244, 236, 0.98) 0%, rgba(247, 244, 236, 0.6) 55%, rgba(247, 244, 236, 0.1) 90%);
    pointer-events: none;
    z-index: 1;
}

.about-hero__tag {
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #8b7a68;
    margin: 0;
}

.about-hero__text {
    position: relative;
    z-index: 2;
    max-width: 620px;
    width: min(100%, 620px);
    overflow: hidden;
    background: rgba(247, 244, 236, 0.85);
    border: 1px solid rgba(70, 50, 30, 0.25);
    border-radius: 18px;
    padding: 24px;
    box-sizing: border-box;
}

.about-hero__text h1 {
    margin: 12px 0;
    font-size: 32px;
}

.about-section {
    border-top: 1px solid rgba(70, 50, 30, 0.2);
    padding-top: 22px;
}

.about-section h2 {
    margin-top: 0;
    font-size: 22px;
}

.about-section ul {
    padding-left: 20px;
    line-height: 1.6;
}

.about-footer {
    text-align: left;
}

.about-footer a {
    color: #2b63c2;
    text-decoration: none;
}
.app-shell {
    width: 100%;
    min-width: 360px;
    height: 100%;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    box-sizing: border-box;
}
.site-footer {
    margin: 8px 16px 16px;
    padding: 12px 18px;
    border-radius: 14px;
    border: 1px solid rgba(70, 50, 30, 0.25);
    background: rgba(255, 255, 255, 0.35);
    color: #8b7a68;
    font-size: 12px;
    text-align: center;
    line-height: 1.5;
}
.site-header {
    flex: 0 0 auto;
    margin-bottom: 0;
}

.app-layout {
    display: grid;
    grid-template-columns: var(--research-col-width, 260px) 4px minmax(0, 1fr) var(--writer-col-width, 0px);
    flex: 1 1 auto;
    width: 100%;
    gap: 0;
    min-height: 0;
    height: calc(100vh - var(--header-height, 72px));
    align-items: start;
    overflow: hidden;
    transition: grid-template-columns 0.2s ease;
}

.layout {
    min-height: 0;
}

.left-panel,
.right-panel,
.chat-panel--main {
    margin-top: 0;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
}

.chat-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    min-height: 0;
    gap: 0;
    padding: 0 24px;
    padding-bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Keep long research content inside the viewport instead of widening it. */
.chat-panel,
.chat-messages,
#chatbox,
.message,
.message-content,
.message-sources,
.input-bar {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.active-session {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid rgba(70, 50, 30, 0.12);
    background: transparent;
    color: #8b7a68;
    font-size: 12px;
    flex: 0 0 auto;
}

.active-session strong {
    color: #2f261d;
}

.active-session__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.writer-tray-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(70, 50, 30, 0.18);
    background: rgba(255, 255, 255, 0.36);
    color: #5a4632;
    border-radius: 999px;
    height: 34px;
    padding: 0 12px;
    transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.writer-tray-toggle:hover {
    border-color: rgba(43, 99, 194, 0.35);
    background: rgba(43, 99, 194, 0.08);
    color: #2b63c2;
}

.writer-tray-toggle[aria-pressed="true"] {
    border-color: rgba(43, 99, 194, 0.45);
    background: rgba(43, 99, 194, 0.12);
    color: #2b63c2;
}

.writer-tray-toggle__icon,
.writer-tray-toggle__icon svg {
    width: 16px;
    height: 16px;
    display: inline-flex;
}

.writer-tray-toggle__label {
    font-size: 12px;
    font-weight: 600;
}

.writer-tray-toggle__count {
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    background: rgba(43, 99, 194, 0.14);
    color: #2b63c2;
    font-size: 11px;
    font-weight: 700;
}

.drag-handle {
    width: 4px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    flex-shrink: 0;
    align-self: stretch;
    z-index: 2;
    transition: background 0.15s;
}

.drag-handle:hover {
    background: var(--border-light, rgba(70, 50, 30, 0.15));
}

body.is-resizing {
    cursor: col-resize;
    user-select: none;
}

body.is-resizing .app-layout {
    transition: none;
}

.writer-panel.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
    opacity: 0;
    border-left: none;
}

.writer-panel {
    min-width: 0;
    justify-self: end;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    gap: 0;
    border-left: 1px solid rgba(70, 50, 30, 0.15);
    transition: opacity 0.2s ease;
}

.writer-panel .workspace-writer {
    flex: 1 1 auto;
    overflow-y: auto;
    background: transparent;
}

.research-set-overview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(43, 99, 194, 0.22);
    border-radius: 10px;
    background: rgba(43, 99, 194, 0.045);
}

.research-set-overview__header,
.research-set-overview__counts {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.research-set-overview__header h4 {
    margin: 0;
    font-size: 13px;
    color: #3a2f23;
}

.research-set-overview__status {
    color: #2b63c2;
    font-size: 12px;
    font-weight: 700;
}

.research-set-overview p {
    margin: 0;
    line-height: 1.35;
}

.research-set-overview__counts {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.research-set-overview__counts span {
    font-size: 11px;
    color: #8b7a68;
}

.research-set-overview__counts strong {
    color: #3a2f23;
    font-size: 14px;
}

.workspace-column-empty {
    border: none;
    border-radius: 0;
    padding: 12px;
    background: transparent;
    color: #8b7a68;
    font-size: 12px;
}

.chat-disclaimer {
    font-size: 11px;
    color: #8b7a68;
    margin: 2px 4px 0;
    line-height: 1.35;
}

@media (min-width: 961px) {
    body.has-collapsed-research .active-session {
        padding-left: 54px;
    }
}

.chat-messages {
    background-color: transparent;
    border-radius: 0;
    width: 100%;
    padding: 16px 32px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    border: none;
    box-shadow: none;
    overflow-y: auto;
    gap: 10px;
}

#chatbox {
    flex: 1 1 auto;
    max-height: 100%;
    min-height: 0;
    padding: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: transparent;
    border-radius: 0;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
}

.site-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: var(--bg);
    border: none;
    border-radius: 0;
    border-bottom: 1px solid rgba(70, 50, 30, 0.15);
    flex-wrap: wrap;
    box-shadow: none;
    margin-bottom: 0;
}

.session-new-chat {
    border: 1px solid rgba(70, 50, 30, 0.3);
    background: rgba(255, 255, 255, 0.6);
    color: #3a2f23;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
}

.brand {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
    flex: 1;
}

.brand--home-link {
    text-decoration: none;
    color: inherit;
}

.brand--home-link:hover .brand-text h1 {
    color: #2b63c2;
}

.brand-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #3a2f23;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 1px;
    border: 1px solid rgba(70, 50, 30, 0.25);
}

.brand-initials {
    pointer-events: none;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-text h1 {
    font-size: 18px;
    margin: 0;
    color: #3a2f23;
    letter-spacing: 0.5px;
}

.brand-text p {
    margin: 0;
    font-size: 12px;
    color: #8b7a68;
}

.session-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    border: 1px solid rgba(70, 50, 30, 0.25);
}

.session-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #c5b9a3;
    color: #3a2f23;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.session-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.session-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.session-name {
    font-size: 13px;
    color: #3a2f23;
    font-weight: 600;
}

.session-email {
    font-size: 11px;
    color: #5c5c5c;
}

.session-logout {
    border: none;
    background: #3a2f23;
    color: #fff;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.session-logout:hover {
    background: #2b2016;
}

.toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translate(-50%, -20px);
    background: #3a2f23;
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid rgba(70, 50, 30, 0.25);
    box-shadow: none;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 1000;
}

.toast.toast--visible {
    opacity: 0.97;
    transform: translate(-50%, 0);
}

.research-panel {
    width: var(--research-col-width, 260px);
    max-width: var(--research-col-width, 260px);
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    align-self: flex-start;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    background: #f7f4ec;
    border: none;
    border-radius: 0;
    border-right: 1px solid rgba(70, 50, 30, 0.15);
    padding: 0;
    position: relative;
    opacity: 1;
    transition: width 0.2s ease, min-width 0.2s ease, padding 0.2s ease;
}

.research-panel .workspace-card,
.research-panel .panel-section:not(.panel-section--header) {
    padding: 12px;
    background: transparent;
}

.research-collapse {
    position: static;
    border: none;
    background: transparent;
    color: #8b7a68;
    border-radius: 6px;
    width: 30px;
    height: 32px;
    padding: 0;
    cursor: pointer;
    z-index: 3;
    box-shadow: none;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.08em;
}

.research-collapse:hover {
    color: #2b63c2;
}

body.has-collapsed-research .research-panel {
    width: 0;
    min-width: 0;
    max-width: 0;
    padding: 0;
    overflow: visible;
    border-right: 0;
}

body.has-collapsed-research .app-layout {
    --research-col-width: 0px;
}

body.has-collapsed-research .research-panel .workspace-card,
body.has-collapsed-research .research-panel .panel-section:not(.panel-section--header),
body.has-collapsed-research .research-panel .workspace-column-empty {
    display: none;
}

body.has-collapsed-research .research-panel .research-collapse {
    position: absolute;
    top: 14px;
    left: 14px;
    width: 34px;
    height: 34px;
    margin: 0;
    border: 1px solid rgba(70, 50, 30, 0.18);
    background: rgba(247, 244, 236, 0.94);
    box-shadow: 0 4px 12px rgba(58, 47, 35, 0.08);
}

.workspace-card {
    background: transparent;
    border-radius: 0;
    padding: 12px;
    border: none;
    border-bottom: 1px solid rgba(70, 50, 30, 0.13);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.workspace-citation {
    order: 2;
}

.workspace-investigations {
    order: 3;
}

.workspace-investigations-list,
.workspace-investigation-evidence {
    list-style: none;
    margin: 0;
    padding: 0;
}

.workspace-investigation-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(70, 50, 30, 0.14);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.workspace-investigation-item + li {
    margin-top: 5px;
}

.workspace-investigation-item.is-active {
    border-color: var(--accent, #4b699f);
    background: rgba(75, 105, 159, 0.08);
}

.workspace-investigation-item small {
    color: var(--muted-text, #6d6a65);
    white-space: nowrap;
}

.workspace-investigation-detail {
    margin-top: 8px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.42);
}

.workspace-investigation-detail h4,
.workspace-investigation-detail p {
    margin: 0 0 7px;
}

.workspace-investigation-evidence {
    margin-top: 8px;
}

.workspace-investigation-evidence li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 0;
    border-top: 1px solid rgba(70, 50, 30, 0.1);
}

.workspace-investigation-remove {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
}

.workspace-investigation-plan {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(70, 50, 30, 0.12);
}

.workspace-plan-add {
    margin: 7px 0 4px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent, #4b699f);
    cursor: pointer;
}

.workspace-investigation-plan-list {
    margin: 6px 0 0 20px;
    padding: 0;
}

.workspace-investigation-plan-list li {
    padding: 6px 0 6px 2px;
    border-top: 1px solid rgba(70, 50, 30, 0.1);
}

.workspace-plan-item-text {
    display: block;
}

.workspace-plan-item-state {
    display: inline-block;
    margin-top: 3px;
    color: var(--muted-text, #6d6a65);
    font-size: 0.82em;
    text-transform: capitalize;
}

.workspace-plan-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.workspace-plan-item-actions button {
    padding: 2px 5px;
    border: 1px solid rgba(70, 50, 30, 0.18);
    border-radius: 5px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 0.78em;
}

.workspace-plan-item-actions button:disabled {
    opacity: 0.4;
    cursor: default;
}

.workspace-notes {
    order: 4;
}

.workspace-history {
    order: 5;
}

.panel-section {
    padding: 6px 12px 10px;
    border-bottom: 1px solid rgba(70, 50, 30, 0.1);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.panel-section--header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f7f4ec;
    border-bottom: 1px solid rgba(70, 50, 30, 0.1);
    box-shadow: 0 1px 0 rgba(70, 50, 30, 0.08);
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
}

.panel-section__header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.panel-section__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

body.has-collapsed-research .research-panel .panel-section--header {
    justify-content: center;
    padding: 8px 4px;
}

body.has-collapsed-research .research-panel .panel-section--header .panel-section__label,
body.has-collapsed-research .research-panel .panel-section--header .session-new-chat {
    display: none;
}

.panel-section--meta {
    opacity: 0.7;
}

.panel-section__label {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #8b7a68;
}

.workspace-profile {
    order: 1;
}

.workspace-history--muted {
    opacity: 0.9;
}

.workspace-profile--minimal {
    opacity: 1;
    padding: 10px 12px;
}

.workspace-profile--minimal .workspace-muted {
    display: none;
}

.workspace-card__actions {
    display: flex;
    gap: 6px;
}

.workspace-icon-btn {
    border: 1px solid rgba(70, 50, 30, 0.25);
    background: rgba(255, 255, 255, 0.6);
    color: #3a2f23;
    border-radius: 8px;
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
}

.workspace-icon-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.workspace-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.workspace-tabpanel {
    display: block;
    margin-top: 10px;
}

.workspace-tabpanel--active {
    display: block;
}

.workspace-viewer-inline {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(70, 50, 30, 0.2);
}

.citation-viewer--inline {
    margin: 4px 10px 8px;
    border-color: transparent;
    background: transparent;
    max-height: none;
    overflow: visible;
}

.workspace-inline-title {
    margin: 0 0 10px;
    font-size: 14px;
    color: #3a2f23;
}

.workspace-card__header h2,
.workspace-card__header h3 {
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8b7a68;
}

.workspace-desc {
    margin: 0;
    font-size: 14px;
    color: #8b7a68;
}

.workspace-muted {
    margin: 0;
    font-size: 13px;
    color: #8b7a68;
}

.workspace-pill {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(70, 50, 30, 0.1);
    color: #3a2f23;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.workspace-pill--muted {
    background: rgba(70, 50, 30, 0.05);
    color: rgba(70, 50, 30, 0.7);
}

.workspace-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: #4f4f4f;
}

.workspace-list--compact li {
    font-size: 12px;
}

.workspace-notes {
    gap: 12px;
}

.workspace-notes-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.workspace-notes-editor label {
    font-size: 12px;
    color: #8b7a68;
}

.workspace-notes-select {
    border-radius: 4px;
    border: 1px solid rgba(70, 50, 30, 0.2);
    padding: 5px 8px;
    background: transparent;
    color: #3a2f23;
    font-size: 13px;
}

.workspace-notes-editor textarea {
    border-radius: 4px;
    border: 1px solid rgba(70, 50, 30, 0.2);
    background: transparent;
    padding: 8px;
    font-size: 13px;
    color: #3a2f23;
    resize: vertical;
    min-height: 72px;
    box-sizing: border-box;
}

.workspace-notes-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.workspace-notes-actions button {
    border: none;
    background: #2b63c2;
    color: #fff;
    border-radius: 4px;
    padding: 5px 14px;
    cursor: pointer;
}

.workspace-notes-actions small {
    color: #8b7a68;
}

.workspace-notes-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.workspace-note-item {
    border: 1px solid rgba(70, 50, 30, 0.15);
    border-radius: 4px;
    padding: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.workspace-note-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #8b7a68;
}

.workspace-note-body {
    margin: 0;
    font-size: 13px;
    color: #3a2f23;
    line-height: 1.4;
}

.workspace-note-actions {
    display: flex;
    justify-content: flex-end;
}

.workspace-note-card {
    cursor: pointer;
}

.workspace-note-date {
    font-size: 11px;
    color: #8b7a68;
    padding: 0 12px 8px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: #8c867f;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.icon-btn:hover,
.icon-btn:focus-visible {
    background: rgba(58, 47, 35, 0.06);
    border-color: rgba(70, 50, 30, 0.08);
    color: #3a2f23;
}

.icon-btn:active {
    transform: scale(0.96);
}

.icon-btn--active {
    color: #2b63c2;
    background: rgba(43, 99, 194, 0.1);
    border-color: rgba(43, 99, 194, 0.16);
}

.icon-btn--destructive {
    color: #8c867f;
    background: transparent;
    border-color: transparent;
}

.icon-btn--destructive:hover,
.icon-btn--destructive:focus-visible {
    background: rgba(198, 40, 40, 0.08);
    color: #c62828;
    border-color: rgba(198, 40, 40, 0.14);
}

.icon-btn__icon,
.icon-btn__icon svg {
    display: inline-flex;
    width: 16px;
    height: 16px;
}

.workspace-note-delete {
    margin-left: auto;
}

.is-removing {
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.workspace-passages-card.is-just-added {
    animation: bookmarkAddedPulse 0.45s ease;
}

@keyframes bookmarkAddedPulse {
    0% {
        background: rgba(43, 99, 194, 0.2);
        border-color: rgba(43, 99, 194, 0.7);
    }
    100% {
        background: transparent;
        border-color: rgba(70, 50, 30, 0.15);
    }
}

.empty-state {
    border: 1px dashed rgba(70, 50, 30, 0.25);
    border-radius: 12px;
    padding: 14px 12px;
    background: rgba(255, 255, 255, 0.28);
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
}

.empty-icon {
    font-size: 13px;
    color: #8b7a68;
    line-height: 1;
}

.empty-title {
    font-size: 13px;
    font-weight: 600;
    color: #3a2f23;
}

.workspace-notes-editor textarea::placeholder,
.workspace-writer textarea::placeholder {
    color: #8b7a68;
}

.workspace-notes-editor textarea:focus::placeholder,
.workspace-writer textarea:focus::placeholder {
    color: rgba(139, 122, 104, 0.35);
}

.empty-action {
    font-size: 12px;
    color: #8b7a68;
}

.workspace-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 13px;
    color: #4f4f4f;
}

.workspace-notes-actions button:not(:disabled):hover {
    background: rgba(43, 99, 194, 0.2);
    border-color: rgba(43, 99, 194, 0.5);
}

.workspace-notes-actions button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: rgba(43, 99, 194, 0.06);
    border-color: rgba(43, 99, 194, 0.2);
    color: rgba(43, 99, 194, 0.55);
}

.workspace-notes-actions small {
    color: #8b7a68;
}

.workspace-passages-body {
    padding: 4px 12px 8px;
    font-size: 12px;
    color: #8b7a68;
    line-height: 1.35;
    display: block;
    position: relative;
    max-height: calc(1.5 * 1.35em);
    overflow: hidden;
    white-space: normal;
}

.workspace-passages-body::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    width: 46%;
    height: 1.05em;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(247, 244, 236, 0), rgba(247, 244, 236, 0.95));
}

.workspace-passages-card.passage-expanded > .workspace-passages-body {
    display: none;
}

.workspace-passages-expanded {
    padding: 0 12px 10px;
}

.workspace-passages-expanded__text {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: #3a2f23;
    white-space: pre-wrap;
}

.workspace-passages-expanded__links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.workspace-passages-expanded__links a {
    font-size: 12px;
    color: #2b63c2;
    text-decoration: none;
}

.workspace-passages-expanded__links a:hover {
    text-decoration: underline;
}

.workspace-note-card .workspace-passages-body {
    color: #3a2f23;
}

.note-viewer--inline {
    margin-top: 2px;
}

.workspace-writer__actions button {
    border: 1px solid rgba(43, 99, 194, 0.35);
    background: rgba(43, 99, 194, 0.1);
    color: #2b63c2;
    border-radius: 4px;
    padding: 5px 14px;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.workspace-writer__actions button:not(:disabled):hover {
    background: rgba(43, 99, 194, 0.2);
    border-color: rgba(43, 99, 194, 0.5);
}

.workspace-writer__actions button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: rgba(43, 99, 194, 0.06);
    border-color: rgba(43, 99, 194, 0.2);
    color: rgba(43, 99, 194, 0.55);
}

.workspace-history-item {
    border: 1px solid rgba(70, 50, 30, 0.13);
    border-radius: 4px;
    padding: 8px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    position: relative;
}

.workspace-history-item--active {
    border-color: rgba(43, 99, 194, 0.4);
    box-shadow: inset 0 0 0 1px rgba(43, 99, 194, 0.25);
    background: rgba(43, 99, 194, 0.06);
}

.workspace-history-item__badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    background: rgba(43, 99, 194, 0.2);
    color: #2b63c2;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}
.workspace-history-item__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.workspace-history-item__title {
    margin: 0;
    font-weight: 600;
    font-size: 13px;
}

.workspace-history-item__title-input {
    border: 1px solid rgba(70, 50, 30, 0.25);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 13px;
    color: #3a2f23;
}

.workspace-history-item__meta {
    font-size: 11px;
    color: #8b7a68;
}

.workspace-history-item__delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
}

.workspace-passages-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.workspace-passages-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.workspace-passages-card {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(70, 50, 30, 0.15);
    border-radius: 4px;
    background: transparent;
    transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
    cursor: pointer;
}

.workspace-passages-card:hover {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(43, 99, 194, 0.28);
    box-shadow: none;
}

.workspace-passages-card--active {
    border-color: rgba(43, 99, 194, 0.4);
    box-shadow: inset 0 0 0 1px rgba(43, 99, 194, 0.2);
}
.workspace-passages-card--selected {
    border-color: rgba(43, 99, 194, 0.3);
    background: rgba(43, 99, 194, 0.03);
}

.workspace-passages-card.is-selected {
    border-color: rgba(43, 99, 194, 0.4);
    background: rgba(43, 99, 194, 0.04);
    box-shadow: inset 0 0 0 1px rgba(43, 99, 194, 0.15);
}

.workspace-passages-card.is-selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: rgba(43, 99, 194, 0.9);
}

.workspace-passages-card.passage-expanded {
    animation: expandFade 0.22s ease;
}

@keyframes expandFade {
    from {
        opacity: 0.55;
        transform: translateY(-2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.workspace-passages-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 8px 12px 0;
    box-sizing: border-box;
}

.workspace-passages-title {
    font-weight: 600;
    font-size: 13px;
    color: #3a2f23;
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workspace-passages-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

.workspace-passages-actions button {
    cursor: pointer;
}

.workspace-note-item--selected {
    border-color: rgba(43, 99, 194, 0.45);
    background: rgba(43, 99, 194, 0.08);
}

.workspace-passages-open {
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid rgba(43, 99, 194, 0.35);
    background: rgba(255, 255, 255, 0.7);
    color: #2b63c2;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.workspace-passages-open:hover {
    background: rgba(43, 99, 194, 0.12);
    border-color: rgba(43, 99, 194, 0.55);
    color: #1f4f9e;
}

.workspace-passages-delete {
    margin-left: 0;
}

.workspace-passages-bookmark {
    margin-left: 0;
}

.workspace-icon-btn:hover {
    background: rgba(43, 99, 194, 0.12);
    border-color: rgba(43, 99, 194, 0.45);
}

.session-new-chat:hover {
    background: rgba(43, 99, 194, 0.12);
    border-color: rgba(43, 99, 194, 0.45);
}


.workspace-button {
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
}

.workspace-button--ghost {
    background: rgba(70, 50, 30, 0.08);
    color: #3a2f23;
}

.workspace-button--active {
    background: rgba(43, 99, 194, 0.18);
    color: #2b63c2;
}

.workspace-button--ghost:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.workspace-collapse-toggle {
    position: absolute;
    top: -40px;
    right: 0;
    border: 1px solid rgba(70, 50, 30, 0.25);
    background: rgba(255, 255, 255, 0.4);
    color: #3a2f23;
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    box-shadow: none;
}

.workspace-link {
    display: inline-block;
    margin-top: 4px;
    font-size: 12px;
    color: #0066cc;
    text-decoration: none;
}

.workspace-history-btn {
    width: 100%;
    border: none;
    background: rgba(70, 50, 30, 0.08);
    border-radius: 8px;
    padding: 6px 8px;
    text-align: left;
    font-size: 12px;
    cursor: pointer;
}

.workspace-history-btn:hover {
    background: rgba(70, 50, 30, 0.15);
}

.workspace-note {
    background: rgba(70, 50, 30, 0.05);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12px;
    color: #3a2f23;
}


.citation-viewer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid rgba(70, 50, 30, 0.18);
    border-radius: 4px;
    padding: 10px;
    background: transparent;
}

.citation-viewer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.citation-viewer__title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #3a2f23;
}

.citation-viewer__tag {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b7a68;
}

.citation-viewer__text {
    border: 1px solid rgba(70, 50, 30, 0.15);
    border-radius: 4px;
    padding: 8px 10px;
    background: rgba(70, 50, 30, 0.03);
    font-size: 13px;
    line-height: 1.5;
    color: #3a2f23;
}

.citation-viewer__links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.citation-viewer__links a {
    font-size: 12px;
    color: #2b63c2;
    text-decoration: none;
}

.citation-viewer__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.citation-viewer__actions--top {
    margin-bottom: 10px;
    justify-content: space-between;
}

.citation-viewer__actions--primary {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.citation-viewer__actions--nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.citation-viewer__btn {
    border: 1px solid rgba(70, 50, 30, 0.25);
    background: rgba(255, 255, 255, 0.6);
    color: #3a2f23;
    border-radius: 999px;
    font-size: 12px;
    padding: 3px 10px;
    cursor: pointer;
    line-height: 1.3;
}

.citation-viewer__icon-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 8px;
}

.citation-viewer__btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.citation-viewer__btn--active {
    background: rgba(43, 99, 194, 0.2);
    border-color: rgba(43, 99, 194, 0.4);
    color: #2b63c2;
}

.workspace-writer textarea {
    width: 100%;
    border-radius: 4px;
    border: 1px solid rgba(70, 50, 30, 0.2);
    background: transparent;
    padding: 8px;
    font-size: 13px;
    color: #3a2f23;
    resize: vertical;
    box-sizing: border-box;
    min-height: 72px;
}

.workspace-writer__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.workspace-writer__actions small {
    color: #8b7a68;
}

.writer-selected-citations {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.writer-selected-citations__title {
    margin: 0;
    font-size: 13px;
    color: #3a2f23;
}

.writer-citation-item {
    border: 1px solid rgba(70, 50, 30, 0.15);
    border-radius: 4px;
    background: transparent;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.writer-citation-item__meta {
    font-size: 12px;
    font-weight: 600;
    color: #3a2f23;
}

.writer-citation-item__preview {
    margin: 0;
    font-size: 12px;
    color: #8b7a68;
    line-height: 1.3;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: calc(2 * 1.3em);
}

.writer-citation-item__actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.mobile-tray-toggle,
.mobile-tray-close {
    display: none;
}

.writer-note-item__actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.writer-controls-row {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 8px;
    align-items: center;
}

.writer-controls-row label {
    font-size: 12px;
    color: #8b7a68;
}

.writer-notes,
.writer-output {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#writerOutput {
    min-height: 180px;
}

@media (min-width: 1024px) {
    .workspace-layout {
        flex-direction: row;
        align-items: flex-start;
        width: 100%;
    }

    .chat-panel {
        max-width: none;
    }

    .research-panel {
        max-width: var(--research-col-width, 260px);
        min-width: 0;
    }

    body {
        overflow-y: auto;
        padding: 16px;
    }
}
.about-nav {
        overflow: visible;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.landing-tagline {
    margin: 0;
    font-size: 14px;
    color: #8b7a68;
}

.about-hero {
    position: relative;
    min-height: 420px;
    padding: 40px 24px;
    background-color: #f8f1df;
    background-image: url('/swedenborg/pics/swedenborg_web.png');
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 50%;
    border-radius: 20px;
}

.about-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(247, 244, 236, 0.98) 0%, rgba(247, 244, 236, 0.6) 55%, rgba(247, 244, 236, 0.1) 90%);
    pointer-events: none;
    z-index: 1;
}
.about-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.avatar-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    background: #8bbf72;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.avatar-dot.status-loading {
    border-top-color: transparent;
    background: #f0b45c;
    animation: spin 1s linear infinite;
    color: transparent;
}

.avatar-dot.status-error {
    background: #c7624a;
}

.avatar-dot.status-error::after {
    content: '!';
}

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

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

@keyframes wave {
    0%, 100% {
        transform: translateY(4px);
        opacity: 0.55;
    }
    50% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.chat-suggestions-shell {
    position: relative;
    border-top: 1px solid var(--border-light);
    background: transparent;
}

.chat-suggestions-shell::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 40px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(247, 244, 236, 0), rgba(247, 244, 236, 1));
}

.chat-suggestions-shell[hidden] {
    display: none;
}

.chat-suggestions {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    background: transparent;
    flex-wrap: nowrap;
    align-items: center;
    min-height: 48px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-gutter: stable;
    padding-right: 40px;
}

.chat-suggestions[hidden] {
    display: none;
}

.suggestion-pill {
    border-radius: 16px;
    border: 0;
    background: #5a4632;
    padding: 6px 12px;
    font-size: 13px;
    line-height: 1;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    white-space: nowrap;
    flex: 0 0 auto;
}

.suggestion-pill:hover {
    opacity: 0.85;
}

.suggestion-pill:active {
    transform: translateY(0);
}

.chat-suggestions--muted {
    opacity: 0.58;
}

.chat-suggestions--muted .suggestion-pill {
    background: rgba(90, 70, 50, 0.2);
    color: #5a4632;
}

.input-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(70, 50, 30, 0.25);
    box-shadow: none;
}

.control-button {
    border: 1px solid rgba(70, 50, 30, 0.25);
    background: rgba(255, 255, 255, 0.4);
    color: #8b7a68;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 6px 10px;
    min-width: 52px;
    height: 32px;
    border-radius: 8px;
    position: relative;
}

.control-button svg {
    width: 16px;
    height: 16px;
}

.control-button.control-button--active {
    color: #2b63c2;
    border-color: rgba(43, 99, 194, 0.5);
}

#voiceButton.control-button--active::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 12px;
    border: 2px solid rgba(43, 99, 194, 0.22);
    animation: voicePulse 1.35s ease-out infinite;
    pointer-events: none;
}

#voiceButton.control-button--active {
    background: rgba(43, 99, 194, 0.12);
    border-color: rgba(43, 99, 194, 0.5);
    color: #2b63c2;
}

@keyframes voicePulse {
    0% {
        transform: scale(0.92);
        opacity: 0.85;
    }
    70% {
        transform: scale(1.08);
        opacity: 0;
    }
    100% {
        transform: scale(1.08);
        opacity: 0;
    }
}

.control-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.control-button:hover {
    color: #c8b59b;
}

.input-bar #sendButton {
    padding: 10px 22px;
    border-radius: 18px;
    background: rgba(43, 99, 194, 0.1);
    border: 1px solid rgba(43, 99, 194, 0.35);
    color: #2b63c2;
    font-weight: 600;
    box-shadow: none;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.input-bar #sendButton:not(:disabled):hover {
    background: rgba(43, 99, 194, 0.2);
    border-color: rgba(43, 99, 194, 0.5);
}

.input-bar #sendButton:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: rgba(43, 99, 194, 0.06);
    border-color: rgba(43, 99, 194, 0.2);
    color: rgba(43, 99, 194, 0.55);
}

.input-bar textarea {
    width: 100%;
    border: none;
    resize: none;
    font-size: 16px;
    line-height: 1.5;
    color: #3a2f23;
    min-height: 40px;
    background: transparent;
}

.input-bar textarea::placeholder {
    color: #8b7a68;
}

.input-bar textarea:focus::placeholder {
    color: rgba(139, 122, 104, 0.35);
}

.input-bar textarea:focus {
    outline: none;
}

.input-bar.disabled {
    opacity: 0.6;
}

button {
    border: none;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .app-layout {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .research-panel {
        width: 100%;
        max-width: none;
        position: static;
    }

    .writer-panel {
        width: 100%;
        max-width: none;
        min-width: 0;
        justify-self: stretch;
    }

    .chat-input {
        padding: 0 12px 18px;
    }

    #ttsButton {
        display: none;
    }

    .chat-suggestions {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    }
}

/* Chat bubbles */
.message {
    width: fit-content;
    max-width: 100%;
    padding: 8px 12px;
    border-radius: 16px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.message-content {
    display: block;
}

.message-sources {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 12px;
}

.message-sources--bridge .sources-label--bridge {
    color: #7a6a54;
    font-style: italic;
}

.message-sources--bridge .message-source-chip__label {
    opacity: 0.78;
}

.message-source-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 6px 4px 9px;
    min-width: 0;
    max-width: 100%;
    border-radius: 999px;
    background: rgba(58, 47, 35, 0.06);
    border: 1px solid rgba(70, 50, 30, 0.08);
}

.message-source-chip__label {
    font-size: 10px;
    color: #5f5a54;
    white-space: nowrap;
    line-height: 1.2;
}

.message-source-chip__label-btn {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    max-width: 220px;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-source-chip__label-btn:hover {
    color: #2b63c2;
}

.message-source-chip__actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.message-source-chip__actions .icon-btn {
    width: 22px;
    height: 22px;
    border-radius: 999px;
}

.message-source-overflow {
    border: 1px solid rgba(70, 50, 30, 0.14);
    background: rgba(255, 255, 255, 0.45);
    color: #5f5a54;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 10px;
    cursor: pointer;
}

.message-source-overflow:hover {
    border-color: rgba(43, 99, 194, 0.3);
    color: #2b63c2;
}

.message-source-stack {
    border: 1px solid rgba(70, 50, 30, 0.08);
    background: rgba(58, 47, 35, 0.06);
    color: #5f5a54;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0;
    max-width: 100%;
}

.message-source-stack:hover {
    border-color: rgba(43, 99, 194, 0.3);
    color: #2b63c2;
}

.message-source-stack__text {
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-source-stack__text strong {
    color: #3a2f23;
    font-weight: 700;
}

.message-tools-menu--sources {
    min-width: 260px;
    max-width: min(380px, calc(100vw - 20px));
}

@media (prefers-reduced-motion: reduce) {
    .message-source-stack,
    .message-source-chip__label-btn,
    .locale-btn {
        transition: none;
    }
}

/* P17 app-shell correction: entry, account and consent use the same quiet
   Tremulations language as the authenticated research surfaces. */
.app-shell--restoring {
    opacity: .82;
}

.app-shell--restoring::before {
    content: 'Restoring your Tremulations research workspace…';
    position: fixed;
    z-index: 20;
    inset: 0;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--color-canvas) 88%, transparent);
    color: var(--color-text-secondary);
    font: 600 14px/1.5 "Inter", sans-serif;
    letter-spacing: .02em;
    pointer-events: none;
}

.session-panel {
    position: relative;
    align-items: center;
    gap: 10px;
}

.account-menu-button {
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text-primary);
    padding: 8px 12px;
    font: 600 12px/1 "Inter", sans-serif;
    cursor: pointer;
}

.account-menu-button:hover,
.account-menu-button:focus-visible {
    border-color: var(--color-accent);
    outline: 2px solid color-mix(in srgb, var(--color-focus-ring) 28%, transparent);
    outline-offset: 2px;
}

.account-menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 10px);
    right: 0;
    min-width: 240px;
    display: grid;
    gap: 2px;
    padding: 10px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    box-shadow: 0 16px 36px rgba(14, 20, 29, .16);
}

.account-menu__identity {
    display: grid;
    gap: 2px;
    padding: 8px 10px 12px;
    border-bottom: 1px solid var(--color-divider);
}

.account-menu__identity span,
.account-menu__label {
    color: var(--color-text-tertiary);
    font: 600 11px/1.4 "Inter", sans-serif;
}

.account-menu__label {
    padding: 10px 10px 4px;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.account-menu a,
.account-menu__signout {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border: 0;
    background: transparent;
    color: var(--color-text-primary);
    text-align: left;
    text-decoration: none;
    font: 500 13px/1.35 "Inter", sans-serif;
    cursor: pointer;
}

.account-menu a:hover,
.account-menu a:focus-visible,
.account-menu__signout:hover,
.account-menu__signout:focus-visible {
    background: var(--color-accent-soft);
    color: var(--color-accent);
    outline: none;
}

.tos-overlay {
    display: grid;
    place-items: center;
    padding: 24px;
    background: color-mix(in srgb, var(--color-canvas) 84%, rgba(14, 20, 29, .36));
    backdrop-filter: blur(8px);
}

.tos-overlay.hidden { display: none !important; }

.tos-surface {
    width: min(100%, 560px);
    box-sizing: border-box;
    padding: clamp(24px, 5vw, 44px);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-primary);
    box-shadow: 0 24px 70px rgba(14, 20, 29, .18);
}

.tos-surface__identity {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    color: var(--color-accent);
    font: 700 11px/1.2 "Inter", sans-serif;
    letter-spacing: .12em;
}

.tos-surface__identity img { width: 34px; height: 34px; }
.tos-surface h2 { margin: 6px 0 12px; font: 600 clamp(28px, 5vw, 42px)/1.05 "Source Serif 4", serif; }
.tos-surface__lead { margin: 0; color: var(--color-text-secondary); font-size: 15px; line-height: 1.65; }
.tos-surface__links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 18px 0; }
.tos-surface__links a { color: var(--color-accent); font-weight: 600; }
.tos-consent { display: flex; align-items: flex-start; gap: 10px; margin: 22px 0; color: var(--color-text-primary); font-size: 14px; line-height: 1.5; }
.tos-consent input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--color-accent); }
.tos-surface__primary { width: 100%; padding: 12px 16px; border: 0; border-radius: 6px; background: var(--color-accent); color: var(--color-on-accent); font: 700 14px/1.2 "Inter", sans-serif; cursor: pointer; }
.tos-surface__primary:disabled { opacity: .45; cursor: not-allowed; }
.tos-surface__note { margin: 18px 0 0; color: var(--color-text-tertiary); font-size: 12px; line-height: 1.5; }

@media (max-width: 680px) {
    .account-menu { position: fixed; top: 76px; right: 16px; left: 16px; }
    .tos-overlay { align-items: end; padding: 0; }
    .tos-surface { width: 100%; max-height: 92vh; overflow-y: auto; border-bottom: 0; }
}

/* Keep the platform boundary last in the cascade so legacy environment
   selectors cannot reintroduce brown/sepia values into the authenticated shell. */
body:not(.landing-page):not(.tos-page) {
    background: var(--color-canvas);
    color: var(--color-text-primary);
    --bg: var(--color-canvas);
    --cl-canvas: var(--color-canvas);
    --cl-parchment: var(--color-surface-subtle);
    --cl-card: var(--color-surface);
    --cl-text-primary: var(--color-text-primary);
    --cl-text-secondary: var(--color-text-secondary);
    --cl-text-muted: var(--color-text-tertiary);
    --cl-blue: var(--color-accent);
    --cl-blue-hover: var(--color-focus-ring);
    --cl-blue-soft: var(--color-accent-soft);
    --cl-border: var(--color-border);
    --cl-ink: var(--color-divider);
    --border-light: var(--color-divider);
}

body:not(.landing-page):not(.tos-page) .brand-avatar--trace,
body:not(.landing-page):not(.tos-page) .brand-avatar--trace img {
    color: var(--color-accent);
}

body:not(.landing-page):not(.tos-page) .app-shell,
body:not(.landing-page):not(.tos-page) .site-header,
body:not(.landing-page):not(.tos-page) .research-panel,
body:not(.landing-page):not(.tos-page) .chat-panel,
body:not(.landing-page):not(.tos-page) .writer-panel,
body:not(.landing-page):not(.tos-page) .panel-section,
body:not(.landing-page):not(.tos-page) .workspace-card {
    color: var(--color-text-primary);
    background: var(--color-surface);
    border-color: var(--color-divider);
}

body:not(.landing-page):not(.tos-page) .app-shell input,
body:not(.landing-page):not(.tos-page) .app-shell textarea,
body:not(.landing-page):not(.tos-page) .app-shell select {
    color: var(--color-text-primary);
    background: var(--color-surface);
    border-color: var(--color-border);
}

body:not(.landing-page):not(.tos-page) .app-shell .message-tools-source-label {
    color: var(--color-text-secondary);
}

/* P17 Resonant Ledger primitives. These classes are shared by the platform
   shell and environment landing surfaces; environment accents stay local. */
body:not(.landing-page):not(.tos-page) {
    background: var(--color-canvas);
    color: var(--color-text-primary);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    --bg: var(--color-canvas);
    --cl-canvas: var(--color-canvas);
    --cl-parchment: var(--color-surface-subtle);
    --cl-card: var(--color-surface);
    --cl-text-primary: var(--color-text-primary);
    --cl-text-secondary: var(--color-text-secondary);
    --cl-text-muted: var(--color-text-tertiary);
    --cl-blue: var(--color-accent);
    --cl-blue-hover: var(--color-focus-ring);
    --cl-blue-soft: var(--color-accent-soft);
    --cl-border: var(--color-border);
    --cl-ink: var(--color-divider);
    --border-light: var(--color-divider);
}

body:not(.landing-page):not(.tos-page) .app-shell,
body:not(.landing-page):not(.tos-page) .site-header,
body:not(.landing-page):not(.tos-page) .research-panel,
body:not(.landing-page):not(.tos-page) .chat-panel,
body:not(.landing-page):not(.tos-page) .writer-panel,
body:not(.landing-page):not(.tos-page) .panel-section,
body:not(.landing-page):not(.tos-page) .workspace-card {
    color: var(--color-text-primary);
    background: var(--color-surface);
    border-color: var(--color-divider);
}

body:not(.landing-page):not(.tos-page) .app-shell input,
body:not(.landing-page):not(.tos-page) .app-shell textarea,
body:not(.landing-page):not(.tos-page) .app-shell select {
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

body:not(.landing-page):not(.tos-page) .app-shell .message-tools-source-label {
    color: var(--color-text-secondary);
}

.landing-page {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.landing-page h1,
.landing-page h2,
.landing-page h3,
.landing-page h4 {
    font-family: "Source Serif 4", Georgia, serif;
}

.brand-avatar--trace {
    display: grid;
    place-items: center;
    position: relative;
}

.brand-avatar--trace img {
    width: 34px;
    height: 34px;
    color: var(--color-accent);
}

.brand-avatar--trace .avatar-dot {
    right: -2px;
    bottom: -2px;
}

.tremulations-propagation {
    color: var(--color-accent);
    width: min(100%, 720px);
    margin: 8px auto 4px;
}

.tremulations-propagation picture,
.landing-platform-proof__method picture {
    display: block;
}

.tremulations-propagation img {
    display: block;
    width: 100%;
    height: auto;
}

.investigation-shell-overview__system-proof {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.semantic-state-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.semantic-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.semantic-state > span:first-child {
    color: var(--color-accent);
    font-size: 15px;
}

.semantic-state--result {
    border-style: dashed;
}

.semantic-state--retained {
    border-inline-start: 3px solid var(--color-success);
}

.semantic-state--generated {
    background: var(--color-generated-background-subtle);
    color: var(--color-generated-foreground);
}

.semantic-state--note {
    border-inline-start: 3px solid var(--color-unresolved-border);
}

.semantic-state--writing {
    border-radius: var(--radius-panel);
}

.workspace-passages-card.is-just-added {
    animation: tremulations-trace-propagate 420ms ease-out both;
}

@keyframes tremulations-trace-propagate {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-accent) 35%, transparent); }
    55% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--color-accent) 12%, transparent); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.brand-mark--trace {
    display: grid;
    place-items: center;
    color: var(--cl-blue);
}

.brand-mark--trace img {
    width: 34px;
    height: 34px;
}

.landing-platform-proof {
    display: grid;
    grid-template-columns: minmax(260px, .8fr) minmax(360px, 1.2fr);
    gap: 28px;
    align-items: center;
    padding: 20px 24px;
    border: 1px solid color-mix(in srgb, var(--cl-blue) 20%, var(--cl-border));
    border-radius: 18px;
    background: color-mix(in srgb, var(--cl-card) 88%, var(--cl-blue-soft));
}

.landing-platform-proof__identity {
    display: flex;
    align-items: center;
    gap: 16px;
}

.landing-platform-proof__mark {
    width: 52px;
    height: 52px;
    color: var(--cl-blue);
    flex: 0 0 auto;
}

.landing-platform-proof__title {
    margin: 2px 0 4px;
    color: var(--cl-text-primary);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 20px;
}

.landing-platform-proof__copy {
    margin: 0;
    color: var(--cl-text-secondary);
    font-size: 13px;
    line-height: 1.45;
}

.landing-platform-proof__method {
    position: relative;
    color: var(--cl-blue);
    min-width: 0;
}

.landing-platform-proof__method::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 12%;
    width: 10px;
    height: 10px;
    border: 2px solid var(--cl-blue);
    border-radius: 50%;
    background: var(--cl-card);
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--cl-blue) 15%, transparent);
    transform: translate(-50%, -50%);
    animation: tremulations-hero-pulse 4.2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes tremulations-hero-pulse {
    0%, 12% { left: 12%; opacity: .25; }
    24% { opacity: 1; }
    88%, 100% { left: 88%; opacity: .25; }
}

.landing-platform-proof__method img {
    display: block;
    width: 100%;
    height: auto;
}

@media (max-width: 760px) {
    .landing-platform-proof {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 18px;
    }

    .landing-platform-proof__method {
        overflow: hidden;
    }

    .landing-platform-proof__method img {
        min-width: 520px;
        transform: translateX(-12%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .workspace-passages-card.is-just-added {
        animation: none;
    }

    .landing-platform-proof__method::after {
        animation: none;
        left: 88%;
        opacity: .65;
    }
}

/* People-first P12 shell: the selected artifact owns the canvas and legacy
   rails become contextual inspector content. */
body.people-first .app-layout {
    grid-template-columns: minmax(0, 1fr);
}
body.people-first #researchPanel,
body.people-first #writerPanel,
body.people-first #dragHandle {
    display: none !important;
}
body.people-first .chat-panel--main {
    padding: 0 clamp(16px, 4vw, 48px);
}
.people-first-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
    gap: var(--space-6);
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
    padding: var(--space-5) 0;
}
.workspace-canvas {
    min-width: 0;
    overflow-y: auto;
    padding: 0 var(--space-2) var(--space-6);
}
.workspace-mode-canvas {
    min-height: 100%;
    background: var(--color-canvas);
}
.workspace-canvas__title {
    margin: 0 0 var(--space-5);
    color: var(--color-text-primary);
    font-size: 22px;
    font-weight: 600;
}
.workspace-mode-canvas > .panel-section,
.workspace-mode-canvas > .workspace-card,
.workspace-mode-canvas > .workspace-investigation-detail {
    margin: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
.workspace-mode-canvas .workspace-investigations,
.workspace-mode-canvas .workspace-citation,
.workspace-mode-canvas .workspace-writer {
    display: block;
    width: 100%;
    max-width: 860px;
}
.workspace-inspector {
    min-width: 0;
    align-self: start;
    padding: var(--space-4) 0;
    border-left: 1px solid var(--color-divider);
    color: var(--color-text-secondary);
}
.workspace-inspector > * {
    margin-left: var(--space-4);
    margin-right: var(--space-4);
}
.workspace-inspector .panel-section {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-divider);
    background: transparent;
}
.workspace-inspector .panel-section__label {
    color: var(--color-text-primary);
}
body.people-first .message.user {
    align-self: flex-end;
    background: var(--color-accent-soft);
    border: 1px solid var(--color-accent);
    color: var(--color-text-primary);
}
body.people-first .message.ai {
    align-self: flex-start;
    background: var(--color-surface);
    border: 1px solid var(--color-divider);
    color: var(--color-text-primary);
    border-radius: var(--radius-panel);
}
body.people-first .active-session,
body.people-first .workspace-mode-canvas .workspace-writer h3,
body.people-first .workspace-mode-canvas .workspace-writer h4,
body.people-first .workspace-mode-canvas .workspace-writer label,
body.people-first .workspace-mode-canvas .workspace-writer p,
body.people-first .workspace-mode-canvas .workspace-writer small,
body.people-first .workspace-mode-canvas .workspace-writer .workspace-muted,
body.people-first .workspace-mode-canvas .research-set-overview__counts span {
    color: var(--color-text-secondary);
}
body.people-first .workspace-mode-canvas .workspace-writer h3,
body.people-first .workspace-mode-canvas .workspace-writer h4 {
    color: var(--color-text-primary);
}
body.people-first .discussion-pane .chat-suggestions {
    background: transparent;
}
body.people-first .discussion-pane .suggestion-pill {
    background: var(--color-surface-subtle);
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}
body.people-first .discussion-pane .chat-input-wrapper,
body.people-first .discussion-pane .input-bar {
    background: var(--color-surface);
    border-color: var(--color-divider);
}
body.people-first .discussion-pane .chat-disclaimer {
    color: var(--color-text-tertiary);
}
@media (max-width: 900px) {
    .people-first-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .workspace-inspector {
        display: none;
    }
}
@media (max-width: 699px) {
    body.people-first .chat-panel--main {
        padding: 0 var(--space-3);
    }
    .people-first-layout {
        padding-top: var(--space-3);
    }
}

/* P12 authenticated investigation anatomy. Public marketing selectors above
   retain their own palette; this boundary is the only product workspace. */
body:not(.landing-page):not(.tos-page) .investigation-shell-nav,
body:not(.landing-page):not(.tos-page) .investigation-shell-overview,
body:not(.landing-page):not(.tos-page) .discussion-pane {
    font-family: Inter, "Segoe UI", sans-serif;
}

.investigation-shell-nav {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-divider);
    overflow-x: auto;
}
.investigation-shell-nav__item,
.investigation-shell-nav__discussion,
.discussion-pane__actions button,
.discussion-pane__close {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color var(--motion-standard) ease, color var(--motion-standard) ease, border-color var(--motion-standard) ease;
}
.investigation-shell-nav__item.is-active,
.investigation-shell-nav__item:hover,
.discussion-pane__actions button:hover {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
    color: var(--color-text-primary);
}
.investigation-shell-nav__discussion { margin-left: auto; color: var(--color-accent); }
.investigation-shell-overview {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    margin: var(--space-4);
    padding: var(--space-5);
    background: var(--color-surface-subtle);
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-panel);
}
.workspace-eyebrow { margin: 0 0 var(--space-2); color: var(--color-text-tertiary); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.investigation-shell-overview h2, .discussion-pane h2 { margin: 0 0 var(--space-2); color: var(--color-text-primary); }
.investigation-shell-overview p:not(.workspace-eyebrow), .discussion-pane p { margin: 0; color: var(--color-text-secondary); }
.investigation-shell-overview__states { display: flex; align-items: flex-start; gap: var(--space-2); flex-wrap: wrap; }
.state-chip { border: 1px solid; border-radius: 999px; padding: 4px 8px; font-size: 12px; }
.state-chip--generated { color: var(--color-generated-foreground); background: var(--color-generated-background-subtle); border-color: var(--color-generated-border); }
.state-chip--unresolved { color: var(--color-unresolved-foreground); background: var(--color-unresolved-background-subtle); border-color: var(--color-unresolved-border); }
.discussion-pane { margin: 0 var(--space-4) var(--space-4); padding: var(--space-5); background: var(--color-surface-elevated); border: 1px solid var(--color-accent); border-radius: var(--radius-panel); box-shadow: 0 8px 24px rgba(23, 32, 51, .12); }
.discussion-pane__header { display: flex; justify-content: space-between; gap: var(--space-4); }
.discussion-pane__actions { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }
.discussion-pane__actions small { color: var(--color-text-tertiary); }
.discussion-pane__conversation { min-height: 320px; display: flex; flex-direction: column; margin-top: var(--space-4); border-top: 1px solid var(--color-divider); }
.discussion-pane__conversation .chat-messages { min-height: 220px; flex: 1 1 auto; }
body[data-workspace-mode="research"] .workspace-investigations,
body[data-workspace-mode="evidence"] .workspace-citation,
body[data-workspace-mode="synthesis"] .workspace-investigation-detail,
body[data-workspace-mode="write"] .writer-panel { box-shadow: inset 3px 0 0 var(--color-accent); }
body:not(.discussion-open) .chat-panel--main > .chat-messages,
body:not(.discussion-open) .chat-panel--main > .chat-input-wrapper,
body:not(.discussion-open) .chat-panel--main > .chat-suggestions-shell,
body:not(.discussion-open) .chat-panel--main > .chat-disclaimer { display: none; }
.writer-output textarea, .writer-panel textarea, .message-content { font-family: "Source Serif 4", Georgia, serif; }
.writer-panel, .research-panel, .chat-panel, .workspace-card, .panel-section, .chat-messages, #chatbox { color: var(--color-text-primary); background: var(--color-surface); border-color: var(--color-divider); }
.app-shell input, .app-shell textarea, .app-shell select { color: var(--color-text-primary); background: var(--color-surface); border-color: var(--color-border); }
.app-shell button { font-family: Inter, "Segoe UI", sans-serif; }

@media (max-width: 699px) {
    .investigation-shell-nav { padding: var(--space-2); }
    .investigation-shell-nav__discussion { margin-left: 0; }
    .investigation-shell-overview { margin: var(--space-3); padding: var(--space-4); display: block; }
    .investigation-shell-overview__states { margin-top: var(--space-3); }
    .discussion-pane { margin: 0 var(--space-3) var(--space-3); min-height: calc(100dvh - 210px); }
    .discussion-pane { position: fixed; inset: 0; z-index: 120; margin: 0; border-radius: 0; overflow: auto; }
    .discussion-pane__actions { align-items: stretch; flex-direction: column; }
}

.message-tools-source-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-radius: 8px;
    padding: 2px;
}

.message-tools-source-label {
    border: none;
    background: transparent;
    text-align: left;
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 12px;
    color: #3a2f23;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-tools-source-label:hover,
.message-tools-source-label:focus-visible {
    background: rgba(43, 99, 194, 0.1);
    color: #1f4f9e;
}

.message-tools-source-bookmark {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 999px;
}

.bookmark-fly-token {
    position: fixed;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: rgba(43, 99, 194, 0.12);
    border: 1px solid rgba(43, 99, 194, 0.28);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 2600;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.bookmark-fly-token__icon,
.bookmark-fly-token__icon svg {
    width: 14px;
    height: 14px;
    color: #2b63c2;
}

.source-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 20px;
    z-index: 999;
}

.source-modal.hidden {
    display: none;
}

.source-modal__panel {
    width: min(640px, 100%);
    max-height: 80vh;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 18px 18px 0 0;
    border: 1px solid rgba(70, 50, 30, 0.25);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.source-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    gap: 12px;
}

.source-modal__header h3 {
    margin: 0;
    font-size: 15px;
    flex: 1;
}

.source-modal__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.source-modal__action-btn {
    height: 32px;
    width: 32px;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.source-modal__action-btn svg {
    width: 16px;
    height: 16px;
}

.source-modal__action-btn--icon {
    width: 32px;
    padding: 0;
    justify-content: center;
}

.source-modal__translation {
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(70, 50, 30, 0.18);
    border-radius: 8px;
    padding: 10px 12px;
    white-space: pre-wrap;
}

.source-modal__translation-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #8b7a68;
    font-size: 12px;
}

.source-modal__translation-meta strong {
    font-weight: 500;
}

.source-modal__translation-link {
    border: none;
    padding: 0;
    background: transparent;
    color: #2b63c2;
    font: inherit;
    cursor: pointer;
}

.source-modal__translation-link:hover {
    text-decoration: underline;
}

.source-modal__translation-loading {
    padding: 18px 16px;
    border: 1px solid rgba(70, 50, 30, 0.14);
    border-radius: 10px;
    color: #8b7a68;
    background: rgba(255, 255, 255, 0.42);
}

.source-modal__translation--animated {
    animation: sourceTranslationSwapIn 360ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.source-modal__translation-loading--animated {
    animation: sourceTranslationSwapIn 260ms cubic-bezier(0.2, 0.8, 0.2, 1), sourceTranslationPulse 900ms ease-in-out infinite;
}

@keyframes sourceTranslationSwapIn {
    from {
        opacity: 0;
        transform: translateY(8px);
        filter: blur(1.5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

@keyframes sourceTranslationPulse {
    0%, 100% {
        opacity: 0.72;
    }
    50% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .source-modal__translation--animated,
    .source-modal__translation-loading--animated {
        animation: none;
    }
}

.source-modal__body {
    padding: 16px;
    font-size: 14px;
    line-height: 1.5;
    overflow-y: auto;
    white-space: pre-wrap;
}

.source-modal--evidence .source-modal__panel {
    width: min(760px, 100%);
}

.evidence-drawer__intro {
    margin: 0 0 14px;
    color: #6b6258;
    font-size: 13px;
    white-space: normal;
}

.evidence-drawer__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.evidence-drawer__item {
    border: 1px solid rgba(70, 50, 30, 0.15);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.45);
}

.evidence-drawer__actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
    padding: 6px;
}

.evidence-drawer__open {
    min-width: 0;
    border: 0;
    padding: 8px 10px;
    background: transparent;
    text-align: left;
    color: #3a2f23;
    cursor: pointer;
}

.evidence-drawer__open strong,
.evidence-drawer__open span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.evidence-drawer__open strong {
    font-size: 13px;
}

.evidence-drawer__open span {
    margin-top: 3px;
    color: #8b7a68;
    font-size: 12px;
    font-weight: 400;
}

.evidence-drawer__open:hover,
.evidence-drawer__open:focus-visible {
    background: rgba(43, 99, 194, 0.08);
    border-radius: 8px;
    outline: none;
}

@media (max-width: 600px) {
    .evidence-drawer__actions {
        grid-template-columns: minmax(0, 1fr) auto auto;
    }

    .evidence-drawer__open span {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
}

.bible-context-block {
    background: #fefcf3;
    border-left: 4px solid #efd889;
    padding: 12px 14px;
    border-radius: 10px;
    margin: 10px 0;
    font-size: 15px;
    line-height: 1.5;
    color: #3a2f23;
}
.bible-context {
    display: inline;
    font-weight: 400;
    color: #8b7a68;
}
.bible-context.main {
    font-weight: 600;
    color: #3a2f23;
    padding: 0 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(70, 50, 30, 0.25);
}

.swedenborg-context-block {
    background: rgba(255, 255, 255, 0.4);
    border-left: 4px solid rgba(70, 50, 30, 0.25);
    padding: 14px 16px;
    border-radius: 10px;
    margin: 10px 0;
    font-size: 15px;
    line-height: 1.55;
    color: #3a2f23;
}
.swedenborg-context-block p {
    margin: 0 0 10px;
}
.swedenborg-context-block p:last-child {
    margin-bottom: 0;
}

.citation-link {
    border: none;
    background: rgba(43, 99, 194, 0.1);
    color: #2b63c2;
    border-radius: 999px;
    padding: 2px 8px;
    margin: 0 2px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
}

.citation {
    display: inline-flex;
    align-items: center;
    border: none;
    background: rgba(43, 99, 194, 0.1);
    color: #2b63c2;
    border-radius: 999px;
    padding: 1px 7px;
    margin: 0 2px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
}

.glossary-term {
    border-bottom: 1px dotted #8b7355;
    cursor: help;
}

.glossary-tooltip {
    position: absolute;
    background: #fffdf7;
    border: 1px solid #d8cfc0;
    padding: 10px;
    border-radius: 6px;
    max-width: 260px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 2200;
    font-size: 12.5px;
    line-height: 1.4;
    color: #3a2f23;
}

.message-actions {
    margin-top: 8px;
    display: flex;
    justify-content: flex-start;
}

.message-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.message-tools-menu {
    position: absolute;
    z-index: 2300;
    min-width: 180px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(70, 50, 30, 0.2);
    border-radius: 10px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message-tools-menu__item {
    border: none;
    background: transparent;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    color: #3a2f23;
    cursor: pointer;
}

.message-tools-menu__item:hover,
.message-tools-menu__item:focus-visible {
    background: rgba(43, 99, 194, 0.1);
    color: #1f4f9e;
}

.deepen-btn {
    border: 1px solid rgba(70, 50, 30, 0.25);
    border-radius: 999px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.75);
    color: #3a2f23;
    font-size: 12px;
    cursor: pointer;
}

.deepen-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.highlight {
    background: #fff3a0;
    transition: background 2s ease;
}
.user {
    align-self: flex-end;
    background-color: rgba(255, 255, 255, 0.5);
    border-bottom-right-radius: 4px;
}

.ai {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(70, 50, 30, 0.25);
    border-bottom-left-radius: 4px;
}

.message.system {
    align-self: center;
    background-color: #ffecec;
    border: 1px dashed #f28b82;
    color: #c62828;
}

@media (max-width: 768px) {
    html, body {
        overflow-y: auto;
        height: auto;
    }

    .app-shell {
        min-width: 0;
        flex: 1 1 auto;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .writer-panel {
        width: 100%;
        max-width: none;
        min-width: 0;
        flex: 1 1 auto;
        justify-self: stretch;
    }

    .research-collapse {
        position: static;
        transform: none;
        width: 100%;
        height: 32px;
        border-radius: 8px;
    }

    .app-layout {
        grid-template-columns: 1fr;
        min-height: 0;
        flex: 1 0 auto;
    }

    .drag-handle {
        display: none;
    }

    .chat-panel {
        min-height: calc(100vh - 220px);
    }

    .research-panel {
        width: auto;
        max-width: none;
        position: static;
        max-height: none;
        margin-top: 12px;
        align-self: stretch;
    }
}

@media (max-width: 960px) {
    .app-layout {
        grid-template-columns: 1fr;
        gap: 12px;
        height: auto;
        overflow: hidden;
    }

    .drag-handle {
        display: none;
    }

    .left-panel,
    .right-panel,
    .chat-panel--main,
    .chat-panel,
    .research-panel,
    .writer-panel {
        height: auto;
    }

    .chat-panel {
        order: 1;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        justify-self: stretch;
    }

    .research-panel {
        order: 2;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        max-height: none;
        position: static;
        align-self: stretch;
    }

    body.has-collapsed-research .research-panel {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        max-height: 56px;
    }

    body.has-collapsed-research .app-layout {
        grid-template-columns: 1fr;
    }

    .writer-panel {
        order: 3;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        justify-self: stretch;
    }
}

/* Mobile trays: the chat remains the primary surface and workspaces open as sheets. */
@media (max-width: 960px) {
    html,
    body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .app-shell {
        min-width: 0;
        min-height: 100dvh;
        height: auto;
    }

    .app-layout {
        display: block;
        height: auto;
        min-height: calc(100dvh - var(--header-height, 72px));
        overflow: visible;
    }

    .chat-panel,
    .chat-panel--main {
        width: 100%;
        height: auto;
        min-height: calc(100dvh - var(--header-height, 72px));
        overflow: visible;
        overflow-x: clip;
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }

    .chat-messages,
    #chatbox {
        flex: none;
        max-height: none;
        overflow: visible;
        width: 100%;
        overflow-x: clip;
    }

    .chat-input-wrapper {
        position: sticky;
        bottom: 0;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .mobile-tray-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        min-height: 34px;
        padding: 0 11px;
        border: 1px solid rgba(70, 50, 30, 0.18);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.36);
        color: #5a4632;
        font-size: 12px;
    }

    .mobile-tray-toggle[aria-expanded="true"] {
        border-color: rgba(43, 99, 194, 0.45);
        background: rgba(43, 99, 194, 0.12);
        color: #2b63c2;
    }

    .research-panel {
        position: fixed;
        inset: var(--header-height, 72px) auto 0 0;
        z-index: 1200;
        width: min(420px, 100vw);
        max-width: min(420px, 100vw);
        height: auto;
        max-height: none;
        margin: 0;
        border-right: 1px solid rgba(70, 50, 30, 0.18);
        box-shadow: 12px 0 32px rgba(58, 47, 35, 0.16);
        transform: translateX(-105%);
        transition: transform 0.22s ease;
    }

    body:not(.has-collapsed-research) .research-panel {
        transform: translateX(0);
    }

    body.has-collapsed-research .research-panel {
        width: min(420px, 100vw);
        min-width: 0;
        max-width: min(420px, 100vw);
        padding: 0;
        overflow-y: auto;
    }

    body.has-collapsed-research .research-panel .panel-section--header {
        display: flex;
    }

    body.has-collapsed-research .research-panel .workspace-card,
    body.has-collapsed-research .research-panel .panel-section:not(.panel-section--header),
    body.has-collapsed-research .research-panel .workspace-column-empty {
        display: flex;
    }

    .writer-panel,
    .writer-panel.collapsed {
        position: fixed;
        inset: var(--header-height, 72px) 0 0 auto;
        z-index: 1190;
        width: min(420px, 100vw);
        max-width: min(420px, 100vw);
        height: auto;
        min-height: 0;
        border-left: 1px solid rgba(70, 50, 30, 0.18);
        background: #f7f4ec;
        box-shadow: -12px 0 32px rgba(58, 47, 35, 0.16);
        transform: translateX(105%);
        visibility: hidden;
        pointer-events: none;
        opacity: 1;
        transition: transform 0.22s ease, visibility 0s linear 0.22s;
    }

    .writer-panel:not(.collapsed) {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
        transition-delay: 0s;
    }

    .writer-panel .workspace-writer {
        overflow-y: auto;
        padding-bottom: max(18px, env(safe-area-inset-bottom));
    }

    .message {
        width: 100%;
        max-width: 100%;
    }

    .message-sources {
        gap: 6px 8px;
    }

    .message-source-chip__label-btn {
        max-width: min(220px, 58vw);
    }

    .mobile-tray-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border: 1px solid rgba(70, 50, 30, 0.18);
        border-radius: 999px;
        background: transparent;
        color: #5a4632;
        font-size: 22px;
        line-height: 1;
    }

    .active-session__actions {
        gap: 6px;
    }

    @media (prefers-reduced-motion: reduce) {
        .research-panel,
        .writer-panel,
        .writer-panel.collapsed {
            transition: none;
        }
    }
}
.control-row button {
    border: none;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
}
.chat-input {
    padding: 0;
    margin-top: 0;
    flex-shrink: 0;
}

.chat-input-wrapper {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--bg);
    padding-bottom: clamp(10px, 2vh, 24px);
}

.input-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(70, 50, 30, 0.25);
    box-shadow: none;
}

.input-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 16px;
    margin-top: 2px;
}

.input-icons {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: auto;
}
.topic-bar {
    margin: 4px 0 0;
}
.tos-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.tos-modal {
    background: #fffef7;
    border-radius: 18px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: center;
}

.tos-modal h2 {
    margin: 0;
    font-size: 20px;
    color: #3a2f23;
}

.tos-link {
    margin: 0;
    font-size: 13px;
}

.tos-link a {
    color: #2b63c2;
    text-decoration: underline;
}

.tos-consent {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #3a2f23;
}

.tos-modal button {
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    background: #2b63c2;
    color: #fff;
    cursor: pointer;
}

.tos-modal button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.about-hero__portrait-inline {
    display: none;
}

.about-hero__portrait-inline img {
    border: 1px solid rgba(70, 50, 30, 0.2);
    border-radius: 20px;
    width: 100%;
    object-fit: cover;
}

@media (max-width: 1099px) {
    .about-hero {
        background-size: 42%;
        background-position: calc(100% - 20px) center;
        padding-right: 200px;
    }
    .about-hero__text {
        max-width: 440px;
    }
}

@media (max-width: 699px) {
    .about-nav,
    .landing-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .about-hero {
        background: none;
        padding: 24px 12px;
    }
    .about-hero__portrait-inline {
        display: block;
        margin-bottom: 16px;
    }
    .about-hero__portrait-inline img {
        border-radius: 20px;
    }
    .about-hero__text {
        max-width: none;
        width: 100%;
    }
}
.correspondence-field {
    min-height: 340px;
}

@media (max-width: 1099px) {
    .correspondence-field {
        min-height: 300px;
    }
    .correspondence-field__figure {
        opacity: 0.55;
    }
    .correspondence-field__labels .label--optional {
        display: none;
    }
.landing-hero__visual::before,
.landing-hero__visual::after {
        background-size: cover;
        background-position: center;
        opacity: 0.28;
    }
}

@media (max-width: 699px) {
    .landing-hero__visual {
        padding: 18px;
    }
.landing-hero__visual::before,
.landing-hero__visual::after {
        background-size: cover;
        background-position: center 15%;
        opacity: 0.22;
    }
    .correspondence-field {
        min-height: 220px;
    }
    .correspondence-field__figure {
        opacity: 0.45;
    }
    .correspondence-field__labels .label:not(.label--core) {
        display: none;
    }
    .correspondence-field__watermark {
        opacity: 0.55;
        font-size: 15px;
    }
}
.hero-link {
    font-size: 14px;
    color: var(--cl-blue);
    text-decoration: none;
}

.hero-link:hover {
    text-decoration: underline;
}
.signup-page {
    background: #f7f4ec;
    color: #3a2f23;
    font-family: Arial, sans-serif;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    box-sizing: border-box;
}

.signup-shell {
    max-width: var(--public-shell-max-width);
    width: 100%;
    margin: 0 auto;
    padding: var(--public-shell-padding);
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100vh;
    box-sizing: border-box;
}

.signup-header,
.landing-header,
.about-nav {
    min-height: 72px;
    padding: 8px 0;
    box-sizing: border-box;
}

.signup-main {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1 1 auto;
}

.signup-card {
    max-width: 560px;
    width: 100%;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(70, 50, 30, 0.25);
    border-radius: 20px;
    padding: 32px;
    text-align: left;
}

.signup-eyebrow {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8b7a68;
    margin: 0;
}

.signup-card h2 {
    margin: 6px 0 16px;
}

.signup-consent {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    margin: 16px 0;
    font-size: 14px;
}

.signup-card button {
    width: 100%;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #2b63c2, #295cb5);
    color: #fff;
    padding: 12px 18px;
    font-size: 15px;
}

.signup-card button:disabled {
    opacity: 0.6;
}

.signup-note {
    font-size: 12px;
    color: #8b7a68;
}

.signup-login a {
    color: #2b63c2;
}

.about-hero--plain {
    background-image: none;
    background-color: rgba(248, 241, 223, 0.8);
}

.about-hero--plain::after {
    background: linear-gradient(90deg, rgba(247, 244, 236, 0.92) 0%, rgba(247, 244, 236, 0.76) 100%);
}
@keyframes grandManFade {
    0% { opacity: 0.85; }
    40% { opacity: 0.85; }
    50% { opacity: 0; }
    90% { opacity: 0; }
    100% { opacity: 0.85; }
}

/* Authenticated P12 shell boundary. Public pages retain their environment
   styling while workspace chrome uses the shared platform semantics. */
body:not(.landing-page):not(.tos-page) {
    background: var(--color-canvas);
    color: var(--color-text-primary);
    font-family: Inter, "Open Sans", "Segoe UI", sans-serif;
}

body:not(.landing-page):not(.tos-page) .app-shell,
body:not(.landing-page):not(.tos-page) .chat-panel,
body:not(.landing-page):not(.tos-page) .chat-messages,
body:not(.landing-page):not(.tos-page) #chatbox {
    background: var(--color-canvas);
    color: var(--color-text-primary);
}

body:not(.landing-page):not(.tos-page) .site-header,
body:not(.landing-page):not(.tos-page) .writer-panel,
body:not(.landing-page):not(.tos-page) .research-panel {
    background: var(--color-surface);
    color: var(--color-text-primary);
    border-color: var(--color-divider);
}

body:not(.landing-page):not(.tos-page) .workspace-card,
body:not(.landing-page):not(.tos-page) .research-panel .panel-section:not(.panel-section--header),
body:not(.landing-page):not(.tos-page) .active-session {
    border-color: var(--color-divider);
}

body:not(.landing-page):not(.tos-page) button,
body:not(.landing-page):not(.tos-page) input,
body:not(.landing-page):not(.tos-page) textarea,
body:not(.landing-page):not(.tos-page) select {
    font: inherit;
}

body:not(.landing-page):not(.tos-page) input,
body:not(.landing-page):not(.tos-page) textarea,
body:not(.landing-page):not(.tos-page) select {
    color: var(--color-text-primary);
    background: var(--color-surface);
    border-color: var(--color-border);
}

body:not(.landing-page):not(.tos-page) input::placeholder,
body:not(.landing-page):not(.tos-page) textarea::placeholder {
    color: var(--color-text-tertiary);
    opacity: 1;
}

body:not(.landing-page):not(.tos-page) .brand-text h1,
body:not(.landing-page):not(.tos-page) .writer-panel h3,
body:not(.landing-page):not(.tos-page) .writer-panel h4 {
    color: var(--color-text-primary);
}

body:not(.landing-page):not(.tos-page) .panel-section__label,
body:not(.landing-page):not(.tos-page) .writer-panel label,
body:not(.landing-page):not(.tos-page) .writer-panel small,
body:not(.landing-page):not(.tos-page) .writer-panel p,
body:not(.landing-page):not(.tos-page) .research-panel p {
    color: var(--color-text-secondary);
}

body:not(.landing-page):not(.tos-page) button:focus-visible,
body:not(.landing-page):not(.tos-page) input:focus-visible,
body:not(.landing-page):not(.tos-page) textarea:focus-visible,
body:not(.landing-page):not(.tos-page) select:focus-visible {
    outline: 2px solid var(--color-focus-ring);
    outline-offset: 2px;
}

body:not(.landing-page):not(.tos-page) .workspace-muted,
body:not(.landing-page):not(.tos-page) .chat-disclaimer,
body:not(.landing-page):not(.tos-page) .active-session {
    color: var(--color-text-tertiary);
}

body:not(.landing-page):not(.tos-page) .research-set-overview {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
}

body:not(.landing-page):not(.tos-page) .generated-state {
    color: var(--color-generated-foreground);
    background: var(--color-generated-background-subtle);
    border-color: var(--color-generated-border);
}

body:not(.landing-page):not(.tos-page) .unresolved-state {
    color: var(--color-unresolved-foreground);
    background: var(--color-unresolved-background-subtle);
    border-color: var(--color-unresolved-border);
}

@media (prefers-reduced-motion: reduce) {
    body:not(.landing-page):not(.tos-page) *,
    body:not(.landing-page):not(.tos-page) *::before,
    body:not(.landing-page):not(.tos-page) *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}
