/* Wave Studio - Study'N Fun Hub multitrack audio editor */
:root {
  --bg: #00000F;
  --panel: #070c18;
  --panel2: #0b1322;
  --line: rgba(64, 196, 255, 0.18);
  --line2: rgba(64, 196, 255, 0.35);
  --text: #d6e6ff;
  --muted: #8aa6bf;
  --accent: #FFCB6B;
  --cyan: #40c4ff;
  --red: #ff5a5a;
  --green: #7BE495;
  --hw: 236px;
  --side: 330px;
  --honey: #fbbf24;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.35 "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.ws-app {
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top top" "main side" "drawer drawer" "status status";
}
.ws-app.no-side { grid-template-columns: minmax(0, 1fr) 40px; }
.ws-app.no-side .ws-side-body,
.ws-app.no-side .ws-tab:not(.collapse) { display: none; }

/* ---------- top bar ---------- */
.ws-top {
  grid-area: top;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  padding: 7px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line2);
}
.ws-brand { font-weight: 700; font-size: 15px; letter-spacing: 0.5px; color: var(--accent); white-space: nowrap; }
.ws-logo { color: var(--cyan); font-size: 18px; }
.ws-group { display: flex; align-items: center; gap: 4px; }
.ws-spacer { flex: 1; }
.ws-lbl { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); white-space: nowrap; }

.ws-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 28px; padding: 3px 10px;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line2); border-radius: 7px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.ws-btn:hover:not(:disabled) { border-color: var(--cyan); color: #fff; }
.ws-btn:disabled { opacity: 0.4; cursor: default; }
.ws-btn.icon { min-width: 30px; padding: 3px 6px; font-size: 14px; }
.ws-btn.small { min-height: 24px; padding: 2px 8px; font-size: 12px; }
.ws-btn.primary { background: var(--accent); color: #1b1300; border-color: var(--accent); font-weight: 600; }
.ws-btn.primary:hover:not(:disabled) { background: #ffd98e; color: #1b1300; }
.ws-btn.on { background: rgba(64, 196, 255, 0.18); border-color: var(--cyan); color: #fff; }
.ws-btn.play.on { background: rgba(123, 228, 149, 0.2); border-color: var(--green); }
.ws-btn.rec { color: var(--red); }
.ws-btn.rec.on { background: var(--red); color: #fff; border-color: var(--red); }

.ws-clock {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 2px 10px; min-width: 104px;
  background: #03060c; border: 1px solid var(--line); border-radius: 7px;
  font-variant-numeric: tabular-nums;
}
.ws-tc { font: 600 16px/1.1 Consolas, "Cascadia Mono", monospace; color: var(--accent); }
.ws-tcb { font: 11px/1.1 Consolas, "Cascadia Mono", monospace; color: var(--muted); }

.ws-select, .ws-num, .ws-text {
  min-height: 26px; padding: 2px 6px;
  background: #03060c; color: var(--text);
  border: 1px solid var(--line2); border-radius: 6px;
}
.ws-select { appearance: none; padding-right: 22px;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 12px) 50%, calc(100% - 7px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; }
.ws-select option { background: #0b1322; color: var(--text); }
.ws-select.small { min-height: 22px; font-size: 12px; }
.ws-num { width: 84px; }
.ws-num.tiny { width: 62px; }
.ws-text { flex: 1; min-width: 0; }
.ws-select:focus, .ws-num:focus, .ws-text:focus { outline: none; border-color: var(--cyan); }

/* ---------- main timeline ---------- */
.ws-main {
  grid-area: main;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0; min-height: 0;
  background: var(--panel);
}
.ws-main.dropping { box-shadow: inset 0 0 0 2px var(--accent); }
.ws-ruler-row, .ws-hrow { display: flex; min-width: 0; }
.ws-corner {
  flex: none; width: var(--hw);
  display: flex; align-items: center; padding: 0 8px;
  background: #0a1120; border-right: 1px solid var(--line2); border-bottom: 1px solid var(--line);
}
.ws-corner.small { border-bottom: none; }
.ws-ruler-wrap { flex: 1; min-width: 0; }
.ws-ruler-wrap canvas, .ws-lanes-wrap canvas { display: block; }
#ruler { cursor: pointer; }

.ws-tracks { overflow-y: auto; overflow-x: hidden; min-height: 0; }
.ws-tracks-inner { display: flex; align-items: stretch; min-height: 100%; }
.ws-headers {
  flex: none; width: var(--hw);
  background: #0a1120; border-right: 1px solid var(--line2);
}
.ws-lanes-wrap { flex: 1; min-width: 0; }

.ws-hscroll { flex: 1; min-width: 0; overflow-x: scroll; overflow-y: hidden; height: 14px; }
.ws-hscroll-in { height: 1px; }
.ws-hscroll::-webkit-scrollbar { height: 12px; }
.ws-hscroll::-webkit-scrollbar-thumb { background: rgba(64, 196, 255, 0.35); border-radius: 6px; }
.ws-tracks::-webkit-scrollbar { width: 12px; }
.ws-tracks::-webkit-scrollbar-thumb { background: rgba(64, 196, 255, 0.25); border-radius: 6px; }

/* track header */
.ws-th {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 5px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.ws-th.sel { background: rgba(64, 196, 255, 0.07); }
.ws-th-color { grid-row: 1 / 3; display: flex; cursor: pointer; }
.ws-th-colorpick { width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.ws-th-body { display: flex; flex-direction: column; gap: 3px; padding: 5px 6px 2px; min-width: 0; overflow: hidden; }
.ws-th-row { display: flex; align-items: center; gap: 3px; min-width: 0; }
.ws-th-name {
  flex: 1; min-width: 0; height: 22px; padding: 0 5px;
  background: transparent; border: 1px solid transparent; border-radius: 5px; font-weight: 600;
}
.ws-th-name:hover, .ws-th-name:focus { border-color: var(--line2); background: #03060c; outline: none; }
.ws-th-btn {
  min-width: 22px; height: 20px; padding: 0 4px;
  background: #03060c; border: 1px solid var(--line2); border-radius: 4px;
  font-size: 11px; font-weight: 700; cursor: pointer;
}
.ws-th-btn.mute.on { background: #ff8c69; color: #1b0700; border-color: #ff8c69; }
.ws-th-btn.solo.on { background: var(--accent); color: #1b1300; border-color: var(--accent); }
.ws-th-btn.arm { color: var(--red); }
.ws-th-btn.arm.on { background: var(--red); color: #fff; border-color: var(--red); }
.ws-th-btn.fx { color: var(--cyan); }
.ws-th-btn.auto { color: var(--green); }
.ws-th-btn.auto.on { background: rgba(123, 228, 149, 0.18); border-color: var(--green); }
.ws-th-btn:hover { border-color: var(--cyan); }
.ws-th-lbl { width: 24px; flex: none; color: var(--muted); font-size: 11px; }
.ws-th-val { width: 52px; flex: none; text-align: right; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ws-th-tools { gap: 4px; }
.ws-th-meter { flex: 1; min-width: 0; height: 6px; border-radius: 3px; }
.ws-th-mini {
  width: 20px; height: 18px; padding: 0;
  background: transparent; border: 1px solid var(--line); border-radius: 4px;
  font-size: 9px; color: var(--muted); cursor: pointer;
}
.ws-th-mini:hover:not(:disabled) { color: #fff; border-color: var(--cyan); }
.ws-th-mini:disabled { opacity: 0.3; cursor: default; }
.ws-th-mini.on { color: var(--cyan); border-color: var(--cyan); }
.ws-th-mini.danger:hover:not(:disabled) { color: var(--red); border-color: var(--red); }
.ws-th-resize { grid-column: 2; cursor: ns-resize; }
.ws-th-resize:hover { background: rgba(64, 196, 255, 0.3); }

.ws-range { flex: 1; min-width: 0; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---------- side panel ---------- */
.ws-side {
  grid-area: side;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--line2);
}
.ws-tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line2); }
.ws-tab {
  padding: 6px 10px; background: transparent; border: 1px solid transparent; border-bottom: none;
  border-radius: 7px 7px 0 0; color: var(--muted); cursor: pointer;
}
.ws-tab:hover { color: #fff; }
.ws-tab.active { background: var(--panel2); border-color: var(--line2); color: var(--accent); }
.ws-tab.collapse { margin-left: auto; }
.ws-app.no-side .ws-tab.collapse { margin: 0 auto; }
.ws-side-body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }

.ws-p-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ws-p-row .ws-select { flex: 1; min-width: 0; }
.ws-p-lbl { width: 70px; flex: none; color: var(--muted); }
.ws-p-lbl.wide { width: 130px; }
.ws-p-unit { color: var(--muted); font-size: 12px; }
.ws-p-title { margin: 8px 0 0; font-weight: 700; color: var(--accent); }
.ws-p-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ws-p-args { display: flex; flex-direction: column; gap: 6px; }
.ws-muted { margin: 0; color: var(--muted); font-size: 12px; }

.ws-fx {
  border: 1px solid var(--line2); border-radius: 9px; padding: 7px 8px;
  background: rgba(255, 255, 255, 0.025);
  display: flex; flex-direction: column; gap: 4px;
}
.ws-fx.off { opacity: 0.55; }
.ws-fx-head { display: flex; align-items: center; gap: 5px; }
.ws-fx-head input { accent-color: var(--accent); }
.ws-fx-title { flex: 1; font-weight: 700; color: var(--cyan); }
.ws-fx-row { display: flex; align-items: center; gap: 6px; }
.ws-fx-lbl { width: 72px; flex: none; color: var(--muted); font-size: 12px; }
.ws-fx-val { width: 64px; flex: none; text-align: right; font-size: 11px; color: var(--text); font-variant-numeric: tabular-nums; }
.ws-fx-row .ws-select { flex: 1; }
.ws-spec { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }

.ws-th.midi .ws-th-name { color: var(--green); }
.ws-select.ws-th-inst { flex: none; width: 82px; min-height: 18px; height: 18px; padding: 0 18px 0 4px; font-size: 11px; line-height: 16px; }

/* ---------- bottom drawer: piano roll + mixer ---------- */
.ws-drawer {
  grid-area: drawer;
  display: flex; flex-direction: column;
  height: 340px; min-height: 0;
  background: var(--panel); border-top: 1px solid var(--line2);
}
.ws-drawer-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 4px 8px; border-bottom: 1px solid var(--line);
}
.ws-drawer-bar .ws-tab { border-radius: 7px; border: 1px solid transparent; }
.ws-drawer-bar .ws-tab.active { border-color: var(--line2); }
.ws-pr-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-left: 10px; }
.ws-pr-tools[hidden] { display: none; }
.ws-pr-title { color: var(--accent); font-weight: 600; margin-right: 6px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-pr {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 64px;
}
.ws-pr canvas { display: block; }
#prKeys { cursor: pointer; border-right: 1px solid var(--line2); }
.ws-pr-grid, .ws-pr-vel { min-width: 0; min-height: 0; overflow: hidden; }
.ws-pr-vel { border-top: 1px solid var(--line2); cursor: ns-resize; }
.ws-pr-vlabel {
  display: flex; align-items: center; justify-content: center;
  border-top: 1px solid var(--line2); border-right: 1px solid var(--line2);
  color: var(--muted); font-size: 11px; background: #0a1120;
}

.ws-mixer {
  flex: 1; min-height: 0;
  display: flex; gap: 6px; padding: 8px; overflow-x: auto;
}
.ws-mx-strip {
  flex: none; width: 92px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 0 6px 6px; border: 1px solid var(--line2); border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
}
.ws-mx-strip.master { border-color: rgba(255, 203, 107, 0.5); }
.ws-mx-name {
  align-self: stretch; padding-top: 4px; border-top: 3px solid var(--accent);
  text-align: center; font-weight: 600; font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ws-mx-sub { color: var(--muted); font-size: 10px; }
.ws-mx-body { display: flex; align-items: stretch; gap: 6px; flex: none; }
.ws-mx-meter { width: 10px; height: 118px; border-radius: 3px; }
.ws-mx-fader {
  writing-mode: vertical-lr; direction: rtl;
  width: 22px; height: 118px; margin: 0; accent-color: var(--accent); cursor: pointer;
}
.ws-mx-db { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ws-mx-strip .ws-range { width: 100%; flex: none; }
.ws-mx-row { display: flex; gap: 4px; }

/* ---------- status bar ---------- */
.ws-status {
  grid-area: status;
  display: flex; align-items: center; gap: 12px;
  padding: 4px 10px; min-height: 26px;
  background: var(--panel); border-top: 1px solid var(--line2);
  font-size: 12px;
}
.ws-status-msg { color: var(--accent); }
.ws-status-sel { color: var(--muted); }
.ws-master-meter { width: 220px; height: 14px; border-radius: 3px; }

/* ---------- dialogs ---------- */
.ws-dlg {
  padding: 0; border: 1px solid var(--line2); border-radius: 14px;
  background: var(--panel); color: var(--text);
  width: min(460px, 94vw);
  box-shadow: 0 0 1px rgba(64, 196, 255, 0.7), 0 12px 40px rgba(0, 0, 0, 0.7);
}
.ws-dlg.wide { width: min(940px, 96vw); }
.ws-dlg::backdrop { background: rgba(0, 0, 8, 0.7); }
.ws-dlg-body { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; max-height: 88vh; overflow-y: auto; }
.ws-dlg h2 { margin: 0 0 4px; color: var(--accent); font-size: 18px; }
.ws-dlg h3 { margin: 10px 0 2px; color: var(--cyan); font-size: 14px; }
.ws-dlg p { margin: 0; }
.ws-dlg-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); }
.ws-dlg-row .ws-select { min-width: 220px; }
.ws-chk { display: flex; align-items: center; gap: 8px; }
.ws-chk input { accent-color: var(--accent); }
.ws-dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.ws-dlg-actions.left { justify-content: flex-start; }
.ws-dlg-row .ws-text { flex: 1; max-width: 300px; }
.ws-cloud-list { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; margin-top: 8px; }
.ws-cloud-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.ws-cloud-row.current { border-color: var(--accent); }
.ws-cloud-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-cloud-meta { font-size: 11px; white-space: nowrap; }
.ws-cloud-login a { color: var(--cyan); }
.ws-progress { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.ws-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
.ws-help { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; }
.ws-help p { color: var(--muted); }
.ws-keys { border-collapse: collapse; width: 100%; font-size: 12px; }
.ws-keys td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
.ws-keys td:first-child { color: var(--accent); white-space: nowrap; font-family: Consolas, monospace; }

@media (max-width: 1720px) {
  .ws-top { gap: 6px 7px; }
  .ws-brand { display: none; }
}
@media (max-width: 1100px) {
  :root { --side: 280px; --hw: 210px; }
  .ws-brand { display: none; }
}
