/* ==================== Reset & Base ==================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* Light (default) — 深色字体 */
:root, [data-theme="light"] {
    --bg: #c7d2e3;
    --wave: #5a6a84;
    --text-muted: rgba(40,50,70,0.55);
    --volume-track-bg: rgba(100,115,140,0.2);
    --volume-fill: #6a7a94;
    --tab-bg: rgba(255,255,255,0.08);
    --tab-text: rgba(40,50,70,0.6);
    --tab-active-text: rgba(25,35,50,0.9);
    --tab-active-bg: rgba(255,255,255,0.16);
    --tab-active-line: #8898b0;
    --dot-inactive: rgba(70,85,110,0.45);
    --copyright: rgba(40,50,70,0.45);
    --marquee-text: rgba(40,50,70,0.5);
    --theme-icon-color: rgba(40,50,70,0.65);
    --theme-icon-active: rgba(20,30,45,0.92);
    --theme-bg: rgba(255,255,255,0.08);
    --vol-num: rgba(40,50,70,0.6);
}

/* Dark — 浅色字体 */
[data-theme="dark"] {
    --bg: #1a1e2c;
    --wave: #a0b0c8;
    --text-muted: rgba(200,215,230,0.55);
    --volume-track-bg: rgba(150,165,190,0.18);
    --volume-fill: #98a8c0;
    --tab-bg: rgba(255,255,255,0.04);
    --tab-text: rgba(200,215,230,0.6);
    --tab-active-text: rgba(235,240,248,0.92);
    --tab-active-bg: rgba(255,255,255,0.1);
    --tab-active-line: #7888a0;
    --dot-inactive: rgba(150,165,185,0.42);
    --copyright: rgba(180,195,215,0.45);
    --marquee-text: rgba(200,215,230,0.5);
    --theme-icon-color: rgba(200,215,230,0.5);
    --theme-icon-active: rgba(235,240,248,0.88);
    --theme-bg: rgba(255,255,255,0.05);
    --vol-num: rgba(200,215,230,0.6);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #1a1e2c;
        --wave: #a0b0c8;
        --text-muted: rgba(200,215,230,0.55);
        --volume-track-bg: rgba(150,165,190,0.18);
        --volume-fill: #98a8c0;
        --tab-bg: rgba(255,255,255,0.04);
        --tab-text: rgba(200,215,230,0.6);
        --tab-active-text: rgba(235,240,248,0.92);
        --tab-active-bg: rgba(255,255,255,0.1);
        --tab-active-line: #7888a0;
        --dot-inactive: rgba(150,165,185,0.42);
        --copyright: rgba(180,195,215,0.45);
        --marquee-text: rgba(200,215,230,0.5);
        --theme-icon-color: rgba(200,215,230,0.5);
        --theme-icon-active: rgba(235,240,248,0.88);
        --theme-bg: rgba(255,255,255,0.05);
        --vol-num: rgba(200,215,230,0.6);
    }
}

body {
    width: 100vw; min-height: 100dvh;
    overflow-x: hidden; overflow-y: auto;
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: var(--bg);
    transition: background 0.6s ease;
    user-select: none; -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

/* ==================== Site Title ==================== */
.site-title {
    position: fixed;
    top: max(30px, env(safe-area-inset-top, 30px));
    left: max(18px, env(safe-area-inset-left, 18px));
    display: flex; align-items: center; gap: 3px;
    z-index: 30;
    pointer-events: none;
}
.site-logo {
    width: 28px; height: 28px;
    display: block;
    fill: currentColor;
    color: var(--text-muted);
    opacity: 0.7;
    transition: color 0.6s ease, opacity 0.6s ease;
}
.site-title-text {
    font-size: 20px; font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-muted);
    opacity: 0.65;
    transition: color 0.6s ease;
    line-height: 1;
    margin: 0;
}

/* ==================== Theme Toggle ==================== */
.theme-toggle {
    position: fixed;
    top: max(30px, env(safe-area-inset-top, 30px));
    right: max(14px, env(safe-area-inset-right, 14px));
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border: none; outline: none;
    border-radius: 10px;
    background: var(--theme-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    z-index: 30;
    transition: background 0.6s ease;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}
.theme-toggle svg {
    width: 18px; height: 18px;
    fill: none; stroke: var(--theme-icon-active);
    stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
    transition: stroke 0.6s ease, transform 0.3s ease;
}
.theme-toggle:active svg {
    transform: scale(0.9);
}


/* ==================== Tab Navigation ==================== */
.tab-nav {
    grid-row: 1;
    justify-self: center;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 5px;
    margin-top: max(73px, env(safe-area-inset-top, 73px));
    border-radius: 14px;
    background: var(--tab-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background 0.6s ease;
    z-index: 20;
    max-width: calc(100vw - 60px);
}
.tab-btn {
    border: none; outline: none;
    background: transparent;
    display: flex; flex-direction: column;
    align-items: center; gap: 1px;
    padding: 8px 14px 7px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    min-width: 80px;
}
.tab-btn.active {
    background: var(--tab-active-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.tab-emoji {
    font-size: 18px; line-height: 1.2;
    transition: transform 0.3s ease;
}
.tab-btn.active .tab-emoji {
    transform: scale(1.15);
}
.tab-label {
    font-size: 12px; font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--tab-text);
    transition: color 0.35s ease;
}
.tab-btn.active .tab-label {
    color: var(--tab-active-text);
}
.tab-sub {
    font-size: 10px; font-weight: 400;
    letter-spacing: 0.3px;
    color: var(--tab-text);
    opacity: 0.55;
    transition: opacity 0.35s ease;
    white-space: nowrap;
}
.tab-btn.active .tab-sub {
    opacity: 0.72;
}

/* ==================== Track Indicator (right) ==================== */
.track-indicator {
    position: fixed;
    right: max(18px, env(safe-area-inset-right, 18px));
    top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column;
    align-items: center; gap: 10px;
    pointer-events: none; z-index: 10;
}
.track-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--dot-inactive);
    transition: all 0.4s ease;
}
.track-dot.active {
    background: var(--wave);
    width: 8px; height: 8px;
    box-shadow: 0 0 8px var(--wave);
}

/* ==================== Main Container ==================== */
.app-container {
    grid-row: 2;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    cursor: pointer;
    overflow: hidden;
    min-height: 0;
}

/* ==================== Vinyl Stage ==================== */
.vinyl-stage {
    position: relative;
    --s: min(80vw, 480px);
    width: var(--s); height: var(--s);
    display: flex; justify-content: center; align-items: center;
}

/* Vinyl Disc */
.vinyl-disc {
    position: relative; z-index: 1;
    width: 64%; height: 64%;
    border-radius: 50%;
    overflow: hidden;
    filter: drop-shadow(0 4px 24px rgba(0,0,0,0.3));
    will-change: transform;
    transition: box-shadow 0.6s ease;
}
.vinyl-disc img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}
/* Dark mode: 唱片外围微光环 */
[data-theme="dark"] .vinyl-disc {
    box-shadow: 0 0 40px rgba(120,140,170,0.1), 0 0 2px rgba(255,255,255,0.04);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .vinyl-disc {
        box-shadow: 0 0 40px rgba(120,140,170,0.1), 0 0 2px rgba(255,255,255,0.04);
    }
}
.vinyl-disc svg {
    width: 100%; height: 100%;
    display: block;
}

/* Fixed shine — 不旋转，叠在唱片上方产生光影流动 */
.vinyl-shine {
    position: absolute; z-index: 2;
    width: 64%; height: 64%;
    border-radius: 50%;
    background: radial-gradient(
        ellipse at 32% 28%,
        rgba(255,255,255,0.22) 0%,
        rgba(255,255,255,0.06) 30%,
        rgba(255,255,255,0.01) 50%,
        transparent 65%
    );
    pointer-events: none;
}

/* ==================== Tonearm ==================== */
.tonearm {
    position: absolute; z-index: 5;
    /* Anchor to disc edge — disc is 64% centered, edge offset = (100%-64%)/2 = 18% */
    --disc-gap: calc((100% - 64%) / 2);
    right: calc(var(--disc-gap) - 13%);
    top:   calc(var(--disc-gap) - 6%);
    width: 24%; height: 62%;
    transform-origin: 50% 10%;
    transform: rotate(-13deg);
    transition: transform 0.7s cubic-bezier(0.25, 0.1, 0.25, 1);
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25));
    pointer-events: none;
}
.tonearm img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.tonearm.playing {
    transform: rotate(8deg);
}

/* ==================== Track Marquee ==================== */
.track-marquee {
    width: 200px; height: 18px;
    overflow: hidden; white-space: nowrap;
    margin: 14px 0 8px;
}
.track-marquee .track-marquee-inner {
    display: inline-block;
    font-size: 11px; letter-spacing: 1px;
    color: var(--marquee-text);
    white-space: nowrap;
    animation: marqueeScroll 10s linear infinite;
    animation-play-state: paused;
}
.track-marquee.playing .track-marquee-inner { animation-play-state: running; }

@keyframes marqueeScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* ==================== Status Overlay ==================== */
.status-overlay {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: flex; flex-direction: column;
    align-items: center; gap: 6px;
    pointer-events: none; opacity: 0;
    transition: opacity 0.5s ease; z-index: 2;
}
.status-overlay.visible { opacity: 1; }
.status-icon {
    font-size: 28px; line-height: 1; color: var(--wave);
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.06));
}
.status-text {
    font-size: 13px; font-weight: 500; letter-spacing: 2px;
    color: var(--wave); opacity: 0.75; white-space: nowrap;
}

/* ==================== Bottom Panel ==================== */
.bottom-panel {
    grid-row: 3;
    display: flex; flex-direction: column;
    align-items: center; gap: 10px;
    padding: 16px 0 max(20px, env(safe-area-inset-bottom, 20px));
    pointer-events: none;
}

/* ==================== Volume Control ==================== */
.volume-control {
    display: flex; align-items: center; gap: 10px;
    pointer-events: auto;
    touch-action: none;
    -webkit-user-select: none;
    cursor: pointer;
    padding: 8px 0;
    opacity: 0.28;
    transition: opacity 0.4s ease;
}
.volume-control.interacting {
    opacity: 1;
}
.volume-track {
    width: 140px; height: 2px;
    background: var(--volume-track-bg);
    border-radius: 2px;
    position: relative; overflow: visible;
}
.volume-fill {
    height: 100%; border-radius: 2px;
    background: var(--volume-fill);
    width: 70%;
    transition: width 0.04s linear;
}
.volume-num {
    font-size: 11px; font-weight: 500;
    color: var(--vol-num);
    min-width: 22px; text-align: right;
}

/* ==================== Hint & Copyright ==================== */
.hint-text {
    font-size: 11px; letter-spacing: 1px;
    color: var(--text-muted);
    opacity: 0.6; text-align: center;
    padding: 0 20px; line-height: 1.5;
    transition: color 0.6s ease;
    pointer-events: none;
}
.copyright {
    font-size: 10px; letter-spacing: 0.8px;
    color: var(--copyright);
    transition: color 0.6s ease;
    pointer-events: none;
    padding-bottom: 4px; text-align: center;
}

/* ==================== Responsive ==================== */
@media (max-width: 480px) {
    .vinyl-stage {
        --s: min(80vw, calc(100dvh - 170px));
        width: var(--s); height: var(--s);
    }
    .theme-toggle {
        top: max(22px, env(safe-area-inset-top, 22px));
        right: max(8px, env(safe-area-inset-right, 8px));
        width: 32px; height: 32px;
    }
    .theme-toggle svg { width: 16px; height: 16px; }
    .site-title {
        top: max(22px, env(safe-area-inset-top, 22px));
        left: max(14px, env(safe-area-inset-left, 14px));
    }
    .site-logo { width: 24px; height: 24px; }
    .site-title-text { font-size: 18px; letter-spacing: 2px; }

    .tab-nav {
        margin-top: max(63px, env(safe-area-inset-top, 63px));
        padding: 3px; gap: 2px;
    }
    .tab-btn { padding: 6px 10px 5px; min-width: 64px; }
    .tab-emoji { font-size: 16px; }
    .tab-label { font-size: 11px; }
    .tab-sub { display: none; }

    .track-indicator {
        right: max(10px, env(safe-area-inset-right, 10px));
        gap: 8px;
    }
    .track-dot { width: 5px; height: 5px; }
    .track-dot.active { width: 6px; height: 6px; }

    .track-marquee { width: 150px; margin: 10px 0 4px; }
    .track-marquee-inner { font-size: 10px; }

    .volume-track { width: 110px; }
    .volume-num { font-size: 11px; }

    .bottom-panel { padding-top: 10px; gap: 6px; }
    .hint-text { font-size: 10px; letter-spacing: 0.5px; }
    .status-icon { font-size: 22px; }
    .status-text { font-size: 11px; }

    .tonearm {
        --disc-gap: calc((100% - 64%) / 2);
        right: calc(var(--disc-gap) - 14%);
        top:   calc(var(--disc-gap) - 7%);
        width: 26%; height: 58%;
    }
}

@media (min-width: 768px) {
    .vinyl-stage { --s: 440px; }
    .hint-text { font-size: 12px; letter-spacing: 1.5px; }
    .volume-track { width: 170px; }
    .tab-btn { padding: 10px 20px 9px; }
    .tab-emoji { font-size: 20px; }
    .tab-label { font-size: 13px; }
    .tab-sub { font-size: 11px; }
}

/* ==================== Accessibility ==================== */
@media (prefers-reduced-motion: reduce) {
    .vinyl-disc { animation: none !important; }
    body, *, *::before, *::after { transition-duration: 0s !important; }
}
