/* ============ StemShare – dark studio theme ============ */
:root {
  color-scheme: dark;
  --bg: #12141a;
  --bg2: #1a1d26;
  --bg3: #222633;
  --line: #2c3140;
  --txt: #e8eaf0;
  --dim: #9aa1b5;
  --acc: #7c6cf0;
  --acc2: #9d90ff;
  --ok: #3ddc84;
  --warn: #ffb454;
  --bad: #ff5c69;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
}
.hidden { display: none !important; }

/* ---------- generic ---------- */
button.btn {
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--txt);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background .12s, border-color .12s;
}
button.btn:hover { background: #2b3040; border-color: #3a4056; }
.btn.primary { background: var(--acc); border-color: var(--acc); font-weight: 600; }
.btn.primary:hover { background: var(--acc2); border-color: var(--acc2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; }
.btn.round { width: 44px; height: 44px; border-radius: 50%; font-size: 17px; padding: 0; }
.btn:disabled { opacity: .45; cursor: default; }
input[type="text"], input[type="search"], input[type="password"], select {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 14px;
  outline: none;
}
input:focus, select:focus { border-color: var(--acc); }
input[type="range"] { accent-color: var(--acc); }
.badge {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(124,108,240,.16);
  color: var(--acc2);
  white-space: nowrap;
}
.time { font-family: var(--mono); font-size: 12px; color: var(--dim); min-width: 42px; text-align: center; }

/* ---------- login ---------- */
#view-login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 360px; max-width: 100%;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 16px;
  padding: 36px 32px;
}
.login-card h1 { margin: 0; font-size: 22px; text-align: center; }
.login-card .sub { margin: 6px 0 18px; text-align: center; color: var(--dim); font-size: 13.5px; }
.login-card label { display: block; font-size: 12.5px; color: var(--dim); margin: 14px 0 4px; }
.login-card input { width: 100%; }
.error {
  background: rgba(255,92,105,.1); border: 1px solid rgba(255,92,105,.4);
  color: #ffb3bb; border-radius: 8px; padding: 9px 12px; font-size: 13.5px; margin-bottom: 8px;
}

/* ---------- header / layout ---------- */
header {
  position: sticky; top: 0; z-index: 10;
  display: flex; gap: 16px; align-items: center;
  padding: 12px 20px;
  background: rgba(18,20,26,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
#search { flex: 1; max-width: 380px; }
header nav { margin-left: auto; display: flex; gap: 8px; align-items: center; }
#whoami { color: var(--dim); font-size: 13px; }

.layout { display: flex; min-height: calc(100vh - 57px - 74px); }
aside {
  width: 260px; flex-shrink: 0;
  padding: 16px; border-right: 1px solid var(--line);
}
main { flex: 1; padding: 20px 24px 40px; min-width: 0; }

.project-section { margin-top: 18px; }
.project-section h3 {
  margin: 0 0 7px; color: var(--dim); font-size: 11px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
}
.project-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.project-list button.item {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent;
  color: var(--txt); padding: 9px 11px; border-radius: 8px; cursor: pointer; font-size: 14.5px;
}
.project-list button.item:hover { background: var(--bg2); }
.project-list button.item.active { background: var(--bg3); border-color: var(--line); }
.project-list .meta { display: block; color: var(--dim); font-size: 11.5px; margin-top: 2px; }
.project-list .empty-projects { color: #70778a; font-size: 12px; padding: 5px 10px 10px; }
.empty-note { color: var(--dim); padding: 24px 8px; font-size: 14px; line-height: 1.7; }

/* ---------- project view ---------- */
.proj-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.proj-head h2 { margin: 0; font-size: 21px; word-break: break-all; }
.proj-actions { margin-left: auto; display: flex; gap: 8px; }
.hint { color: var(--dim); font-size: 13px; margin: 0 0 18px; }

.version {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 12px; overflow: hidden;
}
.v-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; cursor: pointer; user-select: none;
}
.v-head:hover { background: #1e222e; }
.v-head .arrow { transition: transform .15s; color: var(--dim); font-size: 12px; }
.version.open .v-head .arrow { transform: rotate(90deg); }
.v-meta { color: var(--dim); font-size: 12.5px; }
.v-actions { margin-left: auto; display: flex; gap: 6px; }
.v-comment { padding: 0 16px 10px 38px; color: var(--warn); font-size: 13.5px; }
.v-body { border-top: 1px solid var(--line); padding: 8px 10px 12px; }
.stem-filter { margin: 4px 4px 10px; width: min(340px, 90%); }

table.stems { width: 100%; border-collapse: collapse; }
table.stems td { padding: 7px 10px; border-top: 1px solid #232838; font-size: 14px; }
table.stems tr:first-child td { border-top: none; }
tr.stem:hover td { background: #20242f; }
tr.stem.current td { background: rgba(124,108,240,.09); }
td.s-play { width: 34px; }
td.s-name { font-family: var(--mono); font-size: 13px; word-break: break-all; }
td.s-dur, td.s-size { width: 80px; color: var(--dim); font-family: var(--mono); font-size: 12.5px; text-align: right; }
td.s-act { width: 44px; text-align: right; }
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--txt);
  font-size: 15px; padding: 4px 6px; border-radius: 6px; opacity: .75;
}
.icon-btn:hover { opacity: 1; background: var(--bg3); }
.playing-ind { color: var(--acc2); }

/* ---------- waveform multitrack mixer ---------- */
.mix-toolbar {
  position: sticky; top: 58px; z-index: 5;
  display: grid; grid-template-columns: auto auto auto minmax(130px, 1fr) auto auto;
  gap: 9px; align-items: center; margin: 2px 2px 12px; padding: 10px;
  background: rgba(20,22,30,.96); border: 1px solid var(--line); border-radius: 10px;
}
.mix-seek { width: 100%; accent-color: var(--acc); }
.mix-status { color: var(--dim); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.stem-mixer-list { display: grid; gap: 5px; }
.stem-mixer-row {
  padding: 7px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  transition: opacity .12s, border-color .12s;
}
.stem-mixer-row.muted { opacity: .56; }
.stem-mixer-row.current { border-color: var(--acc); box-shadow: inset 3px 0 0 var(--acc); }
.stem-mixer-row.decode-error { border-color: rgba(255,92,105,.35); }
.stem-title-row { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.stem-title-row strong { min-width: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.stem-meta { flex-shrink: 0; color: var(--dim); font-family: var(--mono); font-size: 11px; }
.stem-meta a { color: var(--acc2); }
.waveform-wrap {
  position: relative; height: 40px; overflow: hidden; cursor: crosshair;
  background: #151823; border: 1px solid #272c3b; border-radius: 7px;
}
.waveform-wrap::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: var(--mix-progress, 0%);
  width: 1px; background: var(--warn); box-shadow: 0 0 5px rgba(255,180,84,.7); pointer-events: none;
}
.waveform { display: block; width: 100%; height: 40px; }
.waveform-loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--dim); font-family: var(--mono); font-size: 11px; pointer-events: none;
}
.track-controls { display: flex; gap: 6px; align-items: center; margin-top: 5px; }
.track-controls .btn { padding: 4px 8px; font-size: 11.5px; }
.track-controls .track-mute.active { color: #151823; background: var(--warn); border-color: var(--warn); }
.track-controls .track-solo.active { color: #151823; background: var(--ok); border-color: var(--ok); }
.track-controls label { display: flex; align-items: center; gap: 7px; margin-left: auto; color: var(--dim); font-size: 11.5px; }
.track-volume { width: min(180px, 22vw); }
.track-controls output { min-width: 37px; color: var(--txt); font-family: var(--mono); }
.stem-mixer-row.no-audio { padding-block: 6px; }
.stem-mixer-row.no-audio .stem-title-row { margin-bottom: 3px; }
.no-audio-lane {
  min-height: 20px; display: flex; align-items: center; padding: 1px 8px;
  color: var(--dim); background: #151823; border: 1px solid #272c3b; border-radius: 6px;
  font-family: var(--mono); font-size: 10.5px;
}

/* ---------- player bar ---------- */
footer#player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; flex-direction: column; gap: 2px;
  background: rgba(20,22,30,.97); border-top: 1px solid var(--line);
  padding: 8px 20px 10px;
}
.p-info { display: flex; gap: 10px; align-items: baseline; overflow: hidden; }
.p-info strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.p-info span { color: var(--dim); font-size: 12px; font-family: var(--mono); }
.p-controls { display: flex; align-items: center; gap: 10px; }
#p-seek { flex: 1; }
.vol-wrap { display: flex; align-items: center; gap: 4px; }
.vol-ico { font-size: 13px; }
#p-vol { width: 90px; }

/* ---------- modal ---------- */
#modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8,9,12,.72); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px; overflow-y: auto;
}
#modal {
  background: var(--bg2); border: 1px solid #33394b; border-radius: 14px;
  width: 640px; max-width: 100%;
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
  animation: pop .14s ease-out;
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-head {
  display: flex; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px;
}
.modal-close { margin-left: auto; }
.modal-body { padding: 18px 20px 22px; }
.field label { display: block; font-size: 12.5px; color: var(--dim); margin: 14px 0 4px; }
.field:first-child label { margin-top: 0; }
.field input[type="text"], .field input[type="password"] { width: 100%; }

.dropzone {
  border: 2px dashed #39405a; border-radius: 12px;
  padding: 28px 16px; text-align: center; color: var(--dim);
  margin-top: 14px; cursor: pointer; transition: border-color .15s, background .15s;
  font-size: 14px; line-height: 1.6;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--acc); background: rgba(124,108,240,.06); color: var(--txt); }

.batch-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-top: 10px; align-items: center;
}
.batch-row .fname { font-family: var(--mono); font-size: 12.5px; color: var(--dim); grid-column: 1 / -1; }
.batch-row input { padding: 7px 9px; }
.upl-progress { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.upl-progress > div { height: 100%; width: 0; background: var(--acc); transition: width .2s; }
.upl-status { font-size: 12.5px; color: var(--dim); margin-top: 6px; font-family: var(--mono); }

/* users table */
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th { text-align: left; color: var(--dim); font-weight: 500; font-size: 12.5px; padding: 6px 8px; }
table.users td { padding: 8px; border-top: 1px solid #232838; }

.sharing-options { display: grid; gap: 9px; margin: 10px 0; }
.sharing-choice { display: flex; align-items: flex-start; gap: 8px; color: var(--txt); font-size: 14px; }
.sharing-choice small { display: block; color: var(--dim); margin-top: 2px; }
.member-picker {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px;
  max-height: 180px; overflow-y: auto; padding: 10px; margin-top: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
}
.member-picker label { display: flex; gap: 7px; align-items: center; font-size: 13px; }

/* toasts */
#toasts { position: fixed; bottom: 96px; right: 20px; z-index: 99; display: grid; gap: 8px; }
.toast {
  background: #23283a; border: 1px solid #39405a; border-left: 3px solid var(--acc);
  padding: 10px 14px; border-radius: 8px; font-size: 14px; max-width: 340px;
  animation: slidein .18s ease-out; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.err { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

@media (max-width: 760px) {
  aside { width: 100%; border-right: none; border-bottom: 1px solid var(--line); }
  .layout { flex-direction: column; }
  header nav span#whoami { display: none; }
  .member-picker { grid-template-columns: 1fr; }
  .mix-toolbar { position: static; grid-template-columns: auto auto 1fr auto; }
  .mix-status { grid-column: 1 / -1; }
  .stem-title-row { align-items: flex-start; flex-direction: column; gap: 4px; }
  .track-controls { flex-wrap: wrap; }
  .track-controls label { width: 100%; margin-left: 0; }
  .track-volume { flex: 1; width: auto; }
}
