:root {
  color-scheme: dark;
  --bg: #0e1210;
  --panel: rgba(18, 24, 21, 0.86);
  --ink: #f4f0e6;
  --muted: #b3aa9a;
  --gold: #dcaf5b;
  --line: rgba(244, 240, 230, 0.1);
  --live: #ff5a36;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1000px 420px at 0% -10%, rgba(220, 175, 91, 0.14), transparent 50%),
    var(--bg);
  font-family: Outfit, "Avenir Next", "Segoe UI", sans-serif;
  font-weight: 380;
}

button, input, select { font: inherit; color: inherit; }
input[type="range"] { accent-color: var(--gold); width: 100%; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.brand {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
  letter-spacing: -0.03em;
}
.brand span, .kicker, .lamp, .listeners, .hint, .time, .nextline, .artist {
  color: var(--muted);
  font-family: Outfit, sans-serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.gate {
  width: min(420px, calc(100% - 32px));
  margin: 12vh auto;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  display: grid;
  gap: 12px;
}
.gate[hidden],
#app[hidden] { display: none; }
.gate h1 { font-family: Fraunces, Georgia, serif; margin: 0 0 8px; font-weight: 560; }
.gate label, dialog label, dialog fieldset { display: grid; gap: 6px; }
.gate input, dialog input, dialog select, #search {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
}
.gate button, .primary, .top-actions button, .upload, .top-actions a, dialog button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--gold);
  color: #1a1408;
  text-decoration: none;
  font-weight: 600;
}
.top-actions button, .top-actions a, .upload, dialog button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.primary { background: var(--gold); color: #1a1408; border: 0; }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 22px;
  align-items: center;
  padding: 18px 20px 0;
}
.lamp::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.lamp.on::before { background: var(--live); box-shadow: 0 0 12px var(--live); }
.lamp.open::before { background: var(--gold); }
#clock { font-variant-numeric: tabular-nums; letter-spacing: 0.08em; }
.modes { display: flex; padding: 4px; border-radius: 999px; border: 1px solid var(--line); }
.modes button { border: 0; background: transparent; border-radius: 999px; padding: 8px 14px; }
.modes button.on { background: var(--gold); color: #1a1408; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.top-actions button.hot { color: var(--live); border-color: var(--live); }

.desk {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(260px, 320px);
  gap: 16px;
  padding: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px;
}
.panel header, .row, .pages { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel h2, dialog h2 { font-family: Fraunces, Georgia, serif; font-weight: 560; margin: 0; font-size: 28px; }
.library header h2, .queue header h2, .carts h2 { font-size: 22px; }

#search, .cats { margin-top: 12px; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cats button, .queue button, .cart button, .pages button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 6px 10px;
}
.cats button.on { border-color: var(--gold); color: var(--gold); }

.list { margin-top: 12px; display: grid; gap: 8px; max-height: 58vh; overflow: auto; }
.item, .qitem {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
}
.item strong, .qitem strong { font-weight: 560; }
.item small, .qitem small { color: var(--muted); grid-column: 1; }
.item .actions, .qitem .actions { display: flex; gap: 4px; }
.item.over, .list.over { border-color: var(--gold); }
.badge { color: var(--gold); letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px; }

.deck { min-height: 360px; }
.deck h2 { font-size: clamp(32px, 4vw, 52px); line-height: 1; margin: 8px 0; }
#wave { width: 100%; height: 96px; display: block; margin-top: 12px; }
.time { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; text-transform: none; font-size: 14px; }
.nextline { min-height: 1em; text-transform: none; letter-spacing: 0; font-size: 14px; }

.carts { margin: 0 16px 16px; }
.cartgrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.cart {
  min-height: 92px;
  border-radius: 18px;
  text-align: left;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
}
.cart b { font-weight: 600; }
.cart em { font-style: normal; color: var(--muted); font-size: 12px; }
.cart.empty { border-style: dashed; color: var(--muted); }
.cart .x {
  align-self: flex-end;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

dialog {
  width: min(560px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #141a17;
  color: var(--ink);
  padding: 22px;
}
dialog form { display: grid; gap: 12px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.hint { line-height: 1.45; text-transform: none; letter-spacing: 0; font-size: 14px; }
.check { display: flex; grid-template-columns: none; align-items: center; gap: 8px; }
#pattern { display: flex; flex-wrap: wrap; gap: 6px; }
#pattern button { border-radius: 999px; border: 1px solid var(--line); background: transparent; padding: 6px 10px; }
.error { color: #ffb4a2; min-height: 1.2em; margin: 0; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: #f4f0e6;
  color: #1a1408;
  opacity: 0;
  pointer-events: none;
}
.toast.show { opacity: 1; }
#preview { width: 100%; }

@media (max-width: 1100px) {
  .desk { grid-template-columns: 1fr; }
  .list { max-height: none; }
  .cartgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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