:root {
  --ink: #1b1917;
  --studio: #25231f;
  --raised: #302d28;
  --raised-2: #38342e;
  --paper: #fbf4e4;
  --paper-dim: #d8d0bf;
  --coral: #ff6b52;
  --coral-soft: rgba(255, 107, 82, 0.14);
  --lilac: #9996ff;
  --lilac-soft: rgba(153, 150, 255, 0.14);
  --lime: #cce85c;
  --sky: #4fb8db;
  --line: rgba(251, 244, 228, 0.13);
  --line-strong: rgba(251, 244, 228, 0.23);
  --shadow: 5px 6px 0 rgba(0, 0, 0, 0.24);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  color: var(--paper);
  cursor: pointer;
  transition: transform 120ms ease, border-color 160ms ease,
    background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--line-strong);
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.36;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 500;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--lime);
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

/* Header */
.studio-header {
  position: relative;
  z-index: 60;
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(37, 35, 31, 0.97);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--paper);
  font-size: 23px;
  font-weight: 950;
  letter-spacing: -0.06em;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px 14px 11px 13px;
  background: var(--coral);
  color: var(--ink);
  font-size: 28px;
  font-weight: 950;
  line-height: 1;
}

.brand-mark::after {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  content: "";
}

.wordmark-dot {
  color: var(--coral);
}

.studio-name {
  margin-left: -3px;
  color: var(--paper-dim);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.bpm-chip,
.service-chip,
.landing-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--raised);
  color: var(--paper-dim);
  font-size: 11px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.service-chip::before {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--paper-dim);
  content: "";
}

.service-chip.ready::before {
  background: var(--lime);
  box-shadow: 0 0 0 3px rgba(204, 232, 92, 0.12);
}

.service-chip.partial::before {
  background: #f0c86a;
}

.service-chip.offline::before {
  background: var(--coral);
}

.landing-chip:hover {
  border-color: var(--coral);
  color: var(--paper);
}

.transport {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

#time-display {
  min-width: 116px;
  color: var(--paper-dim);
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.btn-round {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--raised);
  font-size: 14px;
}

.btn-round:first-child {
  border-color: transparent;
  background: var(--coral);
  color: var(--ink);
}

.btn-round.small {
  width: 30px;
  height: 30px;
  color: var(--paper-dim);
  font-size: 12px;
}

.btn-primary {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 0 16px;
  background: var(--coral);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.btn-primary:hover:not(:disabled) {
  background: #ff7a64;
}

.btn-primary.big {
  width: 100%;
  min-height: 45px;
  margin-bottom: 9px;
  font-size: 14px;
}

.btn-ghost {
  width: 100%;
  min-height: 38px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--paper-dim);
  padding: 8px 10px;
  font-size: 12px;
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--lilac);
  color: var(--paper);
}

/* Workspace */
.layout {
  display: flex;
  height: calc(100% - 72px);
  min-height: 0;
}

.sidebar {
  display: flex;
  width: 324px;
  min-width: 324px;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: #201e1b;
  scrollbar-color: var(--raised-2) transparent;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--studio);
}

.panel-kicker,
.eyebrow {
  color: var(--coral);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.panel h3 {
  margin: 2px 0 12px;
  color: var(--paper);
  font-size: 15px;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.deck-card {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 15px 17px 16px 14px;
  padding: 10px;
  background: var(--raised);
}

.deck-card.dragging {
  border-color: var(--lime);
  background: #36352b;
}

.deck-card.loaded .deck-drop {
  opacity: 0.65;
  font-size: 10px;
}

.deck-tag {
  display: grid;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 9px 11px 8px 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 950;
}

.tag-a {
  background: var(--coral);
}

.tag-b {
  background: var(--lilac);
}

.deck-body {
  min-width: 0;
  flex: 1;
}

.deck-name {
  overflow: hidden;
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-drop {
  padding: 5px 0;
  color: var(--paper-dim);
  cursor: pointer;
  font-size: 11px;
}

.deck-drop:hover {
  color: var(--lime);
}

.deck-yt {
  display: flex;
  gap: 6px;
  margin: 4px 0 7px;
}

.deck-yt .yt-url {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  padding: 6px 9px;
  font-size: 11px;
}

.deck-yt .yt-url::placeholder {
  color: var(--paper-dim);
  opacity: 0.7;
}

.deck-yt .yt-url:focus {
  border-color: var(--lilac);
  outline: none;
}

.deck-yt .yt-go {
  min-width: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
}

.deck-info {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}

.badge {
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--lilac-soft);
  color: #c8c6ff;
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.deck-stem-btn {
  width: 100%;
  min-height: 32px;
  margin: 2px 0 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--lilac-soft);
  color: #cfcdff;
  font-size: 10px;
  font-weight: 750;
}

.deck-stem-btn.done {
  border-color: rgba(204, 232, 92, 0.28);
  background: rgba(204, 232, 92, 0.1);
  color: var(--lime);
  opacity: 1;
}

.deck-add {
  display: flex;
  gap: 5px;
  margin-bottom: 7px;
}

.deck-add button {
  min-height: 29px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper-dim);
  padding: 4px 2px;
  font-size: 9px;
}

.deck-add button:hover:not(:disabled) {
  border-color: var(--coral);
  color: var(--paper);
}

.deck-controls {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 5px;
  color: var(--paper-dim);
  font-size: 10px;
}

.deck-controls label {
  display: flex;
  align-items: center;
  gap: 5px;
}

.deck-controls input[type="range"] {
  width: 70px;
}

input[type="range"] {
  accent-color: var(--coral);
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  padding: 3px 6px;
}

.tpl-btn {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 7px;
  border: 1px solid var(--line);
  border-radius: 12px 14px 13px 11px;
  background: var(--raised);
  padding: 9px 11px;
  text-align: left;
}

.tpl-btn:hover:not(:disabled) {
  border-color: var(--lilac);
  background: var(--raised-2);
}

.tpl-btn strong {
  font-size: 12px;
}

.tpl-btn span {
  color: var(--paper-dim);
  font-size: 10px;
  line-height: 1.35;
}

.master-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
  color: var(--paper-dim);
  font-size: 11px;
}

.master-row input[type="range"] {
  flex: 1;
}

#speed-val {
  color: var(--paper);
  font-family: "SF Mono", ui-monospace, monospace;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hint {
  margin: -5px 0 10px;
  color: var(--paper-dim);
  font-size: 9px;
  opacity: 0.65;
  text-align: center;
}

.check-row {
  justify-content: flex-start;
}

.check-row input {
  accent-color: var(--lime);
}

.btn-ghost.lucky {
  margin-bottom: 10px;
}

.rights-note {
  margin: 0;
  padding: 2px 6px 10px;
  color: var(--paper-dim);
  font-size: 10px;
  line-height: 1.5;
}

.rights-note a {
  color: var(--lime);
}

/* Main editing surface */
.main {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 11px;
  overflow: auto;
  padding: 18px;
  background: var(--ink);
}

.studio-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 2px 4px;
}

.studio-intro .eyebrow {
  display: block;
  margin-bottom: 3px;
}

.studio-intro h1 {
  margin: 0;
  font-size: clamp(22px, 2.4vw, 34px);
  font-weight: 950;
  letter-spacing: -0.045em;
  line-height: 1;
}

.studio-intro p {
  max-width: 360px;
  margin: 0;
  color: var(--paper-dim);
  font-size: 11px;
  text-align: right;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 7px;
  background: var(--studio);
}

.btn-tool {
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--raised);
  padding: 5px 10px;
  font-size: 11px;
}

.btn-tool:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--raised-2);
}

.toolbar .spacer {
  flex: 1;
}

.tool-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--paper-dim);
  font-size: 10px;
}

.tool-label input[type="range"] {
  width: 105px;
}

#timeline {
  flex-shrink: 0;
}

.tl-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #141310;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.tl-spacer {
  position: absolute;
  top: 0;
  left: 0;
}

.tl-canvas {
  position: sticky;
  top: 0;
  left: 0;
  display: block;
}

.inspector {
  display: none;
  max-width: 520px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--studio);
  padding: 13px 15px;
}

.inspector.show {
  display: block;
}

.inspector h4 {
  margin: 0 0 9px;
  color: var(--lime);
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.inspector label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--paper-dim);
  font-size: 11px;
}

.inspector input[type="range"] {
  max-width: 250px;
  flex: 1;
}

.btn-tool.rec.recording {
  border-color: var(--coral);
  background: var(--coral);
  color: var(--ink);
  animation: record-pulse 1.2s ease-in-out infinite;
}

@keyframes record-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 82, 0.3); }
  50% { box-shadow: 0 0 0 7px rgba(255, 107, 82, 0); }
}

/* Onboarding and guidance */
.onboarding {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 9, 8, 0.82);
  backdrop-filter: blur(5px);
}

.onboarding.show {
  display: flex;
}

.ob-card {
  position: relative;
  width: min(450px, calc(100% - 28px));
  border: 1px solid var(--line-strong);
  border-radius: 24px 27px 22px 25px;
  padding: 30px 30px 22px;
  background: var(--studio);
  box-shadow: 12px 16px 0 rgba(0, 0, 0, 0.28);
}

.ob-x {
  position: absolute;
  top: 12px;
  right: 13px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  color: var(--paper-dim);
}

.ob-x:hover {
  background: var(--raised);
  color: var(--paper);
}

.ob-steps {
  position: relative;
  min-height: 220px;
}

.ob-step {
  display: none;
  text-align: center;
  animation: ob-fade 280ms ease;
}

.ob-step.active {
  display: block;
}

@keyframes ob-fade {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.ob-buddies {
  display: flex;
  height: 62px;
  align-items: end;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.ob-buddies span {
  position: relative;
  display: block;
  width: 47px;
  height: 56px;
  border-radius: 23px 23px 17px 17px;
  background: var(--coral);
  animation: buddy-float 1.8s ease-in-out infinite alternate;
}

.ob-buddies span:nth-child(2) {
  height: 48px;
  background: var(--lilac);
  animation-delay: -0.7s;
}

.ob-buddies span::before,
.ob-buddies span::after {
  position: absolute;
  top: 21px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink);
  content: "";
}

.ob-buddies span::before { left: 15px; }
.ob-buddies span::after { right: 15px; }

@keyframes buddy-float {
  to { transform: translateY(-5px) rotate(1deg); }
}

.ob-symbol {
  display: grid;
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 17px 19px 16px 18px;
  background: var(--coral);
  color: var(--ink);
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 15px;
  font-weight: 950;
}

.ob-step:nth-child(even) .ob-symbol {
  background: var(--lilac);
}

.ob-card h2 {
  margin: 0 0 11px;
  font-size: 22px;
  font-weight: 950;
  letter-spacing: -0.035em;
}

.ob-step p {
  margin: 0;
  color: var(--paper-dim);
  font-size: 13px;
  line-height: 1.62;
}

.ob-step p strong {
  color: var(--paper);
}

.ob-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 18px 0 15px;
}

.ob-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--raised-2);
  cursor: pointer;
  transition: width 180ms ease, background-color 180ms ease;
}

.ob-dot.on {
  width: 22px;
  border-radius: 999px;
  background: var(--coral);
}

.ob-nav {
  display: flex;
  gap: 9px;
}

.ob-nav .ob-prev {
  width: auto;
  flex: 0 0 auto;
  padding: 8px 17px;
}

.ob-nav .ob-next {
  flex: 1;
}

.coach {
  position: fixed;
  z-index: 300;
  inset: 0;
  display: none;
}

.coach.show {
  display: block;
}

.coach-hole {
  position: absolute;
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(10, 9, 8, 0.8);
  pointer-events: none;
  transition: top 280ms ease, left 280ms ease, width 280ms ease, height 280ms ease;
}

.coach-ring {
  position: absolute;
  border: 2px solid var(--lime);
  border-radius: 14px;
  box-shadow: 0 0 0 4px rgba(204, 232, 92, 0.12);
  pointer-events: none;
  transition: top 280ms ease, left 280ms ease, width 280ms ease, height 280ms ease;
}

.coach-bubble {
  position: absolute;
  width: min(340px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 18px 20px 17px 19px;
  padding: 16px;
  background: var(--studio);
  box-shadow: var(--shadow);
  transition: top 280ms ease, left 280ms ease;
}

.coach-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.coach-icon {
  display: grid;
  width: 31px;
  height: 31px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 10px;
  background: var(--coral);
  color: var(--ink);
  font-size: 14px;
}

.coach-title {
  flex: 1;
  font-size: 14px;
  font-weight: 850;
}

.coach-count {
  color: var(--paper-dim);
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 11px;
}

.coach-text {
  margin: 0;
  color: var(--paper-dim);
  font-size: 12px;
  line-height: 1.55;
}

.coach-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 13px;
}

.coach-skip {
  background: transparent;
  color: var(--paper-dim);
  padding: 6px 4px;
  font-size: 12px;
}

.coach-next {
  min-height: 35px;
  padding: 0 16px;
}

#toast {
  position: fixed;
  z-index: 400;
  bottom: 24px;
  left: 50%;
  max-width: min(620px, calc(100vw - 28px));
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 10px 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(80px);
  transition: opacity 220ms ease, transform 220ms ease;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1120px) {
  .studio-name,
  .landing-chip {
    display: none;
  }

  .sidebar {
    width: 304px;
    min-width: 304px;
  }

  .studio-intro p {
    display: none;
  }
}

@media (max-width: 900px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  body {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .studio-header {
    position: sticky;
    top: 0;
    flex-wrap: wrap;
    gap: 7px 9px;
    min-height: 64px;
    padding: 9px 11px;
  }

  .logo {
    font-size: 20px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 25px;
  }

  .service-chip {
    display: none;
  }

  .transport {
    order: 3;
    width: auto;
    margin-left: auto;
  }

  #time-display {
    min-width: 0;
    font-size: 10px;
  }

  .layout {
    height: auto;
    flex-direction: column;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main {
    overflow: visible;
    padding: 13px;
  }

  .studio-intro {
    align-items: start;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar .spacer {
    display: none;
  }

  .tool-label input[type="range"] {
    width: 78px;
  }

  .inspector {
    max-width: 100%;
  }

  .deck-yt .yt-url {
    font-size: 16px;
  }
}

@media (max-width: 520px) {
  .bpm-chip {
    display: none;
  }

  .btn-round.small {
    display: none;
  }

  .transport {
    margin-left: auto;
  }

  #btn-export {
    width: 100%;
    order: 4;
  }

  .deck-controls {
    flex-wrap: wrap;
  }

  .studio-intro h1 {
    font-size: 25px;
  }

  .ob-card {
    padding: 24px 18px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
