/*! LuckyDrop | MIT licence */
:root {
  --bg: #17152E;
  --panel: #221F42;
  --raised: #2B2752;
  --field: #1C1A38;
  --line: #34305E;
  --text: #EEEAF8;
  --muted: #A29DC8;
  --edge: #53D8C8;
  --groove: #6FB3FF;
  --build: #FFB547;
  --drop: #FF5FA2;
  --brk: #B69CFF;
  --bad: #FF7A8A;
  --focus: #FFB547;
  --rail: 250px;
  --row: 30px;
  --r-pad: 3px;
  --r-ctl: 10px;
  --r-panel: 16px;
  font-family: 'Bricolage Grotesque', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-optical-sizing: auto;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.5;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}
a { color: var(--groove); text-underline-offset: 3px; }
a:hover { color: var(--text); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -0.015em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
.num, .big-num, output, .tl-meta { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.lede { color: var(--muted); font-size: 1.1rem; max-width: 60ch; }
.measure { max-width: 72ch; }
.small-print { font-size: .85rem; margin-top: .75em; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--text); color: var(--bg); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px clamp(16px, 3vw, 32px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; }
.mark { width: 26px; height: 26px; }
.nav { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; }
.nav a, .linkish { color: var(--muted); text-decoration: none; font-weight: 600; background: none; border: 0; padding: 4px 0; cursor: pointer; }
.nav a:hover, .linkish:hover { color: var(--text); }
.inline { display: inline; margin: 0; }

/* ---------- layout ---------- */
.wide { max-width: 1240px; margin: 0 auto; padding: clamp(20px, 4vw, 44px) clamp(16px, 3vw, 32px) 64px; }
.narrow { max-width: 560px; margin: 0 auto; padding: clamp(24px, 6vw, 64px) 20px 64px; }
.card-page { }
.auth .card-page { padding-top: clamp(32px, 10vh, 110px); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 20px; margin-bottom: 20px; }
.empty { color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r-ctl); padding: 18px; }
.flash { max-width: 1240px; margin: 14px auto 0; padding: 10px 16px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--panel); width: calc(100% - 32px); }
.flash-ok { border-color: var(--edge); }
.flash-err { border-color: var(--bad); }
.err { color: #FFD1D7; background: rgba(255, 122, 138, .12); border: 1px solid rgba(255, 122, 138, .45); padding: 10px 14px; border-radius: var(--r-ctl); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-ctl);
  padding: 8px 14px; font-weight: 600; font-size: .95rem; line-height: 1.2; cursor: pointer; text-decoration: none; color: var(--text);
}
.btn:hover:not(:disabled) { background: #36316A; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--drop); border-color: var(--drop); color: #1A0E1F; }
.btn.primary:hover:not(:disabled) { background: #FF7DB4; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.btn.danger { color: var(--bad); }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
.form small { color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input:not([type]), select, textarea {
  background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0;
}
input[type=file] { color: var(--muted); }
select { cursor: pointer; }
input[type=range] { accent-color: var(--drop); width: 100%; cursor: pointer; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.check input { width: 18px; height: 18px; accent-color: var(--drop); }
.check.small { font-size: .9rem; }
.row-form { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.grid-form { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: start; }
.grid-form .span2 { grid-column: 1 / -1; }
.grid-form > .btn { justify-self: start; }
.form > .btn { justify-self: start; }

/* ---------- dashboard ---------- */
.start { margin-bottom: 48px; }
.genre-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-top: 24px; }
.genre-tile {
  --c: var(--groove);
  display: grid; gap: 6px; align-content: start; padding: 18px; min-height: 150px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--text); text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.genre-tile:hover { border-color: var(--c); color: var(--text); transform: translateY(-2px); }
.g-house { --c: var(--groove); } .g-deephouse { --c: var(--edge); } .g-techhouse { --c: var(--build); }
.g-techno { --c: var(--brk); } .g-trance { --c: var(--drop); } .g-garage { --c: #7FE08A; }
.g-chillout { --c: #7FD4E0; } .g-ninetiesstyle { --c: #FFD166; } .g-retrosound { --c: #FF6F59; } .g-groove { --c: #C9A6FF; }
.genre-tile.gt-lucky { --c: var(--drop); background: linear-gradient(160deg, #3A1F4E, var(--panel) 70%); }
.gt-name { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.gt-bpm { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.gt-blurb { color: var(--muted); font-size: .92rem; line-height: 1.4; }
.gt-pads { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; margin: 6px 0 4px; }
.gt-pads i { height: 10px; border-radius: 2px; background: var(--line); }
.gt-pads i:nth-child(4n+1) { background: #413C72; }
.gt-pads i.k { background: var(--c); }
.gt-pads i.c { background: var(--text); opacity: .7; }
.tracks h2 { margin-bottom: 12px; }
.track-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.track-list li { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.track-list form { margin: 0; }
.tl-main { flex: 1; display: grid; gap: 2px; padding: 14px 4px; text-decoration: none; color: var(--text); min-width: 0; }
.tl-main:hover .tl-title { color: var(--drop); }
.tl-title { font-weight: 700; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-meta { color: var(--muted); font-size: .9rem; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0 24px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current=page] { color: var(--text); border-bottom-color: var(--drop); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-panel); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.off td { opacity: .55; }
.table td.num { text-align: right; }
.table form { margin: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input[type=text] { width: 150px; }
.inline-form select { width: auto; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--raised); color: var(--muted); font-size: .8rem; font-weight: 600; }
.pill.ok { background: rgba(83, 216, 200, .16); color: var(--edge); }

/* ---------- studio ---------- */
.studio-main { padding: 18px clamp(12px, 2.5vw, 28px) 64px; max-width: 1600px; margin: 0 auto; }
#studio.loading { min-height: 50vh; display: grid; place-items: center; }
.boot-msg { color: var(--muted); font-size: 1.1rem; }
.boot-err { max-width: 560px; margin: 10vh auto; }
.st-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.title-wrap { flex: 1 1 280px; min-width: 0; }
.st-title {
  width: 100%; background: transparent !important; border: 1px solid transparent !important; border-radius: 10px;
  font-size: clamp(1.5rem, 3vw, 2.2rem) !important; font-weight: 800; letter-spacing: -0.02em; padding: 2px 8px !important; margin-left: -8px;
}
.st-title:hover { border-color: var(--line) !important; }
.st-title:focus { border-color: var(--focus) !important; outline: none; }
.save-state { color: var(--muted); font-size: .88rem; min-width: 56px; }
.save-state.pending { color: var(--build); }
.head-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn span { display: inline; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 250px; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 18px 40px rgba(8, 6, 24, .55); }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.menu button:hover, .menu button:focus-visible { background: #36316A; }

.transport {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel) var(--r-panel) 0 0; border-bottom: 0; padding: 12px 14px;
}
.play { width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); display: grid; place-items: center; cursor: pointer; flex: none; }
.play svg { width: 26px; height: 26px; }
.play.on { background: var(--edge); }
.icon-only { width: 40px; height: 40px; padding: 0; }
.readout { display: grid; line-height: 1.2; min-width: 118px; }
.big-num { font-size: 1.25rem; font-weight: 700; }
.readout .muted { font-size: .85rem; }
.meter { width: 72px; height: 6px; border-radius: 3px; background: var(--field); overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--edge), var(--build) 75%, var(--drop)); transform-origin: left; transform: scaleX(0); }
.facts { display: flex; gap: 6px 18px; flex-wrap: wrap; margin: 0; flex: 1 1 260px; font-size: .95rem; }
.facts b { font-weight: 700; }
.facts .prog { color: var(--muted); word-spacing: .2em; }
.lucky-group { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.lucky {
  display: inline-flex; align-items: center; gap: 10px; border: 0; cursor: pointer;
  background: var(--drop); color: #1A0E1F; font-weight: 800; font-size: 1.1rem; letter-spacing: -0.01em;
  padding: 12px 22px 12px 16px; border-radius: 99px; box-shadow: 0 0 0 0 rgba(255, 95, 162, .5);
  transition: transform .12s, box-shadow .2s;
}
.lucky svg { width: 24px; height: 24px; transition: transform .35s; }
.lucky:hover { box-shadow: 0 0 0 6px rgba(255, 95, 162, .18); }
.lucky:hover svg { transform: rotate(90deg); }
.lucky:active { transform: scale(.97); }

/* arrangement: the pads */
.arr { background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 var(--r-panel) var(--r-panel); margin-bottom: 20px; }
.arr-scroll { overflow-x: auto; overscroll-behavior-x: contain; border-top: 1px solid var(--line); }
.arr-inner { display: flex; position: relative; }
.arr-rail { position: sticky; left: 0; z-index: 3; width: var(--rail); flex: none; background: var(--panel); border-right: 1px solid var(--line); }
.rail-head { height: 56px; display: flex; align-items: flex-end; padding: 0 12px 8px; font-size: .85rem; }
.rail-row { height: var(--row); display: grid; grid-template-columns: 1fr 26px 24px 24px 64px; gap: 4px; align-items: center; padding: 0 10px 0 12px; }
.rail-row.is-muted .lane-name { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(162, 157, 200, .6); }
.lane-name { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ic, .ms { width: 24px; height: 22px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.ic svg { width: 17px; height: 17px; }
.ic:hover, .ms:hover { background: var(--raised); color: var(--text); }
.ms { font-size: .72rem; font-weight: 700; border: 1px solid var(--line); }
.ms[aria-pressed=true] { background: var(--build); border-color: var(--build); color: #1F1400; }
.ms.solo[aria-pressed=true] { background: var(--edge); border-color: var(--edge); color: #04201D; }
.ic[aria-pressed=true] { background: var(--text); color: var(--bg); }
.lvol { height: 16px; }

.arr-body { position: relative; flex: 1; min-width: 0; margin-right: 8px; }
.sec-row { display: grid; height: 56px; }
.sec {
  --c: var(--groove); --soft: rgba(111, 179, 255, .12);
  min-width: 0; margin-left: 4px; padding: 6px 4px 6px 7px; display: flex; flex-direction: column; justify-content: space-between;
  border-top: 3px solid var(--c); background: var(--soft); border-radius: 0 0 6px 6px; overflow: hidden;
}
.s-edge { --c: var(--edge); --soft: rgba(83, 216, 200, .12); }
.s-groove { --c: var(--groove); --soft: rgba(111, 179, 255, .12); }
.s-build { --c: var(--build); --soft: rgba(255, 181, 71, .12); }
.s-drop { --c: var(--drop); --soft: rgba(255, 95, 162, .14); }
.s-brk { --c: var(--brk); --soft: rgba(182, 156, 255, .13); }
.sec.now { background: color-mix(in srgb, var(--c) 30%, transparent); }
.sec.looped { outline: 1px dashed var(--c); outline-offset: -1px; }
.sec-name { background: none; border: 0; padding: 0; text-align: left; font-weight: 700; font-size: .88rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.sec-name:hover { color: var(--c); }
.sec-tools { display: flex; gap: 2px; }
.sec-tools .ic { width: 22px; height: 20px; }

.pad-row { display: grid; height: var(--row); align-items: center; cursor: pointer; }
.pad-row.is-muted { opacity: .35; }
.pd { display: block; height: calc(var(--row) - 10px); margin: 0 1px; border-radius: var(--r-pad); background: var(--c); }
.pd.first { margin-left: 5px; }
.pd.l0 { background: #29264C; }
.pd.l1 { opacity: .32; }
.pd.l2 { opacity: .55; }
.pd.l3 { opacity: .8; }
.pd.l4 { opacity: 1; box-shadow: 0 0 10px -2px var(--c); }
.pd.filt { background: repeating-linear-gradient(135deg, var(--c) 0 2px, transparent 2px 5px); opacity: .7; box-shadow: none; }
.row-note { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; padding-left: 8px; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: 2px; background: var(--text); box-shadow: 0 0 12px rgba(238, 234, 248, .7); pointer-events: none; z-index: 2; left: 0; }
#arr.spun .arr-body { animation: spun .5s ease-out; }
@keyframes spun { from { filter: brightness(1.9) saturate(1.2); } to { filter: none; } }
.arr-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); }
.arr-foot p { margin: 0; font-size: .88rem; }

/* panels */
.panels { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.panels .panel { margin: 0; }
.field { display: grid; gap: 7px; margin-bottom: 16px; min-width: 0; }
.flabel { font-weight: 600; font-size: .9rem; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.flabel output { color: var(--text); font-weight: 700; }
.field-row { display: grid; grid-template-columns: 110px 1fr; gap: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--field); padding: 6px 12px; border-radius: 99px; font-size: .9rem; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed=true] { background: var(--text); border-color: var(--text); color: var(--bg); }
.sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 20px; }
.ends { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; margin-top: -4px; }
.nudges { display: flex; flex-wrap: wrap; gap: 6px; }
.sound-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }
.sample-box { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }

.hist-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hist { list-style: none; margin: 0 -8px; padding: 0; max-height: 540px; overflow-y: auto; }
.hist li { display: flex; align-items: stretch; border-radius: 8px; }
.hist li.current { background: var(--raised); box-shadow: inset 3px 0 0 var(--drop); }
.hist li.empty { color: var(--muted); padding: 10px; font-size: .9rem; }
.h-go { flex: 1; display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: baseline; text-align: left; background: none; border: 0; padding: 8px 6px 8px 12px; cursor: pointer; border-radius: 8px; min-width: 0; }
.h-go:hover { background: rgba(255, 255, 255, .04); }
.h-no { color: var(--muted); font-size: .8rem; }
.h-label { font-size: .92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-time { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.h-star { width: 34px; background: none; border: 0; color: #4A4580; cursor: pointer; display: grid; place-items: center; border-radius: 8px; }
.h-star svg { width: 17px; height: 17px; }
.h-star:hover { color: var(--muted); }
.h-star[aria-pressed=true] { color: var(--build); }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-weight: 600; font-size: .92rem; z-index: 50; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #FFD1D7; color: #3A0610; border-radius: 14px; }

@media (max-width: 1180px) {
  .panels { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .panels .history { grid-column: 1 / -1; }
  .hist { max-height: 360px; }
}
@media (max-width: 760px) {
  :root { --rail: 156px; --row: 32px; }
  .rail-row { grid-template-columns: 1fr 26px 24px 24px; padding: 0 6px 0 10px; }
  .lvol { display: none; }
  .panels { grid-template-columns: 1fr; }
  .lucky-group { margin-left: 0; width: 100%; }
  .lucky { flex: 1; justify-content: center; }
  .facts { order: 5; }
  .meter { display: none; }
  .icon-btn span { display: none; }
  .icon-btn { padding: 8px 10px; }
  .field-row { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
