/* FM 화면 스타일: 휴대폰 먼저, 밝은·어두운 화면 모두
   색: 보라(다이얼 불빛). 숫자(주파수)는 고정폭 숫자
   크기 단계: 글 13·14·15·16·18·22 / 둥글기 10·14·16 / 간격 4의 배수
   화면 틀·터치·가로 조건은 모든 서비스 공통 규칙 /srv/infra/shared/UX.md */
:root {
  --bg: #f5f3f8;
  --card: #ffffff;
  --line: #e4dfec;
  --text: #17131f;
  --dim: #5b5468;
  --faint: #6f687c;
  --accent: #6d3bb8;
  --accent-text: #ffffff;
  --accent-soft: #efe7fa;
  --heart: #c2255c;
  --good: #1d7a4c;
  --good-soft: #e2f3e9;
  --warn: #9a5b00;
  --warn-soft: #fff1dc;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --shadow: 0 1px 2px rgba(24, 16, 40, .04), 0 2px 8px rgba(24, 16, 40, .05);
  --shadow-lift: 0 -2px 16px rgba(24, 16, 40, .08);
  --radius: 16px;
  --bar-h: 72px;
  /* 왼쪽·오른쪽 안전 여백: 아이폰은 가로일 때 아일랜드가 한쪽에만 있어도 양쪽에 같은 폭을 알려 준다.
     common.js가 돌린 방향을 보고 html.island-left/right를 붙이면 반대쪽은 0 */
  --sa-l: env(safe-area-inset-left, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  color-scheme: light dark;
}
html.island-left { --sa-r: 0px; }
html.island-right { --sa-l: 0px; }
/* 어두운 색: 기기 설정이 어둡고 '밝게'를 고르지 않았을 때, 또는 '어둡게'를 골랐을 때 (화면 모드는 theme.js가 <html data-theme>로 붙인다). 두 벌을 같이 고친다 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #110f16;
    --card: #1b1823;
    --line: #2d2839;
    --text: #ece8f3;
    --dim: #aaa3b8;
    --faint: #8a8398;
    --accent: #c3a0f5;
    --accent-text: #150f20;
    --accent-soft: #2a2140;
    --heart: #ff7aa5;
    --good: #67d29c;
    --good-soft: #13281e;
    --warn: #f0b660;
    --warn-soft: #2d2414;
    --bad: #ff8a80;
    --bad-soft: #321a19;
    --shadow: none;
    --shadow-lift: 0 -2px 20px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  --bg: #110f16;
  --card: #1b1823;
  --line: #2d2839;
  --text: #ece8f3;
  --dim: #aaa3b8;
  --faint: #8a8398;
  --accent: #c3a0f5;
  --accent-text: #150f20;
  --accent-soft: #2a2140;
  --heart: #ff7aa5;
  --good: #67d29c;
  --good-soft: #13281e;
  --warn: #f0b660;
  --warn-soft: #2d2414;
  --bad: #ff8a80;
  --bad-soft: #321a19;
  --shadow: none;
  --shadow-lift: 0 -2px 20px rgba(0, 0, 0, .4);
}
/* 고른 쪽에 맞춰 입력칸·스크롤 막대 같은 브라우저 부품 색도 */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
/* 문서는 튕기지도 스크롤되지도 않는다. 가운데 내용 칸만 움직인다 (UX.md '1. 화면 틀') */
html, body { overscroll-behavior: none; }
/* 누르는 것은 두 번 눌러도 확대되지 않게 (UX.md '7. 터치') */
a, button, summary, label, input, select { touch-action: manipulation; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  word-break: keep-all; overflow-wrap: anywhere; letter-spacing: -.005em; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2 { line-height: 1.3; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
small, .small { font-size: 13px; }
.muted { color: var(--dim); }
.ic { flex: none; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-fill { fill: currentColor; stroke: none; }
.top-spacer { flex: 1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* 아이폰 홈 화면 앱(iOS 26~): 화면 맨 위에 고정된 띠가 없으면 아이폰이 머리줄 위에 뿌연 흐림을 덮는다.
   보이지 않는 고정 띠(.ios-edge, 각 HTML의 body 첫 줄)를 두면 흐림 대신 이 배경색으로 상태 표시줄 자리를 칠한다 (CHECKLIST F10) */
.ios-edge {
  position: fixed; top: 0; left: 0; right: 0; height: 11px; z-index: 2147483647; pointer-events: none;
  background-color: var(--bg); -webkit-background-clip: text; background-clip: text;
}
body.ak .ios-edge { background-color: var(--ak-card); }

/* ---- 화면 틀: 머리줄 · 내용 칸(이 칸만 스크롤) · 재생 막대 ---- */
body.main-page, body.login-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.top {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, var(--sa-r)) 10px max(16px, var(--sa-l));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.view, .login-page main {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; outline: none;
  padding: 16px max(16px, var(--sa-r)) calc(32px + env(safe-area-inset-bottom, 0px)) max(16px, var(--sa-l));
}
body.has-bar .view { padding-bottom: 24px; }
#app, #pending { max-width: 1080px; margin: 0 auto; }
#app > .ak-install { margin-bottom: 16px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-height: 44px; }
.brand-mark { display: block; border-radius: 9px; flex: none; }
.brand-text { display: grid; line-height: 1.15; font-weight: 800; font-size: 18px; letter-spacing: .06em; }
.brand-text small { font-size: 12px; font-weight: 500; letter-spacing: 0; color: var(--dim); }
.count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--bad); color: var(--card); font-size: 11px; font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
@media (pointer: coarse) { .btn.small { min-height: 44px; } }
@media (hover: hover) { .btn.ghost:hover { background: var(--accent-soft); color: var(--text); } }
.acct .ic { display: none; }

.notice { margin-bottom: 16px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 14px; font-weight: 600; }
.empty { padding: 14px 16px; border-radius: 12px; border: 1px dashed var(--line); color: var(--dim); font-size: 14px; }
.foot-note { margin-top: 24px; color: var(--faint); font-size: 13px; text-align: center; }
.load-err { display: grid; justify-items: center; gap: 8px; margin: 48px auto; max-width: 360px; padding: 24px 20px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); text-align: center; }
.load-err .ic { color: var(--warn); }
.load-err .btn { margin-top: 8px; }

/* ---- 방송 목록 ---- */
.grp { margin-top: 24px; }
.grp:first-child { margin-top: 0; }
.grp h2 { font-size: 15px; font-weight: 700; color: var(--dim); margin: 0 4px 8px; }
.st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; grid-auto-rows: max-content; }
.st {
  display: flex; align-items: stretch; min-width: 0; border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
  border: 1px solid transparent;
}
.st.on { border-color: var(--accent); background: var(--accent-soft); }
.st-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 4px 8px 10px;
  border: 0; border-radius: 14px 0 0 14px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.st-freq {
  flex: none; display: grid; place-items: center; width: 56px; height: 44px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.st.on .st-freq { background: var(--accent); color: var(--accent-text); }
.st-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.st-text b { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-text small { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 600; }
.st-tag.bad { background: var(--bad-soft); color: var(--bad); }
/* 열리지 않는 방송: 흐리게 (눌러 볼 수는 있다) */
.st.down .st-freq, .st.down .st-text b, .st.down .st-fav { opacity: .45; }
.st-fav {
  flex: none; display: grid; place-items: center; width: 52px; min-height: 44px; border: 0; border-radius: 0 14px 14px 0; background: none; color: var(--faint); cursor: pointer;
}
.st-fav.on, .icon-btn.fav.on { color: var(--heart); }
.st-fav.on .ic, .icon-btn.fav.on .ic { fill: currentColor; }
@media (hover: hover) { .st-main:hover .st-text b { color: var(--accent); } .st-fav:hover, .icon-btn:hover { color: var(--text); } .st-fav.on:hover, .icon-btn.fav.on:hover { color: var(--heart); } }
/* 듣는 중 표시: 막대 셋이 오르내린다 (연결하는 중에는 깜빡임) */
.st-eq { flex: none; display: none; align-items: flex-end; gap: 3px; width: 18px; height: 16px; }
.st.playing .st-eq, .st.loading .st-eq { display: flex; }
.st-eq i { flex: 1; height: 100%; border-radius: 2px; background: var(--accent); transform-origin: bottom; animation: eq 1s ease-in-out infinite; }
.st-eq i:nth-child(2) { animation-delay: -.35s; }
.st-eq i:nth-child(3) { animation-delay: -.7s; }
.st.loading .st-eq i { animation: blink 1s ease-in-out infinite; transform: scaleY(.35); }
@keyframes eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
@keyframes blink { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .st-eq i, .st.loading .st-eq i { animation: none; transform: scaleY(.6); } }

/* ---- 아래 재생 막대: 틀의 한 칸 (끌려 다니지 않는다) ---- */
.bar {
  flex: none; display: flex; align-items: center; gap: 4px; min-height: var(--bar-h);
  padding: 8px max(12px, var(--sa-r)) calc(8px + env(safe-area-inset-bottom, 0px)) max(16px, var(--sa-l));
  background: var(--card); border-top: 1px solid var(--line); box-shadow: var(--shadow-lift); z-index: 5;
}
.bar-info { flex: 1; min-width: 0; display: grid; gap: 1px; min-height: 44px; align-content: center; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.bar-info b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-info span { font-size: 13px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar[data-status="playing"] .bar-info span { color: var(--accent); font-weight: 600; }
.bar[data-status="error"] .bar-info span { color: var(--bad); font-weight: 600; }
.icon-btn { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: var(--dim); cursor: pointer; }
.icon-btn.sleep.on { color: var(--accent); background: var(--accent-soft); }
.icon-btn.sleep.on .ic { fill: currentColor; }
.play-btn { flex: none; display: grid; place-items: center; width: 52px; height: 52px; margin-left: 4px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-text); cursor: pointer; }
.play-btn:active { opacity: .8; }
/* 아래 알림(kit toast)은 재생 막대 위에 뜬다 (UX.md '4. 아래 알림') */
body.has-bar { --ak-toast-b: var(--bar-h); }

/* ---- 로그인·가입 신청 ---- */
.login-page main { padding-top: 8vh; }
.login-page main > * { max-width: 420px; margin-left: auto; margin-right: auto; }
.login-head { text-align: center; margin-bottom: 20px; display: grid; justify-items: center; gap: 6px; }
.login-head .brand-mark { border-radius: 14px; }
.login-head h1 { font-size: 26px; letter-spacing: .08em; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); margin-bottom: 16px; }
.tabs button { min-height: 44px; border: 0; border-radius: 9px; background: none; color: var(--dim); font: inherit; font-weight: 600; cursor: pointer; }
.tabs button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.form { display: grid; gap: 14px; }
.form label, .pw-field { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.form label small { font-weight: 400; color: var(--dim); }
.form input {
  width: 100%; min-width: 0; min-height: 48px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-size: 16px; font-weight: 400;
}
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 72px; }
.pw-eye { position: absolute; right: 2px; top: 50%; margin-top: -22px; min-width: 60px; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--accent); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.msg { margin: 12px 0 0; font-size: 14px; color: var(--bad); }
.msg:empty { display: none; }
/* 터치 기기에서는 폭과 상관없이 입력칸 글자 16px 이상 (아이폰이 화면을 확대하지 않게. UX.md '6. 입력칸') */
@media (pointer: coarse) { input, select, textarea { font-size: 16px; } }

/* ---- PC·넓은 화면 ---- */
@media (min-width: 700px) {
  .acct .ic { display: block; }
  .view { padding-top: 24px; }
  .grp h2 { font-size: 16px; }
}

/* ==== 휴대폰 가로 화면 (모든 서비스가 같은 조건. UX.md '5. 가로 모드 조건') ====
   높이가 귀하다: 머리줄·재생 막대를 낮추고 목록은 여러 칸으로. 로그인은 로고 왼쪽·카드 오른쪽 */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 560px) {
  :root { --bar-h: 60px; }
  .top { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .brand-text small { display: none; }
  .view { padding-top: 12px; }
  .st-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .st-main { min-height: 56px; }
  .bar { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
  .play-btn { width: 48px; height: 48px; }
  .foot-note { margin-top: 16px; }
  .login-page main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 20px; align-items: start; padding-top: 16px; }
  .login-page main > * { max-width: 420px; margin: 0; width: 100%; }
  .login-head { margin-bottom: 0; justify-self: end; align-self: center; }
  .login-page .card { padding: 12px; }
  .login-page .tabs { margin-bottom: 10px; }
  .login-page .form { gap: 8px; }
  .login-page .form input { min-height: 44px; }
}
