:root { color-scheme: dark; --bg:#0f1115; --panel:#171a21; --line:#262b36; --accent:#2d6cdf; --txt:#e6e8eb; --muted:#8b93a3; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font: 16px/1.4 -apple-system, system-ui, sans-serif; background: var(--bg); color: var(--txt);
  padding: max(12px, env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.hidden { display: none !important; }

header { display: flex; align-items: center; justify-content: space-between; }
h1 { font-size: 18px; margin: 6px 0 12px; }
h2 { font-size: 15px; margin: 0 0 10px; }

button { font: inherit; background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: #2a303c; }
.banner { background: #3a2323; border: 1px solid #ff6b6b; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }

/* big gear face */
.gear-face { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; text-align: center; margin-bottom: 14px; }
.gear-num { font-size: clamp(64px, 22vw, 120px); font-weight: 800; line-height: 1; letter-spacing: -2px; }
.gear-of { font-size: 22px; color: var(--muted); font-weight: 600; margin-left: 8px; }
.gear-sub { color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.shift-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.shift { padding: 18px; font-size: 17px; font-weight: 700; background: #222a38; }
.shift:active:not(:disabled) { background: var(--accent); }

/* connection cards */
.cards { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .cards { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card button { width: 100%; }

.pill { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #333a48; color: var(--muted); }
.pill.ok { background: #163a22; color: #46c46b; }
.pill.off { background: #333a48; color: var(--muted); }
.pill.learn { background: #3a3416; color: #ffd23f; }

.learn { display: flex; flex-direction: column; gap: 6px; }
.learn button { font-size: 13px; padding: 8px; text-align: left; }
.strat { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
select { font: inherit; background: var(--bg); color: var(--txt); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

/* settings */
.settings { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.settings input[type=number] { font: inherit; background: var(--bg); color: var(--txt); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.chk { flex-direction: row !important; align-items: center; gap: 8px; margin-top: 12px; }
.log { margin-top: 12px; }
.log pre { background: #0b0d11; border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 30vh; overflow: auto; font: 12px/1.4 ui-monospace, Menlo, monospace; white-space: pre-wrap; }
.hint { color: var(--muted); font-size: 13px; }
code { background: #0b0d11; padding: 1px 5px; border-radius: 5px; }
