:root {
  --bg: #101018;
  --card: #1a1a26;
  --line: #2a2a3c;
  --text: #e9e9f2;
  --muted: #9a9ab0;
  --accent: #ffb347;
  --accent2: #6ee7ff;
  --good: #7dff9e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 560px; margin-inline: auto; padding-bottom: 48px;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; position: sticky; top: 0; z-index: 5;
  background: rgba(16,16,24,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 19px; }
.topbar p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.pill {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.pill.live { color: var(--good); border-color: #2f5b3a; }
main { padding: 12px; display: grid; gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 16px; }
.canvas-wrap { position: relative; }
canvas#circuit { width: 100%; height: auto; display: block; touch-action: manipulation; }
canvas#ivplot { width: 100%; height: auto; display: block; }
.play {
  position: absolute; top: 8px; right: 8px;
  width: 38px; height: 38px; border-radius: 50%;
  background: #26263a; color: var(--text); border: 1px solid var(--line);
  font-size: 14px; cursor: pointer;
}
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 2px 0; }
.readouts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 12px 0; }
.ro {
  background: #14141f; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; text-align: center;
}
.ro span { display: block; font-size: 11px; color: var(--muted); }
.ro b { font-size: 17px; font-variant-numeric: tabular-nums; }
.btn {
  background: #26263a; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; font-size: 14px; cursor: pointer;
}
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.primary { background: #b36a00; border-color: #d98f1f; color: #fff; }
.btn.big { width: 100%; font-size: 16px; padding: 13px; }
.knee { margin-top: 8px; font-size: 14px; }
.knee b { color: var(--accent); font-size: 16px; }
.rowhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.rowhead h2 { margin: 0; }
.rowhead div { display: flex; gap: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td input {
  width: 76px; background: #14141f; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 6px;
  text-align: center; font-size: 14px; font-variant-numeric: tabular-nums;
}
tr.empty td { color: var(--muted); font-size: 13px; padding: 18px 8px; }
.del { background: none; border: none; color: #ff7b7b; font-size: 17px; cursor: pointer; padding: 4px 8px; }
details.card summary { cursor: pointer; font-size: 15px; font-weight: 600; }
.proc { font-size: 14px; line-height: 1.55; }
.proc ol { padding-left: 20px; margin: 8px 0; }
.muted { color: var(--muted); font-size: 13px; }
/* bottom sheet */
.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  background: #1e1e2e; border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 10px 18px 26px;
  max-width: 560px; margin-inline: auto;
  transition: transform .22s ease;
}
.sheet.hidden { transform: translateY(105%); }
.scrim.hidden { display: none; }
.sheet-handle {
  width: 44px; height: 5px; border-radius: 3px; background: #3a3a52;
  margin: 4px auto 12px;
}
.sheet h3 { margin: 0 0 6px; font-size: 16px; }
.sheet .val { font-size: 30px; font-weight: 700; color: var(--accent); margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.sheet input[type=range] { width: 100%; margin: 14px 0 4px; accent-color: var(--accent); height: 34px; }
.sheet .ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.sheet .note { color: var(--muted); font-size: 12.5px; margin: 8px 0 14px; line-height: 1.5; }
.sheet .btn { width: 100%; margin-top: 6px; }
.kv { display: flex; justify-content: space-between; font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv span { color: var(--muted); }
