:root {
  color-scheme: dark;
  --bg: #101615;
  --bg-raised: #171f1d;
  --bg-soft: #202a27;
  --line: #33423d;
  --line-soft: #26322f;
  --text: #eff5ef;
  --muted: #9cafaa;
  --subtle: #6d8078;
  --mint: #75d49a;
  --mint-strong: #a4efb4;
  --cyan: #71c9d4;
  --orange: #f0aa72;
  --coral: #ef8d83;
  --shadow: 0 18px 50px rgba(0, 0, 0, .24);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang TC", "Noto Sans TC", sans-serif;
  font-synthesis: none;
}

#audio {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100svh; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
img { display: block; max-width: 100%; }

.app-shell { min-height: 100svh; padding-bottom: 34px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 12px max(22px, calc((100vw - 1280px) / 2)); background: rgba(16, 22, 21, .93); border-bottom: 1px solid var(--line-soft); backdrop-filter: blur(18px); }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.connection-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.status-dot, .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--subtle); }
.connection-state.ready .status-dot { background: var(--mint); box-shadow: 0 0 0 4px rgba(117, 212, 154, .12); }
.connection-state.error .status-dot { background: var(--coral); }

.app-main { width: min(1280px, calc(100% - 44px)); margin: 0 auto; }
.now-playing { display: grid; grid-template-columns: minmax(280px, 440px) minmax(0, 1fr); gap: clamp(28px, 5vw, 72px); align-items: center; min-height: 468px; padding: 52px 0 58px; border-bottom: 1px solid var(--line-soft); }
.artwork-wrap { position: relative; width: min(100%, 420px); margin: 0 auto; }
.now-cover { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #293731; box-shadow: var(--shadow); }
.artwork-caption { display: flex; align-items: center; gap: 8px; margin-top: 13px; color: var(--subtle); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.artwork-caption .live-dot { background: var(--orange); }
.now-info { min-width: 0; }
.section-kicker { display: inline-flex; align-items: center; gap: 9px; color: var(--mint); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.source-badge { display: inline-block; padding: 4px 7px; border: 1px solid rgba(117, 212, 154, .4); border-radius: 4px; color: var(--mint-strong); font-size: 10px; letter-spacing: 0; }
.now-info h1 { max-width: 650px; margin: 13px 0 5px; overflow: hidden; font-size: clamp(30px, 4vw, 56px); line-height: 1.05; letter-spacing: 0; text-overflow: ellipsis; white-space: nowrap; }
.now-info p { margin: 0; color: var(--muted); font-size: 16px; }
.now-info .muted-line { margin-top: 8px; color: var(--subtle); font-size: 13px; }
.now-actions { display: flex; gap: 7px; margin: 22px 0 28px; }
.progress-area { max-width: 680px; }
.range { display: block; width: 100%; height: 4px; margin: 0; accent-color: var(--mint); cursor: pointer; }
.time-row { display: flex; justify-content: space-between; margin-top: 8px; color: var(--subtle); font-size: 11px; font-variant-numeric: tabular-nums; }
.transport { display: flex; align-items: center; gap: 18px; margin-top: 19px; }
.play-button { display: inline-grid; place-items: center; width: 54px; height: 54px; padding: 0; border: 0; border-radius: 50%; background: var(--mint); color: #102018; }
.play-button:hover { background: var(--mint-strong); }

.icon-button, .compact-icon-button, .mini-play, .clear-button, .reveal-button { display: inline-grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--muted); }
.icon-button { width: 36px; height: 36px; }
.icon-button.large { width: 34px; height: 34px; }
.icon-button:hover, .compact-icon-button:hover, .mini-play:hover { background: var(--bg-soft); color: var(--text); }
.icon-button.active { color: var(--coral); }
.compact-icon-button { width: 32px; height: 32px; }
.icon-button svg, .compact-icon-button svg, .mini-play svg, .play-button svg, .clear-button svg, .reveal-button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.play-button svg { width: 23px; height: 23px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .9fr) minmax(240px, .8fr); gap: 34px; padding: 45px 0 92px; }
.workspace-column { min-width: 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; min-height: 50px; }
.section-heading h2 { margin: 6px 0 0; font-size: 21px; letter-spacing: 0; }
.count-badge { display: inline-grid; place-items: center; min-width: 22px; height: 20px; margin-left: 5px; padding: 0 6px; border-radius: 10px; background: var(--bg-soft); color: var(--muted); font-size: 11px; vertical-align: 2px; }
.compact-button, .primary-button, .secondary-button, .search-submit { min-height: 34px; padding: 0 13px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; }
.compact-button:hover, .secondary-button:hover { border-color: var(--mint); color: var(--text); }
.search-form { display: flex; gap: 8px; margin-top: 24px; }
.search-box { display: flex; flex: 1; align-items: center; min-width: 0; height: 45px; padding: 0 10px 0 13px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg-raised); }
.search-box:focus-within { border-color: var(--mint); }
.search-box input { flex: 1; min-width: 0; height: 100%; padding: 0 10px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; }
.search-box input::placeholder { color: var(--subtle); }
.search-icon, .mode-icon, .empty-icon, .note-icon { position: relative; display: inline-block; flex: 0 0 auto; width: 17px; height: 17px; }
.search-icon::before { content: ""; position: absolute; width: 10px; height: 10px; border: 1.6px solid var(--muted); border-radius: 50%; }
.search-icon::after { content: ""; position: absolute; width: 7px; height: 1.6px; top: 12px; left: 11px; transform: rotate(45deg); background: var(--muted); }
.clear-button { width: 26px; height: 26px; color: var(--subtle); }
.search-submit { border-color: var(--mint); background: var(--mint); color: #122018; font-weight: 700; }
.search-submit:hover { background: var(--mint-strong); }
.source-tabs { display: flex; gap: 6px; margin-top: 18px; border-bottom: 1px solid var(--line-soft); }
.source-tab { position: relative; padding: 0 6px 11px; border: 0; background: transparent; color: var(--subtle); font-size: 12px; }
.source-tab::after { content: ""; position: absolute; right: 6px; bottom: -1px; left: 6px; height: 2px; background: transparent; }
.source-tab.active { color: var(--text); }
.source-tab.active::after { background: var(--mint); }
.inline-status { min-height: 38px; padding: 16px 0 5px; color: var(--subtle); font-size: 12px; }
.inline-status.error { color: var(--coral); }
.result-list, .queue-list { display: flex; flex-direction: column; gap: 2px; }
.result-item, .queue-item { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 11px; align-items: center; min-height: 64px; padding: 8px 6px; border-bottom: 1px solid var(--line-soft); }
.result-item:hover, .queue-item:hover, .queue-item.current { background: rgba(117, 212, 154, .06); }
.result-cover, .queue-cover { width: 46px; height: 46px; object-fit: cover; border-radius: 5px; background: #293731; }
.item-text { min-width: 0; }
.item-title, .item-subtitle { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-title { color: var(--text); font-size: 13px; font-weight: 650; }
.item-subtitle { margin-top: 4px; color: var(--subtle); font-size: 11px; }
.item-actions { display: flex; align-items: center; gap: 2px; }
.item-actions .icon-button { width: 31px; height: 31px; }
.add-button { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); }
.add-button:hover { border-color: var(--mint); color: var(--mint); }
.source-mini { display: inline-block; margin-left: 5px; color: var(--cyan); font-size: 10px; }
.queue-tools { display: flex; justify-content: space-between; align-items: center; margin: 24px 0 8px; }
.queue-mode { display: inline-flex; gap: 7px; align-items: center; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.mode-icon { width: 15px; height: 15px; color: var(--mint); }
.mode-icon::before, .mode-icon::after { content: ""; position: absolute; left: 1px; width: 11px; height: 1px; background: currentColor; box-shadow: 0 4px currentColor, 0 8px currentColor; }
.mode-icon::after { left: 8px; width: 5px; height: 5px; top: 4px; transform: rotate(45deg); border-right: 1px solid currentColor; border-top: 1px solid currentColor; background: transparent; box-shadow: none; }
.queue-item { grid-template-columns: 38px minmax(0, 1fr) auto; min-height: 55px; }
.queue-item .queue-cover { width: 38px; height: 38px; }
.queue-item.current .item-title { color: var(--mint-strong); }
.queue-item.current .item-subtitle::before { content: "播放中 · "; color: var(--mint); }
.queue-item .item-subtitle .auto-label { color: var(--mint); }
.autoplay-toggle { position: relative; flex: 0 0 auto; width: 42px; height: 24px; margin-top: 10px; padding: 2px; border: 1px solid var(--line); border-radius: 20px; background: var(--bg); }
.autoplay-toggle span { display: block; width: 18px; height: 18px; border-radius: 50%; background: var(--subtle); transform: translateX(0); transition: transform .2s ease, background .2s ease; }
.autoplay-toggle.enabled { border-color: var(--mint); background: rgba(117, 212, 154, .15); }
.autoplay-toggle.enabled span { background: var(--mint); transform: translateX(18px); }
.autoplay-panel { margin-top: 24px; padding: 16px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--bg-raised); }
.autoplay-status { min-height: 37px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.autoplay-suggestion { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 10px; align-items: center; min-height: 0; margin-top: 10px; }
.autoplay-suggestion:empty { display: none; }
.autoplay-suggestion img { width: 42px; height: 42px; border-radius: 4px; object-fit: cover; background: var(--bg-soft); }
.autoplay-suggestion strong, .autoplay-suggestion span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.autoplay-suggestion strong { color: var(--text); font-size: 12px; }
.autoplay-suggestion span { margin-top: 4px; color: var(--mint); font-size: 10px; }
.autoplay-note { margin: 14px 0; color: var(--subtle); font-size: 10px; line-height: 1.55; }
.autoplay-note a { color: var(--mint); text-decoration: none; }
.autoplay-note a:hover { text-decoration: underline; }
.autoplay-panel .compact-button { width: 100%; }
.empty-state { display: grid; place-items: center; padding: 46px 12px; text-align: center; color: var(--subtle); }
.empty-state p { margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
.empty-state small { font-size: 11px; }
.empty-icon { border: 1px solid var(--line); border-radius: 50%; }
.empty-icon::after { content: ""; position: absolute; width: 7px; height: 7px; top: 4px; left: 4px; border: 1px solid var(--subtle); border-radius: 50%; }
.mini-player { position: fixed; right: 22px; bottom: 20px; z-index: 30; display: flex; align-items: center; gap: 10px; width: min(370px, calc(100% - 32px)); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(23, 31, 29, .97); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.mini-player > img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.mini-meta { flex: 1; min-width: 0; }
.mini-meta strong, .mini-meta span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-meta strong { color: var(--text); font-size: 12px; }
.mini-meta span { margin-top: 4px; color: var(--subtle); font-size: 10px; }
.mini-player .icon-button { width: 28px; height: 28px; }
.mini-play { width: 30px; height: 30px; background: var(--mint); color: #102018; }
.mini-play:hover { background: var(--mint-strong); }

.settings-dialog { width: min(460px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow); }
.settings-dialog::backdrop { background: rgba(0, 0, 0, .68); backdrop-filter: blur(4px); }
.settings-form { padding: 24px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 25px; }
.dialog-header h2 { margin: 6px 0 0; font-size: 22px; }
.field-label { display: flex; justify-content: space-between; margin: 17px 0 7px; color: var(--muted); font-size: 12px; }
.field-label span { color: var(--mint); font-size: 10px; }
.secret-field { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); }
.secret-field:focus-within { border-color: var(--mint); }
.secret-field input, .text-field, .select-field { width: 100%; min-height: 43px; padding: 0 12px; border: 1px solid var(--line); border-radius: 5px; outline: 0; background: var(--bg); color: var(--text); font-size: 13px; }
.secret-field input { border: 0; background: transparent; }
.text-field:focus, .select-field:focus { border-color: var(--mint); }
.reveal-button { width: 38px; height: 38px; margin-right: 2px; }
.field-help { margin: 8px 0 0; color: var(--subtle); font-size: 11px; line-height: 1.5; }
.settings-note { display: flex; gap: 10px; margin-top: 21px; padding: 11px; border-left: 2px solid var(--orange); background: rgba(240, 170, 114, .07); color: var(--muted); }
.settings-note p { margin: 0; font-size: 11px; line-height: 1.55; }
.note-icon { width: 15px; height: 15px; border: 1px solid var(--orange); border-radius: 50%; }
.note-icon::after { content: "i"; position: absolute; top: -1px; left: 5px; color: var(--orange); font-family: Georgia, serif; font-weight: 700; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 26px; }
.primary-button { border-color: var(--mint); background: var(--mint); color: #102018; font-weight: 700; }
.primary-button:hover { background: var(--mint-strong); }
.toast { position: fixed; right: 22px; bottom: 86px; z-index: 50; max-width: min(360px, calc(100% - 44px)); padding: 11px 14px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg-soft); color: var(--text); font-size: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(239, 141, 131, .65); color: #ffc5bd; }
.loading-bar { position: fixed; top: 0; left: 0; z-index: 100; width: 100%; height: 2px; background: var(--mint); box-shadow: 0 0 12px var(--mint); animation: loading 1.1s infinite ease-in-out; }
@keyframes loading { 0% { transform: translateX(-100%); } 50% { transform: translateX(-18%); } 100% { transform: translateX(100%); } }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr); }
  .autoplay-column { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .topbar { min-height: 60px; padding: 10px 16px; }
  .connection-state { display: none; }
  .app-main { width: calc(100% - 32px); }
  .now-playing { display: block; min-height: 0; padding: 26px 0 30px; }
  .artwork-wrap { width: min(82vw, 350px); }
  .now-info { padding-top: 27px; text-align: center; }
  .section-kicker { justify-content: center; }
  .now-info h1 { font-size: 30px; }
  .now-info p { font-size: 14px; }
  .now-actions { justify-content: center; margin: 17px 0 23px; }
  .transport { justify-content: center; gap: 16px; }
  .progress-area { text-align: left; }
  .workspace { display: block; padding-top: 32px; padding-bottom: 106px; }
  .workspace-column { padding: 25px 0; border-bottom: 1px solid var(--line-soft); }
  .workspace-column:first-child { padding-top: 0; }
  .autoplay-column { border-bottom: 0; }
  .autoplay-panel { margin-top: 18px; }
  .mini-player { right: 10px; bottom: calc(9px + env(safe-area-inset-bottom)); width: calc(100% - 20px); }
  .toast { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
