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

/* Tokens shared with mslv.space. */
:root {
    --fg: #3F3A39;
    --bg: #EDF2F4;
    /* Secondary text: the lowest opacity that still gives 4.5:1 contrast on --bg. */
    --muted: 0.74;
    --line: color-mix(in srgb, var(--fg) 28%, transparent);
    --gutter: 2rem;
}

html {
    font-size: 13px;
    -webkit-text-size-adjust: 100%;
    scrollbar-width: thin;
    scrollbar-color: rgb(63 58 57 / 0.25) transparent;
}

body {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    font-family: 'Geist', system-ui, sans-serif;
    line-height: 1.5;
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'tnum';
}

::selection {
    background: var(--fg);
    color: var(--bg);
}

.muted {
    opacity: var(--muted);
}

a {
    color: inherit;
    text-decoration: none;
    padding-bottom: 1px;
    background: repeating-linear-gradient(90deg, color-mix(in srgb, currentColor 45%, transparent) 0 1px, transparent 1px 3px) no-repeat 0 100% / 100% 1px;
}

a:hover {
    background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 100% 1px;
}

[hidden] {
    display: none !important;
}

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

button {
    background: none;
    border: 0;
    cursor: inherit;
}

:focus-visible {
    outline: 1px solid var(--fg);
    outline-offset: 2px;
}

/* Cursors from mslv.space: the favicon arrow, tilted over anything clickable. */
@media (hover: hover) and (pointer: fine) {
    html {
        cursor: url("/img/cursor/cursor.png") 1 1, auto;
        cursor: image-set(url("/img/cursor/cursor.png") 1x, url("/img/cursor/cursor@2x.png") 2x) 1 1, auto;
    }

    a, button, select, label, input[type="range"], input[type="color"] {
        cursor: url("/img/cursor/cursor-pointer.png") 1 1, pointer;
        cursor: image-set(url("/img/cursor/cursor-pointer.png") 1x, url("/img/cursor/cursor-pointer@2x.png") 2x) 1 1, pointer;
    }

    a:active, button:active {
        cursor: url("/img/cursor/cursor-press.png") 1 1, pointer;
        cursor: image-set(url("/img/cursor/cursor-press.png") 1x, url("/img/cursor/cursor-press@2x.png") 2x) 1 1, pointer;
    }
}

/* ─── Header ─────────────────────────────────────────────────────────────────────── */
.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: var(--gutter) var(--gutter) 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 500;
    background: none;
}

.brand:hover {
    background: none;
}

.brand .muted {
    font-weight: 400;
}

/* Segmented toggles, as on mslv.space: a thin frame, the chosen option filled. */
.langs,
.seg {
    display: inline-flex;
    border: 1px solid var(--line);
}

.langs button,
.seg button {
    padding: 0.2rem 0.65rem;
    opacity: var(--muted);
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.langs button:hover,
.seg button:hover {
    opacity: 1;
    background-color: color-mix(in srgb, var(--fg) 8%, transparent);
}

.langs [aria-pressed="true"],
.seg [aria-pressed="true"] {
    opacity: 1;
    background: var(--fg);
    color: var(--bg);
}


/* ─── Layout ─────────────────────────────────────────────────────────────────────── */
.app {
    display: grid;
    grid-template-columns: 17rem minmax(0, 1fr);
    gap: 3rem;
    padding: 2.5rem var(--gutter);
    min-height: 0;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
}

fieldset {
    border: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
}

legend {
    padding: 0 0 0.6rem;
    float: left;
    width: 100%;
}

legend .muted,
legend output,
.slider output {
    margin-left: 0.4rem;
}

/* Four equal options across the panel. */
.seg-fill {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}

.seg-fill button {
    padding: 0.35rem 0;
    font-size: 0.92rem;
}

.slider {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.row .ghost {
    flex: 1;
    padding: 0.3rem 0.5rem;
}

select {
    width: 100%;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.3rem 1.2rem 0.3rem 0;
    border-radius: 0;
    outline-offset: 3px;
    appearance: none;
    background: no-repeat right 0.1rem center / 8px 5px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 5'%3E%3Cpath d='M0 0h8L4 5z' fill='%233F3A39'/%3E%3C/svg%3E");
}

select:hover {
    border-bottom-color: var(--fg);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--fg);
}

.note {
    font-size: 0.92rem;
}

.swatches {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0.4rem;
}

.swatch {
    aspect-ratio: 1;
    border: 1px solid var(--line);
    background: linear-gradient(135deg, var(--ink) 0 50%, var(--paper) 50% 100%);
}

.swatch[aria-checked="true"] {
    outline: 1px solid var(--fg);
    outline-offset: 2px;
}

.swatch.custom {
    background: conic-gradient(from 45deg, var(--ink) 0 50%, var(--paper) 50% 100%);
}

.custom-colors {
    display: flex;
    gap: 1.2rem;
}

.custom-colors label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

input[type="color"] {
    width: 1.6rem;
    height: 1.6rem;
    border: 1px solid var(--line);
    background: none;
    padding: 0;
}

/* ─── Stage ──────────────────────────────────────────────────────────────────────── */
.stage {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: 70vh;
    background: var(--bg);
    border: 1px solid var(--line);
}

.frame canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.frame.dragging {
    outline: 1px solid var(--fg);
    outline-offset: 4px;
}

/* In full screen the picture is everything; the cursor hides when idle. */
.frame:fullscreen {
    max-height: none;
    aspect-ratio: auto;
    border: 0;
}

.frame:fullscreen.idle {
    cursor: none;
}

.empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1.5rem;
    text-align: center;
    pointer-events: none;
}

.empty > * {
    background: var(--bg);
    padding: 0.15rem 0.5rem;
}

.empty .primary {
    pointer-events: auto;
    margin-top: 0.6rem;
    padding: 0.5rem 1rem;
}

.empty-title {
    font-weight: 500;
    font-size: 1.15rem;
}

.drop-hint,
.fail {
    position: absolute;
    left: 0.75rem;
    top: 0.75rem;
    background: var(--fg);
    color: var(--bg);
    padding: 0.2rem 0.6rem;
}

.meta {
    min-height: 1.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.transport {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.transport input[type="range"] {
    flex: 1;
    min-width: 8rem;
}

.transport output {
    min-width: 6.5rem;
    text-align: right;
}

.primary,
.ghost {
    padding: 0.5rem 1rem;
    border: 1px solid var(--fg);
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.primary {
    background: var(--fg);
    color: var(--bg);
}

.primary:hover {
    background: color-mix(in srgb, var(--fg) 86%, var(--bg));
}

.ghost {
    border-color: var(--line);
}

.ghost:hover {
    border-color: var(--fg);
}

.ghost.small {
    padding: 0.15rem 0.6rem;
}

.toggle[aria-pressed="true"] {
    background: var(--fg);
    color: var(--bg);
    border-color: var(--fg);
}

button:disabled {
    opacity: 0.4;
}

#play {
    min-width: 6.5rem;
}

/* ─── Playlist ───────────────────────────────────────────────────────────────────── */
.queue {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.queue-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.queue-head > span {
    margin-right: auto;
}

.tracks {
    list-style: none;
    border-top: 1px solid var(--line);
    max-height: 15rem;
    overflow-y: auto;
}

.tracks li {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--line);
}

.tracks .pick {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 0.8rem;
    padding: 0.35rem 0;
    text-align: left;
    opacity: var(--muted);
}

.tracks .pick:hover,
.tracks [aria-current="true"] .pick {
    opacity: 1;
}

.tracks [aria-current="true"] .pick {
    font-weight: 500;
}

.tracks .n {
    width: 1.6rem;
    flex: none;
    opacity: var(--muted);
}

.tracks .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tracks .drop {
    padding: 0.35rem 0.5rem;
    opacity: 0.5;
}

.tracks .drop:hover {
    opacity: 1;
}

.hint {
    font-size: 0.92rem;
}

.foot {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 0 var(--gutter) var(--gutter);
}

/* ─── Narrow screens: picture first, settings after ─────────────────────────────── */
@media (max-width: 800px) {
    :root {
        --gutter: 16px;
    }

    .brand .muted {
        display: none;
    }

    .app {
        grid-template-columns: minmax(0, 1fr);
        gap: 2rem;
        padding-top: 1.5rem;
    }

    .stage {
        order: -1;
    }

    .frame {
        aspect-ratio: 1;
    }

    .hint {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

.volume {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.volume input[type="range"] {
    width: 6rem;
    min-width: 0;
    flex: none;
}

.volume .ghost {
    min-width: 5.6rem;
}
