*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden;
  background:
    radial-gradient(60% 40% at 90% 0%, rgba(225, 29, 60, 0.14), transparent 70%),
    radial-gradient(50% 35% at 0% 40%, rgba(25, 240, 224, 0.07), transparent 70%),
    var(--bg);
  min-height: 100vh;
}
main, .top, .foot { width: 100%; max-width: 920px; margin: 0 auto; padding: 0 16px; }
section { margin: 28px 0; }
h1, h2 { line-height: 1.15; margin: 0 0 12px; }
h1 { font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 750; letter-spacing: -0.02em; }
h2 { font-size: 0.78rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
p { margin: 0 0 14px; }
a { color: var(--aqua); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--aqua); outline-offset: 3px; }

/* header */
.top { display: flex; align-items: center; gap: 12px; padding-top: 20px; padding-bottom: 14px; }
.logo { color: var(--text); font-weight: 750; letter-spacing: 0.02em; display: inline-flex; align-items: center; gap: 10px; }
.logo:hover { text-decoration: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 14px var(--red); }
.by { color: var(--muted); font-size: 0.85rem; margin-left: auto; }
.pill { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--red); border: 1px solid var(--red); border-radius: 999px; padding: 3px 10px; }

/* hero and copy */
.hero { margin-top: 36px; }
.intro p { max-width: 66ch; color: #d9d9e0; }
.fine { font-size: 0.85rem; color: var(--muted); }

/* cards */
.card { background: linear-gradient(180deg, var(--panel), #0b0b0e); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.about p { max-width: 66ch; color: #d9d9e0; }

/* player */
.stage { position: relative; border-radius: 14px; overflow: hidden; background: #000; border: 1px solid var(--line); min-height: 140px; display: grid; place-items: center; }
.stage canvas, .stage video { width: 100%; height: auto; display: block; }
.stage audio { display: none; }
.empty { color: var(--muted); padding: 40px 16px; margin: 0; }
.transport { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, var(--red), #8f0f24); box-shadow: 0 8px 22px rgba(225, 29, 60, 0.35); flex: none; }
.round svg { width: 22px; height: 22px; fill: currentColor; }
.round:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
.scrub { flex: 1 1 280px; min-width: 0; }
.scrub .meta { display: flex; justify-content: space-between; gap: 12px; font-size: 0.88rem; margin-bottom: 6px; }
#now-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
#time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.vol { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.85rem; }
.vol input { width: 110px; }
.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; font: inherit; font-size: 0.85rem; }
.ghost:hover { border-color: var(--aqua); color: var(--aqua); }
.row { margin-top: 14px; }

/* custom range */
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin: 8px 0; border-radius: 999px; outline: none; cursor: pointer;
  background: linear-gradient(90deg, var(--red) var(--p, 0%), var(--line) var(--p, 0%));
}
input[type="range"]:disabled { opacity: 0.4; cursor: default; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(25, 240, 224, 0.25); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(25, 240, 224, 0.25); }
input[type="range"]::-moz-range-track { background: transparent; }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.9rem; color: var(--muted); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.knob { position: relative; width: 44px; height: 24px; border-radius: 999px; background: var(--line); transition: background 0.2s; }
.knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch input:checked + .knob { background: var(--aqua); }
.switch input:checked + .knob::after { transform: translateX(20px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--aqua); outline-offset: 3px; }

/* playlist */
.list { list-style: none; padding: 0; margin: 16px 0 0; border-top: 1px solid var(--line); }
.list li { border-bottom: 1px solid var(--line); }
.list button { width: 100%; display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; text-align: left; background: none; border: 0; color: var(--text); padding: 12px 6px; font: inherit; cursor: pointer; border-radius: 10px; }
.list button:hover { background: rgba(255, 255, 255, 0.03); }
.list .num { color: var(--red); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.list .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.list button[aria-current="true"] .title { color: var(--aqua); font-weight: 650; }

/* upload */
.upform { display: grid; gap: 14px; max-width: 520px; }
.filerow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pick { cursor: pointer; border: 1px dashed var(--red); color: var(--text); border-radius: 12px; padding: 12px 18px; font-weight: 600; }
.pick:hover { background: rgba(225, 29, 60, 0.08); }
.btn { justify-self: start; font: inherit; font-weight: 700; color: #fff; background: linear-gradient(145deg, var(--red), #8f0f24); border: 0; border-radius: 999px; padding: 11px 26px; cursor: pointer; box-shadow: 0 8px 20px rgba(225, 29, 60, 0.3); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
#barFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--red), var(--aqua)); transition: width 0.2s; }
.msg { margin: 0; font-size: 0.92rem; min-height: 1.4em; }

/* AI zone */
.ai-zone { border: 1px dashed var(--aqua); background: rgba(25, 240, 224, 0.04); }
.ai-zone ul { padding-left: 20px; margin: 10px 0 0; color: #d9d9e0; }
.tag { display: inline-block; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; border-radius: 6px; padding: 2px 8px; margin-right: 6px; vertical-align: middle; }
.tag.ai { background: rgba(25, 240, 224, 0.12); color: var(--aqua); border: 1px solid var(--aqua); }
.tag.wait { background: rgba(225, 29, 60, 0.12); color: var(--red); border: 1px solid var(--red); }

.foot { border-top: 1px solid var(--line); margin-top: 40px; padding-top: 16px; padding-bottom: 40px; color: var(--muted); font-size: 0.85rem; }
.foot p { margin: 0 0 6px; }

@media (max-width: 520px) {
  .card { padding: 18px; }
  .list .meta { display: none; }
  .by { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* header nav and logo */
.logo img { width: 34px; height: 34px; display: block; border-radius: 6px; }
.logo span { white-space: nowrap; }
.nav { display: flex; gap: 14px; margin-left: auto; }
.nav a { color: var(--muted); font-size: 0.88rem; text-decoration: none; padding: 4px 2px; border-bottom: 1px solid transparent; }
.nav a:hover, .nav a:focus-visible { color: var(--text); border-bottom-color: var(--red); }
.top .pill { margin-left: 4px; }
@media (max-width: 520px) { .nav { display: none; } }

/* storage notice and usage */
.notice { margin-top: 14px; font-size: 0.86rem; color: #c9c9d2; border-left: 2px solid var(--red); padding: 8px 12px; background: rgba(225, 29, 60, 0.06); border-radius: 0 8px 8px 0; }
.notice:empty { display: none; }
#usage { margin-top: -6px; }

/* labs */
.labs-list { padding-left: 20px; margin: 10px 0 0; color: #d9d9e0; display: grid; gap: 8px; }
.labs-list li::marker { color: var(--aqua); }

/* support and heart */
.donate { border: 1px solid var(--red); background: linear-gradient(180deg, rgba(225, 29, 60, 0.07), transparent); }
.donate:not([hidden]) { animation: rise 0.25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sig { display: flex; align-items: center; gap: 8px; color: var(--muted); letter-spacing: 0.02em; }
.sig span { color: var(--text); font-weight: 600; }
.heart { background: none; border: 0; padding: 0 2px; font-size: 0.95rem; cursor: pointer; line-height: 1; filter: grayscale(1) brightness(0.8); transition: transform 0.15s ease; }
.heart:hover, .heart:focus-visible { transform: scale(1.15); filter: none; }
.heart[aria-expanded="true"] { transform: scale(1.15); }

/* hover-warmed links get a subtle cue */
[data-preload]:hover { color: var(--text); }

/* v2: install, skip link, copy section, mobile-first polish */
.skip { position: absolute; left: -9999px; top: 0; background: var(--red); color: #fff; padding: 8px 12px; border-radius: 0 0 8px 0; z-index: 10; }
.skip:focus { left: 0; }
.install { cursor: pointer; font: inherit; color: var(--aqua); border-color: var(--aqua); background: transparent; }
.install:hover { background: rgba(25, 240, 224, 0.1); }
.copy p, .copy h2 { max-width: 66ch; }
.copy p { color: #d9d9e0; }
.top { padding-top: max(20px, env(safe-area-inset-top)); }
main, .foot { padding-bottom: env(safe-area-inset-bottom); }
button, .pick, .nav a, .list button, .switch { min-height: 44px; }
.round { min-height: 52px; min-width: 52px; }
.heart { min-height: 44px; min-width: 44px; display: inline-grid; place-items: center; }
@media (hover: none) { .heart:hover { transform: none; } }
@media (max-width: 380px) { h1 { font-size: 1.85rem; } .top .pill { display: none; } }

/* ---- Labs, shrinking header, settings, sticky dock, reading options ---- */
.top { position: sticky; top: 0; z-index: 20; background: rgba(6, 6, 7, 0.82); backdrop-filter: blur(10px); transition: padding 0.25s ease, background 0.25s ease; }
.top.shrink { padding-top: 6px; padding-bottom: 6px; }
.top.shrink .logo img { width: 22px; height: 22px; }
.top.shrink .logo span { font-size: 0.9rem; }
.top.shrink .nav { display: none; }
.top { flex-wrap: wrap; }
.cog { min-width: 44px; min-height: 44px; border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 999px; display: grid; place-items: center; cursor: pointer; }
.cog svg { width: 20px; height: 20px; fill: currentColor; }
.cog:hover { border-color: var(--aqua); color: var(--aqua); }
.labs { border-color: var(--aqua); background: linear-gradient(160deg, rgba(25, 240, 224, 0.06), rgba(225, 29, 60, 0.05)); }
.lab-tag { font-family: ui-monospace, Consolas, monospace; color: var(--aqua); font-size: 0.85rem; margin: 0 0 4px; }
.labs-title { font-size: 1.6rem; color: var(--text); text-transform: none; letter-spacing: -0.01em; }
.lab-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 16px; }
@media (min-width: 640px) { .lab-grid { grid-template-columns: 1fr 1fr; } }
.lab-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: rgba(0, 0, 0, 0.3); }
.lab-card h3 { margin: 4px 0 6px; font-size: 1.05rem; }
.lab-card p { margin: 0 0 6px; color: #d9d9e0; }
.lab-id { font-family: ui-monospace, Consolas, monospace; color: var(--red); font-size: 0.75rem; letter-spacing: 0.1em; }
.lab-state { color: var(--aqua) !important; font-size: 0.82rem; }
.lab-options h3 { font-size: 0.95rem; margin: 18px 0 6px; color: var(--muted); }
.ai-deep { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 12px; }
.ai-deep summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; min-height: 44px; display: flex; align-items: center; }
.ai-deep ul { padding-left: 20px; color: #d9d9e0; }

/* sticky dock (appears when the player scrolls away) */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(12, 12, 15, 0.94); border-top: 1px solid var(--aqua); backdrop-filter: blur(10px); }
.dock[hidden] { display: none; }
.dock-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 0.92rem; }
.round.small { width: 44px; height: 44px; min-width: 44px; min-height: 44px; box-shadow: none; }
.ghost.small { padding: 8px 12px; min-height: 44px; }
html[data-dock="off"] .dock { display: none !important; }

/* settings panel */
.settings { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(92vw, 460px); max-height: 86vh; }
.settings::backdrop { background: rgba(0, 0, 0, 0.6); }
.settings-inner { padding: 22px; display: grid; gap: 14px; }
.settings h2 { font-size: 1.1rem; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; }
.settings fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.settings legend { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 6px; padding: 0; }
.opt { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; cursor: pointer; font-size: 0.95rem; }
.opt input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--aqua); flex: none; }
.opt .why { display: block; color: var(--muted); font-size: 0.8rem; }
.settings-actions { display: flex; justify-content: space-between; gap: 10px; }

/* reading and display options (set on <html>) */
html[data-text="large"] { font-size: 19px; }
html[data-spacing="relaxed"] body { line-height: 1.9; letter-spacing: 0.02em; word-spacing: 0.08em; }
html[data-font="dyslexic"] body, html[data-font="dyslexic"] h1, html[data-font="dyslexic"] h2 { font-family: Verdana, "Trebuchet MS", Arial, sans-serif; text-align: left; letter-spacing: 0.04em; word-spacing: 0.12em; }
html[data-contrast="high"] { --bg: #000; --panel: #000; --line: #fff; --text: #fff; --muted: #e6e6e6; --red: #ff3b5c; --aqua: #5cffef; }
html[data-contrast="high"] .card, html[data-contrast="high"] .lab-card { border-width: 2px; }
html[data-focus="on"] .labs, html[data-focus="on"] .ai-zone, html[data-focus="on"] .about, html[data-focus="on"] .copy, html[data-focus="on"] .hero, html[data-focus="on"] .upload, html[data-focus="on"] .nav { display: none; }
html[data-focus="on"] .player { margin-top: 24px; }
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
html[data-motion="reduce"] .top.shrink { backdrop-filter: none; }
@media (prefers-reduced-motion: reduce) { html:not([data-motion="off"]) .donate { animation: none; } }

/* expandable copy: a real button-like summary, keyboard and screen reader friendly */
.expand { margin-top: 12px; }
.expand > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--aqua); border-radius: 999px; color: var(--aqua); font-weight: 600; font-size: 0.92rem; }
.expand > summary::-webkit-details-marker { display: none; }
.expand > summary::after { content: "+"; font-size: 1.1rem; line-height: 1; }
.expand[open] > summary::after { content: "-"; }
.expand > summary:hover, .expand > summary:focus-visible { background: rgba(25, 240, 224, 0.1); }
.expand[open] > *:not(summary) { margin-top: 12px; }
.ai-deep > summary { min-height: 44px; }

/* owner counts page */
.owner { max-width: 760px; margin: 0 auto; padding: 24px 16px; }
.owner-h { font-size: 1.5rem; margin: 0 0 8px; }
.owner-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 16px 0; }
.owner-form .field { flex: 1 1 220px; display: grid; gap: 4px; color: var(--muted); font-size: 0.9rem; }
.owner-form input { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-height: 44px; }
.owner section { margin: 24px 0; }
.bar-row { display: grid; grid-template-columns: 9rem 1fr 3rem; gap: 10px; align-items: center; margin: 6px 0; font-size: 0.9rem; }
.bar-track { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--aqua)); }
.bar-num { text-align: right; font-variant-numeric: tabular-nums; }
.owner-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.owner-table th, .owner-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }

/* owner library editor */
.lib-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; margin-bottom: 12px; background: var(--panel); }
.lib-meta { margin: 0; font-size: 0.8rem; color: var(--muted); word-break: break-all; }
.lib-card input[type="text"], .lib-card input:not([type]) { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-height: 44px; width: 100%; }
.btn.small { padding: 8px 18px; min-height: 44px; }
.lab-card select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-height: 44px; }
.lab-card .field { display: grid; gap: 4px; color: var(--muted); font-size: 0.9rem; margin: 6px 0; }
.lab-card .opt { min-height: 44px; display: flex; align-items: center; gap: 10px; }
.lab-card .opt input { width: 22px; height: 22px; accent-color: var(--aqua); }

/* upload and text helpers */
.drop-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(6, 6, 7, 0.82); border: 2px dashed var(--aqua); pointer-events: none; }
.drop-overlay[hidden] { display: none; }
.drop-overlay p { font-size: 1.6rem; font-weight: 700; color: var(--aqua); margin: 0; }
.draft-banner { position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 40; background: var(--panel); border: 1px solid var(--aqua); border-radius: 14px; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.draft-banner p { margin: 0; flex: 1 1 220px; font-size: 0.95rem; }
.draft-banner .btn, .draft-banner .ghost { min-height: 44px; }
.leave-dialog { background: var(--panel); color: var(--text); border: 1px solid var(--red); border-radius: 18px; padding: 22px; width: min(92vw, 420px); }
.leave-dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.leave-dialog h2 { font-size: 1.1rem; text-transform: none; letter-spacing: 0; margin: 0 0 8px; color: var(--text); }
.leave-dialog p { color: #d9d9e0; }
.leave-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.edit-toggle { position: fixed; left: 12px; bottom: 16px; z-index: 50; min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--aqua); background: var(--panel); color: var(--aqua); font: inherit; font-weight: 600; cursor: pointer; }
[data-cms].editing { outline: 2px dashed var(--aqua); outline-offset: 4px; border-radius: 4px; cursor: text; }
.toast { position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%); z-index: 70; background: var(--panel); border: 1px solid var(--aqua); border-radius: 999px; padding: 10px 18px; font-size: 0.9rem; }
.archive { max-width: 760px; margin: 0 auto; padding: 24px 16px; }
.archive-stage { margin-top: 16px; }
.archive-stage video { width: 100%; display: block; }
