/* ==========================================================================
   VIRAT — Research workspace
   Plain flexbox CSS, no frameworks.
   Concept: ink on paper, with a highlighter marking what VIRAT is reading.
   ========================================================================== */

:root {
    --paper: #f3f4f7;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --ink: #18213d;
    --ink-2: #48516f;
    --ink-3: #7b839c;
    --rule: #e1e4ec;
    --rule-2: #eceef3;
    --navy: #24346b;
    --navy-hover: #1b2858;
    --navy-soft: #e9edf8;
    --on-navy: #ffffff;
    --mark: #ffe066;
    --mark-ink: #3a3000;
    --mark-soft: #fff6cc;
    --mark-stroke: #ffe066;
    --cite: #c4561f;
    --ok: #1f7a5a;
    --ok-soft: #e4f4ec;
    --danger: #b3261e;

    --font-ui: "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-read: "Source Serif 4", Georgia, "Times New Roman", serif;

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --shadow-pop: 0 18px 50px rgba(18, 26, 56, .18);
    --focus: 0 0 0 3px rgba(36, 52, 107, .28);
    --ease: cubic-bezier(.2, .7, .2, 1);

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #0e1324;
        --surface: #141a2f;
        --surface-2: #19203a;
        --ink: #e8ebf4;
        --ink-2: #b4bacd;
        --ink-3: #8088a4;
        --rule: #283050;
        --rule-2: #1f2742;
        --navy: #9bb0f2;
        --navy-hover: #b5c5f6;
        --navy-soft: #1f2a4d;
        --on-navy: #0e1324;
        --mark: #e7c63b;
        --mark-ink: #1d1700;
        --mark-soft: rgba(231, 198, 59, .14);
        --mark-stroke: rgba(231, 198, 59, .34);
        --cite: #f0915e;
        --ok: #5fcf9f;
        --ok-soft: rgba(95, 207, 159, .12);
        --danger: #ff8a80;
        --shadow-pop: 0 18px 50px rgba(0, 0, 0, .5);
        --focus: 0 0 0 3px rgba(155, 176, 242, .35);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --paper: #0e1324;
    --surface: #141a2f;
    --surface-2: #19203a;
    --ink: #e8ebf4;
    --ink-2: #b4bacd;
    --ink-3: #8088a4;
    --rule: #283050;
    --rule-2: #1f2742;
    --navy: #9bb0f2;
    --navy-hover: #b5c5f6;
    --navy-soft: #1f2a4d;
    --on-navy: #0e1324;
    --mark: #e7c63b;
    --mark-ink: #1d1700;
    --mark-soft: rgba(231, 198, 59, .14);
    --mark-stroke: rgba(231, 198, 59, .34);
    --cite: #f0915e;
    --ok: #5fcf9f;
    --ok-soft: rgba(95, 207, 159, .12);
    --danger: #ff8a80;
    --shadow-pop: 0 18px 50px rgba(0, 0, 0, .5);
    --focus: 0 0 0 3px rgba(155, 176, 242, .35);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
    background: var(--paper);
    color: var(--ink);
    font: 15px/1.5 var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--navy); }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: var(--r-sm); }

.muted { color: var(--ink-3); }

/* highlighter stroke used across the app */
.marked {
    background-image: linear-gradient(transparent 56%, var(--mark-stroke) 56%, var(--mark-stroke) 90%, transparent 90%);
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

/* ---------- App shell ---------- */
.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--surface);
}

.pane-library  { flex: 0 0 340px; border-right: 1px solid var(--rule); background: var(--surface-2); }
.pane-center   { flex: 1 1 auto; }
.pane-assistant{ flex: 0 0 400px; border-left: 1px solid var(--rule); background: var(--surface-2); }

.pane-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 60px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--rule);
}

.head-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- Brand ---------- */
.brand { text-decoration: none; color: var(--ink); }
.brand-word {
    font-weight: 700;
    font-size: 22px;
    letter-spacing: .06em;
    padding: 0 3px;
    background-image: linear-gradient(transparent 60%, var(--mark-stroke) 60%, var(--mark-stroke) 88%, transparent 88%);
}

/* ---------- Buttons ---------- */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--r-md);
    color: var(--ink-3);
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--rule-2); color: var(--ink); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 38px; padding: 0 14px;
    border-radius: var(--r-md);
    font-weight: 700; font-size: 14px;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
}
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn-primary { background: var(--navy); color: var(--on-navy); }
.btn-primary:hover:not(:disabled) { background: var(--navy-hover); }
.btn-ghost { color: var(--ink-2); border: 1px solid var(--rule); background: var(--surface); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-3); color: var(--ink); }
.btn-mark { background: var(--mark-soft); color: var(--ink); border: 1px solid transparent; }
.btn-mark:hover:not(:disabled) { border-color: var(--mark); }
.btn-mark.is-on { background: var(--mark); color: var(--mark-ink); }

.text-btn {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--ink-2); font-size: 13px; font-weight: 700;
    padding: 4px 6px; border-radius: var(--r-sm);
}
.text-btn:hover { color: var(--navy); }

/* ---------- Search ---------- */
.search { position: relative; margin: 14px 16px 6px; }
.search input {
    width: 100%; height: 44px;
    padding: 0 40px 0 38px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { border-color: var(--navy); box-shadow: var(--focus); }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 14px; }
.search-kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
    font: 12px var(--font-ui); color: var(--ink-3);
    border: 1px solid var(--rule); border-radius: 5px; background: var(--surface-2);
}
.search input:focus ~ .search-kbd { display: none; }

.search-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 2px 16px 8px;
}
.result-count { font-size: 13px; color: var(--ink-3); }
.filter-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cite); display: inline-block; }

.filters {
    display: flex; flex-direction: column; gap: 12px;
    margin: 0 16px 10px; padding: 14px;
    background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md);
}
.field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 0; min-width: 0; font-size: 13px; color: var(--ink-2); }
.field input, .field select {
    height: 36px; padding: 0 10px; width: 100%;
    background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--r-sm);
}
.field input:focus, .field select:focus { border-color: var(--navy); box-shadow: var(--focus); }
.field-row { display: flex; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--navy); }
.filters-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }

/* ---------- Library tabs + uploads ---------- */
.lib-tabs { display: flex; gap: 4px; padding: 10px 16px 0; }
.lib-tab {
    flex: 1 1 0;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 34px; border-radius: var(--r-md);
    font-size: 13.5px; font-weight: 700; color: var(--ink-3);
}
.lib-tab:hover { color: var(--ink); background: var(--rule-2); }
.lib-tab.is-active { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule); }
.lib-count {
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--navy-soft); color: var(--navy); font-size: 11.5px;
}
.lib-count:empty { display: none; }
.lib-view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

.dropzone {
    flex: 0 0 auto;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    margin: 14px 16px 8px; padding: 18px 16px;
    border: 1.5px dashed var(--rule); border-radius: var(--r-lg);
    background: var(--surface);
    text-align: center; cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--navy); background: var(--navy-soft); }
.dropzone:focus-visible { box-shadow: var(--focus); }
.dropzone i { font-size: 22px; color: var(--navy); margin-bottom: 4px; }
.dropzone strong { font-size: 14.5px; }
.dropzone span { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }

.uploads { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 10px 16px; }
.upload {
    display: flex; flex-direction: column; gap: 8px;
    padding: 11px 12px 9px;
    border-radius: var(--r-md); border: 1px solid transparent;
    cursor: pointer;
}
.upload:hover { background: var(--surface); border-color: var(--rule); }
.upload.is-open { background: var(--surface); border-color: var(--navy); }
.upload.is-busy { cursor: default; }
.upload-main { display: flex; gap: 10px; align-items: flex-start; }
.upload-type {
    flex: 0 0 auto; margin-top: 2px;
    padding: 2px 6px; border-radius: 4px;
    background: var(--navy-soft); color: var(--navy);
    font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.upload-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.upload-text strong { font: 600 15px/1.35 var(--font-read); overflow-wrap: anywhere; }
.upload.in-context .paper-title span {
    background-image: linear-gradient(transparent 58%, var(--mark-stroke) 58%, var(--mark-stroke) 92%, transparent 92%);
    -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.upload-failed { color: var(--danger); font-weight: 700; }
.upload .thinking { font-size: 13px; }
.chip-btn.is-danger { color: var(--danger) !important; background: rgba(179, 38, 30, .08); }

/* upload reader extras */
.fact-wide { flex-basis: 100%; }
.bullets { margin: 0; padding-left: 1.3em; font: 16px/1.65 var(--font-read); max-width: 68ch; }
.bullets li { margin: 4px 0; }
.feedback { margin: 0 0 12px; padding-left: 1.4em; font: 16px/1.65 var(--font-read); }
.feedback li { margin: 6px 0; padding-left: 4px; }
.ideas { display: flex; flex-wrap: wrap; gap: 12px; }
.idea {
    flex: 1 1 260px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
    padding: 14px 16px;
    border: 1px solid var(--rule); border-radius: var(--r-md);
    background: var(--surface);
}
.idea-type { font-size: 12px; font-weight: 700; color: var(--cite); }
.idea h3 { margin: 0; font: 600 16.5px/1.35 var(--font-read); }
.idea p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.idea .btn { margin-top: auto; }
.idea p + .btn, .idea h3 + .btn { margin-top: 6px; }

/* ---------- Results ---------- */
.results {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto;
    padding: 0 10px 16px;
}

.paper {
    position: relative;
    display: flex; flex-direction: column; gap: 6px;
    padding: 12px 12px 10px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    cursor: pointer;
}
.paper + .paper { margin-top: 2px; }
.paper:hover { background: var(--surface); border-color: var(--rule); }
.paper.is-open { background: var(--surface); border-color: var(--navy); }
.paper-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--ink-3); }
.paper-meta .oa { color: var(--ok); font-weight: 700; }
.paper-title {
    margin: 0;
    font: 600 15.5px/1.35 var(--font-read);
    color: var(--ink);
}
.paper.in-context .paper-title span {
    background-image: linear-gradient(transparent 58%, var(--mark-stroke) 58%, var(--mark-stroke) 92%, transparent 92%);
    -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.paper-authors { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paper-venue   { font-size: 13px; color: var(--ink-3); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paper-actions { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.paper-actions .chip-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 9px;
    border-radius: var(--r-sm);
    font-size: 12.5px; font-weight: 700; color: var(--ink-2);
    text-decoration: none;
}
.paper-actions .chip-btn:hover { background: var(--rule-2); color: var(--ink); }
.paper-actions .chip-btn.add { margin-left: auto; background: var(--mark-soft); color: var(--ink); }
.paper-actions .chip-btn.add.is-on { background: var(--mark); color: var(--mark-ink); }

.load-more { display: flex; justify-content: center; padding: 12px 0 4px; }

/* empty + loading states */
.empty {
    display: flex; flex-direction: column; gap: 10px;
    padding: 22px 8px;
    color: var(--ink-2);
}
.empty h3 { margin: 0; font-size: 16px; color: var(--ink); }
.empty p { margin: 0; font-size: 14px; }
.empty-sub { margin-top: 10px !important; font-size: 12.5px !important; font-weight: 700; color: var(--ink-3); }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestion {
    padding: 6px 11px; border-radius: 999px;
    border: 1px solid var(--rule); background: var(--surface);
    font-size: 13px; color: var(--ink-2);
}
.suggestion:hover { border-color: var(--navy); color: var(--navy); }
.suggestion i { font-size: 11px; margin-right: 4px; color: var(--ink-3); }

.skeleton { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.skeleton i {
    display: block; height: 11px; border-radius: 4px;
    background: linear-gradient(90deg, var(--rule-2), var(--rule), var(--rule-2));
    background-size: 200% 100%;
    animation: shimmer 1.2s linear infinite;
}
.skeleton i:nth-child(1) { width: 40%; }
.skeleton i:nth-child(2) { width: 92%; height: 14px; }
.skeleton i:nth-child(3) { width: 70%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Account (bottom of library) ---------- */
.account {
    position: relative;
    flex: 0 0 auto;
    padding: 10px;
    border-top: 1px solid var(--rule);
}
.account-btn {
    width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 8px;
    border-radius: var(--r-md);
    text-align: left;
}
.account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--surface); }
.avatar {
    flex: 0 0 36px; width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--navy); color: var(--on-navy);
    font-weight: 700; font-size: 14px;
    object-fit: cover;
}
.account-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.account-text strong, .account-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text strong { font-size: 14px; }
.account-text small { font-size: 12px; color: var(--ink-3); }
.account-caret { color: var(--ink-3); font-size: 12px; transition: transform .15s; }
.account-btn[aria-expanded="true"] .account-caret { transform: rotate(180deg); }
.account-login { width: 100%; }

.account-menu {
    position: absolute; left: 10px; right: 10px; bottom: calc(100% - 4px);
    z-index: 20;
    display: flex; flex-direction: column;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
    animation: pop .14s var(--ease);
}
.account-menu-head {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 10px 10px; margin-bottom: 4px;
    border-bottom: 1px solid var(--rule-2);
    font-size: 13px; color: var(--ink-2);
    overflow-wrap: anywhere;
}
.account-menu-head strong { font-size: 14.5px; color: var(--ink); }
.account-warn { color: var(--cite); font-weight: 700; margin-top: 4px; }
.account-menu a, .account-menu button {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    font-size: 14px; color: var(--ink);
    text-decoration: none; text-align: left;
}
.account-menu a:hover, .account-menu button:hover { background: var(--rule-2); }
.account-menu i { width: 16px; color: var(--ink-3); }
.account-menu form { margin: 0; }

/* ---------- Center: tabs ---------- */
.center-head { padding-top: 0; padding-bottom: 0; align-items: stretch; }
.tabs { display: flex; gap: 4px; align-items: stretch; }
.tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 0 12px;
    font-weight: 700; font-size: 14px; color: var(--ink-3);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--navy); }
.tab-count { font-size: 12px; font-weight: 400; color: var(--ink-3); }
.center-head .head-actions { padding: 10px 0; }

.view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.reader-scroll { flex: 1 1 auto; overflow-y: auto; }

/* ---------- Reader ---------- */
.reader {
    max-width: 760px;
    margin: 0 auto;
    padding: 36px 40px 80px;
}
.reader-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-3); }
.reader-meta .oa { color: var(--ok); font-weight: 700; }
.reader h1 {
    margin: 12px 0 14px;
    font: 600 clamp(24px, 2.4vw, 32px)/1.2 var(--font-read);
    letter-spacing: -.01em;
    color: var(--ink);
}
.reader-authors { font-size: 14.5px; color: var(--ink-2); }
.reader-authors button { color: var(--navy); font-size: 13px; font-weight: 700; margin-left: 4px; }
.reader-venue { margin-top: 4px; font: italic 15px var(--font-read); color: var(--ink-3); }

.reader-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 6px; }

.reader-section { margin-top: 34px; }
.reader-section > h2 {
    margin: 0 0 10px;
    font-size: 13px; font-weight: 700;
    color: var(--ink-3);
    letter-spacing: .02em;
}
.prose {
    font: 17px/1.72 var(--font-read);
    color: var(--ink);
    max-width: 68ch;
}
.prose p { margin: 0 0 1em; }

.summary-card {
    padding: 18px 20px;
    border-left: 4px solid var(--mark);
    background: var(--mark-soft);
    border-radius: 0 var(--r-md) var(--r-md) 0;
}
.summary-card .tldr { font: 600 17px/1.55 var(--font-read); margin: 0 0 10px; }
.summary-card .prose { font-size: 16px; }
.summary-card .prose p:last-child { margin-bottom: 0; }
.summary-source { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); }
.summary-loading { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; }

.note {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px; border-radius: var(--r-md);
    background: var(--surface-2); color: var(--ink-2); font-size: 14px;
}

.facts { display: flex; flex-wrap: wrap; border-top: 1px solid var(--rule); }
.fact {
    flex: 1 1 200px;
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 0; margin-right: 20px;
    border-bottom: 1px solid var(--rule-2);
}
.fact span { font-size: 12.5px; color: var(--ink-3); }
.fact strong { font-weight: 400; font-size: 14.5px; overflow-wrap: anywhere; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    padding: 4px 10px; border-radius: 999px;
    background: var(--navy-soft); color: var(--navy);
    font-size: 13px;
}
button.tag:hover { text-decoration: underline; }

.refs { margin: 0; padding-left: 1.6em; font-size: 14px; color: var(--ink-2); }
.refs li { padding: 3px 0; overflow-wrap: anywhere; }
.refs a { text-decoration: none; }
.refs a:hover { text-decoration: underline; }

/* reader welcome */
.welcome { max-width: 640px; margin: 0 auto; padding: 64px 40px; }
.welcome h1 { margin: 0 0 12px; font: 600 34px/1.15 var(--font-read); letter-spacing: -.01em; }
.welcome > p { margin: 0 0 28px; font: 18px/1.6 var(--font-read); color: var(--ink-2); }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; counter-reset: s; }
.steps li { display: flex; gap: 14px; align-items: flex-start; counter-increment: s; }
.steps li::before {
    content: counter(s);
    flex: 0 0 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--navy-soft); color: var(--navy);
    font-weight: 700; font-size: 14px;
}
.steps b { display: block; margin-bottom: 2px; }
.steps span { color: var(--ink-2); font-size: 14.5px; }

/* ---------- Writing planner ---------- */
.planner { max-width: 780px; margin: 0 auto; padding: 32px 40px 80px; }
.planner h1 { margin: 0 0 8px; font: 600 30px/1.2 var(--font-read); letter-spacing: -.01em; }
.planner-lead { margin: 0 0 24px; font: 16.5px/1.6 var(--font-read); color: var(--ink-2); max-width: 64ch; }
.planner-form {
    display: flex; flex-direction: column; gap: 14px;
    padding: 20px; margin-bottom: 28px;
    background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--r-lg);
}
.planner-form .field { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.planner-form .field em { font-style: normal; font-weight: 400; color: var(--ink-3); }
.planner-form .field input, .planner-form .field select { height: 40px; background: var(--surface); font-weight: 400; }
.planner-form textarea {
    width: 100%; padding: 10px 12px; resize: vertical; min-height: 96px;
    background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-sm);
    font: 400 15px/1.55 var(--font-ui);
}
.planner-form textarea:focus { border-color: var(--navy); box-shadow: var(--focus); }
.planner-form .field-row { flex-wrap: wrap; }
.planner-form .field-row .field { flex: 1 1 160px; }
.planner-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.planner-actions .btn .dots i { background: currentColor; }

.plan-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.plan-head h2 { margin: 2px 0 0; font: 600 24px/1.2 var(--font-read); }
.plan-head .muted { font-size: 13px; }
.plan-sec { margin-top: 26px; }
.plan-sec h3 { margin: 0 0 10px; font-size: 14px; color: var(--ink-3); }
.plan-sec h3 .muted { font-weight: 400; }
.plan-note { margin-top: 20px; font-size: 13px; }
.titles { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.titles li {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface);
    font: 600 16px/1.4 var(--font-read);
}
.outline { margin: 0; padding: 0; list-style: none; counter-reset: o; display: flex; flex-direction: column; gap: 10px; }
.outline > li {
    counter-increment: o;
    padding: 14px 16px 14px 48px; position: relative;
    border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface);
}
.outline > li::before {
    content: counter(o);
    position: absolute; left: 14px; top: 14px;
    width: 24px; height: 24px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--navy-soft); color: var(--navy); font-size: 13px; font-weight: 700;
}
.outline-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.outline-head strong { font: 600 16.5px/1.35 var(--font-read); }
.outline-head .muted { font-size: 12.5px; white-space: nowrap; }
.outline-purpose { margin: 4px 0 6px; font-size: 14px; color: var(--ink-2); font-style: italic; }
.outline ul { margin: 6px 0 0; padding-left: 1.2em; font: 15px/1.6 var(--font-read); }
.outline-src { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.related { display: flex; flex-direction: column; gap: 4px; }
.related-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--rule-2);
}
.related-item > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.related-item .muted { font-size: 12.5px; }
.related-title { text-align: left; font: 600 15px/1.35 var(--font-read); color: var(--ink); }
.related-title:hover { color: var(--navy); text-decoration: underline; }
.related-item .chip-btn {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px;
    border-radius: var(--r-sm); font-size: 12.5px; font-weight: 700;
    background: var(--mark-soft); color: var(--ink);
}
.related-item .chip-btn.is-on { background: var(--mark); color: var(--mark-ink); }

/* ---------- Draft ---------- */
.draft-wrap {
    flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column;
    width: 100%; max-width: 800px; margin: 0 auto;
    padding: 28px 40px 14px;
}
.draft-title {
    border: 0; background: transparent;
    font: 600 28px/1.25 var(--font-read);
    padding: 4px 0 10px;
    border-bottom: 1px solid var(--rule);
}
.draft-title::placeholder { color: var(--ink-3); }
.draft-body {
    flex: 1 1 auto; min-height: 200px;
    border: 0; background: transparent; resize: none;
    padding: 18px 0;
    font: 17px/1.75 var(--font-read);
}
.draft-body::placeholder { color: var(--ink-3); }
.draft-foot { display: flex; justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-2); }

/* ---------- Assistant ---------- */
.assistant-id { display: flex; align-items: center; gap: 10px; }
.assistant-id strong { display: block; font-size: 15px; }
.assistant-id small { display: block; font-size: 12.5px; color: var(--ink-3); }
.assistant-glyph {
    width: 34px; height: 34px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--navy); color: var(--on-navy); font-size: 14px;
}

.context {
    flex: 0 0 auto;
    padding: 10px 16px 10px;
    border-bottom: 1px solid var(--rule);
    max-height: 34%;
    display: flex; flex-direction: column;
}
.context-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--ink-2); font-weight: 700; }
.context-list { list-style: none; margin: 8px 0 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.context-empty { font-size: 13.5px; color: var(--ink-3); padding: 2px 0 4px; }
.ctx {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 6px 6px 6px 4px; border-radius: var(--r-sm);
}
.ctx:hover { background: var(--surface); }
.ctx.flash { animation: flash 1.2s var(--ease); }
@keyframes flash { 0%, 40% { background: var(--mark-soft); } 100% { background: transparent; } }
.ctx-n {
    flex: 0 0 auto; min-width: 22px; height: 20px; padding: 0 5px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 4px; background: var(--mark); color: var(--mark-ink);
    font-size: 12px; font-weight: 700;
}
.ctx-title {
    flex: 1 1 auto; min-width: 0;
    font: 14px/1.35 var(--font-read);
    color: var(--ink);
    text-align: left;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ctx-title:hover { color: var(--navy); }
.ctx-remove { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 4px; color: var(--ink-3); font-size: 12px; }
.ctx-remove:hover { background: var(--rule-2); color: var(--danger); }

.messages {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 18px;
}

.msg { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.msg-user { align-items: flex-end; }
.msg-user .bubble {
    max-width: 88%;
    padding: 10px 14px;
    background: var(--navy); color: var(--on-navy);
    border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg);
    font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-mode { font-size: 12px; color: var(--ink-3); }

.msg-ai .answer {
    font: 15.5px/1.65 var(--font-read);
    color: var(--ink);
    overflow-wrap: anywhere;
}
.answer > *:first-child { margin-top: 0; }
.answer p, .answer ul, .answer ol, .answer pre, .answer blockquote { margin: 0 0 .8em; }
.answer h3, .answer h4 {
    margin: 1.1em 0 .4em;
    font: 700 14.5px/1.35 var(--font-ui);
    color: var(--ink);
}
.answer ul, .answer ol { padding-left: 1.3em; }
.answer li { margin: .2em 0; }
.answer code { font-size: .88em; padding: 1px 5px; border-radius: 4px; background: var(--rule-2); }
.answer pre { padding: 10px 12px; border-radius: var(--r-sm); background: var(--rule-2); overflow-x: auto; font-size: 13px; }
.answer pre code { padding: 0; background: none; }
.answer blockquote { padding-left: 12px; border-left: 3px solid var(--rule); color: var(--ink-2); }
.answer hr { border: 0; border-top: 1px solid var(--rule); margin: 1em 0; }

.cite-ref {
    display: inline-flex; align-items: center;
    height: 18px; padding: 0 5px; margin: 0 1px;
    border-radius: 4px;
    background: var(--mark); color: var(--mark-ink);
    font: 700 11.5px/1 var(--font-ui);
    vertical-align: 2px;
    cursor: pointer;
}
.cite-ref:hover { outline: 2px solid var(--cite); }

.msg-tools { display: flex; gap: 2px; }
.msg-tools button {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 8px; border-radius: var(--r-sm);
    font-size: 12.5px; font-weight: 700; color: var(--ink-3);
}
.msg-tools button:hover { background: var(--rule-2); color: var(--ink); }

.msg-error .answer { color: var(--danger); font-family: var(--font-ui); font-size: 14px; }

.thinking { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: dot 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.intro { display: flex; flex-direction: column; gap: 10px; }
.intro p { margin: 0; font: 15.5px/1.6 var(--font-read); color: var(--ink-2); }
.intro .suggestions { margin-top: 4px; }

/* composer */
.composer-wrap { flex: 0 0 auto; padding: 8px 12px 12px; border-top: 1px solid var(--rule); }
.modes {
    display: flex; gap: 6px;
    overflow-x: auto; scrollbar-width: none;
    padding: 2px 2px 8px;
}
.modes { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
.modes::-webkit-scrollbar { display: none; }
.mode {
    flex: 0 0 auto;
    height: 28px; padding: 0 11px;
    border-radius: 999px;
    border: 1px solid var(--rule);
    background: var(--surface);
    font-size: 12.5px; font-weight: 700; color: var(--ink-2);
}
.mode:hover { border-color: var(--ink-3); color: var(--ink); }
.mode.is-active { background: var(--ink); border-color: var(--ink); color: var(--surface); }

.composer {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-lg);
    padding: 10px 10px 8px 14px;
    transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--navy); box-shadow: var(--focus); }
.composer textarea {
    width: 100%;
    min-height: 24px; max-height: 220px;
    border: 0; background: transparent; resize: none;
    font-size: 15px; line-height: 1.5;
}
.composer textarea:focus-visible,
.search input:focus-visible,
.draft-title:focus-visible,
.draft-body:focus-visible { box-shadow: none; }
.search input:focus-visible { box-shadow: var(--focus); }
.composer textarea::placeholder { color: var(--ink-3); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.composer-hint { font-size: 12px; color: var(--ink-3); }
.send-btn {
    flex: 0 0 auto;
    margin-left: auto;
    width: 34px; height: 34px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--navy); color: var(--on-navy);
}
.send-btn:hover:not(:disabled) { background: var(--navy-hover); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 14, 30, .5); }
.modal-panel {
    position: relative;
    width: min(620px, 100%);
    max-height: calc(100dvh - 32px); overflow-y: auto;
    padding: 20px 22px;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-pop);
    animation: pop .18s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 18px; }
.cite-paper { margin: 6px 0 16px; font: italic 15px/1.45 var(--font-read); color: var(--ink-2); }
.cite-styles { display: flex; flex-wrap: wrap; gap: 6px; }
.cite-styles button {
    height: 30px; padding: 0 12px; border-radius: 999px;
    border: 1px solid var(--rule); font-size: 13px; font-weight: 700; color: var(--ink-2);
}
.cite-styles button:hover { border-color: var(--ink-3); }
.cite-styles button.is-active { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.cite-output {
    margin: 16px 0;
    padding: 14px 16px;
    min-height: 74px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--rule);
    font: 15.5px/1.6 var(--font-read);
    user-select: all;
    overflow-wrap: anywhere;
}
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    z-index: 60;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 10px 16px;
    border-radius: var(--r-md);
    background: var(--ink); color: var(--surface);
    font-size: 14px;
    box-shadow: var(--shadow-pop);
    animation: pop .18s var(--ease);
}

/* ---------- Landing / sign-in ---------- */
body.landing { min-height: 100%; height: auto; display: flex; flex-direction: column; background: var(--paper); }
.lp-top {
    display: flex; align-items: baseline; gap: 12px;
    width: 100%; max-width: 1160px; margin: 0 auto;
    padding: 22px 24px 0;
}
.lp-by { font-size: 13px; color: var(--ink-3); }

.lp {
    flex: 1 0 auto;
    display: flex; align-items: flex-start; gap: 56px;
    width: 100%; max-width: 1160px; margin: 0 auto;
    padding: 40px 24px 56px;
}
.lp-main { flex: 1 1 auto; min-width: 0; max-width: 640px; }
.lp-main h1 {
    margin: 0 0 18px;
    font: 600 clamp(32px, 4.2vw, 50px)/1.08 var(--font-read);
    letter-spacing: -.02em;
    color: var(--ink);
}
.lp-lead { margin: 0 0 32px; font: 18.5px/1.62 var(--font-read); color: var(--ink-2); max-width: 60ch; }

.specimen {
    margin: 0 0 44px;
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.specimen-paper { padding: 20px 22px 18px; border-bottom: 1px dashed var(--rule); }
.specimen-meta { font-size: 12.5px; color: var(--ink-3); }
.specimen-title { margin: 6px 0 10px; font: 600 19px/1.35 var(--font-read); color: var(--ink); }
.specimen-tldr {
    margin: 0; padding: 10px 14px;
    border-left: 4px solid var(--mark);
    background: var(--mark-soft);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    font: 15.5px/1.55 var(--font-read);
}
.specimen-answer { padding: 16px 22px 20px; background: var(--surface-2); }
.specimen-ask {
    display: inline-block; margin-bottom: 10px; padding: 6px 12px;
    background: var(--navy); color: var(--on-navy);
    border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg);
    font-size: 13.5px;
}
.specimen-answer p { margin: 0; font: 15.5px/1.65 var(--font-read); color: var(--ink); }
.specimen .cite-ref { cursor: default; }
.specimen .cite-ref:hover { outline: none; }

.lp-h2 { margin: 0 0 16px; font-size: 18px; color: var(--ink); }
.uses { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 22px 28px; }
.uses li { flex: 1 1 260px; display: flex; gap: 12px; align-items: flex-start; }
.uses i {
    flex: 0 0 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--r-md);
    background: var(--navy-soft); color: var(--navy);
    font-size: 14px;
}
.uses b { display: block; margin-bottom: 2px; font-size: 15px; }
.uses span { font-size: 14px; line-height: 1.5; color: var(--ink-2); }

.lp-side { flex: 0 0 380px; position: sticky; top: 24px; }
.signin {
    padding: 28px 26px 24px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-lg);
    box-shadow: 0 20px 50px rgba(18, 26, 56, .08);
}
.signin h2 { margin: 0 0 6px; font: 600 24px/1.2 var(--font-read); }
.signin-sub { margin: 0 0 20px; font-size: 14px; color: var(--ink-2); }
.signin-form { display: flex; flex-direction: column; gap: 14px; }
.signin-form .field { font-size: 14px; font-weight: 700; color: var(--ink); }
.signin-form .field input { height: 44px; padding: 0 12px; font-size: 15px; font-weight: 400; background: var(--surface); border-radius: var(--r-md); }
.field-top { display: flex; justify-content: space-between; align-items: baseline; }
.field-top a { font-weight: 400; font-size: 13px; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px !important; }
.pw-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px; border-radius: var(--r-sm); color: var(--ink-3);
}
.pw-toggle:hover { color: var(--ink); background: var(--rule-2); }
.signin-btn { height: 46px; margin-top: 4px; font-size: 15px; }
.signin-alt { margin: 18px 0 0; font-size: 14px; color: var(--ink-2); }
.form-error {
    display: flex; gap: 8px; align-items: flex-start;
    margin: 0 0 16px; padding: 10px 12px;
    border-radius: var(--r-md);
    background: rgba(179, 38, 30, .08); color: var(--danger);
    font-size: 14px;
}
.form-note { margin: 0 0 16px; padding: 10px 12px; border-radius: var(--r-md); background: var(--ok-soft); color: var(--ok); font-size: 14px; }

.lp-foot {
    display: flex; flex-wrap: wrap; gap: 8px 20px;
    width: 100%; max-width: 1160px; margin: 0 auto;
    padding: 18px 24px 28px;
    border-top: 1px solid var(--rule);
    font-size: 13px; color: var(--ink-3);
}
.lp-foot a { color: var(--ink-2); text-decoration: none; }
.lp-foot a:hover { text-decoration: underline; }

@media (max-width: 960px) {
    .lp { flex-direction: column; gap: 36px; padding-top: 24px; }
    .lp-main { max-width: none; display: contents; }
    .lp-main h1 { order: 1; }
    .lp-lead { order: 2; margin-bottom: 0; }
    .lp-side { order: 3; position: static; flex-basis: auto; width: 100%; max-width: 460px; }
    .specimen { order: 4; margin-bottom: 0; }
    .lp-h2 { order: 5; margin-bottom: -16px; }
    .uses { order: 6; }
}
@media (max-width: 520px) {
    .lp-top, .lp, .lp-foot { padding-left: 16px; padding-right: 16px; }
    .signin { padding: 22px 18px 20px; }
    .lp-lead { font-size: 17px; }
}

/* ---------- Mobile tabs ---------- */
.mobile-tabs { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
    .pane-library { flex-basis: 300px; }
    .pane-assistant { flex-basis: 360px; }
    .reader { padding: 30px 28px 70px; }
}

@media (max-width: 1060px) {
    .hide-sm { display: none; }
}

@media (max-width: 900px) {
    .app { height: calc(100dvh - 60px); }
    .pane { flex: 1 1 auto !important; border: 0 !important; }
    .app[data-view="library"] .pane-center,
    .app[data-view="library"] .pane-assistant,
    .app[data-view="center"] .pane-library,
    .app[data-view="center"] .pane-assistant,
    .app[data-view="assistant"] .pane-library,
    .app[data-view="assistant"] .pane-center { display: none; }

    .mobile-tabs {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
        display: flex;
        height: 60px;
        background: var(--surface);
        border-top: 1px solid var(--rule);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .mobile-tabs button {
        position: relative;
        flex: 1 1 0;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        font-size: 12px; font-weight: 700; color: var(--ink-3);
    }
    .mobile-tabs button i { font-size: 17px; }
    .mobile-tabs button.is-active { color: var(--navy); }
    .mobile-badge {
        position: absolute; top: 7px; left: calc(50% + 8px);
        min-width: 18px; height: 18px; padding: 0 5px;
        border-radius: 9px; background: var(--mark); color: var(--mark-ink);
        font-size: 11px; display: inline-flex; align-items: center; justify-content: center;
    }

    .reader, .welcome, .planner { padding: 22px 16px 48px; }
    .planner-form { padding: 14px; }
    .draft-wrap { padding: 18px 16px 10px; }
    .welcome h1 { font-size: 27px; }
    .prose { font-size: 16.5px; }
    .composer-hint { display: none; }
    .toasts { bottom: 76px; }
    .center-head { padding: 0 8px; }
    .tab { padding: 0 8px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* stored article summary extras */
.summary-facts { margin-top: 16px; }
.reader-section .sub-h { margin: 22px 0 8px; font-size: 13px; font-weight: 700; color: var(--ink-3); letter-spacing: .02em; }

/* ---------- Plan & billing ---------- */
.bill-top { justify-content: space-between; align-items: center; }
.bill { flex: 1 0 auto; width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 24px 56px; }
.bill h1 { margin: 0 0 20px; font: 600 34px/1.15 var(--font-read); letter-spacing: -.01em; }
.bill h2 { margin: 0; font: 600 22px/1.2 var(--font-read); }
.bill-current {
    padding: 22px 24px; margin-bottom: 40px;
    background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg);
}
.bill-current-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.bill-current-head .muted { font-size: 13px; }
.bill-current-head h2 { font-size: 28px; margin: 2px 0 4px; }
.bill-current-head p { margin: 0; color: var(--ink-2); }
.note-warn { margin-top: 16px; background: var(--mark-soft); color: var(--ink); }
.meters { display: flex; flex-wrap: wrap; gap: 18px 28px; margin-top: 22px; }
.meter { flex: 1 1 200px; min-width: 0; }
.meter-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.meter-top b { font-weight: 700; white-space: nowrap; }
.meter-bar { height: 8px; margin: 6px 0 4px; border-radius: 4px; background: var(--rule-2); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 4px; background: var(--navy); transition: width .4s var(--ease); }
.meter.is-high .meter-bar i { background: var(--cite); }
.meter small { font-size: 12px; color: var(--ink-3); }

.bill-plans-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.cycle { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--rule-2); }
.cycle button { height: 32px; padding: 0 14px; border-radius: 999px; font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.cycle button span { font-weight: 400; font-size: 12px; color: var(--ok); margin-left: 4px; }
.cycle button.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.plan-cards { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.plan-card {
    position: relative;
    flex: 1 1 280px;
    display: flex; flex-direction: column; gap: 6px;
    padding: 24px 22px 20px;
    background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg);
}
.plan-card.is-featured { border-color: var(--navy); box-shadow: 0 16px 40px rgba(36, 52, 107, .10); }
.plan-card.is-current { border-color: var(--mark); box-shadow: inset 0 0 0 1px var(--mark); }
.plan-flag {
    position: absolute; top: -11px; left: 20px;
    padding: 2px 10px; border-radius: 999px;
    background: var(--navy); color: var(--on-navy); font-size: 12px; font-weight: 700;
}
.plan-card.is-current .plan-flag { background: var(--mark); color: var(--mark-ink); }
.plan-card h3 { margin: 0; font: 600 22px/1.2 var(--font-read); }
.plan-tag { margin: 0; font-size: 14px; color: var(--ink-2); min-height: 2.6em; }
.plan-price { display: flex; align-items: baseline; gap: 6px; margin-top: 8px; }
.plan-price b { font: 600 34px/1 var(--font-read); }
.plan-price span { color: var(--ink-3); font-size: 14px; }
.plan-sub { margin: 0 0 12px; font-size: 13px; color: var(--ink-3); }
.plan-card .btn { width: 100%; height: 42px; }
.plan-feats { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.plan-feats li { display: flex; gap: 10px; align-items: baseline; }
.plan-feats i { color: var(--ok); width: 14px; flex: 0 0 14px; }
.plan-feats li.off { color: var(--ink-3); }
.plan-feats li.off i { color: var(--ink-3); }
.plan-fair { flex-basis: 100%; margin: 4px 0 0; font-size: 12.5px; color: var(--ink-3); }
.bill-note { margin: 18px 0 0; max-width: 78ch; font-size: 13.5px; color: var(--ink-2); }

.bill-history { margin-top: 44px; }
.bill-history h2 { margin-bottom: 14px; }
.pay-table { display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.pay-row { display: flex; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--rule-2); font-size: 14px; align-items: center; }
.pay-row:first-child { border-top: 0; }
.pay-row span { flex: 1 1 0; min-width: 0; }
.pay-row span:nth-child(3) { flex: 1.6 1 0; }
.pay-row span:last-child { flex: 0 0 90px; text-align: right; }
.pay-head { background: var(--surface-2); font-size: 12.5px; font-weight: 700; color: var(--ink-3); }

/* account menu plan line */
.account-plan { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.plan-pill { padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--rule-2); color: var(--ink-2); }
.plan-pill.is-paid { background: var(--mark); color: var(--mark-ink); }
.account-upgrade { margin: 4px 0 2px; }

/* upgrade dialog */
.upgrade-panel { width: min(520px, 100%); }
.upgrade-panel p { margin: 6px 0 16px; color: var(--ink-2); }
.upgrade-compare { display: flex; gap: 10px; margin-bottom: 18px; }
.upgrade-compare div { flex: 1 1 0; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-md); font-size: 13.5px; }
.upgrade-compare b { display: block; font: 600 17px/1.3 var(--font-read); margin-bottom: 4px; }
.upgrade-compare div.is-rec { border-color: var(--navy); }

/* landing pricing */
.lp-pricing { width: 100%; max-width: 1160px; margin: 0 auto; padding: 8px 24px 56px; }
.lp-pricing h2 { margin: 0 0 6px; font: 600 28px/1.2 var(--font-read); }
.lp-pricing > p { margin: 0 0 20px; color: var(--ink-2); }

@media (max-width: 700px) {
    .bill { padding: 20px 16px 40px; }
    .pay-row { flex-wrap: wrap; }
    .pay-row span, .pay-row span:nth-child(3) { flex: 1 1 45%; }
    .pay-row span:last-child { text-align: left; }
    .pay-head { display: none; }
    .upgrade-compare { flex-direction: column; }
}
.account-menu a.account-upgrade { justify-content: center; color: var(--on-navy); background: var(--navy); }
.account-menu a.account-upgrade:hover { background: var(--navy-hover); }
.account-menu a.account-upgrade i { color: var(--on-navy); }
.lp-pricing .plan-card .btn { text-decoration: none; }

/* ---------- Credits ---------- */
.credit-big { font: 600 40px/1.1 var(--font-read) !important; }
.credit-big span { font-size: 18px; color: var(--ink-3); font-weight: 400; }
.credit-facts { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 13.5px; color: var(--ink-2); }
.credit-facts i { color: var(--navy); margin-right: 6px; }
.plan-flag-soft { background: var(--mark) !important; color: var(--mark-ink) !important; }
.pack-eg { margin-top: 10px; min-height: 0; font-size: 13px; }
.bill-costs { margin-top: 44px; }
.bill-costs h2 { margin-bottom: 6px; }
.bill-costs > p { max-width: 75ch; font-size: 14px; }
.cost-table { display: flex; flex-direction: column; margin-top: 14px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); }
.cost-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 11px 16px; border-top: 1px solid var(--rule-2); font-size: 14.5px; }
.cost-row:first-child { border-top: 0; }
.cost-row span { display: flex; flex-direction: column; min-width: 0; }
.cost-row small { font-size: 12.5px; color: var(--ink-3); }
.cost-row b { flex: 0 0 auto; padding: 2px 10px; border-radius: 999px; background: var(--mark-soft); font-size: 13.5px; }
.ledger .pay-row { font-size: 13.5px; }
.ledger-when { flex: 0 0 150px !important; color: var(--ink-3); }
.ledger-what { flex: 1 1 auto !important; }
.ledger-what i { width: 18px; color: var(--ink-3); margin-right: 6px; }
.ledger-amt { flex: 0 0 70px !important; text-align: right; font-weight: 700; }
.ledger-amt.pos { color: var(--ok); }
.ledger-bal { flex: 0 0 70px !important; text-align: right !important; color: var(--ink-3); }
.credit-pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--mark-soft); color: var(--ink); font-size: 11.5px; font-weight: 700; }
.credit-pill i { font-size: 10px; color: var(--cite); }
@media (max-width: 700px) {
    .ledger .pay-row { flex-wrap: wrap; }
    .ledger-when { flex-basis: 100% !important; }
    .ledger-what { flex-basis: 60% !important; }
}
.tab-link { text-decoration: none; }
.thesis-cta {
    display: flex; align-items: center; gap: 14px;
    margin: 0 0 26px; padding: 14px 18px;
    border-radius: var(--r-lg); border: 1px solid var(--navy);
    background: var(--navy-soft); color: var(--ink); text-decoration: none;
    font-size: 14.5px;
}
.thesis-cta:hover { background: var(--surface); }
.thesis-cta + .thesis-cta { margin-top: -16px; }
.thesis-cta > i:first-child { font-size: 20px; color: var(--navy); }
.thesis-cta span { flex: 1 1 auto; }
.thesis-cta b { display: block; font-size: 15px; }
.lp-costs { max-width: 760px; margin-top: 24px; }
