:root {
  --bg: #16130f;
  --panel: #211c16;
  --panel-2: #2a241c;
  --line: #3a3127;
  --text: #efe6d8;
  --muted: #9c8f7d;
  --amber: #ffb347;
  --amber-dim: #8a5f26;
  --live: #7fd18b;
  --error: #ff7b6b;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.top h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.pill {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.pill.live {
  color: var(--live);
  border-color: color-mix(in srgb, var(--live) 40%, transparent);
}

.pill.error {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 40%, transparent);
}

.set {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px 16px 16px;
}

.readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: 0;
  padding: 4px 0;
}

.band,
.unit {
  font-size: 0.95rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.freq {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: clamp(3.4rem, 18vw, 4.6rem);
  font-weight: 600;
  color: var(--amber);
  text-shadow: 0 0 18px color-mix(in srgb, var(--amber) 35%, transparent);
  font-variant-numeric: tabular-nums;
}

.station-name {
  margin: 0 0 14px;
  text-align: center;
  color: var(--text);
  min-height: 1.3em;
}

.dial {
  position: relative;
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(var(--panel-2), #1b1712);
  border: 1px solid var(--line);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.dial:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.dial-ticks {
  position: absolute;
  inset: 0 12px;
}

.tick {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 8px;
  background: var(--line);
}

.tick.major {
  height: 16px;
  background: var(--muted);
}

.tick-label {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.needle {
  position: absolute;
  top: 4px;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
  pointer-events: none;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin: 20px 0 14px;
}

.step,
.play {
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.step {
  width: 56px;
  height: 56px;
  background: var(--panel-2);
}

.step svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--text);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.play {
  width: 84px;
  height: 84px;
  background: var(--amber);
  border-color: var(--amber);
}

.play svg {
  width: 36px;
  height: 36px;
  fill: #1b1206;
}

.play .icon-stop,
.play.on .icon-play {
  display: none;
}

.play.on .icon-stop {
  display: block;
}

.step:active,
.play:active {
  transform: scale(0.95);
}

.seek-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.seek {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.95rem;
}

.seek svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--amber);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.seek:disabled,
.scan:disabled {
  opacity: 0.5;
}

.seek:active {
  transform: scale(0.97);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scan {
  margin: 24px 4px 10px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--amber-dim);
  background: transparent;
  color: var(--amber);
  font-size: 0.85rem;
}

.bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  margin-left: auto;
  padding-left: 10px;
}

.bars i {
  width: 4px;
  border-radius: 1px;
  background: var(--line);
}

.bars i:nth-child(1) { height: 4px; }
.bars i:nth-child(2) { height: 7px; }
.bars i:nth-child(3) { height: 10px; }
.bars i:nth-child(4) { height: 14px; }

.bars i.on {
  background: var(--live);
}

.save {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
}

.save svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.save.saved svg {
  fill: var(--amber);
  stroke: var(--amber);
}

.status {
  margin: 12px 0 0;
  min-height: 1.3em;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.status.error {
  color: var(--error);
}

.favorites h2 {
  margin: 24px 4px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.favorites ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.fav {
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.fav.current {
  border-color: var(--amber-dim);
}

.fav-main {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  padding: 14px 16px;
  background: none;
  border: 0;
  text-align: left;
}

.fav-freq {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.fav-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-action {
  display: grid;
  place-items: center;
  width: 44px;
  height: 48px;
  background: none;
  border: 0;
}

.fav-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fav-action.saved svg {
  fill: var(--amber);
  stroke: var(--amber);
}

.empty {
  margin: 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.login {
  display: grid;
  gap: 10px;
}

.login-icon {
  justify-self: center;
  border-radius: 16px;
  margin-bottom: 6px;
}

.login label {
  color: var(--muted);
  font-size: 0.9rem;
}

.login input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
}

.login-button {
  padding: 12px;
  border-radius: 12px;
  border: 0;
  background: var(--amber);
  color: #1b1206;
  font-weight: 600;
}

.sign-out {
  display: block;
  margin: 28px auto 0;
  padding: 8px 12px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

dialog {
  width: min(360px, calc(100vw - 32px));
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}

dialog label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

dialog input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
}

dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
}

dialog menu button {
  padding: 10px 16px;
  border-radius: 10px;
  border: 0;
  background: var(--amber);
  color: #1b1206;
  font-weight: 600;
}

dialog menu button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
