/* style.css */
:root {
  --bg: #1f2329;
  --panel: #272c33;
  --line: #3a414b;
  --text: #e6e8eb;
  --muted: #9aa3ae;
  --accent: #4da3ff;
  --good: #2ecc71;
  --bad: #ff4d4d;
  --pole-n: #ff8c1a;
  --pole-s: #2f7dff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
  position: fixed; /* iOS: no rubber-band scroll, which resizes the view */
  inset: 0;
  height: 100dvh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr); /* long status text must not widen the page (resizes the 3D view) */
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Ubuntu, sans-serif;
  overflow: hidden;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 15px; letter-spacing: 0.02em; margin-right: 4px; }
.group { display: flex; gap: 4px; }

button {
  font: inherit;
  color: var(--text);
  background: #323842;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  touch-action: manipulation; /* iOS: no double-tap zoom on repeated taps */
}
button:hover { background: #3b424d; }
button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.palette button {
  width: 24px;
  height: 24px;
  padding: 0;
  background: var(--c);
}
.palette button.active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }

.help-toggle { margin-left: auto; width: 30px; padding: 5px 0; }

#viewport { position: relative; min-height: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.statusbar {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 6px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  color: var(--muted);
}
#status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status[data-tone="good"] { color: var(--good); }
#status[data-tone="error"] { color: var(--bad); }
.legend { display: flex; align-items: center; gap: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; }
.dot.n { background: var(--pole-n); }
.dot.s { background: var(--pole-s); }

.help {
  position: fixed;
  top: 56px;
  right: 12px;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding: 12px 16px;
  background: rgba(39, 44, 51, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.help h2 { font-size: 13px; margin: 6px 0; color: var(--accent); }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 8px; }
.help dt { color: var(--text); white-space: nowrap; }
.help dd { margin: 0; color: var(--muted); }
.help p { margin: 6px 0; color: var(--muted); }
