:root {
    --navy: #0b2148;
    --navy-2: #12315f;
    --blue: #2563eb;
    --ink: #1e293b;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f4f7fb;
    --card: #fff;
    --ok: #e8f8ee;
    --ok-line: #b7e4c7;
    --ok-ink: #166534;
    --need: #fff7e8;
    --need-line: #f3d19c;
    --need-ink: #9a6700;
    --user: #dbeafe;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font-family: "Segoe UI", system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
}
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
}
.brand { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 28px; }
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; color: #b9c7e6; font-size: 13px; margin-top: 2px; }
.scales { width: 42px; height: 42px; color: #fff; flex: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar nav a {
    color: #e8eefc;
    text-decoration: none;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
}
.sidebar nav a.active, .sidebar nav a:hover { background: var(--blue); color: #fff; }
.side-bottom { margin-top: auto; }
.sources-foot { display: flex; gap: 10px; align-items: flex-start; padding-top: 16px; border-top: 1px solid #23406f; }
.ok-dot { width: 18px; height: 18px; border-radius: 50%; background: #22c55e; flex: none; margin-top: 2px; }
.sources-foot .muted, .who { color: #b9c7e6; font-size: 12px; }
.who { margin: 12px 0 4px; }
.linkish {
    background: none; border: 0; color: #dbe7ff; padding: 0; cursor: pointer;
}
.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 18px;
    flex-wrap: wrap;
}
.pill {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: var(--ink);
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
}
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill:has(input:checked) { background: var(--blue); border-color: var(--blue); color: #fff; }
.year-label { margin-left: auto; color: var(--muted); display: flex; align-items: center; gap: 8px; }
select, .textin, .composer textarea {
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 8px 10px;
    background: #fff;
}
.stage {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    padding: 16px 18px 8px;
    min-height: 0;
}
.thread { overflow: auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 12px; }
.bubble {
    align-self: flex-end;
    max-width: 70%;
    background: var(--user);
    border-radius: 16px 16px 4px 16px;
    padding: 12px 14px;
}
.bubble .meta, .muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.answer {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.conclusion { display: flex; gap: 10px; border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.conclusion.ok { background: var(--ok); color: var(--ok-ink); }
.conclusion.need { background: var(--need); color: var(--need-ink); }
.conclusion.split { background: #eef2ff; color: #312e81; }
.conclusion p, .answer section p { margin: 0; white-space: pre-wrap; }
.answer h3 { margin: 14px 0 6px; color: #1d4ed8; font-size: 16px; }
.sources { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.disclaimer {
    margin-top: 14px;
    background: #eef6ff;
    color: #1e3a8a;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
}
.alts { display: grid; gap: 8px; }
.alt { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.rail { display: flex; flex-direction: column; gap: 12px; }
.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
}
.panel h2 { margin: 0 0 10px; font-size: 15px; }
.panel ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.panel li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.tick { color: #16a34a; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.actions a, .actions button.as-link {
    background: none; border: 0; color: #1d4ed8; text-align: left; padding: 0; cursor: pointer;
}
.composer {
    display: flex;
    gap: 8px;
    padding: 10px 18px 16px;
    background: var(--bg);
}
.composer textarea {
    flex: 1;
    min-height: 52px;
    resize: vertical;
}
.send {
    width: 52px;
    border: 0;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    cursor: pointer;
}
.send:disabled { opacity: .6; }
.wait-banner {
    margin: 0 18px;
    background: #e0ecff;
    color: #1e3a8a;
    border-radius: 10px;
    padding: 10px 12px;
}
.page { padding: 24px; max-width: 860px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list a.row {
    display: flex; justify-content: space-between; gap: 12px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: inherit; text-decoration: none;
}
.star { color: #d97706; }
.form-grid { display: grid; gap: 12px; max-width: 520px; }
.form-grid label { display: grid; gap: 4px; }
.primary, .ghost {
    border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer;
}
.primary { background: var(--blue); color: #fff; }
.ghost { background: #e2e8f0; }
.alert { background: #fee2e2; color: #991b1b; padding: 10px 12px; border-radius: 10px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--navy); }
.login-card { background: #fff; padding: 28px; border-radius: 16px; width: min(420px, calc(100% - 32px)); }
.login-card h1 { margin-top: 0; }
.bron { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; white-space: pre-wrap; }
.compare-flag { margin: 0 0 8px; color: #1d4ed8; font-weight: 600; }
.compare-note { align-self: flex-end; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 24px 8px; }
@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: sticky; top: 0; z-index: 2; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .side-bottom { display: none; }
    .stage { grid-template-columns: 1fr; }
    .year-label { margin-left: 0; }
    .bubble { max-width: 100%; }
}
