/* lowband Phase 0 — minimal dialer. No web fonts: size and offline-first matter. */
:root {
  --bg: #f7f7f5;
  --ink: #161616;
  --muted: #6b6b66;
  --line: #d9d9d4;
  --key: #ffffff;
  --call: #1e8e3e;
  --hang: #c62828;
  --mode-good: #1e8e3e;
  --mode-low: #b58400;
  --mode-extreme: #d35400;
  --mode-survival: #c62828;
  --tab-h: 4rem;
  --mini-h: 5.25rem;
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); height: 100%; }
body { padding: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }
[hidden] { display: none !important; }

.screen {
  min-height: 100dvh; max-width: 420px; margin: 0 auto;
  padding: calc(0.75rem + env(safe-area-inset-top)) 1.25rem calc(var(--tab-h) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 0.75rem;
}
.topbar { display: flex; justify-content: space-between; align-items: center; font-size: 15px; color: var(--muted); min-height: 44px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--muted); font-size: 15px; margin: 0; }
.center { text-align: center; }
.error { color: var(--hang); }
h1 { font-size: 24px; margin: 8px 0 0; }
h1.brand { margin: 0; font-size: 22px; letter-spacing: 0.14em; font-weight: 700; text-align: center; }

.app-header { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; min-height: 48px; }
.slogan { margin: 0; text-align: center; color: var(--muted); font-size: 15px; letter-spacing: 0.02em; }
.icon-btn, .text-btn {
  border: 0; background: transparent; min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.text-btn { color: var(--muted); font-size: 15px; }
.sheet {
  position: absolute; z-index: 8; top: calc(56px + env(safe-area-inset-top)); left: 16px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 8px 24px rgba(22, 22, 22, 0.12); padding: 8px; min-width: 180px;
  display: flex; flex-direction: column;
}
.sheet button { background: none; border: 0; text-align: left; padding: 12px 14px; border-radius: 10px; }
.sheet button:active { background: var(--bg); }
.sheet-right { left: auto; right: 16px; min-width: 220px; }
#profile-panel .mono { padding: 8px 14px 4px; }
#screen-dialer {
  position: relative;
  height: 100dvh;
  max-height: 100dvh;
  overflow: auto;
  gap: 0.65rem;
}
#screen-dialer > .display { margin-top: auto; }
#screen-dialer > .call-row { margin-bottom: auto; }

.display {
  font-size: clamp(32px, 9vw, 44px); letter-spacing: 0.06em; text-align: center;
  padding: 18px 8px 4px; min-height: 76px; font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.display.placeholder { color: #b0b0aa; letter-spacing: 0; font-size: clamp(26px, 7vw, 34px); font-weight: 500; }
#dial-status { min-height: 1.2em; }

.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 18px;
  width: min(100%, 336px); margin: 6px auto 0; justify-items: center;
}
.keypad button {
  width: clamp(64px, 18vw, 76px); height: clamp(64px, 18vw, 76px);
  border: 0; border-radius: 50%; background: var(--key);
  box-shadow: 0 1px 3px rgba(22, 22, 22, 0.1);
  font-size: clamp(24px, 6vw, 28px); font-weight: 500;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.keypad button:active { background: #ecece8; transform: scale(0.96); }
.tabbar button:active, .btn.call:active, .text-btn:active, .icon-btn:active { transform: scale(0.96); }

.call-row {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  width: min(100%, 336px); margin: 8px auto 0;
}
.call-row .text-btn { justify-self: start; }
.call-row .icon-btn { justify-self: end; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--key); font-size: 18px; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.call { background: var(--call); color: #fff; border-color: var(--call); border-radius: 999px; min-width: 148px; padding: 0 28px; }
.btn.hangup { background: var(--hang); color: #fff; border-color: var(--hang); }
.btn.ghost { background: transparent; }
.btn.small { height: 40px; font-size: 15px; }
.link { background: none; border: 0; color: var(--ink); text-decoration: underline; padding: 6px 0; }
input[type=text], input[type=url] { height: 52px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--key); width: 100%; }

.brand { font-weight: 700; letter-spacing: 0.14em; color: var(--ink); }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plain-list button { width: 100%; text-align: left; background: var(--key); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; }
.station-logo { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; margin: 0 auto; }
.mini-player {
  position: fixed; left: 0; right: 0; z-index: 6; margin: 0 auto; max-width: 420px;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  min-height: var(--mini-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0.5rem 0.75rem; background: #fff; border-top: 1px solid var(--line);
}
.mini-player[hidden] { display: none !important; }
.mini-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mini-meta strong, .mini-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-logo { width: 36px; height: 36px; object-fit: cover; border-radius: 8px; }
body.has-radio .screen { padding-bottom: calc(var(--tab-h) + var(--mini-h) + env(safe-area-inset-bottom)); }
body.in-call .mini-player, body.in-call .tabbar { display: none !important; }
body.in-call .screen { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; margin: 0 auto; max-width: 420px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
}
.tabbar button {
  border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; min-height: 48px; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.tabbar button[aria-current="page"] { color: var(--call); font-weight: 600; }

@media (min-width: 400px) {
  .keypad, .call-row { width: min(100%, 360px); }
  .keypad button { width: 76px; height: 76px; }
}
@media (max-width: 360px) {
  .screen { padding-left: 12px; padding-right: 12px; }
  .keypad { gap: 12px 10px; }
}
@media (max-height: 740px) {
  #screen-dialer { gap: 0.4rem; padding-top: calc(0.35rem + env(safe-area-inset-top)); }
  .display { min-height: 44px; padding-top: 2px; padding-bottom: 0; }
  .app-header { min-height: 40px; }
  .keypad { gap: 8px 10px; margin-top: 0; }
  .keypad button { width: 52px; height: 52px; font-size: 22px; }
  .btn.call { height: 46px; min-width: 120px; }
  .slogan { font-size: 13px; }
  .call-row { margin-top: 0; }
}
h2 { font-size: 18px; margin: 8px 0 0; }
#screen-radio.has-frequency > .topbar { order: -2; }
#screen-radio.has-frequency #radio-name { order: -1; font-size: 28px; font-weight: 700; margin: 8px 0 0; }
#screen-radio.has-frequency #radio-code { font-size: 22px; min-height: 0; padding: 4px 0 0; letter-spacing: 0.04em; }
#radio-dial { margin: 0; white-space: pre-line; }
.radio-controls { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.radio-controls .btn { width: 100%; }
#radio-message { margin: 0; overflow-wrap: anywhere; }
#radio-audio-slot { width: 0; height: 0; overflow: hidden; }
#radio-audio {
  position: fixed; width: 1px; height: 1px; max-width: 1px; max-height: 1px;
  overflow: hidden; opacity: 1; pointer-events: none; border: 0;
  left: 0; bottom: 0;
}
#radio-ios {
  position: fixed; width: 2px; height: 2px; opacity: 1; pointer-events: none;
  border: 0; left: 0; bottom: 0; object-fit: contain;
}
.playback-log {
  margin-top: 12px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; font-size: 12px; padding: 4px 8px;
}
.playback-log[hidden] { display: none !important; }
.playback-log ol { max-height: 12rem; overflow: auto; margin: 0.25rem 0 0.4rem; padding-left: 1.1rem; }

.counter { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; }
.counter > div { display: flex; justify-content: space-between; font-size: 15px; }
.counter .k { color: var(--muted); }
.audio-modes { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.audio-modes button {
  min-height: 44px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px;
}
.audio-modes button[aria-pressed="true"] { border-color: var(--ink); font-weight: 600; background: #fff; }
#media-note, #call-usage { margin: 0; font-size: 13px; }
.mode[data-mode="automatic"] { color: var(--ink); }
.mode[data-mode="save"] { color: var(--mode-low); }
.mode[data-mode="quality"] { color: var(--mode-good); }
.mode[data-mode="GOOD"] { color: var(--mode-good); }
.mode[data-mode="LOW DATA"] { color: var(--mode-low); }
.mode[data-mode="EXTREME"] { color: var(--mode-extreme); }
.mode[data-mode="SURVIVAL"] { color: var(--mode-survival); font-weight: 600; }

.diag { font-size: 13px; border-top: 1px solid var(--line); padding-top: 8px; }
.diag summary { cursor: pointer; color: var(--muted); }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 8px 0; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.exp { border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 12px 12px; }
.exp legend { color: var(--muted); padding: 0 4px; }
.exp label { display: flex; align-items: center; gap: 6px; }
.exp select { height: 36px; }
.exp .auto, .exp button { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; margin-top: 8px; }
.row .btn { flex: 1; }

button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #4a90d9; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
