:root {
  --dj-page: #f4f4f2;
  --dj-surface: #ffffff;
  --dj-surface-soft: #f7f7f5;
  --dj-ink: #202020;
  --dj-muted: #737373;
  --dj-line: #dededb;
  --dj-line-strong: #c9c9c4;
  --dj-accent: #f7a917;
  --dj-cyan: #32b9a8;
  --dj-red: #b42318;
  --dj-green: #14805e;
  --dj-shadow: 0 16px 42px rgba(20, 20, 20, 0.09);
  --dj-radius: 8px;
  color-scheme: light;
}

.dark {
  --dj-page: #202020;
  --dj-surface: #2c2c2c;
  --dj-surface-soft: #353535;
  --dj-ink: #f5f5f5;
  --dj-muted: #b7b7b7;
  --dj-line: #464646;
  --dj-line-strong: #5a5a5a;
  --dj-shadow: 0 20px 52px rgba(0, 0, 0, 0.24);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--dj-page);
  color: var(--dj-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button { color: inherit; }

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dj-topbar .en-header-inner {
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
}

.dj-view-nav button span {
  white-space: nowrap;
}

.dj-workspace {
  height: calc(100vh - var(--en-app-header-height));
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  overflow: hidden;
}

.dj-sidebar {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--dj-line);
  background: var(--dj-surface);
}

.dj-sidebar-head,
.dj-section-head,
.dj-panel-head {
  min-height: 58px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--dj-line);
}

.dj-sidebar-head {
  min-height: 62px;
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
}

.dj-sidebar-head span,
.dj-section-head span,
.dj-panel-head span {
  display: block;
  color: var(--dj-muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.dj-sidebar-head strong,
.dj-section-head strong,
.dj-panel-head strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
  line-height: 1.1;
}

.dj-set-actions {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-bottom: 1px solid var(--dj-line);
}

.dj-button,
.dj-icon-button {
  border: 1px solid var(--dj-line);
  border-radius: 7px;
  background: var(--dj-surface);
  color: var(--dj-ink);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.dj-button {
  min-height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

.dj-icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.dj-button:hover,
.dj-icon-button:hover,
.dj-button.is-active,
.dj-icon-button.is-active {
  border-color: var(--dj-line-strong);
  background: var(--dj-surface-soft);
}

.dj-button:active,
.dj-icon-button:active {
  transform: translateY(1px);
}

.dj-button:focus-visible,
.dj-icon-button:focus-visible,
.dj-set-row:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(247, 169, 23, .55);
  outline-offset: 2px;
}

.dj-button-primary {
  border-color: #cc8706;
  background: var(--dj-accent);
  color: #171717;
}

.dj-button-primary:hover {
  border-color: #a66a00;
  background: #f1a00a;
}

.dj-button-danger {
  border-color: rgba(180, 35, 24, .34);
  color: var(--dj-red);
}

.dj-button-danger:hover {
  border-color: rgba(180, 35, 24, .55);
  background: rgba(180, 35, 24, .08);
}

.dj-set-list {
  min-height: 0;
  padding: 8px;
  flex: 1;
  overflow-y: auto;
}

.dj-set-row {
  width: 100%;
  min-height: 58px;
  margin: 0 0 7px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--dj-ink);
  text-align: left;
  cursor: pointer;
}

.dj-set-row:hover,
.dj-set-row.is-active {
  border-color: var(--dj-line);
  background: var(--dj-surface-soft);
}

.dj-set-row strong,
.dj-set-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dj-set-row strong {
  display: block;
  font-size: 13px;
}

.dj-set-row span {
  display: block;
  margin-top: 5px;
  color: var(--dj-muted);
  font-size: 11px;
}

.dj-set-row em {
  align-self: start;
  display: inline-flex;
  min-width: 38px;
  justify-content: center;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(50, 185, 168, .14);
  color: var(--dj-cyan);
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}

.dj-sidebar-foot {
  min-height: 58px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--dj-line);
}

.dj-sidebar-foot strong,
.dj-sidebar-foot small {
  display: block;
}

.dj-sidebar-foot strong {
  font-size: 12px;
}

.dj-sidebar-foot small {
  margin-top: 2px;
  color: var(--dj-muted);
  font-size: 11px;
}

.dj-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--dj-green);
  box-shadow: 0 0 0 4px rgba(20, 128, 94, .12);
}

.dj-status-dot.is-dirty {
  background: var(--dj-accent);
  box-shadow: 0 0 0 4px rgba(247, 169, 23, .16);
}

.dj-main {
  min-width: 0;
  height: 100%;
  overflow: auto;
  background: var(--dj-page);
}

.dj-stage,
.dj-mixer,
.dj-sets-view {
  min-height: 100%;
  padding: 14px;
}

.dj-transport {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(190px, 260px) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--dj-line);
  border-radius: var(--dj-radius);
  background: var(--dj-surface);
  box-shadow: var(--dj-shadow);
}

.dj-title-block label,
.dj-tempo label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--dj-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.dj-title-block input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--dj-line);
  border-radius: 6px;
  background: var(--dj-surface-soft);
  color: var(--dj-ink);
  font-size: 15px;
  font-weight: 700;
}

.dj-transport-buttons,
.dj-head-actions,
.dj-meters {
  display: flex;
  align-items: center;
  gap: 7px;
}

.dj-play {
  border-color: rgba(20, 128, 94, .45);
  color: var(--dj-green);
}

.dj-play.is-running {
  border-color: #a66a00;
  background: var(--dj-accent);
  color: #171717;
}

.dj-tempo input,
.dj-master input,
.dj-channel input[type="range"] {
  width: 100%;
  accent-color: var(--dj-accent);
}

.dj-meters {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.dj-meters span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--dj-line);
  border-radius: 999px;
  color: var(--dj-muted);
  font-size: 11px;
  font-weight: 700;
}

.dj-live-grid {
  min-height: calc(100vh - 154px);
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(420px, 1.08fr) minmax(320px, .92fr);
  gap: 14px;
}

.dj-editor,
.dj-visual,
.dj-mixer,
.dj-sets-view {
  border: 1px solid var(--dj-line);
  border-radius: var(--dj-radius);
  background: var(--dj-surface);
  box-shadow: var(--dj-shadow);
}

.dj-editor,
.dj-visual {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.dj-editor textarea {
  min-height: 420px;
  flex: 1;
  resize: none;
  padding: 16px;
  border: 0;
  border-bottom: 1px solid var(--dj-line);
  background: #151515;
  color: #f5f5f5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
  tab-size: 2;
}

.dark .dj-editor textarea {
  background: #111111;
}

.dj-log {
  min-height: 44px;
  max-height: 86px;
  padding: 10px 14px;
  overflow: auto;
  color: var(--dj-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
}

.dj-visual canvas {
  width: 100%;
  min-height: 260px;
  flex: 1;
  display: block;
  background:
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,.04) 1px, transparent 1px),
    #171717;
  background-size: 32px 32px;
}

.dj-master {
  min-height: 58px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--dj-line);
}

.dj-master label {
  color: var(--dj-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.dj-section-head {
  margin: -14px -14px 14px;
}

.dj-channel-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(138px, 1fr));
  gap: 10px;
}

.dj-channel {
  min-height: 330px;
  padding: 10px;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 10px;
  border: 1px solid var(--dj-line);
  border-radius: 8px;
  background: var(--dj-surface-soft);
}

.dj-channel h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.dj-channel select {
  width: 100%;
  height: 34px;
  border: 1px solid var(--dj-line);
  border-radius: 6px;
  background: var(--dj-surface);
  color: var(--dj-ink);
  font-size: 12px;
}

.dj-channel-meter {
  position: relative;
  min-height: 120px;
  border: 1px solid var(--dj-line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--dj-surface);
}

.dj-channel-meter span {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--level, 5%);
  background: linear-gradient(180deg, var(--dj-cyan), var(--dj-accent));
  transition: height .08s linear;
}

.dj-channel-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.dj-toggle.is-active {
  border-color: var(--dj-accent);
  background: rgba(247, 169, 23, .16);
}

.dj-toggle.is-muted {
  border-color: rgba(180, 35, 24, .38);
  color: var(--dj-red);
}

.dj-channel label {
  display: grid;
  gap: 5px;
  color: var(--dj-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.dj-library {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.dj-library-item {
  min-height: 126px;
  padding: 13px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--dj-line);
  border-radius: 8px;
  background: var(--dj-surface-soft);
}

.dj-library-item strong,
.dj-library-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dj-library-item span {
  color: var(--dj-muted);
  font-size: 12px;
}

.dj-library-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.dj-empty {
  min-height: 92px;
  padding: 16px;
  display: grid;
  place-content: center;
  gap: 6px;
  color: var(--dj-muted);
  text-align: center;
}

.dj-empty strong {
  color: var(--dj-ink);
}

.dj-backdrop {
  display: none;
}

.dj-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--dj-line);
  border-radius: 8px;
  background: var(--dj-surface);
  color: var(--dj-ink);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .28);
}

.dj-dialog::backdrop {
  background: rgba(10, 10, 10, .48);
  backdrop-filter: blur(4px);
}

.dj-dialog form {
  margin: 0;
}

.dj-dialog-head {
  min-height: 62px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--dj-line);
}

.dj-dialog-head span {
  display: block;
  color: var(--dj-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.dj-dialog-head strong {
  display: block;
  margin-top: 5px;
}

.dj-dialog-body {
  padding: 16px;
}

.dj-dialog-body p {
  margin: 0 0 14px;
  color: var(--dj-muted);
  line-height: 1.5;
}

.dj-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 1180px) {
  .dj-live-grid {
    grid-template-columns: 1fr;
  }

  .dj-channel-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .dj-topbar .en-header-inner {
    grid-template-columns: minmax(120px, 1fr) auto auto;
  }

  .dj-view-nav > button {
    min-width: 42px;
    padding: 0 8px;
  }

  .dj-view-nav span {
    display: none;
  }

  .dj-workspace {
    height: auto;
    min-height: calc(100vh - var(--en-app-header-height));
    display: block;
  }

  .dj-sidebar {
    position: fixed;
    inset: var(--en-app-header-height) auto 0 0;
    z-index: 40;
    width: min(300px, 86vw);
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: 20px 0 50px rgba(0, 0, 0, .16);
  }

  .dj-workspace.is-panel-open .dj-sidebar {
    transform: translateX(0);
  }

  .dj-backdrop {
    position: fixed;
    inset: var(--en-app-header-height) 0 0;
    z-index: 35;
    border: 0;
    background: rgba(0, 0, 0, .32);
  }

  .dj-workspace.is-panel-open .dj-backdrop {
    display: block;
  }

  .dj-main {
    height: auto;
    overflow: visible;
  }

  .dj-transport {
    grid-template-columns: 1fr;
  }

  .dj-transport-buttons,
  .dj-meters {
    justify-content: flex-start;
  }

  .dj-editor textarea {
    min-height: 360px;
  }

  .dj-channel-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .dj-master {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .dj-stage,
  .dj-mixer,
  .dj-sets-view {
    padding: 10px;
  }

  .dj-live-grid {
    gap: 10px;
  }

  .dj-channel-grid,
  .dj-library {
    grid-template-columns: 1fr;
  }

  .dj-panel-head,
  .dj-section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .dj-head-actions,
  .dj-dialog-actions {
    width: 100%;
  }

  .dj-dialog-actions .dj-button,
  .dj-head-actions .dj-button {
    flex: 1;
  }
}
