:root {
  --night: #1c1026;
  --plum: #2b1b38;
  --plum-2: #3d2a4d;
  --ink: #f5ecf6;
  --dusk: #a893b4;
  --saffron: #f2b33d;
  --saffron-hi: #ffc75c;
  --rose: #ec6f98;
  --vinyl: #130b19;
  --lacquer: #2a1934;
  --font: "Bricolage Grotesque", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", system-ui, sans-serif;
  --dock-h: 76px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--saffron); outline-offset: 2px; border-radius: 6px; }
a { color: var(--saffron); }

/* ---------- Wordmark: the "o" is a record ---------- */
.wordmark {
  display: inline-flex;
  align-items: baseline;
  font-size: 30px;
  font-weight: 800;
  font-variation-settings: "wdth" 75, "opsz" 96;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  margin: 0;
}
.wordmark .o {
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.03em;
  border-radius: 50%;
  align-self: baseline;
  background:
    radial-gradient(circle, var(--night) 0 17%, transparent 18%),
    repeating-radial-gradient(circle, var(--saffron) 0 0.06em, #c98a22 0.06em 0.09em);
}

/* ---------- Discs ---------- */
.disc {
  --size: 56px;
  --p: 1;
  position: relative;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  isolation: isolate;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 6px 18px rgba(0, 0, 0, 0.35);
}
.disc .spin {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--lacquer);
  animation: spin 1.8s linear infinite;
  animation-play-state: paused;
}
.disc .grooves {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, #1e1226 0 0.6px, var(--vinyl) 0.6px 2px);
  -webkit-mask: conic-gradient(#000 calc(var(--p) * 1turn), transparent 0);
  mask: conic-gradient(#000 calc(var(--p) * 1turn), transparent 0);
}
.disc .label {
  position: absolute;
  inset: 31%;
  border-radius: 50%;
  background-color: var(--plum-2);
  background-image: var(--art, radial-gradient(circle at 35% 30%, var(--c1, var(--saffron)), var(--c2, var(--rose)) 70%));
  background-size: cover;
  background-position: center;
}
.disc::before { /* static light on the vinyl: it does not turn with the record */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
  background: conic-gradient(from 20deg, transparent 0 8%, rgba(255, 255, 255, 0.09) 13%, transparent 20% 56%, rgba(255, 255, 255, 0.06) 62%, transparent 69%);
}
.disc::after { /* spindle hole */
  content: "";
  position: absolute;
  inset: 47.5%;
  border-radius: 50%;
  background: var(--night);
  z-index: 3;
}
.disc.playing .spin,
.disc.pressing .spin { animation-play-state: running; }
.disc.pressing .spin { animation-duration: 3.2s; }
.disc.pressing .label { opacity: 0.85; }
.disc.failed .grooves { opacity: 0.35; }
.disc.small { --size: 46px; }
.disc.mid { --size: 120px; }
.disc.big { --size: 168px; }
.disc.huge { --size: min(72vw, 380px); }
.disc.blank .label { background-image: none; background-color: var(--plum-2); }
@keyframes spin { to { transform: rotate(1turn); } }

/* ---------- Gate ---------- */
.gate {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: start;
  gap: 18px;
  padding: 32px 24px;
  max-width: 440px;
  margin: 0 auto;
}
.gate-disc { margin-bottom: 8px; }
.gate-disc .spin { animation-play-state: running; animation-duration: 6s; }
.gate-mark { font-size: 64px; }
.gate-copy { margin: 0; color: var(--dusk); font-size: 17px; max-width: 34ch; }
.gate-form { display: grid; gap: 12px; width: 100%; }

/* ---------- Header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) 24px 14px;
  background: linear-gradient(var(--night) 70%, rgba(28, 16, 38, 0));
}
.top .wordmark { margin-right: auto; }
.tabs { display: none; gap: 4px; background: var(--plum); border-radius: 999px; padding: 4px; }
.tabs button {
  border: 0;
  background: none;
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--dusk);
}
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--night); }
#tab-count:empty { display: none; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--dusk);
}
.icon-btn:hover { color: var(--ink); background: var(--plum); }

/* ---------- Layout ---------- */
.stage {
  display: grid;
  grid-template-columns: minmax(380px, 540px) minmax(0, 1fr);
  gap: 64px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 24px calc(var(--dock-h) + 48px);
  align-items: start;
}
.pane { min-width: 0; }

/* ---------- Composer ---------- */
.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--plum);
  margin-bottom: 28px;
}
.seg button {
  border: 0;
  background: none;
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--dusk);
  font-weight: 600;
}
.seg button[aria-checked="true"] { background: var(--ink); color: var(--night); }

.ask {
  margin: 0 0 14px;
  font-size: clamp(34px, 5.2vw, 52px);
  line-height: 1.02;
  font-weight: 800;
  font-variation-settings: "wdth" 78, "opsz" 96;
  letter-spacing: -0.025em;
  max-width: 14ch;
}
.ask label { cursor: text; }
.idea {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  font-size: 19px;
  line-height: 1.45;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--plum-2);
  background: var(--plum);
}
.idea::placeholder, textarea::placeholder, input::placeholder { color: #8a7598; }

.field { margin: 22px 0 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field legend, .field-head label {
  display: block;
  padding: 0;
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.count { font-size: 13px; color: var(--dusk); font-variant-numeric: tabular-nums; }
.count.over { color: var(--rose); }
.hint { margin: 6px 0 0; font-size: 14px; color: var(--dusk); max-width: 60ch; }
.err { margin: 10px 0 0; color: var(--rose); font-size: 15px; min-height: 0; }
.err:empty { display: none; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--plum-2);
  background: var(--plum);
  font-size: 16px;
  line-height: 1.5;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--saffron); }
#lyrics { min-height: 260px; line-height: 1.65; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--plum-2);
  background: none;
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 15px;
  line-height: 1.3;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--dusk); }
.chip[aria-pressed="true"] { background: var(--saffron); border-color: var(--saffron); color: var(--night); font-weight: 600; }

.tagbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.tag {
  border: 0;
  background: var(--plum);
  color: var(--dusk);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.tag:hover { color: var(--ink); background: var(--plum-2); }

.writer { margin: 26px 0 4px; }
.row-fields { display: flex; gap: 32px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 650;
  font-size: 16px;
  text-decoration: none;
  color: var(--ink);
}
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn.primary { background: var(--saffron); color: var(--night); }
.btn.primary:hover:not([disabled]) { background: var(--saffron-hi); }
.btn.ghost { background: none; border: 1.5px solid var(--saffron); color: var(--saffron); }
.btn.ghost:hover:not([disabled]) { background: rgba(242, 179, 61, 0.1); }
.btn.quiet { background: var(--plum); color: var(--ink); }
.btn.quiet:hover { background: var(--plum-2); }
.btn.busy span::after { content: "…"; }
.make-btn { width: 100%; height: 60px; font-size: 19px; margin-top: 30px; border-radius: 16px; font-variation-settings: "wdth" 85; }
.quota { text-align: left; }

.more { margin-top: 22px; }
.more summary { cursor: pointer; color: var(--dusk); font-weight: 600; width: max-content; }
.more summary:hover { color: var(--ink); }
.more-body { padding-left: 2px; }

.drop {
  display: grid;
  gap: 4px;
  padding: 22px 20px;
  border: 1.5px dashed var(--plum-2);
  border-radius: 18px;
  background: var(--plum);
  cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--saffron); }
.drop:focus-within { outline: 2px solid var(--saffron); outline-offset: 2px; }
.drop-main { font-size: 18px; font-weight: 650; }
.drop-sub { color: var(--dusk); font-size: 14px; }
.drop-bar { height: 4px; background: var(--plum-2); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.drop-bar span { display: block; height: 100%; width: 0; background: var(--saffron); transition: width 0.2s; }

/* Mode switching */
.make[data-mode="song"] .only-cover,
.make[data-mode="cover"] .only-song { display: none; }
.make.instrumental .vocal-only { display: none; }

/* ---------- Library ---------- */
.songs-h {
  margin: 4px 0 14px;
  font-size: 22px;
  font-weight: 750;
  font-variation-settings: "wdth" 85;
}
.list { list-style: none; margin: 0; padding: 0; }
.song {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  padding: 12px 10px;
  margin: 0 -10px;
  border-radius: 14px;
  cursor: pointer;
}
.song + .song { box-shadow: inset 0 1px 0 rgba(168, 147, 180, 0.12); }
.song:hover { background: rgba(43, 27, 56, 0.7); }
.song.current .song-title { color: var(--saffron); }
.song .disc { --size: 60px; }
.song-text { min-width: 0; }
.song-title {
  display: block;
  font-size: 18px;
  font-weight: 700;
  font-variation-settings: "wdth" 88;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.song-title .take { color: var(--dusk); font-weight: 500; font-size: 14px; margin-left: 6px; }
.song-sub {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  color: var(--dusk);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.song.failed .song-sub { color: var(--rose); white-space: normal; }
.song.pressing .song-sub { color: var(--saffron); }
.song-time { font-size: 14px; color: var(--dusk); font-variant-numeric: tabular-nums; }
.song .more-btn { width: 36px; height: 36px; }
.rename { width: 100%; padding: 6px 10px; font-size: 17px; font-weight: 700; }

.empty { display: grid; justify-items: start; gap: 16px; padding: 24px 0; color: var(--dusk); max-width: 40ch; }
.empty p { margin: 0; }
.empty strong { color: var(--ink); }

.menu {
  position: fixed;
  z-index: 60;
  min-width: 190px;
  padding: 6px;
  border-radius: 14px;
  background: #34223f;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.menu button, .menu a {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
}
.menu button:hover, .menu a:hover, .menu button:focus-visible { background: var(--plum-2); }
.menu .danger { color: var(--rose); }

/* ---------- Dock ---------- */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: calc(var(--dock-h) + env(safe-area-inset-bottom));
  padding: 0 20px env(safe-area-inset-bottom);
  background: rgba(28, 16, 38, 0.9);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 -1px 0 rgba(168, 147, 180, 0.15);
}
.dock-progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: rgba(168, 147, 180, 0.15); }
.dock-progress span { display: block; height: 100%; width: 0; background: var(--saffron); }
.dock-open {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  text-align: left;
  padding: 0;
}
.dock-text { display: grid; min-width: 0; }
.dock-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-sub { font-size: 13px; color: var(--dusk); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-ctrl { display: flex; align-items: center; gap: 6px; }
.dock-time { font-size: 13px; color: var(--dusk); font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; }
.slash { margin: 0 4px; opacity: 0.6; }
.play-btn {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--saffron);
  color: var(--night);
}
.play-btn:hover { background: var(--saffron-hi); }
.play-btn.large { width: 72px; height: 72px; }
.play-btn .i-pause, .is-playing .play-btn .i-play { display: none; }
.is-playing .play-btn .i-pause { display: inline; }

/* ---------- Now playing ---------- */
.np {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  background: var(--night);
  padding: max(16px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.np-ambient {
  position: fixed;
  inset: -20%;
  z-index: -1;
  background-image: var(--art, none);
  background-size: cover;
  background-position: center;
  filter: blur(80px) saturate(1.2);
  opacity: 0.28;
  pointer-events: none;
}
.np-close { position: sticky; top: 0; z-index: 2; }
.np-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 56px;
  max-width: 1120px;
  margin: 0 auto;
  align-items: start;
}
.np-left { display: grid; justify-items: center; text-align: center; }
.np-stage { position: relative; display: grid; place-items: center; margin: 8px 0 24px; }
.viz { position: absolute; width: calc(100% + 120px); height: calc(100% + 120px); left: -60px; top: -60px; pointer-events: none; }
.np-title {
  margin: 0;
  font-size: clamp(30px, 4.4vw, 48px);
  line-height: 1.05;
  font-weight: 800;
  font-variation-settings: "wdth" 78, "opsz" 96;
  letter-spacing: -0.02em;
  max-width: 18ch;
}
.np-sub { margin: 8px 0 0; color: var(--dusk); max-width: 46ch; }
.scrub { width: min(100%, 440px); margin-top: 22px; }
.scrub-times { display: flex; justify-content: space-between; font-size: 13px; color: var(--dusk); font-variant-numeric: tabular-nums; margin-top: 4px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  --fill: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--saffron) var(--fill), rgba(168, 147, 180, 0.25) var(--fill));
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 5px; background: rgba(168, 147, 180, 0.25); }
input[type="range"]::-moz-range-progress { height: 5px; border-radius: 5px; background: var(--saffron); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--ink); border: 0; }
.np-ctrl { display: flex; align-items: center; gap: 28px; margin-top: 14px; }
.np-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 24px; }
.np-right { padding-top: 56px; }
.np-lyrics { font-size: 19px; line-height: 1.6; max-width: 36ch; }
.np-lyrics .sec { display: block; margin: 22px 0 4px; font-size: 14px; color: var(--saffron); font-weight: 600; }
.np-lyrics .sec:first-child { margin-top: 0; }
.np-lyrics p { margin: 0; }
.np-lyrics .none { color: var(--dusk); }
.np-style { margin-top: 32px; color: var(--dusk); max-width: 60ch; }
.np-style summary { cursor: pointer; font-weight: 600; }
.np-style p { margin: 10px 0 0; font-size: 15px; }

/* ---------- Settings sheet ---------- */
.sheet {
  border: 0;
  padding: 0;
  border-radius: 22px;
  background: var(--plum);
  color: var(--ink);
  width: min(520px, calc(100vw - 24px));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.sheet::backdrop { background: rgba(10, 5, 14, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet-body { padding: 24px; }
.sheet h2 { margin: 0 0 6px; font-size: 26px; font-weight: 800; font-variation-settings: "wdth" 80; }
.sheet input { background: var(--night); }
.sheet-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.sheet-row.end { justify-content: flex-end; margin-top: 24px; }
#key-result.ok { color: #9be3b0; }
#key-result.no { color: var(--rose); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 20px + env(safe-area-inset-bottom));
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 12px 14px 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--night);
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: var(--night); color: var(--saffron); padding: 6px 12px; border-radius: 9px; font-weight: 700; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .stage { display: block; padding: 4px 16px calc(var(--dock-h) + 40px); }
  .top { padding-left: 16px; padding-right: 10px; gap: 10px; }
  .wordmark { font-size: 26px; }
  .tabs { display: flex; }
  body[data-tab="make"] #songs, body[data-tab="songs"] #make { display: none; }
  .np-grid { grid-template-columns: 1fr; gap: 24px; }
  .np-right { padding-top: 0; }
  .np-lyrics { margin: 0 auto; }
  .np { padding-left: 16px; padding-right: 16px; }
  .hide-sm { display: none !important; }
  .dock { padding-left: 14px; padding-right: 14px; gap: 10px; }
  .song { gap: 12px; }
  .song .disc { --size: 54px; }
  .gate-mark { font-size: 52px; }
}
@media (max-width: 380px) {
  .tabs button { padding: 7px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .disc .spin { animation: none !important; }
  .np { animation: none; }
  .toast { transition: none; }
}
