:root {
    --primary: #151515;
    --secondary: #090909;
    --accent: #dfff00;
    --ink: #f2f2ed;
    --muted: #96968f;
    --muted-strong: #b9b9b1;
    --line: rgba(255, 255, 255, .1);
    --line-strong: rgba(223, 255, 0, .28);
    --surface: #141414;
    --surface-raised: #1b1b1b;
    --danger: #ff5c64;
    --success: #a9dd4d;
    --header-height: 84px;
    --radius: 18px;
    --shadow: 0 24px 80px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; scroll-behavior: smooth; background: var(--secondary); }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 78% 10%, rgba(223, 255, 0, .045), transparent 30rem),
        var(--secondary);
    font-family: "Share Tech", ui-monospace, monospace;
    font-size: 1.04rem;
    line-height: 1.55;
}

body.auth-locked { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

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

.topbar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 50;
    height: var(--header-height);
    display: grid;
    grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
    align-items: center;
    gap: clamp(20px, 3vw, 52px);
    padding: 0 clamp(20px, 3.5vw, 64px);
    border-bottom: 1px solid var(--line);
    background: rgba(9, 9, 9, .91);
    box-shadow: 0 12px 35px rgba(0, 0, 0, .2);
    backdrop-filter: blur(20px);
}

.brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 13px;
    color: inherit;
    text-decoration: none;
}

.brand-logo-slot {
    position: relative;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #101010;
    overflow: hidden;
}

.brand-logo-slot img {
    position: absolute;
    inset: 7px;
    width: calc(100% - 14px);
    height: calc(100% - 14px);
    object-fit: contain;
}

.brand-mark {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #090909;
    background: var(--accent);
    font-family: "Cascadia Mono", monospace;
    font-size: 1.2rem;
    font-weight: 700;
}

.brand-copy { min-width: 0; }
.brand strong, .brand small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand strong { font-family: "Cascadia Mono", monospace; font-size: 1rem; letter-spacing: .18em; }
.brand small { max-width: 270px; color: var(--muted); font-size: .79rem; letter-spacing: .01em; }

.top-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, .025);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025), 0 12px 28px rgba(0, 0, 0, .18);
}
.top-navigation a {
    position: relative;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--muted);
    font-size: .9rem;
    text-decoration: none;
    white-space: nowrap;
    transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
}
.top-navigation a:hover { color: var(--ink); border-color: var(--line); background: rgba(255, 255, 255, .04); transform: translateY(-1px); }
.top-navigation a.active { color: #080808; border-color: var(--accent); background: var(--accent); box-shadow: 0 0 22px rgba(223, 255, 0, .1); }
.auth-locked .top-navigation { pointer-events: none; user-select: none; }
.auth-locked .top-navigation a { opacity: .32; }

.top-actions {
    justify-self: end;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255, 255, 255, .02);
}
.connection-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; white-space: nowrap; }
.connection-state > span:first-child {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #666;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .04);
}
.connection-state[data-state="online"] > span:first-child {
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(223, 255, 0, .08), 0 0 10px rgba(223, 255, 0, .8);
}

.menu-toggle { display: none; }
.icon-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--muted-strong);
    background: transparent;
    cursor: pointer;
    font-size: 1.15rem;
}
.icon-button:hover { color: var(--accent); border-color: var(--line-strong); }

main {
    min-width: 0;
    min-height: 100vh;
    padding: calc(var(--header-height) + clamp(48px, 6vw, 88px)) clamp(24px, 5vw, 88px) clamp(64px, 8vw, 120px);
}
main:focus { outline: none; }
.view { width: min(1480px, 100%); margin: 0 auto; animation: reveal .34s ease both; }
.view-query { width: min(1600px, 100%); }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1, h2, p { margin-top: 0; }
h1, h2, .metric-card strong { font-family: "Cascadia Mono", monospace; }
h1 {
    max-width: 1000px;
    margin-bottom: 20px;
    color: var(--ink);
    font-size: clamp(2.65rem, 6vw, 6.8rem);
    font-weight: 500;
    letter-spacing: -.075em;
    line-height: .98;
}
h1 span { color: var(--accent); }
h2 { margin-bottom: 10px; color: var(--ink); font-size: clamp(1.05rem, 1.5vw, 1.35rem); font-weight: 500; letter-spacing: -.025em; }
p { color: var(--muted); }
.eyebrow {
    margin-bottom: 14px;
    color: var(--accent);
    font-family: "Cascadia Mono", monospace;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .13em;
    text-transform: uppercase;
}
.page-heading { display: flex; justify-content: space-between; gap: 40px; align-items: flex-end; margin-bottom: clamp(36px, 5vw, 66px); }
.page-heading > div > p:last-child { max-width: 680px; margin-bottom: 0; font-size: clamp(1rem, 1.25vw, 1.22rem); }
.page-heading > p { max-width: 460px; margin-bottom: 8px; }

label { color: var(--muted-strong); font-size: .86rem; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 13px 14px;
    color: var(--ink);
    background: #0e0e0e;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input::placeholder, textarea::placeholder { color: #66665f; }
input:hover, select:hover, textarea:hover { border-color: rgba(255, 255, 255, .18); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(223, 255, 0, .08); background: #111; }
select { color-scheme: dark; }
textarea { resize: vertical; }

.button {
    min-height: 43px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 17px;
    color: var(--ink);
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .16s ease, opacity .16s ease, color .16s ease, background .16s ease, border-color .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .48; transform: none; }
.button-primary { color: #080808; background: var(--accent); font-family: "Cascadia Mono", monospace; font-size: .82rem; font-weight: 600; }
.button-primary:hover { background: #ebff5a; box-shadow: 0 0 24px rgba(223, 255, 0, .13); }
.button-quiet { border-color: var(--line); color: var(--muted-strong); background: rgba(255, 255, 255, .03); }
.button-quiet:hover { border-color: var(--line-strong); color: var(--accent); }
.button-danger { color: #090909; background: var(--danger); }
.button-small { min-height: 34px; padding: 6px 10px; font-size: .73rem; }

.card, .metric-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(255, 255, 255, .025), transparent 58%), var(--surface);
    box-shadow: 0 16px 50px rgba(0, 0, 0, .12);
}
.card { padding: clamp(20px, 2.5vw, 34px); margin-bottom: 24px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 14px; margin-bottom: clamp(30px, 4vw, 54px); }
.metric-card { position: relative; min-height: 156px; padding: 26px; overflow: hidden; }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 1px; background: var(--accent); opacity: .5; }
.metric-card strong { display: block; color: var(--ink); font-size: clamp(2.1rem, 3.5vw, 3.5rem); font-weight: 500; line-height: 1; letter-spacing: -.06em; }
.metric-card span { display: block; margin-top: 24px; color: var(--muted); font-size: .86rem; }

.guidance { display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.guidance p { margin-bottom: 0; }
.guidance code { padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--accent); background: #0a0a0a; white-space: nowrap; font-family: "Cascadia Mono", monospace; font-size: .77rem; }
.worker-run-button { min-width: 224px; }

.upload-card { display: grid; grid-template-columns: minmax(260px, 1.3fr) minmax(230px, 1fr) auto; align-items: end; gap: 18px; }
.form-field { min-width: 0; display: grid; gap: 8px; }
.form-field small { color: #6f6f69; font-size: .75rem; }
input[type="file"] { padding: 9px; color: var(--muted); }
input[type="file"]::file-selector-button {
    margin-right: 12px;
    border: 0;
    border-radius: 7px;
    padding: 6px 10px;
    color: #0a0a0a;
    background: var(--accent);
    font-family: "Cascadia Mono", monospace;
    font-size: .7rem;
    cursor: pointer;
}
.upload-progress { grid-column: 1 / -1; padding-top: 18px; border-top: 1px solid var(--line); }
.progress-copy { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 9px; color: var(--muted-strong); font-size: .83rem; }
.progress-copy strong { color: var(--accent); font-family: "Cascadia Mono", monospace; font-size: .77rem; }
.upload-progress progress { width: 100%; height: 5px; display: block; border: 0; border-radius: 999px; background: #282828; overflow: hidden; }
.upload-progress progress::-webkit-progress-bar { background: #282828; }
.upload-progress progress::-webkit-progress-value { background: var(--accent); box-shadow: 0 0 14px rgba(223, 255, 0, .55); transition: width .16s ease; }
.upload-progress progress::-moz-progress-bar { background: var(--accent); box-shadow: 0 0 14px rgba(223, 255, 0, .55); }
.upload-progress > small { display: block; margin-top: 8px; color: #6f6f69; }

.worker-monitor { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; }
.worker-monitor p { margin: 0 0 5px; }
.worker-monitor strong { display: block; color: var(--ink); font-weight: 500; }
.worker-monitor small { display: block; margin-top: 4px; color: var(--muted); }
.worker-monitor code { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--accent); background: #0a0a0a; font-family: "Cascadia Mono", monospace; font-size: .72rem; white-space: nowrap; }
.worker-monitor .worker-run-button { justify-self: end; }
.worker-indicator { width: 11px; height: 11px; border-radius: 50%; background: #666; box-shadow: 0 0 0 5px rgba(255, 255, 255, .03); }
.worker-monitor[data-state="waiting"] .worker-indicator { background: var(--accent); box-shadow: 0 0 0 5px rgba(223, 255, 0, .06); }
.worker-monitor[data-state="running"] .worker-indicator { background: #73bfff; box-shadow: 0 0 16px rgba(115, 191, 255, .7); }
.worker-monitor[data-state="failed"] .worker-indicator { background: var(--danger); box-shadow: 0 0 16px rgba(255, 92, 100, .45); }

.job-progress { min-width: 190px; }
.job-progress-copy { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: var(--muted); font-size: .72rem; }
.job-progress-copy strong { color: var(--ink); font-family: "Cascadia Mono", monospace; font-size: .7rem; white-space: nowrap; }
.job-progress progress { width: 100%; height: 5px; display: block; border: 0; border-radius: 999px; background: #282828; overflow: hidden; }
.job-progress progress::-webkit-progress-bar { background: #282828; }
.job-progress progress::-webkit-progress-value { background: var(--accent); transition: width .25s ease; }
.job-progress progress::-moz-progress-bar { background: var(--accent); }
.job-progress[data-status="running"] progress::-webkit-progress-value { background: #73bfff; box-shadow: 0 0 12px rgba(115, 191, 255, .55); }
.job-progress[data-status="running"] progress::-moz-progress-bar { background: #73bfff; }
.job-progress[data-status="failed"] progress::-webkit-progress-value { background: var(--danger); }
.job-progress[data-status="failed"] progress::-moz-progress-bar { background: var(--danger); }
.job-progress > small { display: block; margin-top: 6px; color: #70706a; font-size: .68rem; }

.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; }
.card-heading h2 { margin: 0; }
.card-heading span { color: var(--muted); font-size: .82rem; }
.table-card { padding: 0; overflow: hidden; }
.table-card .card-heading { padding: 26px 28px 0; }
.table-wrap { overflow-x: auto; scrollbar-color: #3b3b3b transparent; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th, td { padding: 16px 18px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #777770; background: rgba(255, 255, 255, .018); font-family: "Cascadia Mono", monospace; font-size: .64rem; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
td { color: var(--muted-strong); }
td strong { color: var(--ink); font-weight: 400; }
td small { color: #70706a; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }
.empty { padding: 46px; color: var(--muted); text-align: center; }

.status { display: inline-flex; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted-strong); background: #202020; font-size: .7rem; }
.status-ready, .status-completed { color: var(--success); border-color: rgba(169, 221, 77, .2); background: rgba(169, 221, 77, .07); }
.status-running { color: #73bfff; border-color: rgba(115, 191, 255, .2); background: rgba(115, 191, 255, .07); }
.status-failed { color: var(--danger); border-color: rgba(255, 92, 100, .2); background: rgba(255, 92, 100, .07); }
.status-queued { color: var(--accent); border-color: rgba(223, 255, 0, .2); background: rgba(223, 255, 0, .06); }

.query-heading { margin-bottom: 34px; }
.query-heading h1 { font-size: clamp(2.7rem, 5.4vw, 6rem); }
.chat-shell {
    min-height: clamp(590px, calc(100vh - 260px), 900px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: #101010;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.query-result { min-height: 0; flex: 1; overflow-y: auto; padding: clamp(24px, 4vw, 58px); scrollbar-color: #393939 transparent; }
.chat-empty { min-height: 320px; display: grid; place-content: center; justify-items: center; text-align: center; }
.chat-empty-icon { width: 64px; height: 64px; display: grid; place-items: center; margin-bottom: 24px; color: var(--accent); }
.chat-empty-icon svg { width: 29px; height: 29px; fill: currentColor; }
.chat-empty h2 { font-size: clamp(1.3rem, 2.3vw, 2rem); }
.chat-empty p { margin: 0; }
.chat-transcript { max-width: 1120px; display: grid; gap: 34px; margin: 0 auto; }
.chat-turn { display: grid; gap: 14px; }
.chat-message-user {
    max-width: min(78%, 760px);
    justify-self: end;
    padding: 15px 18px;
    border: 1px solid var(--line-strong);
    border-radius: 16px 16px 4px 16px;
    background: rgba(223, 255, 0, .07);
}
.chat-message-user .eyebrow { margin-bottom: 6px; }
.chat-message-user p { margin: 0; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message-assistant { margin: 0; scroll-margin-top: calc(var(--header-height) + 16px); border-radius: 4px 16px 16px 16px; }
.chat-message-pending { color: var(--muted); }
.query-loading { display: inline-flex; align-items: center; gap: 9px; margin: 0; }
.query-loading-dots { display: inline-flex; align-items: center; gap: 5px; }
.query-loading-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 9px rgba(223, 255, 0, .38);
    animation: query-loading-dot 1.05s ease-in-out infinite;
}
.query-loading-dot:nth-child(2) { animation-delay: .14s; }
.query-loading-dot:nth-child(3) { animation-delay: .28s; }
@keyframes query-loading-dot {
    0%, 70%, 100% { opacity: .32; transform: translateY(0) scale(.82); }
    35% { opacity: 1; transform: translateY(-4px) scale(1); }
}
.answer { color: var(--ink); font-size: clamp(1.08rem, 1.3vw, 1.22rem); line-height: 1.75; white-space: pre-wrap; }
.answer-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 18px; margin-top: 26px; }
.answer-figure { min-width: 0; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .018); }
.answer-figure-media { min-height: 190px; display: grid; place-items: center; background: #0a0a0a; }
.answer-figure-media img { width: 100%; max-height: 620px; display: block; object-fit: contain; }
.answer-figure-status { color: var(--muted); font-size: .82rem; }
.answer-figure figcaption { display: grid; gap: 7px; padding: 14px 16px 16px; }
.answer-figure figcaption strong { color: var(--ink); font-size: .95rem; }
.answer-figure figcaption span { color: var(--muted-strong); line-height: 1.55; }
.answer-figure figcaption small { color: var(--muted); font-family: "Cascadia Mono", monospace; }
.result-section { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); }
.result-section h2 { font-size: .95rem; }
.result-section ul { margin: 12px 0 0; padding-left: 20px; }
.result-section li { margin-bottom: 9px; color: var(--muted-strong); }
.evidence-list { display: grid; gap: 10px; padding: 0 !important; list-style: none; }
.evidence-list li {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, .018);
}
.evidence-list code { color: var(--accent); font-family: "Cascadia Mono", monospace; font-size: .75rem; white-space: nowrap; }
.evidence-list span { color: var(--muted-strong); overflow-wrap: anywhere; }
.copy-result-action { display: flex; justify-content: flex-end; margin-top: 16px; }
.button-copy-result { display: inline-flex; align-items: center; gap: 9px; }
.button-copy-result svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}
.query-form { display: grid; grid-template-columns: minmax(210px, 26%) minmax(0, 1fr); gap: 14px; padding: 18px; border-top: 1px solid var(--line); background: rgba(20, 20, 20, .98); }
.composer-document { position: relative; display: grid; gap: 6px; }
.composer-label { padding-left: 3px; color: var(--muted-strong); font-size: .72rem; }
.scope-picker-toggle {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--ink);
    background: #0e0e0e;
    cursor: pointer;
    text-align: left;
}
.scope-picker-toggle:hover, .scope-picker-toggle[aria-expanded="true"] { border-color: var(--line-strong); }
.scope-picker-toggle:disabled { color: var(--muted); cursor: not-allowed; opacity: .62; }
.scope-picker-toggle > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-picker-chevron { width: 20px; height: 20px; flex: 0 0 20px; fill: var(--accent); filter: drop-shadow(0 0 5px rgba(223, 255, 0, .28)); transition: transform .18s ease; }
.scope-picker-toggle[aria-expanded="true"] .scope-picker-chevron { transform: rotate(180deg); }
.query-scope-panel {
    position: absolute;
    z-index: 20;
    right: 0;
    bottom: calc(100% + 8px);
    left: 0;
    max-height: min(52vh, 440px);
    padding: 10px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: #111;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .62);
    overflow-y: auto;
    scrollbar-color: #3b3b3b transparent;
}
.composer-input { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 14px; background: #0c0c0c; }
.composer-input:focus-within { border-color: var(--line-strong); }
.composer-input textarea { min-height: 48px; max-height: 190px; padding: 11px 10px; border: 0; background: transparent; box-shadow: none; }
.composer-actions { display: flex; justify-content: flex-end; gap: 8px; }
.composer-actions .button { min-height: 46px; }

@media (min-width: 821px) {
    .query-form {
        grid-template-columns: minmax(0, 1120px);
        justify-content: center;
    }
    .composer-document, .composer-input {
        width: 100%;
        justify-self: center;
    }
}

.access-panel {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(0, 0, 0, .78);
    backdrop-filter: blur(18px) saturate(.55);
}
.access-modal {
    position: relative;
    width: min(480px, 100%);
    padding: clamp(30px, 6vw, 54px);
    border: 1px solid var(--line);
    border-radius: 24px;
    background: linear-gradient(145deg, #1a1a1a, #111);
    box-shadow: 0 34px 110px rgba(0, 0, 0, .75);
    overflow: hidden;
}
.access-modal::before { content: ""; position: absolute; width: 180px; height: 180px; top: -110px; right: -70px; border-radius: 50%; background: var(--accent); filter: blur(80px); opacity: .1; }
.access-brand { width: 66px; height: 66px; display: grid; place-items: center; margin-bottom: 44px; border: 1px solid var(--line-strong); border-radius: 16px; color: var(--accent); background: #0b0b0b; font-family: "Cascadia Mono", monospace; font-size: .76rem; letter-spacing: .13em; }
.access-brand img {width: 45px; height: auto;}
.access-modal h1 { margin-bottom: 16px; font-size: clamp(2.6rem, 9vw, 4.6rem); }
.access-modal > p:not(.eyebrow) { max-width: 340px; margin-bottom: 32px; }
.access-form { display: grid; gap: 10px; }
.access-form .button { margin-top: 8px; }
.privacy-note { display: block; margin-top: 20px; color: #70706a; text-align: center; }

.session-user {
    max-width: 130px;
    overflow: hidden;
    color: var(--accent);
    font-family: "Cascadia Mono", monospace;
    font-size: .72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
    align-items: end;
    gap: 18px;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 13px;
}

legend {
    padding: 0 8px;
    color: var(--muted-strong);
    font-family: "Cascadia Mono", monospace;
    font-size: .75rem;
}

.permission-card { margin-top: 24px; }
.permission-scope { margin-bottom: 20px; }
.field-help { margin: 0 0 16px; color: var(--muted); font-size: .84rem; }
.permission-tree { display: grid; gap: 10px; }
.tree-branch {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, .014);
    overflow: hidden;
}
.tree-node {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    color: var(--ink);
    cursor: pointer;
}
.tree-node:hover { background: rgba(255, 255, 255, .026); }
.tree-node input { width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--accent); }
.tree-node-copy { min-width: 0; display: grid; gap: 2px; overflow-wrap: anywhere; }
.tree-node-copy strong { color: var(--ink); font-family: "Cascadia Mono", monospace; font-size: .84rem; font-weight: 500; }
.tree-node-copy > span { color: var(--muted-strong); font-size: .88rem; }
.tree-node-copy small { color: var(--muted); font-size: .7rem; }
.tree-project { min-height: 55px; background: rgba(255, 255, 255, .024); }
.tree-project-context { grid-template-columns: minmax(0, 1fr); cursor: default; }
.tree-project-context:hover { background: rgba(255, 255, 255, .024); }
.tree-children { position: relative; display: grid; padding: 5px 8px 8px 34px; }
.tree-children::before { content: ""; position: absolute; top: 0; bottom: 16px; left: 21px; width: 1px; background: var(--line); }
.tree-document { position: relative; border-radius: 8px; }
.tree-document::before { content: ""; position: absolute; top: 50%; left: -13px; width: 12px; height: 1px; background: var(--line); }
.tree-document.is-inherited { cursor: default; opacity: .72; }
.tree-empty { margin: 0; padding: 16px; color: var(--muted); font-size: .84rem; text-align: center; }
.query-scope-tree .tree-node { padding-top: 8px; padding-bottom: 8px; }
.query-scope-tree .tree-project { min-height: 50px; }
.check-list { display: grid; gap: 8px; }
.check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-list label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--ink);
    background: rgba(255, 255, 255, .018);
    cursor: pointer;
}
.check-list input { width: 17px; height: 17px; accent-color: var(--accent); }
.check-list small { grid-column: 2; color: var(--muted); }
.table-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.document-actions, .project-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.document-actions .status { white-space: nowrap; }
.project-actions { margin-top: 18px; }
.project-name-row { grid-template-columns: minmax(260px, 1fr); padding: 0; margin-bottom: 22px; }
.project-profile-field { margin-bottom: 22px; }
.project-profile-field textarea { min-height: 132px; line-height: 1.55; }
.project-documents { margin-top: 8px; }
.project-form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 22px; }
.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.project-card { margin: 0; }
.project-profile-status { margin: 10px 0 14px; color: var(--muted); font-family: "Cascadia Mono", monospace; font-size: .7rem; }
.project-profile-status.is-configured { color: var(--accent); }
.project-card ul { min-height: 52px; padding-left: 20px; color: var(--muted-strong); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-grid .card { display: grid; align-content: start; gap: 14px; }
.settings-grid .card h2, .settings-grid .card p { margin-bottom: 0; }

.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.module-card { margin: 0; display: grid; gap: 16px; align-content: start; }
.module-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.module-card-header h2 { margin-bottom: 4px; }
.module-card-header p, .module-card > p { margin: 0; }
.module-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-family: "Cascadia Mono", monospace; font-size: .7rem; }
.module-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.module-navigation { display: contents; }
.module-dashboard-host { min-width: 0; }
.module-dashboard-host[aria-busy="true"] { cursor: progress; }
.module-dashboard-host[aria-busy="true"] button:disabled,
.module-dashboard-host[aria-busy="true"] input:disabled,
.module-dashboard-host[aria-busy="true"] select:disabled,
.module-dashboard-host[aria-busy="true"] textarea:disabled { opacity: .68; }
.module-action-progress { display: grid; gap: 9px; padding: 15px 17px; border: 1px solid rgba(223, 255, 0, .25); border-radius: 10px; background: rgba(223, 255, 0, .035); }
.module-action-progress[hidden] { display: none !important; }
.module-action-progress-copy { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--muted-strong); font-size: .82rem; }
.module-action-progress progress { width: 100%; height: 5px; display: block; border: 0; border-radius: 999px; overflow: hidden; accent-color: var(--accent); }
.module-action-progress > small { color: var(--muted); font-size: .72rem; }

.text-button {
    width: 100%;
    margin-top: 16px;
    padding: 8px;
    border: 0;
    color: var(--muted-strong);
    background: transparent;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.text-button:hover { color: var(--accent); }
.admin-access { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.admin-access summary { color: var(--muted); cursor: pointer; font-size: .84rem; }
.admin-access .access-form { margin-top: 12px; }
.access-panel { overflow-y: auto; }
.secret-dialog { z-index: 140; }
.secret-dialog .access-modal h2 { font-size: clamp(1.3rem, 4vw, 2rem); }
.recovery-secret {
    display: block;
    margin: 25px 0;
    padding: 18px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    color: var(--accent);
    background: #080808;
    font-family: "Cascadia Mono", monospace;
    font-size: clamp(1.15rem, 5vw, 1.7rem);
    letter-spacing: .09em;
    text-align: center;
    user-select: all;
}
.secret-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.confirmation-dialog { z-index: 145; }
.password-reset-dialog { z-index: 145; }
.confirmation-modal { width: min(560px, 100%); }
.danger-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin-bottom: 28px;
    border: 1px solid rgba(255, 92, 100, .42);
    border-radius: 16px;
    color: var(--danger);
    background: rgba(255, 92, 100, .08);
    box-shadow: 0 0 38px rgba(255, 92, 100, .08);
    font-family: "Cascadia Mono", monospace;
    font-size: 1.45rem;
    font-weight: 700;
}
.confirmation-modal .eyebrow { color: var(--danger); }
.confirmation-modal > p { margin-bottom: 22px; }
.confirmation-instruction {
    display: grid;
    gap: 9px;
    margin: 4px 0 22px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--muted);
    background: #0b0b0b;
    font-size: .82rem;
}
.confirmation-instruction code {
    color: var(--ink);
    font-family: "Cascadia Mono", monospace;
    font-size: .9rem;
    overflow-wrap: anywhere;
    user-select: all;
}
.confirmation-error {
    margin: 10px 0 0 !important;
    color: var(--danger) !important;
    font-size: .82rem;
}
.confirmation-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 26px; }
.confirmation-actions .button-danger { font-family: "Cascadia Mono", monospace; font-size: .78rem; font-weight: 600; }
.compact-brand { width: 58px; height: 58px; margin-bottom: 28px; }
.account-reference {
    margin: 0 0 22px !important;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--muted) !important;
    background: #0b0b0b;
}
.account-reference strong { color: var(--accent); font-family: "Cascadia Mono", monospace; font-weight: 500; }

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 200;
    max-width: min(420px, calc(100vw - 44px));
    padding: 13px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    color: #0a0a0a;
    background: var(--accent);
    box-shadow: var(--shadow);
}
.toast.error { color: #fff; border-color: rgba(255, 92, 100, .38); background: #9d2f36; }

@media (max-width: 1180px) {
    .topbar { grid-template-columns: minmax(190px, 1fr) auto auto; gap: 18px; }
    .menu-toggle {
        width: 42px;
        height: 42px;
        display: grid;
        place-content: center;
        gap: 5px;
        padding: 0;
        border: 1px solid var(--line);
        border-radius: 9px;
        background: transparent;
        cursor: pointer;
    }
    .menu-toggle > span:not(.sr-only) { width: 18px; height: 1px; display: block; background: var(--ink); transition: transform .2s ease, opacity .2s ease; }
    .menu-open .menu-toggle > span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
    .menu-open .menu-toggle > span:nth-child(2) { opacity: 0; }
    .menu-open .menu-toggle > span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
    .top-navigation {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        display: none;
        align-items: stretch;
        padding: 14px clamp(20px, 4vw, 50px) 18px;
        border: 0;
        border-bottom: 1px solid var(--line);
        border-radius: 0;
        background: rgba(9, 9, 9, .98);
        box-shadow: 0 24px 40px rgba(0, 0, 0, .36);
    }
    .menu-open .top-navigation { display: flex; }
    .top-navigation a { flex: 1; justify-content: center; text-align: center; }
    .auth-locked .menu-toggle { opacity: .35; pointer-events: none; }
}

@media (max-width: 820px) {
    :root { --header-height: 72px; }
    .topbar { grid-template-columns: 1fr auto auto; padding: 0 18px; }
    .brand-logo-slot { width: 42px; height: 42px; flex-basis: 42px; }
    .brand small, .connection-state span:last-child { display: none; }
    .top-actions { gap: 8px; }
    .button-session { min-height: 42px; padding: 0 12px; }
    main { padding: calc(var(--header-height) + 44px) 18px 70px; }
    h1 { font-size: clamp(2.6rem, 11vw, 5.3rem); }
    .page-heading, .query-heading { align-items: flex-start; flex-direction: column; gap: 18px; margin-bottom: 38px; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .guidance { align-items: stretch; flex-direction: column; }
    .guidance code { white-space: normal; overflow-wrap: anywhere; }
    .guidance .worker-run-button { width: 100%; }
    .upload-card { grid-template-columns: 1fr; }
    .upload-progress { grid-column: auto; }
    .worker-monitor { grid-template-columns: auto minmax(0, 1fr); }
    .worker-monitor code { grid-column: 1 / -1; white-space: normal; overflow-wrap: anywhere; }
    .worker-monitor .worker-run-button { width: 100%; grid-column: 1 / -1; justify-self: stretch; }
    .chat-shell { min-height: calc(100vh - 230px); border-radius: 18px; }
    .query-form { grid-template-columns: 1fr; }
    .compact-form, .project-name-row { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .module-grid { grid-template-columns: 1fr; }
    .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .session-user { display: none; }
}

@media (max-width: 620px) {
    .brand-copy { display: none; }
    .topbar { grid-template-columns: 1fr auto auto; }
    .top-navigation { flex-direction: column; padding: 10px 16px 16px; }
    .top-navigation a { justify-content: flex-start; padding: 12px 14px; text-align: left; }
    .metric-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 135px; }
    .guidance, .card { border-radius: 14px; }
    .query-result { padding: 22px 16px; }
    .query-form { padding: 12px; }
    .composer-actions { flex-wrap: wrap; }
    .composer-actions .button { width: auto; }
    .query-scope-panel { max-height: min(48vh, 360px); padding: 7px; }
    .tree-children { padding-left: 27px; }
    .tree-children::before { left: 17px; }
    .tree-document::before { left: -10px; width: 9px; }
    .access-panel { padding: 12px; }
    .access-modal { border-radius: 18px; }
    .access-brand { margin-bottom: 34px; }
    th, td { padding: 13px 14px; }
    .toast { right: 14px; bottom: 14px; max-width: calc(100vw - 28px); }
    .check-grid, .project-grid { grid-template-columns: 1fr; }
    .secret-actions .button { width: 100%; }
    .confirmation-actions { flex-direction: column-reverse; }
    .confirmation-actions .button { width: 100%; }
    .evidence-list li { grid-template-columns: 1fr; gap: 6px; }
    .chat-message-user { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .query-loading-dot { opacity: 1; transform: none; }
}
