:root {
    --bg: #08060b;
    --panel: rgba(20, 13, 26, 0.92);
    --panel-2: rgba(14, 10, 19, 0.94);
    --line: rgba(255, 255, 255, 0.09);
    --text: #f5edf7;
    --muted: #a99bac;
    --purple: #a94bff;
    --purple-soft: #d9a8ff;
    --cherry: #7f0f35;
    --cherry-bright: #c72864;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
    --radius: 24px;
    --topbar-height: 72px;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; }
body {
    margin: 0;
    min-height: 100dvh;
    overflow: hidden;
    background:
        radial-gradient(circle at 12% 10%, rgba(121, 33, 180, 0.2), transparent 34%),
        radial-gradient(circle at 90% 85%, rgba(127, 15, 53, 0.22), transparent 38%),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }
button, input[type="range"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--purple-soft); outline-offset: 3px; }

.ambient {
    position: fixed;
    z-index: -1;
    width: 38vw;
    height: 38vw;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.16;
    pointer-events: none;
}
.ambient-a { left: -14vw; top: -12vw; background: var(--purple); }
.ambient-b { right: -12vw; bottom: -14vw; background: var(--cherry-bright); }

.app-shell { min-height: 100dvh; }
.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: max(10px, env(safe-area-inset-top)) clamp(16px, 3vw, 38px) 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 6, 11, 0.72);
    backdrop-filter: blur(22px);
    position: relative;
    z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
    width: 43px;
    height: 43px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-weight: 850;
    letter-spacing: -0.04em;
    background: linear-gradient(145deg, var(--purple), var(--cherry));
    box-shadow: 0 10px 28px rgba(117, 35, 168, 0.33);
}
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: clamp(1rem, 2vw, 1.26rem); line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.78rem; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.text-button, .icon-button, .round-button, .sleep-button, .timer-grid button, .wide-action, .custom-timer button {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.055);
    cursor: pointer;
    transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.text-button:hover, .icon-button:hover, .round-button:hover, .sleep-button:hover, .timer-grid button:hover, .wide-action:hover, .custom-timer button:hover {
    background: rgba(169, 75, 255, 0.14);
    border-color: rgba(196, 130, 255, 0.42);
}
button:active { transform: scale(0.96); }
.text-button { padding: 9px 13px; border-radius: 12px; font-size: 0.82rem; }
.icon-button {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    padding: 0;
}
.icon-button svg, .round-button svg, .sleep-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mobile-only { display: none; }

.app-main {
    height: calc(100dvh - var(--topbar-height));
    display: grid;
    grid-template-columns: minmax(350px, 0.92fr) minmax(390px, 1.08fr);
    gap: clamp(14px, 2vw, 26px);
    padding: clamp(14px, 2vw, 26px);
    max-width: 1500px;
    margin: 0 auto;
}

.player-panel {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(169, 75, 255, .45) transparent;
}
.quote-zone { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 0 0 auto; }
.quote-card {
    min-height: 92px;
    padding: 15px 17px;
    border: 1px solid var(--line);
    border-radius: 19px;
    background: linear-gradient(145deg, rgba(24, 15, 31, .95), rgba(12, 8, 17, .94));
    box-shadow: 0 14px 38px rgba(0, 0, 0, .24);
    position: relative;
    overflow: hidden;
}
.quote-card::after {
    content: "";
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    right: -38px;
    bottom: -48px;
    filter: blur(2px);
    opacity: .18;
}
.daily-quote::after { background: var(--purple); }
.hourly-quote::after { background: var(--cherry-bright); }
.quote-label, .eyebrow {
    color: var(--purple-soft);
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .15em;
    text-transform: uppercase;
}
.hourly-quote .quote-label { color: #ff99bd; }
.quote-card p { margin: 8px 0 0; line-height: 1.42; font-size: clamp(.84rem, 1.35vw, .96rem); position: relative; z-index: 1; }

.player-card {
    flex: 1 0 auto;
    min-height: 0;
    padding: clamp(18px, 2.6vw, 30px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(160deg, rgba(28, 17, 35, .96), rgba(10, 7, 14, .97));
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.now-playing { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 21px; }
.disc {
    width: 112px;
    aspect-ratio: 1;
    border-radius: 50%;
    position: relative;
    display: grid;
    place-items: center;
    background:
        repeating-radial-gradient(circle, rgba(255,255,255,.05) 0 1px, transparent 1px 5px),
        radial-gradient(circle at 35% 30%, #3b2050, #120b18 55%, #050407 100%);
    box-shadow: 0 18px 45px rgba(0,0,0,.42), inset 0 0 0 1px rgba(255,255,255,.07);
}
.disc-ring { position: absolute; inset: 31%; border-radius: 50%; background: linear-gradient(145deg, var(--purple), var(--cherry-bright)); box-shadow: 0 0 30px rgba(169,75,255,.42); }
.disc-center { position: relative; width: 32%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: #0a0710; font-weight: 850; font-size: .82rem; }
.is-playing .disc { animation: spin 7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.track-copy { min-width: 0; }
.track-copy h2 { margin: 8px 0 6px; font-size: clamp(1.18rem, 2.6vw, 1.95rem); line-height: 1.15; overflow-wrap: anywhere; }
.track-copy p { margin: 0; color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.progress-block { margin-top: clamp(22px, 4vh, 34px); }
.range { --fill: 0%; width: 100%; accent-color: var(--purple); cursor: pointer; }
.range[type="range"] {
    appearance: none;
    height: 5px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--purple) var(--fill), rgba(255,255,255,.12) var(--fill));
}
.range[type="range"]::-webkit-slider-thumb { appearance: none; width: 17px; height: 17px; border-radius: 50%; background: #fff; border: 4px solid var(--purple); box-shadow: 0 4px 15px rgba(0,0,0,.4); }
.range[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 4px solid var(--purple); }
.time-row { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .73rem; }

.transport-controls { display: flex; align-items: center; justify-content: center; gap: clamp(9px, 1.8vw, 16px); margin-top: 16px; }
.round-button { width: 51px; height: 51px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.round-button.small { width: 43px; height: 43px; color: var(--muted); }
.round-button.active { color: white; background: rgba(169,75,255,.22); border-color: rgba(202,143,255,.5); box-shadow: 0 0 22px rgba(169,75,255,.18); }
.repeat-one { display: none; fill: currentColor; stroke: none; font-size: 8px; font-weight: 800; }
.repeat-one-active .repeat-one { display: block; }
.play-button {
    width: 72px;
    height: 72px;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    background: linear-gradient(145deg, var(--purple), var(--cherry-bright));
    color: white;
    box-shadow: 0 14px 34px rgba(145, 37, 130, .38);
}
.play-button svg { grid-area: 1 / 1; width: 31px; height: 31px; fill: currentColor; }
.play-button .pause-icon { display: none; }
.is-playing .play-button .play-icon { display: none; }
.is-playing .play-button .pause-icon { display: block; }

.utility-row { margin-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.volume-control { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.volume-range { max-width: 170px; }
.sleep-button { min-height: 42px; padding: 0 14px; border-radius: 13px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.sleep-button.active { border-color: rgba(255, 103, 159, .55); background: rgba(127, 15, 53, .26); }
.status-line { min-height: 20px; margin: 15px 0 0; text-align: center; color: var(--muted); font-size: .75rem; }

.playlist-panel {
    min-width: 0;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-2);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.playlist-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 21px 14px; }
.playlist-head h2 { margin: 5px 0 0; font-size: 1.32rem; }
.search-box { margin: 0 18px 14px; position: relative; flex: 0 0 auto; }
.search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-box input { width: 100%; height: 45px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.045); color: var(--text); padding: 0 14px 0 42px; }
.search-box input::placeholder { color: #7f7282; }
.playlist { min-height: 0; overflow-y: auto; padding: 0 10px 14px; scrollbar-width: thin; scrollbar-color: rgba(169,75,255,.55) transparent; }
.playlist::-webkit-scrollbar, .player-panel::-webkit-scrollbar { width: 8px; }
.playlist::-webkit-scrollbar-thumb, .player-panel::-webkit-scrollbar-thumb { background: rgba(169,75,255,.35); border-radius: 999px; }
.track-row {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    text-align: left;
    cursor: pointer;
}
.track-row:hover { background: rgba(255,255,255,.045); }
.track-row.active { background: linear-gradient(90deg, rgba(169,75,255,.18), rgba(127,15,53,.12)); border-color: rgba(190,121,255,.22); }
.track-row.failed { opacity: .45; }
.track-number { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.045); color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.track-row.active .track-number { color: white; background: linear-gradient(145deg, rgba(169,75,255,.72), rgba(127,15,53,.72)); }
.track-meta { min-width: 0; }
.track-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; font-weight: 650; }
.track-sub { display: block; margin-top: 4px; color: var(--muted); font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-state { width: 24px; color: var(--purple-soft); display: grid; place-items: center; font-size: .76rem; }

.drawer-backdrop, .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.68); backdrop-filter: blur(5px); z-index: 70; }
.sleep-modal {
    position: fixed;
    z-index: 80;
    width: min(430px, calc(100vw - 28px));
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(202,143,255,.25);
    border-radius: 24px;
    padding: 22px;
    background: linear-gradient(160deg, #211329, #0c0810 78%);
    box-shadow: 0 35px 100px rgba(0,0,0,.68);
}
.modal-handle { display: none; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-heading h2 { margin: 6px 0 0; }
.timer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 20px; }
.timer-grid button { min-height: 46px; border-radius: 13px; padding: 7px; }
.custom-timer { margin-top: 17px; }
.custom-timer label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .78rem; }
.custom-timer > div { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.custom-timer input { min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.055); color: var(--text); padding: 0 12px; }
.custom-timer button { border-radius: 12px; padding: 0 15px; }
.wide-action { width: 100%; min-height: 46px; border-radius: 13px; margin-top: 12px; background: linear-gradient(90deg, rgba(169,75,255,.28), rgba(127,15,53,.3)); }
.wide-action.secondary { margin-top: 8px; color: var(--muted); background: rgba(255,255,255,.04); }
[hidden] { display: none !important; }

.empty-state { min-height: calc(100dvh - var(--topbar-height)); display: grid; place-content: center; text-align: center; padding: 28px; }
.empty-note { width: 74px; height: 74px; margin: 0 auto 16px; border-radius: 24px; display: grid; place-items: center; font-size: 2rem; background: linear-gradient(145deg, var(--purple), var(--cherry)); }
.empty-state h2 { margin: 0; }
.empty-state p { color: var(--muted); max-width: 560px; line-height: 1.6; }

@media (max-width: 860px) {
    :root { --topbar-height: 66px; }
    .mobile-only { display: grid; }
    .app-main { display: block; padding: 12px; height: calc(100dvh - var(--topbar-height)); }
    .player-panel { height: 100%; overflow-y: auto; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .quote-zone { grid-template-columns: 1fr; }
    .quote-card { min-height: 76px; padding: 13px 15px; }
    .player-card { min-height: auto; padding: 18px 16px 20px; }
    .now-playing { grid-template-columns: 82px minmax(0,1fr); gap: 15px; }
    .disc { width: 82px; }
    .track-copy h2 { font-size: 1.22rem; }
    .progress-block { margin-top: 22px; }
    .transport-controls { gap: 9px; }
    .round-button { width: 47px; height: 47px; }
    .round-button.small { width: 40px; height: 40px; }
    .play-button { width: 66px; height: 66px; }
    .utility-row { align-items: stretch; flex-direction: column; }
    .volume-control { width: 100%; }
    .volume-range { max-width: none; }
    .sleep-button { width: 100%; justify-content: center; }

    .playlist-panel {
        position: fixed;
        z-index: 75;
        left: 10px;
        right: 10px;
        bottom: 10px;
        height: min(78dvh, 720px);
        transform: translateY(calc(100% + 24px));
        transition: transform .24s ease;
        border-radius: 24px;
    }
    body.playlist-open .playlist-panel { transform: translateY(0); }
    body.playlist-open .drawer-backdrop { display: block !important; }
    .playlist-head { padding-top: 18px; }
    .sleep-modal {
        width: auto;
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 10px;
        transform: none;
        border-radius: 24px;
        padding-bottom: max(22px, env(safe-area-inset-bottom));
    }
    .modal-handle { display: block; width: 48px; height: 5px; border-radius: 99px; background: rgba(255,255,255,.18); margin: -7px auto 16px; }
}

@media (max-width: 430px) {
    .brand p { display: none; }
    .text-button { display: none !important; }
    .topbar { padding-left: 12px; padding-right: 12px; }
    .quote-card p { font-size: .82rem; }
    .timer-grid { grid-template-columns: repeat(2, 1fr); }
    .transport-controls { gap: 6px; }
    .round-button { width: 43px; height: 43px; }
    .round-button.small { width: 37px; height: 37px; }
    .play-button { width: 62px; height: 62px; }
}

@media (max-height: 720px) and (min-width: 861px) {
    .quote-card { min-height: 76px; padding: 12px 15px; }
    .player-card { padding: 17px 22px; }
    .disc { width: 88px; }
    .now-playing { grid-template-columns: 88px minmax(0,1fr); }
    .progress-block { margin-top: 18px; }
    .transport-controls { margin-top: 10px; }
    .play-button { width: 62px; height: 62px; }
    .utility-row { margin-top: 13px; }
}
