:root {
    color-scheme: light;
    --paper: #f4f0e8;
    --paper-deep: #e9e2d7;
    --ink: #1d2723;
    --muted: #6d756f;
    --line: rgba(29, 39, 35, 0.11);
    --green: #285d4b;
    --shadow: 0 24px 80px rgba(48, 55, 48, 0.13);
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

* { box-sizing: border-box; }

html {
    background: var(--paper);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
        "Microsoft YaHei", sans-serif;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 20% 5%, rgba(255, 255, 255, 0.95), transparent 34%),
        linear-gradient(145deg, var(--paper) 0%, #efeae1 100%);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }

.ambient {
    position: fixed;
    z-index: 0;
    width: 28rem;
    height: 28rem;
    border-radius: 50%;
    filter: blur(90px);
    pointer-events: none;
    opacity: 0.34;
}

.ambient-one { top: -12rem; right: -10rem; background: #bed6ca; }
.ambient-two { bottom: -16rem; left: -11rem; background: #e7c49f; }

.app-shell {
    position: relative;
    z-index: 1;
    width: min(100% - 28px, 760px);
    margin: 0 auto;
    padding: max(18px, env(safe-area-inset-top)) 0 calc(88px + env(safe-area-inset-bottom));
}

.topbar, .section-heading, .sheet-header, .player-footer, .time-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar { margin-bottom: 24px; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: -0.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 14px;
    background: var(--ink);
    color: #fffdf7;
    font-family: "Songti SC", "STSong", serif;
    font-size: 22px;
    box-shadow: 0 10px 24px rgba(29, 39, 35, 0.18);
}

.brand-mark.large { width: 58px; height: 58px; border-radius: 18px; font-size: 29px; }

.icon-button, .quiet-button, .control-secondary, .play-button, .primary-button, .queue-item {
    -webkit-tap-highlight-color: transparent;
    transition: transform 150ms var(--ease-out), background-color 180ms ease,
        border-color 180ms ease, opacity 180ms ease;
}

.icon-button:active, .quiet-button:active, .control-secondary:active,
.play-button:active, .primary-button:active, .queue-item:active {
    transform: scale(0.97);
}

.icon-button {
    display: grid;
    width: 42px;
    height: 42px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.5);
    font-size: 24px;
    cursor: pointer;
}

.player-card {
    position: relative;
    overflow: hidden;
    min-height: 470px;
    padding: clamp(24px, 6vw, 44px);
    border: 1px solid rgba(255, 255, 255, 0.74);
    border-radius: 34px;
    background: linear-gradient(145deg, rgba(255,255,255,.92), rgba(245,244,236,.68));
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px);
}

.player-card::after {
    position: absolute;
    top: -90px;
    right: -70px;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(40, 93, 75, 0.14), transparent 70%);
    content: "";
    pointer-events: none;
}

.eyebrow {
    color: var(--green);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.now-playing h1 {
    max-width: 560px;
    margin: 10px 0 8px;
    font-family: "Songti SC", "STSong", serif;
    font-size: clamp(30px, 7vw, 50px);
    font-weight: 600;
    letter-spacing: -0.045em;
    line-height: 1.09;
}

.now-playing p {
    max-width: 560px;
    min-height: 44px;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.sound-orbit {
    display: flex;
    width: 160px;
    height: 72px;
    margin: 28px auto 22px;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.sound-orbit i {
    width: 6px;
    height: 18px;
    border-radius: 999px;
    background: linear-gradient(to top, var(--green), #6e9987);
    opacity: 0.35;
    transform: scaleY(0.65);
    transition: transform 240ms var(--ease-in-out), opacity 180ms ease;
}

.player-card.is-playing .sound-orbit i {
    opacity: 1;
    animation: pulse-wave 940ms var(--ease-in-out) infinite alternate;
}

.player-card.is-playing .sound-orbit i:nth-child(2),
.player-card.is-playing .sound-orbit i:nth-child(4) { animation-delay: -280ms; }
.player-card.is-playing .sound-orbit i:nth-child(3) { animation-delay: -540ms; }

@keyframes pulse-wave {
    from { transform: scaleY(0.65); }
    to { transform: scaleY(2.7); }
}

.timeline { margin-top: 2px; }

.progress {
    width: 100%;
    height: 4px;
    margin: 0;
    appearance: none;
    border-radius: 999px;
    background: linear-gradient(to right, var(--green) var(--played, 0%), var(--paper-deep) var(--played, 0%));
    cursor: pointer;
}

.progress::-webkit-slider-thumb {
    width: 15px;
    height: 15px;
    appearance: none;
    border: 3px solid white;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 2px 8px rgba(29, 39, 35, 0.24);
}

.time-row {
    margin-top: 8px;
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.controls {
    display: flex;
    margin: 16px 0 24px;
    align-items: center;
    justify-content: center;
    gap: 25px;
}

.play-button {
    display: grid;
    width: 72px;
    height: 72px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--ink);
    color: white;
    box-shadow: 0 16px 35px rgba(29, 39, 35, 0.26);
    cursor: pointer;
    font-size: 25px;
}

.play-button span { margin-left: 3px; }
.player-card.is-playing .play-button span { margin-left: 0; }

.control-secondary {
    position: relative;
    display: grid;
    width: 48px;
    height: 48px;
    padding: 0;
    place-items: center;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 28px;
}

.control-secondary small { position: absolute; font-size: 9px; font-weight: 800; }
.player-footer { gap: 12px; color: var(--muted); font-size: 12px; }
.player-footer > span { flex: 1; text-align: center; }
.player-actions { display: flex; align-items: center; gap: 7px; }

.quiet-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.4);
    color: inherit;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    text-decoration: none;
}
.download-button[aria-disabled="true"] { cursor: default; opacity: 0.42; }

.queue-section { padding: 34px 4px 0; }
.section-heading h2 {
    margin: 5px 0 0;
    font-family: "Songti SC", "STSong", serif;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.03em;
}
.queue-count { color: var(--muted); font-size: 12px; }
.queue { display: grid; margin-top: 18px; gap: 10px; }

.queue-item {
    display: grid;
    width: 100%;
    padding: 17px;
    grid-template-columns: 42px 1fr auto;
    align-items: center;
    gap: 13px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.5);
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.queue-item.is-current {
    border-color: rgba(40, 93, 75, 0.34);
    background: rgba(231, 240, 235, 0.72);
}
.queue-item.is-heard { opacity: 0.62; }

.item-index {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 14px;
    background: var(--paper-deep);
    color: var(--green);
    font-family: "Songti SC", "STSong", serif;
    font-size: 16px;
}
.queue-item.is-current .item-index { background: var(--green); color: white; }
.item-copy { min-width: 0; }
.item-copy strong, .item-copy small { display: block; }
.item-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.item-copy small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.item-more { padding: 8px; color: var(--muted); font-size: 20px; }

.empty-state {
    padding: 42px 20px;
    border: 1px dashed rgba(29, 39, 35, 0.18);
    border-radius: 22px;
    color: var(--muted);
    text-align: center;
}
.empty-state span, .empty-state strong { display: block; }
.empty-state span { margin-bottom: 12px; font-size: 30px; }
.empty-state strong { color: var(--ink); }
.empty-state p { margin: 7px 0 0; font-size: 12px; }

.auth-gate {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: grid;
    padding: 24px;
    place-items: center;
    background: rgba(244, 240, 232, 0.86);
    backdrop-filter: blur(22px);
}
.auth-gate[hidden] { display: none; }

.auth-card {
    width: min(100%, 390px);
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow);
}
.auth-card .brand-mark { margin-bottom: 28px; }
.auth-card h1 {
    margin: 8px 0;
    font-family: "Songti SC", "STSong", serif;
    font-size: 30px;
}
.auth-card p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }

label { display: grid; gap: 8px; color: var(--muted); font-size: 12px; }
input, textarea, select {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 13px;
    outline: none;
    background: rgba(255, 255, 255, 0.76);
    color: var(--ink);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}
input:focus, textarea:focus, select:focus {
    border-color: rgba(40, 93, 75, 0.55);
    box-shadow: 0 0 0 4px rgba(40, 93, 75, 0.08);
}
textarea { min-height: 190px; resize: vertical; line-height: 1.6; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.primary-button {
    width: 100%;
    margin-top: 17px;
    padding: 14px 18px;
    border: 0;
    border-radius: 14px;
    background: var(--ink);
    color: white;
    cursor: pointer;
    font-weight: 700;
}
.primary-button:disabled { cursor: wait; opacity: 0.58; }
.form-error { display: block; min-height: 18px; margin-top: 10px; color: #a5473c; }

.sheet {
    width: min(calc(100% - 28px), 620px);
    max-height: min(86vh, 780px);
    padding: 26px;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 27px;
    background: #f9f7f1;
    color: var(--ink);
    box-shadow: 0 30px 100px rgba(29, 39, 35, 0.28);
}
.sheet::backdrop { background: rgba(29, 39, 35, 0.28); backdrop-filter: blur(6px); }
.sheet[open] { animation: sheet-enter 220ms var(--ease-out); }
@keyframes sheet-enter {
    from { opacity: 0; transform: translateY(18px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.sheet h2 { margin: 5px 0 0; font-family: "Songti SC", "STSong", serif; }
.sheet form { display: grid; gap: 17px; }
.sheet form .sheet-header { margin-bottom: 3px; }
.sheet form .primary-button { margin-top: 1px; }
.sheet form > small { color: var(--muted); line-height: 1.5; text-align: center; }
.source-sheet article {
    margin-top: 22px;
    color: #38423d;
    font-family: "Songti SC", "STSong", serif;
    font-size: 16px;
    line-height: 1.95;
    white-space: pre-wrap;
}

.toast {
    position: fixed;
    z-index: 40;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom));
    max-width: min(calc(100% - 28px), 440px);
    padding: 11px 16px;
    border-radius: 999px;
    background: rgba(29, 39, 35, 0.94);
    color: white;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity 180ms ease, transform 220ms var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
    .app-shell { width: min(100% - 20px, 760px); }
    .player-card { min-height: 455px; padding: 25px 21px; border-radius: 27px; }
    .now-playing h1 { font-size: 32px; }
    .player-footer > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sheet { width: calc(100% - 18px); padding: 21px; border-radius: 24px; }
    .form-grid { grid-template-columns: 1fr; }
}

@media (hover: hover) and (pointer: fine) {
    .icon-button:hover, .quiet-button:hover { background: rgba(255, 255, 255, 0.88); }
    .queue-item:hover { border-color: rgba(40, 93, 75, 0.3); background: rgba(255, 255, 255, 0.78); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}
