:root {
    --ink: #ece7dd;
    --ink-dim: #9a958d;
    --ink-faint: #6a665f;
    --gold: #d9b877;
    --teal: #7fd3c4;
    --line: rgba(236, 231, 221, 0.10);
    --panel: rgba(10, 12, 18, 0.72);
    --serif: 'Cormorant Garamond', Georgia, serif;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: #05060a;
    color: var(--ink);
    font-family: var(--sans);
    font-weight: 300;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#ambient {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 0;
}

/* ---------------------------------------------------------------- stage */
.stage {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.2rem;
    padding: 2rem;
    text-align: center;
    pointer-events: none;
}
.stage > * { pointer-events: auto; }

.title-block h1 {
    font-family: var(--serif);
    font-weight: 300;
    font-size: clamp(2.2rem, 6vw, 3.6rem);
    letter-spacing: 0.12em;
    color: var(--ink);
    text-shadow: 0 0 40px rgba(217, 184, 119, 0.25);
}

.tagline {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    letter-spacing: 0.22em;
    text-transform: lowercase;
    color: var(--ink-faint);
}

.readout { line-height: 1.7; }

.readout-key {
    font-family: var(--serif);
    font-size: 1.35rem;
    letter-spacing: 0.08em;
    color: var(--gold);
}

.readout-sub {
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    color: var(--ink-faint);
}

/* --------------------------------------------------------------- play */
.play-btn {
    width: 108px;
    height: 108px;
    border-radius: 50%;
    border: 1px solid rgba(236, 231, 221, 0.18);
    background: rgba(236, 231, 221, 0.03);
    backdrop-filter: blur(8px);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1),
                border-color 1.2s ease, background 1.2s ease, box-shadow 1.2s ease;
}

.play-btn:hover {
    border-color: rgba(217, 184, 119, 0.5);
    box-shadow: 0 0 60px rgba(217, 184, 119, 0.14);
}

.play-btn.on {
    border-color: rgba(127, 211, 196, 0.45);
    background: rgba(127, 211, 196, 0.05);
    box-shadow: 0 0 80px rgba(127, 211, 196, 0.16);
}

.play-btn.loading { opacity: 0.4; pointer-events: none; }

/* Triangle when idle, two bars when sounding. */
.play-glyph {
    width: 0;
    height: 0;
    border-left: 22px solid var(--ink);
    border-top: 14px solid transparent;
    border-bottom: 14px solid transparent;
    margin-left: 6px;
    transition: opacity 0.5s ease;
}

.play-btn.on .play-glyph {
    width: 20px;
    height: 26px;
    margin-left: 0;
    border: none;
    border-left: 6px solid var(--teal);
    border-right: 6px solid var(--teal);
}

/* ------------------------------------------------------------- source */
.source-line {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
}

.link-btn {
    background: none;
    border: none;
    border-bottom: 1px solid rgba(236, 231, 221, 0.2);
    color: var(--ink-dim);
    font: inherit;
    letter-spacing: 0.14em;
    padding: 0 0 2px;
    cursor: pointer;
    transition: color 0.4s ease, border-color 0.4s ease;
}
.link-btn:hover { color: var(--gold); border-color: var(--gold); }

.progress {
    width: min(420px, 70vw);
    height: 1px;
    background: rgba(236, 231, 221, 0.10);
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(to right, var(--teal), var(--gold));
    transition: width 0.6s linear;
}

/* ------------------------------------------------------------- volume */
.volume-bar {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.9rem;
    background: rgba(10, 12, 18, 0.5);
    border: 1px solid var(--line);
    border-radius: 22px;
    backdrop-filter: blur(10px);
    transition: border-color 0.4s ease;
}
.volume-bar:hover { border-color: rgba(217, 184, 119, 0.35); }

.vol-icon {
    font-size: 0.85rem;
    color: var(--ink-faint);
    line-height: 1;
}

.volume-bar input[type=range] { width: 110px; }

.vol-val {
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    color: var(--teal);
    min-width: 2.4em;
    text-align: right;
}

@media (max-width: 620px) {
    .volume-bar { top: auto; bottom: 1.25rem; left: 50%; transform: translateX(-50%); }
    .volume-bar input[type=range] { width: 140px; }
}

/* ------------------------------------------------------------- drawer */
.drawer-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 20;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(10, 12, 18, 0.5);
    backdrop-filter: blur(10px);
    cursor: pointer;
    display: grid;
    place-content: center;
    gap: 4px;
    transition: border-color 0.4s ease;
}
.drawer-toggle:hover { border-color: rgba(217, 184, 119, 0.4); }
.drawer-toggle span {
    display: block;
    width: 16px;
    height: 1px;
    background: var(--ink-dim);
    transition: transform 0.4s ease, opacity 0.4s ease;
}
.drawer-toggle.open span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.drawer-toggle.open span:nth-child(2) { opacity: 0; }
.drawer-toggle.open span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 15;
    width: min(380px, 100vw);
    height: 100%;
    background: var(--panel);
    backdrop-filter: blur(24px);
    border-left: 1px solid var(--line);
    transform: translateX(100%);
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.drawer.open { transform: translateX(0); }

.drawer-inner { padding: 4.5rem 1.5rem 3rem; }

.preset-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    margin-bottom: 1.75rem;
}

.preset {
    padding: 0.55rem 0.4rem;
    font: inherit;
    font-size: 0.7rem;
    letter-spacing: 0.09em;
    color: var(--ink-dim);
    background: rgba(236, 231, 221, 0.03);
    border: 1px solid var(--line);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.4s ease;
}
.preset:hover { color: var(--ink); border-color: rgba(217, 184, 119, 0.35); }
.preset.on {
    color: var(--gold);
    border-color: rgba(217, 184, 119, 0.55);
    background: rgba(217, 184, 119, 0.07);
}

/* -------------------------------------------------------------- groups */
.group { border-top: 1px solid var(--line); }
.group summary {
    position: relative;
    padding: 0.9rem 1.5rem 0.9rem 0;
    font-size: 0.7rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--ink-faint);
    cursor: pointer;
    list-style: none;
    transition: color 0.3s ease;
}
.group summary::-webkit-details-marker { display: none; }

/* Without this a collapsed group is indistinguishable from a plain heading —
   there is nothing to suggest it opens, so whole sections read as missing. */
.group summary::after {
    content: '';
    position: absolute;
    right: 4px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: translateY(-70%) rotate(45deg);
    transition: transform 0.3s ease;
    opacity: 0.8;
}
.group[open] summary::after { transform: translateY(-25%) rotate(-135deg); }
.group summary:hover { color: var(--gold); }
.group[open] summary { color: var(--ink-dim); }

.ctrl { margin-bottom: 1.15rem; }

.ctrl-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    font-size: 0.76rem;
    color: var(--ink-dim);
    margin-bottom: 0.45rem;
}
.ctrl-head em {
    font-style: normal;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--teal);
    white-space: nowrap;
}

.action-btn {
    width: 100%;
    padding: 0.7rem;
    font: inherit;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    color: var(--gold);
    background: rgba(217, 184, 119, 0.07);
    border: 1px solid rgba(217, 184, 119, 0.35);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.35s ease;
}
.action-btn:hover:not(:disabled) {
    background: rgba(217, 184, 119, 0.15);
    border-color: rgba(217, 184, 119, 0.6);
}
.action-btn:disabled { opacity: 0.55; cursor: progress; }

.hint {
    margin-top: 0.4rem;
    font-size: 0.66rem;
    line-height: 1.55;
    color: var(--ink-faint);
}

/* -------------------------------------------------------------- inputs */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 18px;
    background: transparent;
    cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
    height: 1px;
    background: rgba(236, 231, 221, 0.18);
}
input[type=range]::-moz-range-track {
    height: 1px;
    background: rgba(236, 231, 221, 0.18);
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 11px;
    height: 11px;
    margin-top: -5px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 10px rgba(217, 184, 119, 0.5);
    transition: transform 0.25s ease;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.35); }
input[type=range]::-moz-range-thumb {
    width: 11px;
    height: 11px;
    border: none;
    border-radius: 50%;
    background: var(--gold);
}

select {
    width: 100%;
    padding: 0.45rem 0.5rem;
    font: inherit;
    font-size: 0.78rem;
    color: var(--ink);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
select:focus { border-color: rgba(217, 184, 119, 0.5); }
select option { background: #0b0d13; }

.ctrl-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.76rem;
    color: var(--ink-dim);
    cursor: pointer;
}
.ctrl-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.ctrl-toggle i {
    width: 30px;
    height: 15px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.4);
    position: relative;
    flex: none;
    transition: background 0.35s ease, border-color 0.35s ease;
}
.ctrl-toggle i::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ink-faint);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), background 0.35s ease;
}
.ctrl-toggle input:checked + i { border-color: rgba(127, 211, 196, 0.5); background: rgba(127, 211, 196, 0.12); }
.ctrl-toggle input:checked + i::after { transform: translateX(15px); background: var(--teal); }

.footnote {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
    font-size: 0.68rem;
    line-height: 1.7;
    color: var(--ink-faint);
}

/* ---------------------------------------------------------- drop veil */
.drop-veil {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    background: rgba(5, 6, 10, 0.85);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.drop-veil.on { opacity: 1; }
.drop-veil span {
    font-family: var(--serif);
    font-size: 1.6rem;
    letter-spacing: 0.2em;
    color: var(--gold);
    padding: 3rem 5rem;
    border: 1px dashed rgba(217, 184, 119, 0.4);
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(236, 231, 221, 0.12); border-radius: 3px; }

/* The settings panel is much taller than the screen. Its scrollbar needs to be
   visible enough to say so. */
.drawer::-webkit-scrollbar { width: 8px; }
.drawer::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.25); }
.drawer::-webkit-scrollbar-thumb {
    background: rgba(217, 184, 119, 0.28);
    border-radius: 4px;
}
.drawer::-webkit-scrollbar-thumb:hover { background: rgba(217, 184, 119, 0.5); }
.drawer { scrollbar-color: rgba(217, 184, 119, 0.35) rgba(0, 0, 0, 0.25); }

@media (max-width: 620px) {
    .drawer { width: 100vw; }
    .stage { gap: 1.6rem; }
    .play-btn { width: 88px; height: 88px; }
}
