/* ==========================================================================
   SignalPath — design tokens
   Palette: "field instrument" — blueprint paper by day, scope-glow by night.
   Type: IBM Plex Sans (voice) + IBM Plex Mono (every measured number).
   ========================================================================== */

:root {
  --bg: #EEF2F0;
  --bg-grid: rgba(14, 40, 34, .05);
  --surface: #FFFFFF;
  --surface-2: #F4F8F6;
  --ink: #0E1B18;
  --ink-muted: #566B66;
  --ink-faint: #93A29D;
  --line: #DDE6E2;
  --teal: #0E9E86;
  --teal-strong: #077A68;
  --teal-wash: rgba(14, 158, 134, .10);
  --amber: #B5730F;
  --amber-wash: rgba(181, 115, 15, .12);
  --alert: #C6423F;
  --alert-wash: rgba(198, 66, 63, .10);
  --shadow: 0 1px 2px rgba(14,27,24,.04), 0 8px 24px -12px rgba(14,27,24,.12);
  --radius: 10px;
  --sans: 'IBM Plex Sans', -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0A121F;
  --bg-grid: rgba(45, 224, 176, .045);
  --surface: #101B2C;
  --surface-2: #0D1726;
  --ink: #E7EEF3;
  --ink-muted: #8CA3B8;
  --ink-faint: #566B82;
  --line: #1D2C42;
  --teal: #2DE0B0;
  --teal-strong: #6BF0C9;
  --teal-wash: rgba(45, 224, 176, .10);
  --amber: #F2A93B;
  --amber-wash: rgba(242, 169, 59, .12);
  --alert: #FF7A79;
  --alert-wash: rgba(255, 122, 121, .12);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -14px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px) 0 0/32px 32px,
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px) 0 0/32px 32px,
    var(--bg);
  color: var(--ink);
  transition: background-color .25s ease, color .25s ease;
  min-height: 100vh;
}
a { color: inherit; }
button { font-family: inherit; }
::selection { background: var(--teal-wash); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.mono { font-family: var(--mono); }

/* ---------------- layout shell ---------------- */

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; flex: none;
  color: var(--teal);
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand-name b { color: var(--teal-strong); }

.topbar-search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--ink-muted);
  font-size: 13px;
}
.topbar-search input {
  border: 0; background: transparent; outline: none; width: 100%;
  color: var(--ink); font-size: 13px; font-family: var(--sans);
}
.kbd {
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  display: flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 999px; padding: 4px; cursor: pointer;
}
.theme-toggle button {
  border: 0; background: transparent; border-radius: 999px;
  padding: 6px 10px; font-size: 12px; color: var(--ink-muted); cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.theme-toggle button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.theme-toggle svg { width: 14px; height: 14px; }

/* ---------------- sidebar ---------------- */

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 18px 12px 24px;
  overflow-y: auto;
  position: sticky;
  top: 61px;
  height: calc(100vh - 61px);
}
.side-group { margin-bottom: 18px; }
.side-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-faint); padding: 0 10px; margin-bottom: 6px; font-weight: 600;
}
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px;
  color: var(--ink-muted); text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
}
.side-link:hover { background: var(--surface-2); color: var(--ink); }
.side-link.active { background: var(--teal-wash); color: var(--teal-strong); border-color: transparent; font-weight: 600; }
.side-link svg { width: 16px; height: 16px; flex: none; }
.side-link .soon { margin-left: auto; font-size: 9.5px; color: var(--ink-faint); border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; }

.sidebar-toggle { display: none; }

main.content { padding: 28px 32px 64px; max-width: 1180px; }

/* ---------------- home hero ---------------- */

.hero {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 40px 40px 28px;
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}
.hero-eyebrow {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .12em;
  color: var(--teal-strong); text-transform: uppercase; display: flex; align-items: center; gap: 8px;
}
.hero-eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px var(--teal-wash); }
.hero h1 {
  font-size: clamp(28px, 4vw, 42px); line-height: 1.08; letter-spacing: -.02em;
  margin: 14px 0 12px; max-width: 640px;
}
.hero p { color: var(--ink-muted); max-width: 520px; font-size: 15px; line-height: 1.6; margin: 0 0 22px; }
.hero-trace { width: 100%; height: 120px; display: block; margin: 8px 0 20px; }
.hero-trace path.grid { stroke: var(--line); stroke-width: 1; }
.hero-trace path.wave { stroke: var(--teal); stroke-width: 2; fill: none; filter: drop-shadow(0 0 6px var(--teal-wash)); }
.hero-readout {
  position: absolute; top: 36px; right: 40px; text-align: right;
  font-family: var(--mono);
}
.hero-readout .val { font-size: 26px; color: var(--teal-strong); font-weight: 600; }
.hero-readout .lbl { font-size: 10.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .08em; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }

@media (max-width: 720px) {
  .hero-readout { position: static; margin-bottom: 14px; text-align: left; }
}

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 8px; padding: 10px 18px; font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal); color: #04231C; }
.btn-primary:hover { background: var(--teal-strong); }
.btn-ghost { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--teal); }
.btn-danger { background: var(--alert-wash); color: var(--alert); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

/* ---------------- tool grid (home) ---------------- */

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 34px 0 14px; }
.section-head h2 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.section-head span { font-size: 12px; color: var(--ink-faint); font-family: var(--mono); }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tool-card {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; position: relative; transition: border-color .15s ease, transform .15s ease;
}
.tool-card:hover { border-color: var(--teal); transform: translateY(-1px); }
.tool-card.disabled { cursor: default; opacity: .55; }
.tool-card.disabled:hover { transform: none; border-color: var(--line); }
.tool-icon {
  width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: var(--teal-wash); color: var(--teal-strong); margin-bottom: 10px;
}
.tool-icon svg { width: 18px; height: 18px; }
.tool-card h3 { font-size: 14px; margin: 0 0 3px; }
.tool-card p { font-size: 12px; color: var(--ink-muted); margin: 0; line-height: 1.4; }
.tool-tag {
  position: absolute; top: 14px; right: 14px; font-family: var(--mono); font-size: 9px;
  letter-spacing: .05em; text-transform: uppercase; padding: 2px 6px; border-radius: 999px;
}
.tool-tag.live { background: var(--teal-wash); color: var(--teal-strong); }
.tool-tag.soon { background: var(--surface-2); color: var(--ink-faint); border: 1px solid var(--line); }

/* ---------------- tool page ---------------- */

.tool-header { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 22px; }
.tool-header .tool-icon { width: 42px; height: 42px; }
.tool-header .tool-icon svg { width: 22px; height: 22px; }
.tool-header h1 { font-size: 22px; margin: 0 0 4px; }
.tool-header p { color: var(--ink-muted); margin: 0; font-size: 14px; max-width: 560px; }
.crumb { font-size: 12px; color: var(--ink-faint); margin-bottom: 10px; }
.crumb a { color: var(--ink-muted); text-decoration: none; }
.crumb a:hover { color: var(--teal-strong); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 16px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink-muted); }
.field input[type=text], .field input[type=number], .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-size: 13.5px; font-family: var(--mono);
}
.field input:focus, .field select:focus { border-color: var(--teal); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.field-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); }

.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 8px;
  background: var(--teal-wash); color: var(--teal-strong); font-size: 12.5px; margin: 16px 0; line-height: 1.5;
}
.notice svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.notice.warn { background: var(--amber-wash); color: var(--amber); }
.notice.error { background: var(--alert-wash); color: var(--alert); }

/* progress steps */
.steps { display: flex; align-items: center; gap: 6px; margin: 18px 0; }
.step { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-faint); }
.step .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 10px; }
.step.done .dot { background: var(--teal); border-color: var(--teal); color: #04231C; }
.step.active .dot { border-color: var(--teal); color: var(--teal-strong); }
.step-line { flex: 1; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.step-line i { display: block; height: 100%; width: 0; background: var(--teal); transition: width .3s ease; }

/* stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 16px 0; }
.stat-tile { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.stat-tile .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin-bottom: 6px; }
.stat-tile .val { font-family: var(--mono); font-size: 22px; font-weight: 600; }
.stat-tile.alert .val { color: var(--alert); }
.stat-tile.teal .val { color: var(--teal-strong); }

/* gauge for speed test */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; padding: 20px 0 6px; }
.gauge { width: 260px; height: 150px; }
.gauge .arc-bg { stroke: var(--line); }
.gauge .arc-fg { stroke: var(--teal); transition: stroke-dashoffset .25s linear; }
.gauge-num { font-family: var(--mono); font-size: 34px; font-weight: 700; margin-top: -34px; }
.gauge-unit { font-size: 12px; color: var(--ink-faint); }

/* data table */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; }
table.data tr:last-child td { border-bottom: none; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-family: var(--sans); font-weight: 600; }
.badge.ok { background: var(--teal-wash); color: var(--teal-strong); }
.badge.bad { background: var(--alert-wash); color: var(--alert); }
.badge.warn { background: var(--amber-wash); color: var(--amber); }

pre.raw {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px;
  font-family: var(--mono); font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow-y: auto;
}

.result-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--teal-wash); border-top-color: var(--teal); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.live-log { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 220px; overflow-y: auto; }
.live-log div { padding: 2px 0; color: var(--ink-muted); }
.live-log div.new { color: var(--ink); }

.footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 24px 32px; font-size: 12px; color: var(--ink-faint); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* responsive */
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; top: 61px; width: 240px; z-index: 30; transition: left .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
  .topbar-search { display: none; }
  main.content { padding: 20px 16px 48px; }
  .hero { padding: 28px 20px 22px; }
}
