:root {
    --bg: #fafafa;
    --fg: #1a1a1a;
    --muted: #6b6b6b;
    --line: #dddddd;
    --accent: #2563eb;
    --error: #b91c1c;
    --warn: #a16207;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161616;
        --fg: #ececec;
        --muted: #9a9a9a;
        --line: #333333;
        --accent: #60a5fa;
        --error: #f87171;
        --warn: #facc15;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0 auto;
    max-width: 960px;
    /* Keep content clear of the notch and home indicator on iPhones. */
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
             max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { margin: 0; font-size: 1.5rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.muted { color: var(--muted); }

#media-list { list-style: none; padding: 0; margin: 0; }
.media-item {
    display: flex;
    flex-wrap: wrap;                /* actions drop below the name on narrow screens */
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.media-item button {
    padding: 0.75rem 1rem;          /* big enough to tap comfortably */
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.media-item .play {
    flex: 1 1 16rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    text-align: left;
}
.media-item .play.selected { border-color: var(--accent); outline: 1px solid var(--accent); }
.media-item .meta { white-space: nowrap; }
.media-item .actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.media-item progress { width: 8rem; }
.media-item .progress-text { font-size: 0.85rem; font-variant-numeric: tabular-nums; }

video {
    width: 100%;
    margin-top: 1rem;
    background: #000;
    border-radius: 8px;
    aspect-ratio: 16 / 9;
}

.status {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
    font-size: 0.9rem;
}
.status dt { color: var(--muted); }
.status dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

details { margin-top: 1.5rem; }
details summary { cursor: pointer; font-weight: 600; }

.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.buttons button {
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}
#debug-log {
    margin: 0.5rem 0 0;
    padding: 0.5rem;
    list-style: none;
    max-height: 40vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
}
#debug-log li { white-space: pre-wrap; overflow-wrap: anywhere; }
#debug-log .warn { color: var(--warn); }
#debug-log .error { color: var(--error); }
