:root {
  color-scheme: light dark;
  --bg: #f6f5f1; --fg: #1d1d1b; --muted: #6a6a64; --line: #b9b8b0;
  --card: #ffffff; --accent: #1f7a5c; --accent-bg: rgba(31, 122, 92, .18); --warn: #a15c00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a; --fg: #ececea; --muted: #9b9b95; --line: #4a4b4e;
    --card: #232427; --accent: #4cc79a; --accent-bg: rgba(76, 199, 154, .22); --warn: #f0b04a;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; touch-action: manipulation; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
  font: 16px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
[hidden] { display: none !important; }
main { flex: 1; min-height: 0; display: grid; grid-template-columns: 5fr 4fr; grid-template-rows: minmax(0, 1fr); gap: 12px; }
#base { display: flex; flex-direction: column; min-height: 0; gap: 4px; }
#base h2 { margin: 0; font-size: 11px; font-weight: 400; text-transform: uppercase; color: var(--muted); }
#families { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(44px, 1fr); gap: 6px; min-height: 0; }
#side { display: flex; flex-direction: column; min-height: 0; gap: 4px; overflow-y: auto; }
.row { display: flex; align-items: flex-end; gap: 6px; }
.row label { flex: 2; min-width: 0; }
.row label.wide { flex: 3; }
.family {
  min-width: 0; min-height: 44px; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 2px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--fg); font: inherit; font-size: 16px; font-weight: 600;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.family.selected { border-color: var(--accent); }
.family.on { border-color: var(--accent); background: var(--accent-bg); }
label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; text-transform: uppercase; color: var(--muted); }
select {
  min-height: 44px; width: 100%; font: inherit; font-size: 16px; text-transform: none;
  color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 4px; touch-action: manipulation;
}
.toggles { align-items: center; min-height: 44px; }
.toggle {
  flex: 1; flex-direction: row; align-items: center; gap: 6px; min-height: 44px;
  font-size: 14px; text-transform: none; color: var(--fg);
}
.toggle input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.sounding { align-items: center; min-height: 36px; }
#perde { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); }
#intervals { min-height: 1.3em; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
#range-warning {
  flex: none; width: 40px; height: 36px; padding: 0; font-size: 18px;
  border: 1px solid var(--warn); border-radius: 8px; background: var(--card); touch-action: manipulation;
}
#message { min-height: 2.6em; font-size: 13px; color: var(--warn); overflow-y: auto; }
#now {
  margin-top: auto; padding-top: 6px; border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--muted); text-align: center;
}
#debug {
  flex: none; max-height: 18vh; overflow-y: auto; margin: 0 0 6px;
  padding: 4px 8px; font: 10px/1.3 ui-monospace, monospace; white-space: pre-wrap;
  background: rgba(0, 0, 0, .8); color: #9f9;
}
