:root {
  --bg: #f4f4f1; --surface: #ffffff; --ink: #1b1d22; --ink-2: #4b505a; --muted: #7a808c;
  --line: #dcddd8; --accent: #b86a00; --accent-ink: #ffffff; --series: #c27400;
  --good: #1d7f4e; --warn-bg: #fff3d6; --warn-ink: #6b4800; --track: #e6e6e1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --ink: #e8e9ec; --ink-2: #b4b8c1; --muted: #858b97;
    --line: #2a2f38; --accent: #f5a524; --accent-ink: #1a1200; --series: #f5a524;
    --good: #4cc38a; --warn-bg: #3a2a07; --warn-ink: #ffd88a; --track: #252a33;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a20; --ink: #e8e9ec; --ink-2: #b4b8c1; --muted: #858b97;
  --line: #2a2f38; --accent: #f5a524; --accent-ink: #1a1200; --series: #f5a524;
  --good: #4cc38a; --warn-bg: #3a2a07; --warn-ink: #ffd88a; --track: #252a33;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto; max-width: 1100px; padding: 12px 16px 40px;
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 14px; margin: 0 0 8px; color: var(--ink-2); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
button, select, input, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px;
}
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
input[type="number"] { width: 6.5em; }
input[type="text"] { min-width: 0; flex: 1; }
textarea { width: 100%; resize: vertical; margin-top: 10px; }
[hidden] { display: none !important; }
label { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); flex-wrap: wrap; }
.check { gap: 6px; }

.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 0 12px; }
.top .sub { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0 0 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.devices { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.devices select { max-width: 260px; }
.vol input { width: 120px; }
.warn { flex-basis: 100%; background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 8px 10px; }

.spec { padding: 8px; }
.spec-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 6px; }
.spec-head .label { font-weight: 600; color: var(--ink-2); }
.spec-body { display: flex; gap: 4px; }
#spec { flex: 1; min-width: 0; width: 100%; aspect-ratio: 1024 / 384; background: #000; border-radius: 6px; image-rendering: auto; }
.axis { width: 30px; color: var(--muted); }
.meter { display: inline-block; width: 90px; height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; margin-left: auto; }
.meter span { display: block; height: 100%; width: 0; background: var(--good); transition: width .1s; }

.tabs { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--ink-2); padding: 9px 14px; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; background: var(--track); color: var(--ink-2); font-size: 13px; }
.pill.on { background: var(--accent); color: var(--accent-ink); }
.progress { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; margin: 10px 0; }
.progress div { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .3s; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.stats div { display: flex; flex-direction: column; }
.stats span { font-size: 12px; color: var(--muted); }
.stats b { font-size: 18px; font-variant-numeric: tabular-nums; font-weight: 600; }

.drop { display: flex; justify-content: center; border: 1.5px dashed var(--line); border-radius: 10px; padding: 22px 12px; cursor: pointer; color: var(--ink-2); }
.drop.over { border-color: var(--accent); }
.small-drop { padding: 7px 12px; }
.preview { display: block; max-width: 100%; max-height: 160px; margin: 8px 0; background: #000; border-radius: 6px; }

.rxlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rxlist li { border-top: 1px solid var(--line); padding-top: 8px; overflow-wrap: anywhere; }
.rxlist li:first-child { border-top: 0; padding-top: 0; }
.rxlist img { max-width: 100%; max-height: 240px; display: block; margin-top: 6px; border-radius: 6px; }
.rxlist pre { white-space: pre-wrap; margin: 6px 0 0; font: 15px/1.4 system-ui, sans-serif; }

.charts { display: grid; grid-template-columns: 1fr 1fr 220px; gap: 12px; }
figure { margin: 0; min-width: 0; }
figcaption { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chart { width: 100%; height: 150px; display: block; color: var(--muted); }
#constel { width: 100%; max-width: 220px; aspect-ratio: 1; background: var(--bg); border-radius: 8px; display: block; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px; padding: 4px 8px; border-radius: 6px; z-index: 9; }
.log pre { max-height: 220px; overflow: auto; font-size: 12px; margin: 8px 0 0; white-space: pre-wrap; }
.log summary { cursor: pointer; color: var(--ink-2); }

@media (max-width: 760px) {
  body { padding: 8px 16px 32px; }
  .charts { grid-template-columns: 1fr; }
  #constel { max-width: 200px; }
  .axis { width: 24px; }
}
