:root {
  --bg: #0b0f15;
  --bg-panel: #131a24;
  --line: #212b38;
  --ink: #d6dee9;
  --muted: #6e7c8d;
  --accent: #37c6b4;
  --accent-dim: #1f5f58;
  --amber: #e0a44a;
  --err: #e0736a;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  display: grid;
  grid-template-columns: 1fr 300px;
  grid-template-areas:
    "head head"
    "city city"
    "stage panel";
  gap: 18px 26px;
}

.masthead { grid-area: head; }
.title { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim), 0 0 18px var(--accent);
}
h1 { font-size: 1.55rem; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
.tagline { margin: 10px 0 0; max-width: 68ch; color: var(--muted); line-height: 1.55; font-size: 0.95rem; }

/* --- City bar --- */
.citybar { grid-area: city; display: flex; flex-direction: column; gap: 10px; }
.city-in { display: flex; gap: 8px; }
#city-input {
  flex: 1; min-width: 0;
  background: var(--bg-panel); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 10px 12px; font-family: var(--sans); font-size: 0.92rem;
}
#city-input::placeholder { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 20px; padding: 5px 12px; font-size: 0.8rem; cursor: pointer;
  font-family: var(--mono); transition: color .15s, border-color .15s;
}
.chip:hover { color: var(--accent); border-color: var(--accent-dim); }
.city-status { margin: 0; min-height: 1.1em; font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.city-status.working { color: var(--accent); }
.city-status.ok { color: var(--accent); }
.city-status.err { color: var(--err); }

/* --- Stage --- */
.stage-wrap { grid-area: stage; }
.stage-frame {
  position: relative; border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; background: #0f141b;
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
}
#stage { display: block; width: 100%; height: auto; }
.mode-label {
  position: absolute; top: 12px; left: 14px;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent);
  background: rgba(11, 15, 21, 0.72); border: 1px solid var(--line);
  padding: 4px 9px; border-radius: 6px; backdrop-filter: blur(4px);
}

/* --- Panel --- */
.panel { grid-area: panel; display: flex; flex-direction: column; gap: 18px; }
.readout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.metric { background: var(--bg-panel); padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 3px; }
.metric-val { font-family: var(--mono); font-size: 1.7rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1; }
.metric-key { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; }

.controls { background: var(--bg-panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.row.buttons { display: flex; gap: 10px; }
.btn {
  flex: 1; font-family: var(--mono); font-size: 0.82rem; letter-spacing: 0.04em;
  text-transform: uppercase; color: #071613; background: var(--accent);
  border: none; border-radius: 8px; padding: 10px 12px; cursor: pointer; transition: filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { color: var(--ink); background: transparent; border: 1px solid var(--line); }
.city-in .btn { flex: 0 0 auto; }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.slider { display: flex; flex-direction: column; gap: 8px; }
.slider-head { font-size: 0.82rem; color: var(--muted); }
.slider-head b { color: var(--ink); font-family: var(--mono); font-weight: 600; }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: var(--line); cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg-panel); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 3px solid var(--bg-panel); border-radius: 50%; background: var(--accent); }

.toggle { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; color: var(--ink); cursor: pointer; }
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

.legend { font-size: 0.82rem; line-height: 1.6; color: var(--muted); margin: 0; border-left: 2px solid var(--accent-dim); padding-left: 12px; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "head" "city" "stage" "panel"; }
  .readout { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .mark { box-shadow: 0 0 0 4px var(--accent-dim); } }
