/* 온에어 — 기본 테마. 디자인 조사 후 :root 변수만 바꿔도 전체가 따라온다. */
:root {
  --bg: #05070d;
  --bg-grad: radial-gradient(ellipse at 50% 40%, #0b1426 0%, #05070d 65%);
  --surface: rgba(14, 20, 34, 0.72);
  --surface-solid: #0e1422;
  --surface-hi: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e8edf6;
  --text-dim: #93a0b8;
  --text-faint: #5f6b82;
  --radio: #4cc9ff;
  --news: #ff8a3d;
  --news-hi: #ffb547;
  --accent: #4cc9ff;
  --danger: #ff6b6b;
  --radius: 14px;
  --radius-sm: 10px;
  --blur: blur(18px) saturate(140%);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: 16px;
  --player-h: 68px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg) var(--bg-grad);
  color: var(--text);
  font: 15px/1.5 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#globe { position: fixed; inset: 0; }
body.no-globe #globe { display: none; }

/* 시작 화면 */
.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--text-dim); z-index: 50; background: var(--bg) var(--bg-grad); }
.boot[hidden] { display: none; }
.boot-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--radio); box-shadow: 0 0 0 0 rgba(76, 201, 255, .6); animation: pulse 1.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 18px rgba(76, 201, 255, 0); } 100% { box-shadow: 0 0 0 0 rgba(76, 201, 255, 0); } }

/* 상단 */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) 12px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: baseline; gap: 8px; background: none; border: 0; padding: 4px 2px; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); align-self: center; box-shadow: 0 0 10px var(--danger); animation: blink 2.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.brand-name { font-weight: 800; letter-spacing: .12em; font-size: 17px; }
.brand-sub { color: var(--text-dim); font-size: 13px; }

.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search input {
  width: 100%; height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); font: inherit;
}
.search input::placeholder { color: var(--text-faint); }
.q-results {
  position: absolute; top: 46px; left: 0; right: 0; max-height: min(60vh, 460px); overflow: auto;
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
}
.q-row { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 9px 10px; color: var(--text); }
.q-row:hover, .q-row:focus-visible { background: var(--surface-hi); }
.q-row span { color: var(--text-dim); font-size: 13px; }
.q-row.cc b { color: var(--accent); }

.tools { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chip {
  height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-dim); font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.chip.on { color: var(--text); border-color: rgba(255,255,255,.22); }
.chip.icon { width: 34px; justify-content: center; padding: 0; }
.sw { width: 9px; height: 9px; border-radius: 50%; opacity: .35; }
.chip.on .sw { opacity: 1; }
.sw-radio { background: var(--radio); }
.sw-news { background: var(--news); }

/* 패널 */
.panel {
  position: fixed; z-index: 15; right: var(--gutter); top: 74px; bottom: calc(var(--player-h) + 28px);
  width: min(400px, calc(100vw - 2 * var(--gutter)));
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow);
}
.panel[hidden] { display: none; }
.panel-head { display: flex; justify-content: space-between; gap: 10px; padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.panel-kicker { margin: 0; font-size: 12px; color: var(--text-dim); }
.panel-title { margin: 2px 0 0; font-size: 20px; line-height: 1.3; word-break: keep-all; }
.panel-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }
.panel-body { overflow: auto; padding: 8px; overscroll-behavior: contain; }
.x { border: 0; background: var(--surface-hi); width: 32px; height: 32px; border-radius: 50%; font-size: 20px; line-height: 1; flex: none; }

.list { display: flex; flex-direction: column; gap: 2px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0; border-radius: var(--radius-sm); padding: 10px; }
.row:hover, .row:focus-visible { background: var(--surface-hi); }
.row-ic { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: rgba(76,201,255,.12); color: var(--radio); }
.row.playing .row-ic { background: var(--radio); color: #021018; }
.row.playing .row-title { color: var(--radio); }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more, .link-btn {
  display: block; width: 100%; margin: 8px 0 4px; padding: 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-hi); color: var(--text); text-align: center; text-decoration: none; font-size: 14px;
}
.radio-cta { border-color: rgba(76,201,255,.35); color: var(--radio); }
.empty { color: var(--text-dim); padding: 14px 10px; margin: 0; }
.fail p { color: var(--text-dim); padding: 0 8px; }

.day { font-size: 12px; color: var(--text-faint); margin: 14px 10px 4px; letter-spacing: .05em; }
.news { padding: 11px 10px; border-radius: var(--radius-sm); border-left: 3px solid transparent; }
.news.main { border-left-color: var(--news-hi); background: rgba(255,138,61,.05); }
.news-title { color: var(--text); text-decoration: none; font-weight: 600; line-height: 1.45; word-break: keep-all; overflow-wrap: anywhere; }
.news-title:hover { text-decoration: underline; }
.news-meta { margin: 4px 0 0; font-size: 12px; color: var(--text-dim); }
.news-basis { margin: 3px 0 0; font-size: 12px; color: var(--text-faint); }
.news-basis.clickable { cursor: pointer; color: var(--news); }

/* 플레이어 */
.player {
  position: fixed; z-index: 25; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  width: min(640px, calc(100vw - 2 * var(--gutter))); height: var(--player-h);
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow);
}
.pl-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: var(--text); color: #05070d; display: grid; place-items: center; font-size: 18px; }
.pl-btn svg { width: 20px; height: 20px; fill: currentColor; }
.pl-btn.ghost { background: none; color: var(--text-dim); width: 36px; height: 36px; font-size: 20px; }
.pl-btn.ghost.on { color: var(--danger); }
.pl-btn.accent { background: var(--surface-hi); color: var(--text); }
.ic-pause { display: none; }
.player[data-state="playing"] .ic-play, .player[data-state="loading"] .ic-play { display: none; }
.player[data-state="playing"] .ic-pause, .player[data-state="loading"] .ic-pause { display: block; }
.pl-info { flex: 1; min-width: 0; }
.pl-name { margin: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-meta { margin: 0; font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player[data-state="error"] .pl-meta { color: var(--danger); }
.player[data-state="loading"] .pl-meta::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--radio); animation: blink 1s infinite; }
#pl-vol { width: 90px; accent-color: var(--radio); }

.eq { display: none; align-items: flex-end; gap: 2px; height: 18px; }
.player[data-state="playing"] .eq { display: flex; }
.eq i { width: 3px; background: var(--radio); border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; } .eq i:nth-child(4) { animation-delay: -.15s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 18px; } }

/* 지구본 툴팁(globe.gl 이 만드는 요소 안) */
.tip { background: var(--surface-solid); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: 13px/1.4 var(--font); color: var(--text); max-width: 260px; }
.tip b { display: block; }
.tip span { color: var(--text-dim); }

/* 소개 */
.about {
  width: min(560px, calc(100vw - 2 * var(--gutter))); max-height: 85vh; overflow: auto;
  background: var(--surface-solid); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 22px 18px; box-shadow: var(--shadow);
}
.about::backdrop { background: rgba(0,0,0,.55); }
.about form { float: right; }
.about h2 { margin: 0 0 8px; }
.about h3 { margin: 18px 0 6px; font-size: 15px; }
.about ul { margin: 0; padding-left: 18px; color: var(--text-dim); font-size: 14px; }
.about li { margin: 4px 0; }
.about .fine { margin-top: 18px; font-size: 12px; color: var(--text-faint); }
.t-radio { color: var(--radio); } .t-news { color: var(--news); }

.toast {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + var(--player-h) + 28px);
  background: var(--surface-solid); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }

/* 목록 모드(WebGL 불가) */
body.no-globe .panel { left: var(--gutter); right: var(--gutter); width: auto; margin: 0 auto; max-width: 640px; }

/* 모바일: 패널은 바텀시트, 툴은 한 줄 스크롤 */
@media (max-width: 720px) {
  :root { --player-h: 60px; }
  .brand-sub { display: none; }
  .topbar { gap: 8px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .tools { order: 4; flex: 1 1 100%; margin-left: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .tools::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .panel { top: auto; left: var(--gutter); right: var(--gutter); width: auto; height: min(58vh, 520px); bottom: calc(env(safe-area-inset-bottom) + var(--player-h) + 24px); }
  #pl-vol { display: none; }
  .player { padding: 0 8px; gap: 6px; }
  .pl-btn { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
