* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; font: 15px/1.5 var(--sans); background: var(--page); color: var(--page-fg); transition: background .2s, color .2s; }
button, select, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--page-fg); outline-offset: 3px; }

/* ---------- 頁首 ---------- */
header.top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; padding: 14px 22px; }
.brand { font: 700 12px var(--mono); letter-spacing: .22em; }
.sp { flex: 1; }
.link { font: 12px var(--mono); letter-spacing: .04em; color: var(--page-fg); opacity: .62; background: none; border: 0; padding: 4px 0; cursor: pointer; text-decoration: none; }
.link:hover { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }
.who { font: 11px var(--mono); opacity: .45; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbtn { background: none; border: 1px solid color-mix(in srgb, var(--page-fg) 25%, transparent); color: var(--page-fg); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; padding: 0; }
.tbtn svg { width: 15px; height: 15px; fill: currentColor; }

main { flex: 1; display: grid; place-items: center; padding: 4px 16px 28px; }

/* ---------- 播放器卡片 ---------- */
.card { width: min(380px, 100%); background: var(--bg); color: var(--fg); border-radius: 26px; padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.ctop { display: flex; align-items: center; justify-content: space-between; font: 600 10px var(--mono); letter-spacing: .2em; color: var(--muted); }
.live::before { content: "●"; color: #e52d2d; margin-right: 5px; animation: livedot 1.2s ease-in-out infinite; }
@keyframes livedot { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .live::before { animation: none; } }
.paused .live { opacity: .45; }
.paused .live::before { animation: none; }

.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { flex: none; font-size: 12px; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; white-space: nowrap; }
.pill:hover { color: var(--fg); }
.pill[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.genres { flex-wrap: wrap; justify-content: center; overflow: visible; }
.genres:empty { display: none; }
.genres .pill { font-size: 11px; padding: 3px 10px; }

/* 這個電台沒有專輯封面,主視覺是「正在跳動的聲音」 */
.viz { position: relative; background: var(--panel); border-radius: 18px; height: clamp(96px, 24vh, 170px); overflow: hidden; }
.viz canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.recipe { position: absolute; inset: 0; background: var(--panel); padding: 10px 18px; display: none; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; font-size: 12.5px; }
.recipe > :first-child { margin-top: auto; }
.recipe > :last-child { margin-bottom: auto; }
.recipe.on { display: flex; }
.recipe div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 4px 0; flex-shrink: 0; }
.recipe div span:first-child { color: var(--muted); }
.recipe small { color: var(--muted); font-size: 10px; margin-top: 6px; line-height: 1.3; flex-shrink: 0; }

.info { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.meta { min-width: 0; }
.title { margin: 0; font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; min-height: 1.2em; }
.icon { background: none; border: 0; color: var(--fg); width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; border-radius: 50%; flex: none; padding: 0; }
.icon:hover { background: var(--line); }
.icon svg { width: 20px; height: 20px; fill: currentColor; }
.icon.on { background: var(--fg); color: var(--bg); }

.prog { height: 2px; pointer-events: none; cursor: default; background: var(--line); border-radius: 3px; position: relative; margin-top: 2px; }
.prog i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--fg); border-radius: 3px; }
.times { display: flex; justify-content: space-between; font: 10px var(--mono); color: var(--muted); margin-top: -6px; letter-spacing: .06em; min-height: 1em; }

.ctrl { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.vol { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.vol svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.vol input { width: 72px; accent-color: var(--fg); height: 3px; }
.side { display: flex; align-items: center; gap: 14px; }
.play { position: relative; width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--btn); color: var(--btnfg); display: grid; place-items: center; cursor: pointer; transition: transform .1s; padding: 0; }
.play:active { transform: scale(.94); }
.play svg { grid-area: 1 / 1; width: 26px; height: 26px; fill: currentColor; }
.play .i-pause { display: none; } .play.playing .i-pause { display: block; } .play.playing .i-play { display: none; }
.play::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--fg); opacity: 0; pointer-events: none; animation: spin 1s linear infinite; transition: opacity .2s; }
.play.loading::after { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.status { color: var(--muted); font-size: 11.5px; text-align: center; }
.status:empty { display: none; }
.status.err { color: var(--danger); }

/* ---------- 嵌入功能對話框 ---------- */
dialog { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 22px; width: min(580px, 94vw); padding: 22px; max-height: 92dvh; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h3 { margin: 0 0 6px; font-size: 20px; }
dialog h4 { margin: 18px 0 6px; font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: none; color: var(--fg); padding: 7px 16px; border-radius: 999px; cursor: pointer; text-decoration: none; font-size: 13px; }
.btn:hover { border-color: var(--fg); }
.btn.primary { background: var(--btn); color: var(--btnfg); border-color: var(--btn); }
.btn.small { padding: 3px 11px; font-size: 12px; }
.btn.danger { color: var(--danger); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
input[type=text], input[type=email], textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; width: 100%; }
.keyitem { border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin: 10px 0; background: var(--panel); }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow: auto; font: 11.5px/1.45 var(--mono); white-space: pre-wrap; word-break: break-all; margin: 6px 0; }

@media (max-width: 420px) { header.top { padding: 12px 16px; } .who { display: none; } .card { padding: 16px 16px 18px; } }
@media (max-height: 640px) { .viz { height: 88px; } .title { font-size: 22px; } main { padding-bottom: 14px; } }
@media (prefers-reduced-motion: reduce) { .play::after { animation: none; } }
