/* Tokens ------------------------------------------------------------- */
:root {
  --bg: #ffffff;
  --sub: #fafafa;
  --hover: #f2f2f2;
  --line: #ebebeb;
  --line-2: #d9d9d9;
  --ink: #0f0f0f;
  --ink-2: #3d3d3d;
  --muted: #737373;
  --faint: #a3a3a3;
  --accent: #0a62e8;
  --ok: #18794e;
  --warn: #a35200;
  --bad: #c9252d;
  --seg-weights: var(--ink);
  --seg-kv: var(--accent);
  --seg-runtime: #b5b5b5;
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
/* Base --------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h2 { font-size: 13px; font-weight: 500; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { color: var(--ink-2); }
.muted { color: var(--muted); font-size: 12.5px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Bar ---------------------------------------------------------------- */
.bar {
  position: sticky; top: 0; z-index: 20; height: 48px; padding: 0 20px;
  display: flex; align-items: center; gap: 28px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.tagline { color: var(--muted); font-size: 13px; margin-left: -16px; }
@media (max-width: 1180px) { .tagline { display: none; } }
.tabs { display: flex; height: 100%; gap: 20px; }
.tabs button {
  border: 0; background: none; cursor: pointer; padding: 0; height: 100%;
  color: var(--muted); box-shadow: inset 0 -2px 0 transparent; transition: color 0.12s, box-shadow 0.12s;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-checked='true'] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.bar-end { margin-left: auto; display: flex; gap: 16px; }
.text-btn { border: 0; background: none; padding: 4px 0; cursor: pointer; color: var(--muted); font-size: 13px; }
.text-btn:hover { color: var(--ink); }

/* Sheet -------------------------------------------------------------- */
.sheet { display: grid; grid-template-columns: 440px minmax(0, 1fr); min-height: calc(100vh - 48px); }
.inputs { border-right: 1px solid var(--line); background: var(--sub); min-width: 0; }
.results { min-width: 0; }

/* Input rows */
.sec { border-bottom: 1px solid var(--line); padding: 14px 20px 6px; }
.sec-h { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; align-items: start; padding: 5px 0; }
.k { font-size: 13px; color: var(--ink-2); padding-top: 8px; }
.full { position: relative; padding: 2px 0 8px; }
.under { margin-top: 6px; }
.link-btn { border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent); font-size: 12.5px; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.v { min-width: 0; position: relative; }
.hint { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.hint:empty { display: none; }

input, select {
  font: inherit; font-size: 13.5px; color: var(--ink); width: 100%; min-width: 0; height: 34px; padding: 0 10px;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 3.75 5 6.25 7.5 3.75' fill='none' stroke='%23888' stroke-width='1.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input:hover, select:hover { border-color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 8%, transparent); }

/* Number input with unit */
.qty { display: flex; align-items: center; gap: 10px; }
.qty input { width: 88px; flex: none; font-family: var(--mono); font-size: 13px; }
.unit { font-size: 12.5px; color: var(--muted); }

/* Segmented */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; background: var(--bg); }
.seg button {
  border: 0; border-left: 1px solid var(--line-2); background: none; cursor: pointer;
  height: 32px; padding: 0 11px; font-size: 13px; color: var(--ink-2); white-space: nowrap;
  font-family: var(--mono); transition: background-color 0.12s, color 0.12s;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--hover); }
.seg button[aria-checked='true'], .seg button[aria-pressed='true'] { background: var(--ink); color: var(--bg); }
.seg.wrap { display: flex; flex-wrap: wrap; border: 0; gap: 0; overflow: visible; background: none; }
.seg.wrap button { border: 1px solid var(--line-2); margin: 0 -1px -1px 0; font-family: var(--sans); background: var(--bg); }
.seg.wrap button:first-child { border-radius: 6px 0 0 6px; }
.seg.wrap button:last-child { border-radius: 0 6px 6px 0; }
.seg.wrap button[aria-pressed='true'] { background: var(--ink); color: var(--bg); border-color: var(--ink); position: relative; }
.traffic { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Combobox */
.combo-trigger {
  width: 100%; padding: 6px 30px 7px 10px; text-align: left; cursor: pointer; display: block;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 3.75 5 6.25 7.5 3.75' fill='none' stroke='%23888' stroke-width='1.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: calc(100% - 10px) 14px;
  transition: border-color 0.12s;
}
.combo-trigger:hover { border-color: var(--faint); }
.combo-trigger[aria-expanded='true'] { border-color: var(--ink); }
.combo-main { display: block; font-weight: 500; line-height: 1.35; }
.combo-sub { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.combo-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; width: max(100%, 460px); max-width: calc(100vw - 32px);
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column; max-height: min(480px, 70vh); overflow: hidden;
}
.combo-search { flex: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; height: 46px; padding: 0 14px; font-size: 14.5px; box-shadow: none !important; }
.combo-tip { flex: none; padding: 9px 14px; font-size: 12.5px; color: var(--ink-2); background: var(--sub); border-bottom: 1px solid var(--line); }
.combo-tip code { font-size: 12px; color: var(--accent); }
.combo-list { flex: 1; min-height: 0; list-style: none; margin: 0; padding: 4px 0; overflow: auto; }
.combo-group { font-size: 11.5px; color: var(--muted); padding: 10px 12px 4px; }
.combo-opt { padding: 6px 12px; cursor: pointer; }
.combo-opt .o-main { display: flex; justify-content: space-between; gap: 12px; font-weight: 500; }
.combo-opt .o-side { font-family: var(--mono); font-size: 11.5px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.combo-opt .o-sub { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.combo-opt.active { background: var(--hover); }
.combo-opt[aria-selected='true'] { box-shadow: inset 2px 0 0 var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.combo-opt.special .o-main { color: var(--accent); }
.combo-empty { padding: 12px; color: var(--muted); font-size: 13px; }

/* Result blocks ------------------------------------------------------ */
.block { padding: 18px 24px 20px; border-bottom: 1px solid var(--line); }
.block.flush { padding: 0; }
.block-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.block-h.pad { padding: 18px 24px 0; }
.block-h .muted { font-size: 12px; }

/* Status */
.status { display: block; padding-top: 22px; }
.status-title { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent); }
.status[data-status='slow'] .dot, .status[data-status='overloaded'] .dot, .status[data-status='offload'] .dot { background: var(--warn); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 18%, transparent); }
.status[data-status='no'] .dot { background: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 18%, transparent); }
.status-line { margin-top: 6px; color: var(--ink-2); max-width: 78ch; }
.fixes { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 10px; }
.fixes:empty { display: none; }
.fixes p { color: var(--ink-2); }
.fix { border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent); font-weight: 500; }
.fix::after { content: ' →'; }
.fix:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Metrics */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0; }
.metric { padding: 16px 24px 18px; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.metric:first-child { border-left: 0; }
.m-k { font-size: 12.5px; color: var(--muted); }
.m-v { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.3; margin-top: 2px; }
.m-v small { font-size: 13px; color: var(--muted); letter-spacing: 0; margin-left: 4px; font-weight: 400; }
.m-v.miss { color: var(--warn); }
.m-s { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.m-s:empty { display: none; }

/* Memory */
.membar { display: flex; height: 10px; border-radius: 2px; overflow: hidden; background: var(--line); gap: 1px; }
.membar i { height: 100%; min-width: 2px; transition: flex-basis 0.25s ease; }
.membar .cap { flex: none; width: 2px; background: var(--bad); }
[data-k='weights'] { background: var(--seg-weights); }
[data-k='kv'] { background: var(--seg-kv); }
[data-k='runtime'] { background: var(--seg-runtime); }
[data-k='ram'] { background: var(--warn); }
[data-k='over'] { background: repeating-linear-gradient(135deg, var(--bad) 0 3px, transparent 3px 6px); }
[data-k='free'] { background: var(--line); }
.legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 12.5px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend li b { font-family: var(--mono); font-weight: 400; color: var(--ink); }
.legend i { width: 8px; height: 8px; border-radius: 1px; flex: none; }
.note { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.note:empty { display: none; }

/* Chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--muted); font: 10.5px var(--mono); }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 1.75; stroke-linejoin: round; }
.chart .area { fill: var(--ink); opacity: 0.04; }
.chart .target { stroke: var(--warn); stroke-dasharray: 3 3; stroke-width: 1.25; }
.chart .target-label { fill: var(--warn); font: 10.5px var(--mono); }
.chart .limit { stroke: var(--bad); stroke-width: 1.25; stroke-dasharray: 1 3; }
.chart .limit-label { fill: var(--bad); font: 10.5px var(--mono); }
.chart .you { fill: var(--accent); stroke: var(--bg); stroke-width: 2.5; }
.chart .you-label { fill: var(--accent); font: 500 11px var(--mono); }
.chart .hover-dot { fill: var(--ink); }
.chart .hover-line { stroke: var(--line-2); }
.chart-tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%); margin-top: -10px;
  background: var(--ink); color: var(--bg); font: 11.5px var(--mono); padding: 5px 8px; border-radius: 4px; white-space: nowrap;
}
.chart-empty { padding: 36px 0; color: var(--muted); }

/* Table */
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { width: 14px; height: 14px; padding: 0; accent-color: var(--ink); }
.table-wrap { overflow-x: auto; margin-top: 12px; }
.cmp { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmp th { text-align: left; font-weight: 400; color: var(--muted); font-size: 12px; padding: 7px 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--sub); }
.cmp th button { border: 0; background: none; padding: 0; cursor: pointer; color: inherit; font: inherit; }
.cmp th button:hover, .cmp th[aria-sort] button { color: var(--ink); }
.cmp td { padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cmp th:first-child, .cmp td:first-child { padding-left: 24px; }
.cmp th:last-child, .cmp td:last-child { padding-right: 24px; text-align: right; }
.cmp .num { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.cmp th.num { font-family: var(--sans); font-size: 12px; }
.cmp tbody tr:hover { background: var(--sub); }
.cmp tr.current td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.cmp tr.current td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.hw-name { font-weight: 500; }
.hw-sub { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.st::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st[data-status='yes'] { color: var(--ok); }
.st[data-status='slow'], .st[data-status='overloaded'], .st[data-status='offload'] { color: var(--warn); }
.st[data-status='no'] { color: var(--bad); }
.use { border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.use:hover { color: var(--accent); }
tr:hover .use { color: var(--ink); }
.more { display: block; width: 100%; border: 0; background: none; padding: 12px; cursor: pointer; color: var(--muted); font-size: 13px; }
.more:hover { color: var(--ink); background: var(--sub); }

/* Method */
.method summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.method summary::-webkit-details-marker { display: none; }
.method summary::before { content: '+'; font-family: var(--mono); color: var(--muted); width: 10px; }
.method[open] summary::before { content: '−'; }
.method-body { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; max-width: 86ch; color: var(--ink-2); font-size: 13.5px; }
.method-body b { font-weight: 500; color: var(--ink); }
.foot { font-family: var(--mono); font-size: 11.5px; border-bottom: 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 6px; font-size: 13px;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Responsive --------------------------------------------------------- */
@media (max-width: 1200px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n + 3) { border-top: 1px solid var(--line); }
}
@media (max-width: 960px) {
  .sheet { grid-template-columns: minmax(0, 1fr); }
  .inputs { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 560px) {
  .bar { gap: 16px; padding: 0 14px; }
  .brand { display: none; }
  .block { padding: 16px; }
  .block-h.pad { padding: 16px 16px 0; }
  .sec { padding: 12px 16px 4px; }
  .row { grid-template-columns: 78px minmax(0, 1fr); }
  .metric { padding: 14px 16px; }
  .m-v { font-size: 22px; }
  .cmp th:first-child, .cmp td:first-child { padding-left: 16px; }
  .cmp th:last-child, .cmp td:last-child { padding-right: 16px; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Mobile: a summary of the answer while the form is on screen */
.peek {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 25;
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; text-align: left;
  background: var(--ink); color: var(--bg); border: 0; border-radius: 8px; cursor: pointer;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.35); font-size: 13.5px;
}
.peek #peek-text { flex: 1; min-width: 0; }
.peek-go { color: color-mix(in srgb, var(--bg) 70%, transparent); white-space: nowrap; }
.peek[data-status='slow'] .dot, .peek[data-status='overloaded'] .dot, .peek[data-status='offload'] .dot { background: var(--warn); }
.peek[data-status='no'] .dot { background: var(--bad); }
@media (min-width: 961px) { .peek { display: none !important; } }
