:root {
  --bg: #12151a;
  --panel: #191d24;
  --edge: #262c35;
  --text: #d9dee5;
  --muted: #7d8794;
  --amber: #f5a524;
  --amber-dim: rgba(245, 165, 36, 0.18);
  --cyan: #4fd1e0;
  --cyan-dim: rgba(79, 209, 224, 0.16);
  --blue: #5b8def;
  --steel: #8fa3b8;
  --grey: #4a525d;
  --danger: #ef6b5b;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px);
}

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

.brand {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.32em;
  color: var(--amber);
  margin: 0;
}

button { font: inherit; cursor: pointer; }

/* ---- sign-in */

.gate { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

.gate-panel {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 32px 28px;
}

.gate-panel .brand { font-size: 28px; margin-bottom: 24px; }

.gate-form { display: grid; gap: 16px; }

.gate-form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; letter-spacing: 0.04em; }

.gate-form input:not([type="checkbox"]) {
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 6px;
  color: var(--text);
  font: 16px var(--mono);
  padding: 10px 12px;
}

.gate-form input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }

.gate-form .check { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.gate-form button {
  background: var(--amber);
  color: #1b1405;
  border: 0;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 11px;
}

.hint { color: var(--muted); margin: 0; font-size: 14px; }
.error { color: var(--danger); margin: 0; font-size: 14px; }
.quiet { color: var(--muted); font-size: 13px; text-align: center; }

/* ---- console */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--edge);
}

.topbar .brand { font-size: 20px; }
.next-pause { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.spacer { flex: 1; }
.user { color: var(--muted); font-size: 13px; }
.topbar form { margin: 0; }
.link { background: none; border: 0; color: var(--text); text-decoration: underline; padding: 0; font-size: 13px; }

.board {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 280px;
  grid-template-areas:
    "power charts throttle"
    "meters meters meters";
  gap: 18px;
  padding: 20px 24px 28px;
  max-width: 1400px;
  margin: 0 auto;
}

.board > section {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 18px;
}

.power { grid-area: power; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.charts { grid-area: charts; display: grid; gap: 14px; }
.throttle { grid-area: throttle; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.dial-block { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.dial-block + .dial-block { border-top: 1px solid var(--edge); padding-top: 14px; }
.meters { grid-area: meters; display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }

/* rocker switch */

.rocker {
  width: 120px;
  height: 190px;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: linear-gradient(#0e1115, #161a20);
  display: grid;
  grid-template-rows: 1fr 1fr;
  padding: 8px;
  gap: 8px;
}

.rocker span {
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--muted);
  background: #1c2129;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.rocker[aria-checked="true"] .rocker-on {
  background: var(--amber);
  color: #1b1405;
  box-shadow: 0 0 22px rgba(245, 165, 36, 0.45);
}

.rocker[aria-checked="false"] .rocker-off { background: #2a3039; color: var(--text); }

.rocker:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.lamp-row { display: flex; align-items: center; gap: 10px; }

.lamp {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--grey);
}

.lamp.running { background: var(--amber); box-shadow: 0 0 12px var(--amber); animation: pulse 1.6s ease-in-out infinite; }
.lamp.paused { background: var(--blue); box-shadow: 0 0 12px var(--blue); }

@keyframes pulse { 50% { opacity: 0.55; } }

.state-text { font-family: var(--mono); font-weight: 700; letter-spacing: 0.14em; }
.state-detail { margin: 0; color: var(--muted); font-size: 13px; text-align: center; min-height: 2.6em; }

/* charts */

.chart { display: grid; gap: 6px; }
.chart-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; letter-spacing: 0.14em; }
.chart canvas { width: 100%; height: 150px; display: block; background: #0f1216; border-radius: 6px; }

/* dial */

.dial { width: 100%; max-width: 190px; touch-action: none; cursor: grab; }
.dial-mem .dial-value { stroke: var(--cyan); filter: drop-shadow(0 0 6px rgba(79, 209, 224, 0.6)); }
.dial-mem .dial-knob { fill: #e3fbff; stroke: var(--cyan); }
.dial-mem .step:hover { border-color: var(--cyan); }
.dial-mem .dial:focus-visible { outline-color: var(--cyan); }
.dial:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; border-radius: 50%; }
.dial-track { fill: none; stroke: #232932; stroke-width: 14; stroke-linecap: round; }
.dial-value { fill: none; stroke: var(--amber); stroke-width: 14; stroke-linecap: round; filter: drop-shadow(0 0 6px rgba(245, 165, 36, 0.6)); }
.dial-knob { fill: #fff3dc; stroke: var(--amber); stroke-width: 3; }
.dial-text { fill: var(--text); font: 700 38px var(--mono); }
.dial-caption { fill: var(--muted); font: 11px var(--mono); letter-spacing: 0.3em; }

.steps { display: flex; align-items: center; gap: 14px; }

.step {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--edge);
  background: #1c2129;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.step:hover { border-color: var(--amber); }
.target { color: var(--muted); font-size: 12px; text-align: center; min-width: 110px; }

/* meters */

.meter { display: grid; gap: 8px; }
.meter-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; letter-spacing: 0.14em; }
.bar { height: 12px; background: #0f1216; border-radius: 6px; overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: 6px; transition: width 0.6s ease; }
.fill.amber { background: var(--amber); }
.fill.cyan { background: var(--cyan); }
.fill.steel { background: var(--steel); }

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #3a1d1a;
  color: #ffd9d3;
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 10px 16px;
  margin: 0;
}

@media (max-width: 900px) {
  .board {
    grid-template-columns: 1fr;
    grid-template-areas: "power" "throttle" "charts" "meters";
    padding: 14px;
  }
  .power { flex-direction: row; justify-content: center; flex-wrap: wrap; }
  .throttle { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .dial-block { width: auto; flex: 1 1 200px; }
  .dial-block + .dial-block { border-top: 0; padding-top: 0; }
  .rocker { width: 96px; height: 150px; }
  .meters { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .lamp.running { animation: none; }
  .fill { transition: none; }
}
