:root {
  --bg: #F3F6FC;
  --surface: #FFFFFF;
  --surface-2: #F7F9FE;
  --text: #0A1433;
  --text-2: #445274;
  --text-3: #7A87A8;
  --line: #DDE4F2;
  --line-2: #ECF1FA;
  --navy-950: #050B1F;
  --navy-900: #0A1433;
  --navy-800: #0F1F4D;
  --navy-700: #16307A;
  --blue: #2350D6;
  --blue-2: #1A3FB0;
  --blue-soft: #E8EEFD;
  --steel: #9DB2E3;
  --grad: linear-gradient(135deg, #0B1B4D 0%, #17348F 52%, #2A57DB 100%);
  --mesh:
    radial-gradient(900px 520px at 85% -10%, rgba(42, 87, 219, .55), transparent 60%),
    radial-gradient(700px 480px at 105% 110%, rgba(23, 52, 143, .7), transparent 60%),
    radial-gradient(800px 520px at -10% -20%, rgba(22, 48, 122, .85), transparent 60%),
    radial-gradient(600px 420px at 10% 120%, rgba(30, 64, 175, .45), transparent 60%),
    linear-gradient(160deg, #050B1F 0%, #0A1433 50%, #0B1A45 100%);
  --pass: #1F7A4D; --pass-soft: #E4F4EC;
  --fail: #C23328; --fail-soft: #FDECEA;
  --run: #2350D6; --run-soft: #E8EEFD;
  --warn: #9A5F00; --warn-soft: #FFF4DB;
  --term-bg: #07102A; --term-text: #D8E2FA; --term-dim: #7F90BD;
  --radius-l: 18px; --radius-m: 12px; --radius-s: 8px;
  --shadow: 0 1px 2px rgba(10,20,51,.05), 0 10px 28px -12px rgba(15,31,77,.22);
  --font: "Google Sans Flex", "Google Sans", "Noto Sans Devanagari", "Noto Sans Telugu", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Google Sans Code", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #060C20; --surface: #0C1631; --surface-2: #0F1B3B; --text: #EAF0FF; --text-2: #B0BEDF; --text-3: #7F8FB6;
    --line: #1B2A52; --line-2: #132043; --blue: #7C9BF5; --blue-2: #A6BCFA; --blue-soft: #15245A;
    --pass: #5ED39A; --pass-soft: #0F3325; --fail: #FF8A80; --fail-soft: #3A1717; --run: #7C9BF5; --run-soft: #15245A;
    --warn: #F7C35F; --warn-soft: #3A2C0E;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -16px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #060C20; --surface: #0C1631; --surface-2: #0F1B3B; --text: #EAF0FF; --text-2: #B0BEDF; --text-3: #7F8FB6;
  --line: #1B2A52; --line-2: #132043; --blue: #7C9BF5; --blue-2: #A6BCFA; --blue-soft: #15245A;
  --pass: #5ED39A; --pass-soft: #0F3325; --fail: #FF8A80; --fail-soft: #3A1717; --run: #7C9BF5; --run-soft: #15245A;
  --warn: #F7C35F; --warn-soft: #3A2C0E;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -16px rgba(0,0,0,.6);
}
*, *::before, *::after { box-sizing: inherit; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 1rem; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 28px; }
@media (max-width: 640px) { .wrap { padding: 0 18px; } }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(5, 11, 31, .92); backdrop-filter: saturate(1.3) blur(12px); border-bottom: 1px solid rgba(255,255,255,.07); padding-top: env(safe-area-inset-top, 0px); }
.topbar .wrap { display: flex; align-items: center; gap: 22px; height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.brand b { font-size: 1.2rem; letter-spacing: -0.02em; }
.brand b span { font-weight: 500; opacity: .6; }
.brand small { font-size: .78rem; color: var(--steel); border: 1px solid rgba(157,178,227,.35); border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
.topnav { display: flex; gap: 4px; margin-left: 12px; }
.topnav a { color: #B9C6E8; text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 500; font-size: .95rem; }
.topnav a:hover, .topnav a.active { color: #fff; background: rgba(255,255,255,.08); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.05); color: #D6E0FA; cursor: pointer; }
.user { display: flex; align-items: center; gap: 10px; color: #D6E0FA; font-size: .92rem; }
.user img, .user .avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--navy-700); display: grid; place-items: center; font-weight: 600; color: #fff; }
.user .name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: 0; color: #9DB2E3; cursor: pointer; font-size: .9rem; padding: 6px 8px; border-radius: 8px; }
.link-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
@media (max-width: 720px) { .user .name, .brand small { display: none; } }

/* ---------- Page header band ---------- */
.band { position: relative; overflow: hidden; background: var(--navy-900); color: #EEF3FF; padding: 44px 0 40px; }
.band::before { content: ""; position: absolute; inset: 0; background: var(--mesh); pointer-events: none; }
.band::after { content: ""; position: absolute; inset: 0; opacity: .35; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px); background-size: 100% 40px; mask-image: linear-gradient(180deg, transparent, #000 40%, transparent); }
.band .wrap { position: relative; z-index: 1; }
.band h1 { margin: 0; font-size: clamp(1.8rem, 3.4vw, 2.5rem); letter-spacing: -0.03em; line-height: 1.1; }
.band p { margin: 8px 0 0; color: #B9C6E8; max-width: 62ch; }
.band-row { display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: flex-end; justify-content: space-between; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: #9DB2E3; text-decoration: none; font-size: .92rem; margin-bottom: 14px; }
.crumb:hover { color: #fff; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.stat { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 12px 18px; min-width: 140px; }
.stat small { display: block; color: #9DB2E3; font-size: .82rem; }
.stat b { font-size: 1.5rem; letter-spacing: -0.02em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: rgba(255,255,255,.1); color: #DDE6FF; border: 1px solid rgba(255,255,255,.12); }
.chip.light { background: var(--line-2); color: var(--text-2); border-color: transparent; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: .96rem; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; transition: filter .15s, transform .1s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px -10px rgba(35,80,214,.9), inset 0 1px 0 rgba(255,255,255,.18); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn-light { background: #fff; color: var(--navy-900); }
.btn-light:hover { filter: brightness(.96); }
.btn-outline { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--text-3); }
.btn-danger { background: transparent; border-color: var(--line); color: var(--fail); }
.btn-sm { padding: 6px 12px; font-size: .88rem; border-radius: 8px; }

/* ---------- Layout ---------- */
main { padding: 32px 0 80px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 34px 0 14px; }
.section-title h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
.section-title span { color: var(--text-3); font-size: .9rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow); }
.pad { padding: 22px; }
.grid-2 { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.grid-2 > * { min-width: 0; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }
.muted { color: var(--text-3); }
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty h3 { margin: 0 0 6px; color: var(--text); }

/* ---------- Upload ---------- */
.drop { position: relative; display: flex; align-items: center; gap: 18px; padding: 22px 24px; border: 1.5px dashed var(--steel); border-radius: var(--radius-l); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--blue); background: var(--blue-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--grad); color: #fff; flex: none; }
.drop h3 { margin: 0; font-size: 1.05rem; }
.drop p { margin: 2px 0 0; color: var(--text-2); font-size: .92rem; }
.drop code, .code-inline { font-family: var(--mono); font-size: .86em; background: var(--line-2); padding: 1px 6px; border-radius: 5px; }
.notice { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--radius-m); padding: 12px 16px; margin-top: 12px; font-size: .94rem; }
.notice.error { background: var(--fail-soft); color: var(--fail); }
.notice.ok { background: var(--pass-soft); color: var(--pass); }
.notice.info { background: var(--blue-soft); color: var(--blue); }

/* ---------- Task cards ---------- */
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.task-card { display: flex; flex-direction: column; gap: 12px; padding: 20px; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; min-width: 0; }
.task-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.task-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.task-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; word-break: break-word; }
.task-sub { color: var(--text-3); font-size: .84rem; }
.task-instr { color: var(--text-2); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-foot { display: flex; align-items: center; gap: 14px; font-size: .86rem; color: var(--text-2); padding-top: 12px; border-top: 1px solid var(--line-2); margin-top: auto; }
.task-foot .rate { margin-left: auto; font-weight: 600; color: var(--text); }
.passbar { height: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; display: flex; }
.passbar i { display: block; height: 100%; }

/* ---------- Status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.pass { background: var(--pass-soft); color: var(--pass); }
.pill.fail { background: var(--fail-soft); color: var(--fail); }
.pill.partial { background: var(--warn-soft); color: var(--warn); }
.pill.running, .pill.queued { background: var(--run-soft); color: var(--run); }
.pill.error { background: var(--fail-soft); color: var(--fail); }
.pill.idle { background: var(--line-2); color: var(--text-3); }
.dot-spin { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dot-spin { animation: none; } }

/* ---------- Run panel ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: .92rem; }
.field small { color: var(--text-3); font-size: .82rem; }
select, input[type="number"] { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; width: max-content; }
.stepper button { width: 40px; height: 40px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 1.1rem; color: var(--text-2); }
.stepper input { width: 60px; text-align: center; border: 0; border-radius: 0; padding: 8px 0; }
.model-summary { width: 100%; border-collapse: collapse; font-size: .9rem; }
.model-summary th { text-align: left; color: var(--text-3); font-weight: 500; font-size: .8rem; padding: 6px 0; border-bottom: 1px solid var(--line); }
.model-summary td { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.model-summary th + th, .model-summary td + td { padding-left: 14px; }
.model-summary td:first-child { line-height: 1.3; }
.model-summary .r { text-align: right; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.runs { width: 100%; border-collapse: collapse; min-width: 700px; }
.runs th { text-align: left; font-size: .8rem; font-weight: 500; color: var(--text-3); padding: 12px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.runs td { padding: 13px 10px; border-bottom: 1px solid var(--line-2); font-size: .92rem; white-space: nowrap; }
.runs tbody tr { cursor: pointer; transition: background .12s; }
.runs tbody tr:hover { background: var(--blue-soft); }
.runs tr:last-child td { border-bottom: 0; }
.runs .r { text-align: right; }
.tests-mini { display: inline-flex; align-items: center; gap: 8px; }
.tests-mini .passbar { width: 64px; }
.when b { display: block; font-weight: 500; }
.tok small { color: var(--text-3); }
.runs td.mname { white-space: normal; min-width: 120px; line-height: 1.3; }
.when small { color: var(--text-3); font-size: .8rem; }

/* ---------- Instruction & files ---------- */
.md { color: var(--text); font-size: .97rem; line-height: 1.65; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3 { margin: 18px 0 8px; font-size: 1.08rem; }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--line-2); padding: 1px 6px; border-radius: 5px; }
.md pre { background: var(--term-bg); color: var(--term-text); padding: 14px; border-radius: 10px; overflow-x: auto; font-size: .86rem; }
.md pre code { background: none; padding: 0; color: inherit; }
.files { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.files li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.files li:last-child { border-bottom: 0; }
.files a { font-family: var(--mono); font-size: .86rem; text-decoration: none; word-break: break-all; }
.files .size { color: var(--text-3); white-space: nowrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--text-2); cursor: pointer; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--blue); }

/* ---------- Run detail ---------- */
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
@media (max-width: 1100px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .metrics { grid-template-columns: repeat(2, 1fr); } }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.metric small { display: block; color: var(--text-3); font-size: .82rem; }
.metric b { display: block; font-size: 1.55rem; letter-spacing: -0.02em; margin-top: 2px; }
.metric span { font-size: .82rem; color: var(--text-2); }
.timebar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--line-2); margin-top: 10px; }
.timebar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .78rem; color: var(--text-3); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.test-list { list-style: none; margin: 0; padding: 0; }
.test-list li { border-bottom: 1px solid var(--line-2); }
.test-list li:last-child { border-bottom: 0; }
.test-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; width: 100%; background: none; border: 0; text-align: left; cursor: default; }
.test-row.expandable { cursor: pointer; }
.test-row .tname { font-family: var(--mono); font-size: .86rem; word-break: break-all; flex: 1; }
.test-row .tdur { color: var(--text-3); font-size: .8rem; white-space: nowrap; }
.test-msg { margin: 0 0 12px; padding: 12px 14px; background: var(--term-bg); color: #FFC9C3; border-radius: 10px; font-family: var(--mono); font-size: .82rem; white-space: pre-wrap; overflow-x: auto; }
.ticon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; font-size: .75rem; font-weight: 700; }
.ticon.passed { background: var(--pass); }
.ticon.failed { background: var(--fail); }
.ticon.skipped { background: var(--text-3); }

/* Trajectory */
.timeline { position: relative; display: grid; gap: 14px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.step-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); }
.step-no { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--grad); color: #fff; font-weight: 700; font-size: .88rem; flex: none; }
.step-head b { font-size: .98rem; }
.step-meta { margin-left: auto; display: flex; gap: 14px; color: var(--text-3); font-size: .82rem; flex-wrap: wrap; }
.step-body { padding: 16px 18px; display: grid; gap: 12px; }
.thought { font-size: .93rem; color: var(--text-2); }
.thought b { color: var(--text); font-weight: 600; margin-right: 6px; }
.term { background: var(--term-bg); border-radius: 12px; overflow: hidden; border: 1px solid #13224F; }
.term-cmd { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; background: #0B1738; color: #fff; font-family: var(--mono); font-size: .85rem; }
.term-cmd .ps { color: #7C9BF5; flex: none; }
.term-cmd code { white-space: pre-wrap; word-break: break-all; flex: 1; }
.term-cmd .exit { flex: none; font-size: .76rem; padding: 1px 8px; border-radius: 999px; background: rgba(94,211,154,.15); color: #5ED39A; }
.term-cmd .exit.bad { background: rgba(255,138,128,.15); color: #FF8A80; }
.term-out { margin: 0; padding: 12px 14px; color: var(--term-text); font-family: var(--mono); font-size: .82rem; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; }
.term-out:empty::before { content: "(no output)"; color: var(--term-dim); }
.raw { font-size: .85rem; }
.raw summary { cursor: pointer; color: var(--text-3); }
.raw pre { margin: 8px 0 0; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: .8rem; max-height: 320px; overflow: auto; }
.step.err .step-head { background: var(--fail-soft); }
.parse-err { color: var(--fail); font-size: .92rem; }
.logs pre { margin: 0; padding: 14px; background: var(--term-bg); color: var(--term-text); border-radius: 12px; font-family: var(--mono); font-size: .8rem; white-space: pre-wrap; word-break: break-word; max-height: 460px; overflow: auto; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden; background: var(--navy-950); color: #fff; padding: 24px; }
.login::before { content: ""; position: absolute; inset: 0; background: var(--mesh); }
.login::after { content: ""; position: absolute; inset: 0; opacity: .4; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px); background-size: 100% 44px; mask-image: radial-gradient(closest-side, #000, transparent); }
.login-card { position: relative; z-index: 1; width: min(440px, 100%); background: rgba(10, 20, 51, .72); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(16px); border-radius: 24px; padding: 40px 36px; box-shadow: 0 40px 80px -30px rgba(0,0,0,.7); }
.login-card .brand { margin-bottom: 28px; }
.login-card h1 { margin: 0 0 8px; font-size: 1.8rem; letter-spacing: -0.03em; line-height: 1.15; }
.login-card p { margin: 0 0 28px; color: #B9C6E8; }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; padding: 13px 18px; border-radius: 12px; background: #fff; color: #1F1F1F; font-weight: 600; text-decoration: none; border: 0; cursor: pointer; font-size: 1rem; }
.gbtn:hover { background: #F1F4FB; }
.login-foot { margin-top: 20px; font-size: .84rem; color: #8FA0CC; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy-900); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 16px 40px -12px rgba(0,0,0,.5); z-index: 50; font-size: .94rem; max-width: calc(100% - 32px); }
