:root {
  --bg-chassis: #13110f;
  --bg-panel: #1d1916;
  --bg-card: #26211d;
  --bg-dial: #0b0e0c;
  --border-subtle: #352e28;
  --amber: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.35);
  --emerald: #10b981;
  --red: #ef4444;
  --text-main: #f5f0eb;
  --text-muted: #a89f96;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(circle at top, #251e18, #0d0b0a 70%);
  color: var(--text-main);
  height: 100dvh;
  display: flex;
  justify-content: center;
}

.hidden { display: none !important; }

.app-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 540px;
  height: 100dvh;
  max-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  flex-direction: column;
  background: var(--bg-chassis);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, #241e19, #181411);
  border-bottom: 1px solid var(--border-subtle);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 28px; color: var(--amber); }
.brand h1 { font-family: 'Orbitron', sans-serif; font-size: 16px; letter-spacing: 1px; }
.brand .accent { color: var(--amber); }
.brand small { display: block; font-size: 11px; color: var(--text-muted); }

.top-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--amber); color: var(--amber); }
.icon-btn.active {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(245, 158, 11, 0.16);
  box-shadow: 0 0 10px var(--amber-glow);
}

.chip-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.chip-btn .material-symbols-rounded { font-size: 18px; color: var(--amber); }

/* Radio Deck */
.radio-deck {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 0;
  gap: 10px;
}

.band-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.band-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 7px 0;
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
}
.band-btn.active {
  background: linear-gradient(180deg, #f59e0b, #b45309);
  color: #13110f;
  border-color: #fbbf24;
  box-shadow: 0 0 12px var(--amber-glow);
}

/* Illuminated Dial Window */
.dial-window {
  background: linear-gradient(180deg, #0e1310, #070908);
  border: 2px solid #3c342d;
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.9), 0 4px 16px rgba(0, 0, 0, 0.5);
}

.dial-top-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.album-art-box {
  width: 62px;
  height: 62px;
  border-radius: 12px;
  background: #191d1a;
  border: 1px solid #2e3731;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.album-art-box img { width: 100%; height: 100%; object-fit: cover; }
.album-art-box .material-symbols-rounded { font-size: 30px; color: var(--amber); }

.station-readout { flex: 1; min-width: 0; }
.readout-badges { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }

.badge-band {
  background: rgba(245, 158, 11, 0.18);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}
.badge-freq {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  color: #fde68a;
}
.badge-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
}
.badge-status.live { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid #059669; }
.badge-status.off { background: rgba(168, 159, 150, 0.15); color: var(--text-muted); }
.badge-status.loading { background: rgba(245, 158, 11, 0.2); color: var(--amber); }

.station-readout h2 {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fef3c7;
}
.station-sub {
  font-size: 12px;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-playing-ticker {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  font-size: 11px;
  color: #34d399;
}
.now-playing-ticker .material-symbols-rounded { font-size: 14px; }
.now-playing-ticker span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-heart-btn {
  background: transparent;
  border: none;
  color: #57534e;
  cursor: pointer;
  padding: 4px;
}
.fav-heart-btn.active { color: #f43f5e; }

/* Analog Scale */
.analog-scale {
  position: relative;
  height: 28px;
  margin-top: 10px;
  background: linear-gradient(180deg, #101613, #171f1a);
  border: 1px solid #28332c;
  border-radius: 6px;
  overflow: hidden;
}
.scale-ticks {
  height: 100%;
  background-image: repeating-linear-gradient(
    to right,
    rgba(245, 158, 11, 0.55) 0px,
    rgba(245, 158, 11, 0.55) 1px,
    transparent 1px,
    transparent 12px
  );
  opacity: 0.7;
}
.dial-needle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  transition: left 0.25s ease;
}

/* Rotary Knobs & Center Cluster */
.controls-deck {
  display: grid;
  grid-template-columns: 88px 1fr 88px;
  align-items: center;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 14px 10px;
}

.knob-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  user-select: none;
  touch-action: none;
}

.knob-outer {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #44403c, #1c1917 75%);
  border: 3px solid #57534e;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.7), inset 0 1px 2px rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  cursor: grab;
  position: relative;
  touch-action: none;
  user-select: none;
}
.knob-outer:active { cursor: grabbing; }

.knob-inner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #292524, #44403c, #1c1917, #44403c, #292524);
  position: relative;
  transform: rotate(0deg);
}

.knob-indicator {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 12px;
  border-radius: 2px;
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
}

.knob-label { text-align: center; }
.knob-label span { display: block; font-size: 10px; letter-spacing: 0.8px; color: var(--text-muted); }
.knob-label strong { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--amber); }

.center-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.transport-row { display: flex; align-items: center; gap: 10px; }

.round-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f59e0b, #b45309);
  border: 2px solid #fde68a;
  color: #13110f;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 18px var(--amber-glow);
}
.play-btn .material-symbols-rounded { font-size: 32px; }

.vault-slot-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

.vault-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid #44403c;
  background: #221d1a;
  color: var(--text-main);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.vault-pill .vault-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}
.vault-pill.active {
  border-color: var(--red);
  background: rgba(239, 68, 68, 0.2);
  animation: pulse 1.2s infinite;
}
.vault-pill.alt .material-symbols-rounded { font-size: 14px; color: var(--amber); }
.vault-pill:disabled { opacity: 0.45; cursor: not-allowed; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.restriction-note {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #fca5a5;
  text-align: center;
}
.restriction-note .material-symbols-rounded { font-size: 14px; }

/* Bottom Panel & Nav */
.bottom-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  border-radius: 18px 18px 0 0;
  overflow: hidden;
}

.tab-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.search-bar-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.input-icon-wrap {
  flex: 1;
  min-width: 150px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-chassis);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 6px 10px;
}
.input-icon-wrap .material-symbols-rounded { font-size: 18px; color: var(--text-muted); }
.input-icon-wrap input {
  background: transparent;
  border: none;
  color: var(--text-main);
  width: 100%;
  outline: none;
  font-size: 13px;
}

select, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="datetime-local"], input[type="time"], textarea {
  background: var(--bg-chassis);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.small-action-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--amber);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.small-action-btn .material-symbols-rounded { font-size: 16px; }

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.pane-header h3 { font-size: 14px; font-weight: 700; }
.sub-heading { font-size: 12px; color: var(--text-muted); margin: 10px 0 6px; text-transform: uppercase; letter-spacing: 0.6px; }

.tier-pill {
  font-size: 11px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
}

.list-stack { display: flex; flex-direction: column; gap: 8px; }

.station-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 9px 11px;
  cursor: pointer;
  transition: 0.15s;
}
.station-item.active {
  border-color: var(--amber);
  background: rgba(245, 158, 11, 0.08);
}

.station-item-info { flex: 1; min-width: 0; }
.station-item-info strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.station-item-info small {
  font-size: 11px;
  color: var(--text-muted);
}

.station-item-actions { display: flex; align-items: center; gap: 4px; }

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #161310;
  border-top: 1px solid var(--border-subtle);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  cursor: pointer;
  padding: 4px 0;
}
.nav-btn.active { color: var(--amber); }
.nav-btn .material-symbols-rounded { font-size: 22px; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 88dvh;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}
.modal-body > * {
  flex-shrink: 0;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; color: var(--text-muted); }

.btn-primary {
  background: linear-gradient(180deg, #f59e0b, #b45309);
  color: #13110f;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}

.terms-box {
  background: var(--bg-chassis);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  max-height: 220px;
  overflow-y: auto;
  flex-shrink: 0;
}
  overflow-y: auto;
}
.terms-box h4 { color: var(--amber); margin: 8px 0 4px; font-size: 12px; }

.toast {
  position: fixed;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  background: #292524;
  color: #fef3c7;
  border: 1px solid var(--amber);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  z-index: 80;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.rec-settings-card {
  background: var(--bg-chassis);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}

.size-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  color: var(--text-muted);
}
.size-table th, .size-table td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 4px 6px;
  text-align: left;
}
.size-table th { color: var(--amber); font-weight: 600; }

.live-rec-box {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid var(--red);
  color: #fecaca;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}

.desktop-bg-pattern,
#desktopWaveCanvas {
  display: none;
}

@media (min-width: 600px) {
  .desktop-bg-pattern {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.12;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23f59e0b' stroke-width='1.5' stroke-linecap='round'%3E%3Crect x='14' y='20' width='22' height='16' rx='3'/%3E%3Cpath d='M18 20l10-8'/%3E%3Ccircle cx='29' cy='28' r='2.5'/%3E%3Cpath d='M78 24a10 10 0 0 1 14 0M81 28a5 5 0 0 1 8 0'/%3E%3Ccircle cx='85' cy='33' r='2' fill='%23f59e0b'/%3E%3Cpath d='M22 76v12M28 72v20M34 78v8'/%3E%3Ccircle cx='86' cy='84' r='9'/%3E%3Cpath d='M77 84a9 9 0 0 1 18 0'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 120px 120px;
  }
  #desktopWaveCanvas {
    display: block;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
  }
}

.tour-balloon {
  position: fixed;
  z-index: 100;
  max-width: 310px;
  background: #241e19;
  border: 2px solid var(--amber);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.85), 0 0 18px var(--amber-glow);
  color: var(--text-main);
  font-size: 12px;
  line-height: 1.45;
}
.tour-balloon h4 { color: var(--amber); font-size: 13px; margin-bottom: 4px; }
.tour-highlight {
  position: relative;
  z-index: 95 !important;
  box-shadow: 0 0 0 3px var(--amber), 0 0 22px var(--amber-glow) !important;
  border-radius: 12px;
}
