/* DeviceBench lab styles. Tokens live in /tokens.css (shared with the landing page). */
@import url("/tokens.css");

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--page-glow), var(--bg-page);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ---------- Controls: one definition each ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h-control); padding: 0 14px;
  border-radius: var(--r-control); border: 1px solid var(--border-strong);
  background: var(--surface-sheen), var(--bg-surface); color: var(--text);
  box-shadow: var(--shadow-xs), var(--rim);
  font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color 120ms ease-out, border-color 120ms ease-out, transform 100ms ease-out;
}
.btn:hover { background: var(--surface-sheen), var(--bg-hover); }
.btn:active { background: var(--bg-active); box-shadow: var(--input-inset); transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn.primary {
  background: var(--btn-primary-bg); border-color: var(--accent-active); color: var(--text-inverse);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn.primary:hover { background: var(--btn-primary-bg-hover); box-shadow: var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.btn.primary:active { background: var(--accent-active); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.sm { height: var(--h-control-sm); padding: 0 10px; font-size: 12px; }
.btn.icon { width: var(--h-control); padding: 0; }
.btn.icon.sm { width: var(--h-control-sm); }
.btn .spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kbd {
  display: inline-flex; align-items: center; height: 18px; padding: 0 5px;
  border-radius: 4px; border: 1px solid var(--kbd-border); background: var(--kbd-bg);
  font-size: 11px; line-height: 1; color: var(--text-2); font-family: var(--font);
}
.btn.primary .kbd { border-color: rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.15); color: var(--text-inverse); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2); }

.field, .select, .textarea {
  height: var(--h-control); padding: 0 10px; width: 100%;
  border-radius: var(--r-control); border: 1px solid var(--border-strong);
  background: var(--bg-surface); color: var(--text);
  box-shadow: var(--input-inset), 0 0 0 3px var(--bg-ring);
  transition: box-shadow 120ms ease-out, border-color 120ms ease-out;
}
.field::placeholder, .textarea::placeholder { color: var(--text-3); font-weight: 300; }
.field:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: var(--input-inset), 0 0 0 3px var(--accent-wash), 0 0 12px rgba(42, 120, 214, 0.12);
}
.select {
  appearance: none; -webkit-appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b8b8b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: none; line-height: 1.5; }
.field.sm, .select.sm { height: var(--h-control-sm); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; height: var(--h-control); cursor: pointer; white-space: nowrap; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: var(--r-chip); border: 1px solid var(--border); background: var(--bg-subtle);
  font-size: 11.5px; line-height: 1; color: var(--text-2); white-space: nowrap;
}
.chip.mono { font-family: var(--mono); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--status-neutral); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-neutral) 16%, transparent); }
.dot.good { background: var(--status-good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-good) 16%, transparent), 0 0 8px color-mix(in srgb, var(--status-good) 45%, transparent); }
.dot.warn { background: var(--status-warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-warn) 18%, transparent); }
.dot.serious { background: var(--status-serious); box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-serious) 18%, transparent); }
.dot.critical { background: var(--status-critical); box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-critical) 18%, transparent); }

/* ---------- Layout ---------- */

.app { display: grid; grid-template-rows: 48px 1fr; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--surface-sheen), var(--bg-surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs); position: relative; z-index: 2;
}
.brand svg { filter: drop-shadow(0 0 6px rgba(42, 120, 214, 0.35)); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; }
.brand svg { width: 20px; height: 20px; color: var(--accent); }
.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tab {
  height: 32px; padding: 0 12px; border: 0; border-radius: var(--r-control); background: transparent;
  color: var(--text-2); cursor: pointer; font-weight: 500;
}
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab[aria-selected="true"] { background: var(--bg-active); color: var(--text); }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.topbar .spacer { flex: 1; }
.sysline { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12px; }

.body { display: grid; grid-template-columns: 280px minmax(0, 1fr) 400px; min-height: 0; }
.sidebar, .panel { background: var(--bg-surface); overflow-y: auto; min-height: 0; }
.sidebar { border-right: 1px solid var(--border); }
.panel { border-left: 1px solid var(--border); }
.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.section:last-child { border-bottom: 0; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3);
  margin: 0 0 10px; height: 20px;
}
.section-title .btn.sm { height: 24px; padding: 0 8px; font-size: 11px; text-transform: none; letter-spacing: 0; }

/* Provider rows */
.prov-group { font-size: 11px; color: var(--text-3); margin: 8px 0 4px; }
.prov {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 7px 8px; border: 1px solid transparent; border-radius: var(--r-control); background: transparent; cursor: pointer;
}
.prov:hover { background: var(--bg-hover); }
.prov[aria-selected="true"] { background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: var(--rim); }
.prov:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.prov .name { font-weight: 500; line-height: 1.2; }
.prov .detail { font-size: 11.5px; color: var(--text-3); line-height: 1.3; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prov .text { min-width: 0; flex: 1; }
.prov-sub { padding: 6px 8px 8px 8px; display: grid; gap: 8px; }
.prov-sub .row { display: flex; gap: 8px; align-items: center; }
.prov-sub .note { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }

/* Use case list */
.uc {
  display: block; width: 100%; text-align: left; padding: 7px 8px; border: 0; border-radius: var(--r-control);
  background: transparent; cursor: pointer; color: var(--text);
}
.uc:hover { background: var(--bg-hover); }
.uc[aria-selected="true"] { background: var(--accent-wash); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent); }
.uc:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.uc .name { font-weight: 500; line-height: 1.2; display: flex; align-items: center; gap: 8px; }
.uc .desc { font-size: 11.5px; color: var(--text-3); margin-top: 2px; line-height: 1.3; }
.uc-group { font-size: 11px; color: var(--text-3); margin: 10px 0 4px; }

/* Transcript */
.transcript { flex: 1; overflow-y: auto; padding: 24px 0; }
.transcript-inner { max-width: 760px; margin: 0 auto; padding: 0 24px; display: grid; gap: 20px; }
.empty { color: var(--text-3); text-align: center; padding: 64px 24px; line-height: 1.6; }
.empty h2 { font-weight: 500; font-size: 18px; color: var(--text); margin: 0 0 8px; }
.msg { display: grid; gap: 6px; }
.msg-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); height: 22px; }
.msg-head .who { color: var(--text-2); font-weight: 500; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: 13.5px; }
.msg.user .msg-body { background: var(--surface-sheen), var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-card); padding: 12px 14px; box-shadow: var(--shadow-xs); }
.msg.assistant .msg-body { padding: 0 2px; }
.msg .thinking { font-size: 12px; color: var(--text-3); border-left: 2px solid var(--border-strong); padding: 4px 10px; white-space: pre-wrap; margin-bottom: 6px; }
.msg .thinking summary { cursor: pointer; color: var(--text-2); }
.msg .error { color: var(--status-critical); }
.msg .muted { color: var(--text-3); }
.msg pre { margin: 0; font-family: var(--mono); font-size: 12px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-control); padding: 10px 12px; overflow-x: auto; }
.msg-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cursor::after { content: ""; display: inline-block; width: 7px; height: 14px; background: var(--text-2); vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* Composer */
.composer { border-top: 1px solid var(--border); background: var(--surface-sheen), var(--bg-surface); padding: 12px 24px 16px; box-shadow: 0 -1px 0 rgba(var(--shadow-ink), 0.02), 0 -8px 24px rgba(var(--shadow-ink), 0.04); position: relative; z-index: 1; }
.composer .textarea { box-shadow: var(--input-inset), var(--shadow-xs), 0 0 0 3px var(--bg-ring); }
/* the one glow moment: the prompt field breathes while a model is generating */
.composer.running .textarea { border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong)); animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { box-shadow: var(--input-inset), 0 0 0 3px var(--accent-wash), 0 0 14px rgba(42, 120, 214, 0.10); }
  50% { box-shadow: var(--input-inset), 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent), 0 0 26px rgba(42, 120, 214, 0.26); }
}
@media (prefers-reduced-motion: reduce) { .composer.running .textarea { animation: none; } }
.composer-inner { max-width: 760px; margin: 0 auto; display: grid; gap: 10px; }
.composer .options { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.composer .options .opt { display: flex; align-items: center; gap: 6px; }
.composer .options .opt .field, .composer .options .opt .select { width: 84px; }
.composer .options .opt span { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.composer .actions { display: flex; align-items: center; gap: 10px; }
.composer .actions .spacer { flex: 1; }
.composer .target { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); min-width: 0; }
.composer .target strong { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Right panel: charts */
.chart-block { display: grid; gap: 6px; margin-bottom: 14px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; height: 18px; }
.chart-head .t { font-size: 12px; color: var(--text-2); font-weight: 500; }
.chart-head .v { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-head .legend { display: inline-flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text-3); }
.chart-head .legend i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 4px; border-radius: 1px; }
.chart-wrap { position: relative; height: 84px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; border-radius: var(--r-control); box-shadow: inset 0 0 0 1px var(--border), var(--input-inset); }
.chart-tip {
  position: absolute; top: 4px; pointer-events: none; z-index: 1070;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-control);
  box-shadow: var(--shadow-pop); padding: 6px 8px; font-size: 11px; color: var(--text-2); white-space: nowrap;
}
.chart-tip b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.cores { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; height: 14px; }
.cores span { display: block; background: var(--chart-grid); border-radius: 2px; position: relative; overflow: hidden; }
.cores span::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--h, 0%); background: var(--series-1); }
.cores-note { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { border: 1px solid var(--border); border-radius: var(--r-control); padding: 10px 10px 8px; background: var(--surface-sheen), var(--bg-surface); box-shadow: var(--shadow-xs), var(--rim); min-width: 0; }
.tile .l { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 15px; }
.tile .v { font-size: 18px; font-weight: 500; line-height: 1.2; margin-top: 4px; white-space: nowrap; }
.tile .v small { font-size: 11px; color: var(--text-3); font-weight: 400; margin-left: 2px; }
.tile .s { font-size: 11px; color: var(--text-3); margin-top: 2px; height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Attribution list */
.rows { display: grid; gap: 2px; }
.row-item { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; height: 26px; font-size: 12px; }
.row-item .n { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .c, .row-item .m { font-variant-numeric: tabular-nums; text-align: right; color: var(--text); min-width: 52px; }
.row-item .m { color: var(--text-2); min-width: 64px; }

/* Views */
.view { display: none; min-height: 0; }
.view.active { display: contents; }
.page { grid-column: 1 / -1; overflow-y: auto; padding: 24px; }
.page-inner { max-width: 1080px; margin: 0 auto; }
.page h1 { font-size: 18px; font-weight: 500; margin: 0 0 4px; }
.page .sub { color: var(--text-2); margin: 0 0 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.card { background: var(--surface-sheen), var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm), var(--rim); }
.card .card-head { display: flex; align-items: flex-start; gap: 10px; }
.card .card-head .status { padding-top: 1px; }
.card .card-head h3 { font-size: 14px; font-weight: 500; margin: 0; flex: 1; min-width: 0; line-height: 1.25; }
.card .status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.card .desc { color: var(--text-2); line-height: 1.5; }
.card .kv { display: grid; grid-template-columns: 96px 1fr; gap: 4px 12px; font-size: 12px; }
.card .kv dt { color: var(--text-3); }
.card .kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.card .kv dd code { font-family: var(--mono); font-size: 11.5px; background: var(--bg-subtle); padding: 1px 4px; border-radius: 3px; }
.card .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.card .foot { margin-top: auto; display: flex; gap: 8px; align-items: center; }
.card ul.models { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 12px; }
.card ul.models li { display: flex; justify-content: space-between; gap: 8px; }
.card ul.models li span:last-child { color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Runs table */
.table-wrap { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-sm); }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { padding: 0 12px; height: 36px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { font-weight: 500; color: var(--text-2); background: var(--bg-subtle); position: sticky; top: 0; cursor: pointer; user-select: none; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-hover); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

/* Toast */
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 1060; max-width: 380px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-control);
  box-shadow: var(--shadow-lg), var(--rim); padding: 10px 12px; font-size: 12.5px; color: var(--text);
}
.toast.err { border-color: var(--status-critical); }

/* Progress bar (model downloads) */
.progress { height: 4px; background: var(--chart-grid); border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); width: 0; transition: width 200ms ease-out; }

@media (max-width: 1100px) {
  .body { grid-template-columns: 240px minmax(0, 1fr) 340px; }
}
@media (pointer: coarse) {
  :root { --h-control: 44px; --h-control-sm: 36px; }
}

/* ---------- Hosted mode without the companion ---------- */
.brand { color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.companion-note { padding: 8px; border: 1px dashed var(--border-strong); border-radius: var(--r-control); font-size: 11.5px; color: var(--text-2); line-height: 1.45; display: grid; gap: 8px; margin: 2px 0 6px; }
.companion-note .row { display: flex; gap: 8px; }
.companion-text { margin: 0 0 10px; color: var(--text-2); font-size: 12px; line-height: 1.5; }
.companion-cmd { margin: 0 0 10px; font-family: var(--mono); font-size: 11.5px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-control); padding: 10px 12px; overflow-x: auto; white-space: pre; box-shadow: var(--input-inset); }
.no-companion [data-chart="cpu"], .no-companion [data-chart="mem"], .no-companion [data-chart="gpu"], .no-companion [data-chart="net"], .no-companion #cores, .no-companion #cores-note, .no-companion #attribution-section { display: none; }
