:root {
    color-scheme: dark;
    --bg: #080b10;
    --panel: #0f141c;
    --panel-2: #141b25;
    --line: #253041;
    --text: #eef3f8;
    --muted: #93a2b5;
    --accent: #8bf5c6;
    --accent-2: #50d9a0;
    --danger: #ff758d;
    --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .16em; margin-bottom: 8px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(30px, 4vw, 46px); line-height: 1.05; margin-bottom: 12px; letter-spacing: -.035em; }
h2 { letter-spacing: -.02em; }

.topbar { height: 64px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: rgba(8, 11, 16, .92); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: inline-grid; place-items: center; color: #06110c; background: linear-gradient(135deg, var(--accent), #7fc8ff); font-size: 12px; font-weight: 900; }
.brand-mark.large { width: 52px; height: 52px; border-radius: 15px; font-size: 16px; }
.topnav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.topnav form { margin: 0; }
.link-button { border: 0; background: none; color: var(--muted); padding: 0; }
.link-button:hover, .topnav a:hover { color: var(--text); }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 60px 0 90px; }
.page-shell.narrow { width: min(980px, calc(100% - 40px)); }
.hero-row, .section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.section-head { margin: 42px 0 16px; align-items: center; }
.section-head h2 { margin-bottom: 4px; }

.primary, .secondary, .icon-button { border-radius: 10px; border: 1px solid transparent; font-weight: 700; transition: .15s ease; }
.primary { background: var(--accent); color: #05130d; padding: 11px 16px; }
.primary:hover { background: #b3ffde; transform: translateY(-1px); }
.secondary { background: var(--panel-2); border-color: var(--line); color: var(--text); padding: 9px 13px; }
.secondary:hover { border-color: #44536a; background: #192230; }
.icon-button { background: transparent; color: var(--muted); padding: 5px 9px; font-size: 20px; }
.icon-button:hover { color: var(--text); background: var(--panel-2); }
.wide { width: 100%; }
.button-link { display: inline-block; }

.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 36px; }
.metric-card, .project-card, .runner-section, .table-wrap { background: linear-gradient(160deg, rgba(20,27,37,.88), rgba(13,18,25,.88)); border: 1px solid var(--line); border-radius: var(--radius); }
.metric-card { padding: 20px; display: grid; gap: 7px; }
.metric-card span, .metric-card small { color: var(--muted); }
.metric-card strong { font-size: 28px; letter-spacing: -.03em; }
.project-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.project-card { min-height: 190px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.project-card:hover { border-color: #40516a; transform: translateY(-2px); }
.project-card h3 { margin-bottom: 7px; }
.project-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.project-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: #1b2d2a; color: var(--accent); font-weight: 850; }
.tags { display: flex; gap: 6px; margin-top: auto; }
.tag { color: #a8b5c5; background: #151d28; border: 1px solid #2b3748; border-radius: 6px; padding: 3px 7px; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.empty-state { padding: 32px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); grid-column: 1 / -1; text-align: center; }
.empty-state.compact { padding: 18px; }

.runner-section { margin-top: 48px; padding: 22px; }
.runner-section .section-head { margin: 0 0 16px; }
.runner-list { display: grid; gap: 8px; }
.runner-row { min-height: 44px; display: grid; grid-template-columns: auto 180px 120px 1fr; align-items: center; gap: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #465365; }
.status-dot.online { background: var(--accent); box-shadow: 0 0 0 4px rgba(139,245,198,.1); }
.path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auth-shell { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 32px; background: radial-gradient(circle at 50% 20%, rgba(80,217,160,.12), transparent 36%); }
.auth-card { width: min(460px, 100%); background: rgba(15,20,28,.95); border: 1px solid var(--line); border-radius: 18px; padding: 36px; box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #c7d0dc; font-size: 13px; font-weight: 650; }
input, textarea, select { width: 100%; color: var(--text); background: #090e15; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(80,217,160,.1); }
textarea { resize: vertical; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.alert { padding: 11px 13px; border-radius: 9px; font-size: 13px; line-height: 1.45; }
.alert.error { color: #ffc1cb; background: rgba(255,117,141,.1); border: 1px solid rgba(255,117,141,.22); }
.alert.info { color: #b9d8ff; background: rgba(98,164,255,.08); border: 1px solid rgba(98,164,255,.18); }

dialog { width: min(520px, calc(100% - 32px)); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: 0 30px 100px #000; }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; }
.token-box { overflow-wrap: anywhere; white-space: pre-wrap; background: #080c12; border: 1px solid var(--line); border-radius: 9px; padding: 13px; color: var(--accent); }

.workspace { height: calc(100vh - 64px); display: grid; grid-template-columns: 250px minmax(420px, 1fr) minmax(300px, 28%); overflow: hidden; }
.workspace-sidebar, .files-panel { background: #0b1017; padding: 18px; overflow: auto; }
.workspace-sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.files-panel { border-left: 1px solid var(--line); }
.workspace-title { margin-bottom: 20px; }
.workspace-title h2 { margin: 16px 0 10px; font-size: 19px; }
.back-link { color: var(--muted); font-size: 12px; }
.conversation-list { margin-top: 12px; display: grid; gap: 5px; }
.conversation-item { width: 100%; border: 0; border-radius: 8px; background: transparent; color: #aeb9c8; padding: 9px 10px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-item:hover, .conversation-item.active { background: var(--panel-2); color: var(--text); }
.sidebar-bottom { margin-top: auto; padding-top: 20px; }
.chat-panel { min-width: 0; min-height: 0; overflow: hidden; position: relative; display: flex; flex-direction: column; background: radial-gradient(circle at 50% -10%, rgba(80,217,160,.055), transparent 40%); }
.chat-empty { margin: auto; text-align: center; padding: 30px; }
.chat-empty .brand-mark { margin: 0 auto 18px; }
.messages { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 30px max(28px, 8%); display: grid; align-content: start; gap: 18px; }
.message { max-width: 86%; line-height: 1.58; white-space: pre-wrap; overflow-wrap: anywhere; padding: 14px 16px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.message.user { justify-self: end; background: #17251f; border-color: #29483b; }
.message.assistant { justify-self: start; }
.message-meta { font-size: 10px; color: var(--muted); margin-bottom: 7px; text-transform: uppercase; letter-spacing: .08em; }
.message-attachments { display: grid; gap: 7px; margin-top: 12px; }
.message-attachment { display: flex; align-items: center; gap: 9px; min-width: 210px; padding: 9px 11px; border: 1px solid #35465a; border-radius: 9px; background: #0c121a; color: #d7e3ee; font-size: 12px; }
.message-attachment:hover { border-color: var(--accent-2); background: #101a23; }
.attachment-icon { color: var(--accent); font-size: 16px; }
.attachment-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { margin-left: auto; color: var(--muted); font-size: 10px; }
.request-status { max-width: 86%; justify-self: start; padding: 13px 15px; border: 1px solid #304154; border-radius: 13px; background: rgba(17, 24, 34, .92); }
.request-status.completed { border-color: #2d5947; }
.request-status.failed { border-color: rgba(255,117,141,.48); }
.request-status-title { margin-bottom: 9px; font-size: 12px; font-weight: 750; color: #d9e4ef; }
.request-steps { display: flex; flex-wrap: wrap; gap: 7px 16px; }
.request-step { position: relative; padding-left: 17px; color: #68778a; font-size: 11px; }
.request-step::before { content: '○'; position: absolute; left: 0; color: #586779; }
.request-step.done { color: #bdeed8; }
.request-step.done::before { content: '✓'; color: var(--accent); }
.request-step.active { color: #dce7f2; }
.request-step.active::before { content: ''; top: 2px; width: 9px; height: 9px; border: 2px solid #4d6075; border-top-color: var(--accent); border-radius: 50%; animation: request-spin .75s linear infinite; }
.request-step.failed { color: #ffc1cb; }
.request-step.failed::before { content: '!'; color: var(--danger); font-weight: 900; }
.request-error { margin-top: 10px; color: #ffc1cb; font-size: 11px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
@keyframes request-spin { to { transform: rotate(360deg); } }
.composer { flex: 0 0 auto; margin: 0 max(20px, 7%) 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 15px; padding: 11px; }
.composer textarea { border: 0; background: transparent; min-height: 72px; box-shadow: none; }
.composer-actions { display: flex; justify-content: space-between; align-items: center; padding: 4px 3px 0; }
.composer-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.attachment-button { padding: 6px 9px; font-size: 11px; }
.attachment-upload-status { font-size: 10px; }
.agent-toggle { display: flex; color: var(--muted); font-size: 11px; font-weight: 500; }
.selected-context { display: flex; flex-wrap: wrap; gap: 5px; }
.context-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #355a49; background: #13261e; color: #b9f7da; border-radius: 6px; padding: 3px 5px 3px 7px; font-size: 10px; }
.context-chip-remove { border: 0; background: transparent; color: #82bfa4; padding: 0 2px; line-height: 1; }
.context-chip-remove:hover { color: #fff; }
.files-head, .editor-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.files-head h3 { margin: 0; }
.upload-row { margin: 14px 0; display: grid; gap: 8px; }
.upload-row input[type=file] { font-size: 11px; padding: 7px; }
.file-list { display: grid; gap: 2px; font-size: 12px; }
.file-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px; padding: 6px 7px; border-radius: 7px; }
.file-row:hover { background: var(--panel-2); }
.file-name { border: 0; background: transparent; color: #c7d0dc; padding: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-toggle { width: auto; }
.editor { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.editor-head { font-size: 11px; margin-bottom: 8px; }
.editor-head span { overflow: hidden; text-overflow: ellipsis; }
.editor textarea { min-height: 360px; resize: vertical; font: 12px/1.55 "Cascadia Code", "SFMono-Regular", Consolas, monospace; tab-size: 4; }

.table-wrap { overflow: auto; margin-top: 32px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 15px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.status-pill { border-radius: 999px; padding: 4px 8px; background: #2b3340; color: #aeb9c8; font-size: 11px; }
.status-pill.ok { background: #153526; color: var(--accent); }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(420px, calc(100% - 44px)); background: #18212d; border: 1px solid #3c4a5c; border-radius: 10px; padding: 12px 15px; box-shadow: 0 16px 50px #000; }
.toast.error { border-color: rgba(255,117,141,.55); color: #ffd1d8; }

@media (max-width: 1000px) {
    .workspace { grid-template-columns: 210px 1fr; }
    .files-panel { display: none; }
    .project-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
    .topbar { padding: 0 16px; }
    .topnav .muted { display: none; }
    .page-shell { width: min(100% - 24px, 1180px); padding-top: 35px; }
    .hero-row { align-items: flex-start; flex-direction: column; }
    .metrics-grid, .project-grid { grid-template-columns: 1fr; }
    .runner-row { grid-template-columns: auto 1fr; }
    .runner-row .path, .runner-row > .muted:first-of-type { display: none; }
    .workspace { grid-template-columns: 1fr; }
    .workspace-sidebar { display: none; }
    .two-cols { grid-template-columns: 1fr; }
}
