:root {
    color-scheme: light;

    /* As usolder.com: white, black text, light grey borders, black buttons. */
    --background: #ffffff;
    --surface: #ffffff;
    --surface-raised: #f5f5f5;
    --border: #dfdfdf;
    --text: #000000;
    --muted: rgb(0 0 0 / 0.6);
    --accent: #000000;
    --accent-hover: #262626;
    --accent-text: #ffffff;
    --danger: #c62828;

    --radius: 16px;
    --button-radius: 14px;
    --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--text);
    font: 15px/1.5 var(--font);
}

h1, h2, p {
    margin: 0;
}

.bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.brand span {
    color: var(--muted);
    font-weight: 500;
}

.actions, .card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border: 1px solid var(--text);
    border-radius: var(--button-radius);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.button:disabled {
    opacity: 0.5;
    cursor: default;
}

.button:disabled:hover {
    background: inherit;
}

.button:hover {
    background: rgb(0 0 0 / 0.15);
}

.button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.card-actions .button {
    padding-inline: 12px;
}

.button.primary-action,
.button[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.button.primary-action:hover,
.button[aria-pressed="true"]:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 20px;
    padding: 20px;
    max-width: 1500px;
    margin: 0 auto;
}

/*
 * The device: layered renders, each part placed by device/device.css. From
 * the back: the buttons (so a press sinks them into the case), the screen,
 * the body with its screen-shaped hole, then the knobs and the invisible
 * areas that take clicks and touches.
 */

.device {
    align-self: start;
    min-width: 0;
    touch-action: none;
}

.device-art {
    position: relative;
    /* As wide as fits, and never taller than the window. */
    width: min(100%, calc((100vh - 110px) * var(--art-ratio)));
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
}

.device-art img {
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
}

.device.dragging .device-art {
    outline: 3px dashed var(--accent);
    outline-offset: 6px;
    border-radius: 28px;
}

.device:fullscreen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.device:fullscreen .device-art {
    width: min(100vw, calc(100vh * var(--art-ratio)));
}

.device-body {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
}

.screen-frame {
    position: absolute;
    left: var(--screen-x);
    top: var(--screen-y);
    z-index: 1;
    width: var(--screen-width);
    height: var(--screen-height);
    overflow: hidden;
    background: #000;
}

/* Positioned, so the canvas's 800-pixel size never stops the screen shrinking. */
#screen {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    text-align: center;
    background: rgb(8 10 13 / 0.88);
    color: #ffffff;
}

/* On the device's screen, so light on dark whatever the page's colours. */
.overlay .button.primary-action {
    background: #ffffff;
    border-color: #ffffff;
    color: #000000;
}

.overlay[hidden] {
    display: none;
}

.overlay-title {
    font-size: 22px;
    font-weight: 650;
}

.overlay-detail {
    max-width: 52ch;
    color: rgb(255 255 255 / 0.7);
    overflow-wrap: anywhere;
}

.overlay.error .overlay-title {
    color: #ff6b6b;
}

/* Sliders: 0 at the bottom of travel, 100 at the top, as on the device. */

.slider {
    position: absolute;
    left: calc(var(--knob-x) - var(--knob-width) / 2);
    top: var(--travel-y);
    z-index: 3;
    width: calc(var(--knob-width) * 2);
    height: var(--travel-height);
    cursor: ns-resize;
    outline: none;
    touch-action: none;
}

/* Exactly where the knob runs; the slider around it is a wider target. */
.slider-track {
    position: absolute;
    left: 25%;
    top: 0;
    width: 50%;
    height: 100%;
}

.slider-thumb {
    --position: 0.5;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: var(--knob-height);
    /* Moved on its own layer, so nothing beneath is repainted as it slides. */
    transform: translateY(calc((1 - var(--position)) * var(--knob-span) * 100%));
    will-change: transform;
}

.slider:focus-visible .slider-thumb {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 3px;
}

/* The buttons sit on the top edge; each takes clicks over the bezel below it too. */
.button-art {
    position: absolute;
    z-index: 0;
    transition: transform 40ms ease-out;
}

.button-art.down {
    transform: translateY(var(--button-sink));
}

.hardware-button {
    position: absolute;
    left: calc(var(--button-x) - var(--button-width) / 4);
    top: 0;
    z-index: 3;
    width: calc(var(--button-width) * 1.5);
    height: var(--button-reach);
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.hardware-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Side panel */

.panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.card[hidden] {
    display: none;
}

.card h2 {
    margin-bottom: 8px;
    font-size: 16px;
}

.card > p + p, .card > p + dl, .card > dl + .card-actions {
    margin-top: 10px;
}

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

.small {
    margin-top: 10px;
    font-size: 13px;
}

.facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
    margin: 12px 0 0;
    font-size: 13px;
}

.facts dt {
    color: var(--muted);
}

.facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.library {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.library button {
    width: 100%;
    justify-content: space-between;
}

.library button.current {
    border-color: var(--accent);
}

.controls {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.controls th {
    padding: 4px 0;
    color: var(--muted);
    font-weight: 500;
    text-align: left;
}

.controls td {
    text-align: right;
}

kbd {
    display: inline-block;
    min-width: 22px;
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface-raised);
    font: 12px/1.6 var(--font);
    text-align: center;
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
        padding: 16px;
    }
}

@media (max-width: 600px) {
    .bar {
        padding: 10px 16px;
    }

    .overlay-title {
        font-size: 17px;
    }
}
