/* App shell: topbar, three-column workspace, responsive drawers. */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

/* Keep controls clear of notches and home indicators on fullscreen iOS. */
@supports (padding: env(safe-area-inset-bottom)) {
  .topbar {
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .workspace {
    padding-bottom: calc(var(--gap) + env(safe-area-inset-bottom));
  }
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  min-height: var(--topbar-h);
  background: linear-gradient(180deg, rgba(21, 25, 34, 0.94), rgba(11, 14, 19, 0.94));
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: relative;
  z-index: 30;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 0 auto;
}

.topbar-mid {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 2px 0;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent 100%);
}

.topbar-mid .field {
  flex: 0 0 auto;
}

.topbar-mid::-webkit-scrollbar {
  display: none;
}

.topbar-right {
  margin-left: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-right: 4px;
  flex: 0 0 auto;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-hi), var(--accent-lo));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 5px;
  box-shadow: 0 4px 14px rgba(255, 122, 26, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.brand-mark span {
  border-radius: 1px;
  background: rgba(20, 14, 6, 0.55);
}

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(4),
.brand-mark span:nth-child(9) {
  background: rgba(20, 14, 6, 0.18);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.brand-sub {
  font-size: 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 700;
}

/* --------------------------------------------------------------- workspace */

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr) 288px;
  gap: var(--gap);
  padding: var(--gap);
}

.rack,
.sidebar {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 30%), var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.drawer-head .side-title {
  margin-bottom: 0;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 55;
}

.scrim[hidden] {
  display: none;
}


/* ------------------------------------------------------------- breakpoints */

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr) 258px;
  }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 92vw);
    z-index: 60;
    border-radius: 0;
    border-right: 0;
    transform: translateX(105%);
    transition: transform var(--med) var(--ease);
    box-shadow: var(--shadow-2);
    padding: 12px;
  }

  .sidebar.is-open {
    transform: none;
  }

  .sidebar .drawer-head {
    display: flex;
  }

}

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    padding: 8px;
    gap: 8px;
  }

  .rack {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(360px, 92vw);
    z-index: 60;
    border-radius: 0;
    border-left: 0;
    transform: translateX(-105%);
    transition: transform var(--med) var(--ease);
    box-shadow: var(--shadow-2);
    padding: 12px;
  }

  .rack.is-open {
    transform: none;
  }

  .rack .drawer-head {
    display: flex;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
  }

  /* Play toggles, so the separate stop button is redundant on phones. */
  .transport .btn-icon {
    display: none;
  }

  .topbar-group {
    gap: 6px;
  }

  .play-btn {
    width: 38px;
    height: 38px;
  }

  .play-btn svg {
    width: 15px;
    height: 15px;
  }

  .dragnum {
    min-width: 50px;
    height: 38px;
    padding: 0 6px;
  }

  .dragnum-value {
    font-size: 13px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
    padding: 4px;
  }

  .stage-hint {
    display: none;
  }

  .topbar-mid {
    order: 3;
    flex-basis: 100%;
    padding-bottom: 2px;
  }

  .brand-sub {
    display: none;
  }

  .topbar-right {
    margin-left: auto;
  }
}

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

  .topbar {
    gap: 6px;
  }
}
