:root {
  color-scheme: dark;
  --bg: #07120f;
  --ink: #fff7eb;
  --muted: #9dafaa;
  --paper: #0d1916;
  --panel: #0f1f1b;
  --panel-soft: #132923;
  --line: rgba(255, 255, 255, 0.13);
  --red: #f05a45;
  --blue: #3a8cff;
  --green: #39bf73;
  --gold: #f0b943;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(circle at 18% 12%, rgba(58, 140, 255, 0.14), transparent 30%),
    radial-gradient(circle at 86% 82%, rgba(240, 90, 69, 0.1), transparent 32%),
    linear-gradient(135deg, #020706 0%, var(--bg) 54%, #0b1915 100%);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  appearance: none;
  touch-action: manipulation;
}

a {
  color: inherit;
}

.site-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  min-height: 64px;
  padding: 8px clamp(14px, 2vw, 24px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand-link {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 220px;
  text-decoration: none;
}

.brand-link img,
.session-brand img {
  aspect-ratio: 1290 / 1892;
  border: 1px solid rgba(17, 28, 23, 0.18);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(17, 28, 23, 0.16);
  height: auto;
  object-fit: cover;
  object-position: 50% 18%;
  width: 38px;
}

.brand-link strong {
  display: block;
  font-size: 1rem;
  line-height: 1.1;
}

.brand-link small {
  color: var(--muted);
  display: block;
  font-weight: 800;
}

.site-nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.site-nav a,
.builder-menu summary {
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
  padding: 9px 11px;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a.active,
.builder-menu summary:hover,
.builder-menu summary.active {
  background: #eaf2ef;
  color: var(--ink);
}

.site-nav a.active,
.builder-menu summary.active {
  box-shadow: inset 0 -3px 0 var(--red);
}

.mobile-page-menu {
  display: none;
}

.cockpit-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 auto;
  max-width: 1800px;
  min-height: calc(100dvh - 76px);
  padding: 8px;
  width: 100%;
}

.cockpit-topbar {
  align-items: center;
  background: rgba(255, 253, 248, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(17, 28, 23, 0.1);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1.2fr) auto auto auto auto auto auto;
  padding: 8px;
}

.session-brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.cockpit-topbar > *,
.mobile-tabs,
.panel {
  max-width: 100%;
}

.session-brand img {
  max-height: 52px;
  width: 44px;
}

.brand-link img {
  max-height: 56px;
}

.session-brand p,
.panel-heading p,
.current-meta span,
.quick-note span,
.custom-editor span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  margin: 0;
}

.session-brand h1 {
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  line-height: 1.05;
  margin: 0;
}

.status-chip {
  align-items: center;
  background: #f3f7f5;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-weight: 850;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 7px 10px;
  white-space: nowrap;
}

.status-chip span {
  background: var(--gold);
  border-radius: 999px;
  display: block;
  height: 12px;
  width: 12px;
}

.status-chip.live span {
  background: #d43126;
  box-shadow: 0 0 0 6px rgba(212, 49, 38, 0.14);
}

.master-clock {
  align-items: center;
  background: #121c17;
  border-radius: 8px;
  color: white;
  display: grid;
  justify-items: center;
  min-height: 42px;
  min-width: 120px;
  padding: 6px 12px;
}

.master-clock strong {
  font-size: 1.35rem;
  line-height: 1;
}

.master-clock span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  font-weight: 800;
}

.top-button,
.file-loader,
.export-format,
.small-button,
.marker-button,
.next-beat-button,
.transport,
.duration-button,
.scene-cut-button,
.sfx-button,
.custom-pad-button {
  border: 1px solid rgba(17, 28, 23, 0.12);
  border-radius: 12px;
  box-shadow:
    0 8px 18px rgba(17, 28, 23, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.top-button,
.file-loader,
.export-format,
.small-button,
.marker-button,
.next-beat-button,
.transport,
.duration-button,
.scene-cut-button {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  justify-content: center;
  line-height: 1;
}

[data-icon]::before {
  align-items: center;
  background: var(--cat-soft, rgba(17, 28, 23, 0.06));
  border: 1px solid var(--cat-line, rgba(17, 28, 23, 0.08));
  border-radius: 9px;
  content: attr(data-icon);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.92em;
  font-weight: 950;
  height: 1.45em;
  justify-content: center;
  min-width: 1.45em;
}

.cockpit-topbar [data-icon]::before {
  background: var(--cat-soft, rgba(255, 255, 255, 0.1));
  border-color: var(--cat-line, rgba(255, 255, 255, 0.15));
  color: var(--cat, #ffffff);
}

.scene-cut-button[data-icon]::before {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  font-size: 0.86em;
}

.transport.start[data-icon]::before {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.18);
}

.top-button,
.file-loader,
.export-format,
.small-button {
  background: linear-gradient(180deg, #ffffff 0%, #edf4f1 100%);
  color: var(--ink);
  min-height: 42px;
  padding: 8px 10px;
}

.top-button:hover,
.file-loader:hover,
.export-format:hover,
.small-button:hover,
.marker-button:hover,
.next-beat-button:hover,
.duration-button:hover,
.sfx-button:hover,
.custom-pad-button:hover {
  border-color: var(--cat-line, rgba(47, 107, 79, 0.42));
  box-shadow:
    0 12px 22px rgba(17, 28, 23, 0.12),
    0 0 0 1px rgba(var(--cat-rgb, 47, 107, 79), 0.18),
    0 0 18px rgba(var(--cat-rgb, 47, 107, 79), 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  transform: translateY(-1px);
}

.top-button:focus-visible,
.file-loader:focus-within,
.export-format:focus-within,
.small-button:focus-visible,
.marker-button:focus-visible,
.next-beat-button:focus-visible,
.duration-button:focus-visible,
.transport:focus-visible,
.scene-cut-button:focus-visible,
.sfx-button:focus-visible,
.custom-pad-button:focus-visible {
  outline: 3px solid rgba(34, 101, 168, 0.32);
  outline-offset: 2px;
}

.file-loader {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  position: relative;
  text-align: center;
}

.file-loader input {
  height: 1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

.mobile-tabs {
  display: none;
}

.cockpit-grid {
  display: grid;
  flex: 1;
  gap: 8px;
  grid-template-columns: minmax(240px, 0.8fr) minmax(390px, 1.25fr) minmax(290px, 0.9fr);
  grid-template-rows: minmax(0, 1.45fr) minmax(120px, 0.45fr);
  min-height: 0;
}

.panel {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 36px rgba(17, 28, 23, 0.09);
  min-width: 0;
  overflow: hidden;
  padding: 14px;
  position: relative;
}

.runsheet-panel,
.log-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.runsheet-panel {
  grid-column: 1;
  grid-row: 1 / 3;
}

.live-panel {
  align-content: start;
  display: grid;
  gap: 8px;
  grid-column: 2;
  grid-row: 1;
}

.log-panel {
  grid-column: 3;
  grid-row: 1;
}

.sfx-panel {
  grid-column: 2;
  grid-row: 2;
}

.custom-panel {
  grid-column: 3;
  grid-row: 2;
}

.deck-panel {
  grid-column: 1 / 4;
  grid-row: 2;
  overflow: hidden;
}

.panel-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin: -2px 0 12px;
  padding-bottom: 10px;
}

.floating-action {
  font-size: 0.72rem;
  min-height: 30px;
  padding: 5px 8px;
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 3;
}

.log-panel .floating-action {
  right: 12px;
  top: 12px;
}

.runsheet-panel .runsheet-source {
  padding-right: 74px;
}

.log-panel .session-log {
  margin-right: 78px;
}

.runsheet-source,
.next-card {
  background: #f5f8f6;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-weight: 750;
  margin-bottom: 10px;
  padding: 10px;
}

.beat-list,
.session-log {
  display: grid;
  gap: 8px;
  margin: 0;
  overflow: auto;
  padding: 0;
}

.beat-list {
  flex: 1;
}

.beat-item {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-left: 5px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.beat-item strong {
  color: #d7fff5;
  display: block;
  line-height: 1.15;
  text-shadow: 0 0 12px rgba(34, 194, 189, 0.12);
}

.beat-item span {
  color: #93bdb6;
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  margin-top: 4px;
}

.beat-item.active {
  background: #edf5f3;
  border-left-color: var(--red);
  color: var(--ink);
}

.beat-item.active strong {
  color: #ffe0a3;
  text-shadow:
    0 0 14px rgba(240, 185, 67, 0.2),
    0 0 22px rgba(240, 90, 69, 0.14);
}

.beat-item.active span {
  color: #ffbba8;
}

.current-meta {
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.current-meta strong {
  display: block;
  font-size: clamp(1.45rem, 3.2vw, 2.6rem);
  line-height: 1.05;
  margin-top: 4px;
}

.timer-console {
  background: #121c17;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 2px;
  min-height: 154px;
  padding: 8px 14px 6px;
  position: relative;
}

.timer-console .current-meta {
  background: transparent;
  border: 0;
  box-shadow: none;
  left: 18px;
  max-width: calc(100% - 250px);
  min-width: 0;
  padding: 0;
  position: absolute;
  top: 15px;
  z-index: 2;
}

.timer-console .current-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-console .current-meta span {
  display: none;
}

.timer-console .current-meta strong {
  font-size: clamp(1.18rem, 1.55vw, 1.48rem);
  margin-top: 0;
}

.timer-reset {
  min-height: 34px;
  padding: 6px 9px;
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 2;
}

.beat-clock {
  background: transparent;
  border-radius: 10px;
  box-shadow: none;
  color: #f9efe3;
  font-size: clamp(5.2rem, 9vw, 8rem);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 0.95;
  padding: 38px 12px 0;
  text-align: center;
}

.beat-remaining {
  align-items: center;
  color: #d7fff5;
  display: inline-flex;
  font-size: clamp(1rem, 1.35vw, 1.16rem);
  font-weight: 950;
  justify-content: flex-end;
  line-height: 1;
  min-height: 34px;
  position: absolute;
  right: 104px;
  text-align: right;
  top: 14px;
  z-index: 2;
}

.beat-progress {
  background: #dce6e2;
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
}

.beat-progress span {
  background: linear-gradient(90deg, var(--blue), var(--green), var(--gold));
  display: block;
  height: 100%;
  width: 0;
}

.beat-note {
  color: var(--muted);
  display: none;
  font-size: 1rem;
  margin: 0;
  overflow-wrap: anywhere;
}

.transport-row,
.beat-nav-row,
.marker-row,
.duration-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.transport-row.primary-action-row {
  grid-template-columns: 1fr;
}

.marker-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.transport,
.next-beat-button,
.duration-button {
  min-height: 58px;
  padding: 10px;
}

.transport.start {
  background: linear-gradient(180deg, #2f8b63 0%, #216346 100%);
  border-color: rgba(26, 88, 60, 0.5);
  box-shadow:
    0 12px 24px rgba(47, 107, 79, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  color: white;
  font-size: 1.1rem;
  min-height: 68px;
}

.transport.start.paused {
  background: linear-gradient(180deg, #e9b34b 0%, #b98022 100%);
  border-color: rgba(185, 128, 34, 0.52);
  color: #1b1509;
}

.transport.reset,
.next-beat-button,
.marker-button,
.duration-button {
  background: linear-gradient(180deg, #ffffff 0%, #edf4f1 100%);
  color: var(--ink);
}

.scene-cut-button {
  background: linear-gradient(135deg, #ca3e30, #8e241d);
  border: 0;
  border-radius: 14px;
  box-shadow:
    0 16px 34px rgba(181, 64, 48, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  color: white;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  min-height: 72px;
  padding: 12px;
  text-transform: uppercase;
}

.scene-cut-button:active,
.transport:active,
.sfx-button:active,
.duration-button:active,
.marker-button:active,
.next-beat-button:active,
.custom-pad-button:active {
  box-shadow:
    0 4px 10px rgba(17, 28, 23, 0.1),
    inset 0 2px 5px rgba(17, 28, 23, 0.16);
  transform: translateY(1px);
}

.marker-button {
  font-size: 1rem;
  min-height: 62px;
  padding: 8px;
}

.session-log {
  flex: 1;
  list-style: none;
  min-height: 140px;
}

.session-log li {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
}

.session-log time {
  color: var(--red);
  display: inline-block;
  font-weight: 950;
  min-width: 74px;
}

.session-log strong {
  display: block;
}

.quick-note {
  display: block;
  margin: 10px 0;
  position: relative;
}

textarea,
input,
select {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  min-height: 46px;
  padding: 10px;
  width: 100%;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.quick-note textarea {
  display: block;
  min-height: 74px;
  padding-bottom: 44px;
  padding-right: 92px;
  resize: vertical;
}

.note-add-button {
  bottom: 8px;
  min-height: 30px;
  padding: 5px 8px;
  position: absolute;
  right: 8px;
  z-index: 2;
}

.full-width {
  width: 100%;
}

.sfx-grid,
.custom-pad-grid {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sfx-button,
.custom-pad-button {
  align-items: start;
  background: linear-gradient(180deg, #fffefb 0%, #f3f7f4 100%);
  color: var(--ink);
  display: grid;
  gap: 3px 7px;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 70px;
  padding: 8px;
  text-align: left;
}

.sfx-button[data-icon]::before,
.custom-pad-button[data-icon]::before {
  grid-row: 1 / 3;
  margin-top: 1px;
}

.sfx-button strong,
.custom-pad-button strong {
  grid-column: 2;
  line-height: 1.05;
}

.sfx-button span,
.custom-pad-button span {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  grid-column: 2;
  margin-top: 5px;
}

.custom-pad-button.red {
  border-left: 6px solid var(--red);
}

.custom-pad-button.blue {
  border-left: 6px solid var(--blue);
}

.custom-pad-button.green {
  border-left: 6px solid var(--green);
}

.custom-pad-button.gold {
  border-left: 6px solid var(--gold);
}

.custom-pad-button.ink {
  border-left: 6px solid var(--ink);
}

.custom-pad-button.selected {
  border-color: rgba(181, 64, 48, 0.42);
  box-shadow:
    0 12px 24px rgba(181, 64, 48, 0.14),
    inset 0 0 0 2px rgba(181, 64, 48, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.custom-editor {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: 1.1fr 1.2fr 1fr 0.8fr;
  margin-top: 12px;
  padding-top: 12px;
}

.custom-editor label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

/* Cockpit surface: match the generated touch-panel direction more closely. */
.cockpit-topbar {
  background: linear-gradient(135deg, #082f3a 0%, #073643 54%, #0b4652 100%);
  border: 0;
  color: #ffffff;
  gap: 12px;
  grid-template-columns: minmax(230px, 1.15fr) auto auto minmax(180px, 0.8fr) minmax(350px, auto);
  min-height: 88px;
  padding: 10px;
}

.session-brand p,
.session-summary strong,
.session-summary span,
.cockpit-topbar .master-clock span {
  color: rgba(255, 255, 255, 0.72);
}

.session-brand h1 {
  color: #ffffff;
  font-size: clamp(1.35rem, 2vw, 1.85rem);
}

.session-brand img {
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  max-height: 64px;
  width: 44px;
}

.cockpit-topbar .status-chip {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  min-width: 110px;
}

.cockpit-topbar .master-clock {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.14);
  min-width: 148px;
}

.cockpit-topbar .master-clock strong {
  color: #fff4df;
  font-size: 1.65rem;
}

.session-summary {
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-left: 14px;
}

.session-summary strong {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.session-summary span {
  display: -webkit-box;
  font-size: 0.82rem;
  font-weight: 750;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.topbar-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(56px, 1fr));
  min-width: 0;
}

.cockpit-topbar .top-button,
.cockpit-topbar .file-loader,
.cockpit-topbar .export-format {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  min-height: 44px;
}

.cockpit-topbar .top-button:hover,
.cockpit-topbar .file-loader:hover,
.cockpit-topbar .export-format:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.42);
}

.export-format {
  align-items: center;
  display: grid;
  gap: 1px;
  grid-template-columns: auto minmax(0, 1fr);
  min-width: 0;
}

.export-format span {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 950;
  line-height: 1;
}

.export-format select {
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 0.9rem;
  font-weight: 950;
  line-height: 1;
  min-height: 0;
  padding: 0;
}

.cockpit-grid {
  grid-template-columns: minmax(250px, 0.82fr) minmax(460px, 1.42fr) minmax(300px, 0.92fr);
  grid-template-rows: minmax(0, 1fr) auto;
}

.runsheet-panel {
  grid-column: 1;
  grid-row: 1;
}

.live-panel {
  grid-column: 2;
  grid-row: 1;
}

.log-panel {
  grid-column: 3;
  grid-row: 1;
}

.sfx-panel {
  grid-column: 1;
  grid-row: 2;
}

.custom-panel {
  grid-column: 2 / 4;
  grid-row: 2;
}

.deck-panel {
  grid-column: 1 / 4;
  grid-row: 2;
  background:
    radial-gradient(circle at 6% 0%, rgba(34, 101, 168, 0.28), transparent 34%),
    radial-gradient(circle at 94% 12%, rgba(181, 64, 48, 0.24), transparent 32%),
    linear-gradient(135deg, #07110f 0%, #10211d 48%, #07120f 100%);
  border-color: rgba(255, 255, 255, 0.11);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 20px 34px rgba(255, 255, 255, 0.04),
    0 14px 34px rgba(17, 28, 23, 0.2);
}

.panel {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(17, 28, 23, 0.13);
  box-shadow: 0 8px 24px rgba(17, 28, 23, 0.08);
}

.current-meta {
  background: #ffffff;
  border-color: rgba(17, 28, 23, 0.13);
}

.beat-clock {
  background: radial-gradient(circle at 50% 0%, rgba(22, 79, 88, 0.45), transparent 50%), #0e211b;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 14px 34px rgba(17, 28, 23, 0.16);
}

.beat-progress span {
  background: linear-gradient(90deg, #c94333, #e2a835);
}

.scene-cut-button {
  background: linear-gradient(135deg, #d24535, #a92d24);
  box-shadow: 0 14px 30px rgba(181, 64, 48, 0.28);
}

.sfx-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.custom-pad-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.sfx-button,
.custom-pad-button {
  background: #fffdf8;
  min-height: 58px;
}

.custom-editor {
  grid-template-columns: 1fr 1.4fr 1fr 0.8fr;
  margin-top: 8px;
  padding-top: 8px;
}

.custom-editor input,
.custom-editor select,
.quick-note textarea {
  background: #fffdf8;
}

.deck-track {
  --deck-button-height: 84px;
  align-content: start;
  align-items: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: auto;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scroll-snap-type: none;
  scrollbar-color: rgba(215, 255, 245, 0.35) rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
  padding-bottom: 8px;
}

.deck-row {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
  min-height: var(--deck-button-height);
  min-width: max-content;
}

.deck-track::-webkit-scrollbar {
  display: block;
  height: 8px;
}

.deck-track::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.deck-track::-webkit-scrollbar-thumb {
  background: rgba(215, 255, 245, 0.35);
  border-radius: 999px;
}

.deck-button {
  align-items: center;
  background:
    radial-gradient(circle at 50% 18%, rgba(var(--cat-rgb, 34, 101, 168), 0.52), rgba(var(--cat-rgb, 34, 101, 168), 0.2) 34%, transparent 64%),
    linear-gradient(145deg, rgba(var(--cat-rgb, 34, 101, 168), 0.28) 0%, rgba(var(--cat-rgb, 34, 101, 168), 0.12) 42%, #091411 100%);
  border: 1px solid rgba(var(--cat-rgb, 34, 101, 168), 0.6);
  border-radius: 9px;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.3),
    0 0 18px rgba(var(--cat-rgb, 34, 101, 168), 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 10px 18px rgba(255, 255, 255, 0.07),
    inset 0 -12px 20px rgba(0, 0, 0, 0.36);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  gap: 3px;
  height: var(--deck-button-height);
  isolation: isolate;
  justify-items: center;
  aspect-ratio: var(--button-ratio, 16 / 9);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 4px;
  position: relative;
  text-align: center;
  width: var(--button-width, 150px);
}

.deck-button.red {
  --cat: #d75040;
  --cat-rgb: 215, 80, 64;
}

.deck-button.blue {
  --cat: #3a8cff;
  --cat-rgb: 58, 140, 255;
}

.deck-button.green {
  --cat: #42d17d;
  --cat-rgb: 66, 209, 125;
}

.deck-button.teal {
  --cat: #22c2bd;
  --cat-rgb: 34, 194, 189;
}

.deck-button.gold {
  --cat: #f0b943;
  --cat-rgb: 240, 185, 67;
}

.deck-button.ink {
  --cat: #9aa8a0;
  --cat-rgb: 154, 168, 160;
}

.deck-button.has-image {
  align-content: end;
  background:
    linear-gradient(180deg, rgba(2, 8, 7, 0.02) 0%, rgba(2, 8, 7, 0.08) 48%, rgba(2, 8, 7, 0.52) 100%),
    radial-gradient(circle at 50% 20%, rgba(var(--cat-rgb, 34, 101, 168), 0.18), transparent 64%),
    var(--button-image);
  background-color: #06120f;
  background-position: center, center, center;
  background-repeat: no-repeat;
  background-size: 100% 100%, 100% 100%, contain;
  border-color: rgba(var(--cat-rgb, 34, 101, 168), 0.62);
  padding: 5px 6px;
}

.deck-button.selected {
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.24),
    0 0 0 2px rgba(var(--cat-rgb, 181, 64, 48), 0.42),
    0 0 28px rgba(var(--cat-rgb, 181, 64, 48), 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.deck-button:hover,
.deck-button.fired {
  filter: brightness(1.16) saturate(1.22);
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.32),
    0 0 28px rgba(var(--cat-rgb, 34, 101, 168), 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 10px 18px rgba(255, 255, 255, 0.09),
    inset 0 -12px 20px rgba(0, 0, 0, 0.34);
  transform: translateY(-1px);
}

.deck-button:active,
.deck-button.fired {
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.3),
    0 0 34px rgba(var(--cat-rgb, 34, 101, 168), 0.42),
    inset 0 2px 8px rgba(0, 0, 0, 0.38);
}

.deck-icon {
  align-items: center;
  background: rgba(var(--cat-rgb, 34, 101, 168), 0.32);
  border: 1px solid rgba(var(--cat-rgb, 34, 101, 168), 0.7);
  border-radius: 999px;
  box-shadow:
    0 0 12px rgba(var(--cat-rgb, 34, 101, 168), 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: inline-flex;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 950;
  height: 20px;
  justify-content: center;
  min-width: 20px;
  padding: 0 4px;
}

.deck-abbr {
  background: rgba(3, 11, 10, 0.68);
  border: 1px solid rgba(var(--cat-rgb, 34, 101, 168), 0.72);
  border-radius: 999px;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 950;
  line-height: 1;
  max-width: 100%;
  overflow: hidden;
  padding: 3px 8px;
  position: relative;
  text-overflow: ellipsis;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.6);
  text-transform: uppercase;
  white-space: nowrap;
  z-index: 2;
}

.explainer-key {
  margin: 0 auto;
  max-width: 1600px;
  padding: 28px clamp(14px, 3vw, 36px) 72px;
}

.key-shell {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(17, 28, 23, 0.08);
  padding: clamp(18px, 3vw, 28px);
}

.key-shell h2 {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  line-height: 1;
  margin: 0 0 10px;
}

.key-shell p {
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 750;
  margin: 0 0 18px;
  max-width: 760px;
}

.key-grid {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.key-item {
  align-items: center;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-left: 5px solid rgba(34, 101, 168, 0.5);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 10px;
}

.key-item.has-image {
  grid-template-columns: minmax(86px, 118px) minmax(0, 1fr);
  padding: 7px;
}

.key-item.pad {
  border-left-color: rgba(188, 138, 52, 0.72);
}

.key-item.red {
  border-left-color: var(--red);
}

.key-item.blue {
  border-left-color: var(--blue);
}

.key-item.green {
  border-left-color: var(--green);
}

.key-item.teal {
  border-left-color: #22c2bd;
}

.key-item.gold {
  border-left-color: var(--gold);
}

.key-item.ink {
  border-left-color: var(--ink);
}

.key-code {
  align-items: center;
  display: grid;
  gap: 4px;
  justify-items: center;
  min-width: 52px;
}

.key-code b {
  align-items: center;
  background: #edf4f1;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.72rem;
  height: 28px;
  justify-content: center;
  min-width: 28px;
  padding: 0 6px;
}

.key-code strong {
  font-size: 0.78rem;
}

.key-thumb {
  align-items: end;
  aspect-ratio: var(--button-ratio, 16 / 9);
  background:
    linear-gradient(180deg, rgba(2, 8, 7, 0.04), rgba(2, 8, 7, 0.58)),
    var(--button-image);
  background-color: #06120f;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%, contain;
  border: 1px solid rgba(var(--cat-rgb, 34, 101, 168), 0.58);
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  display: grid;
  min-width: 0;
  overflow: hidden;
  padding: 4px;
}

.key-thumb strong {
  background: rgba(3, 11, 10, 0.72);
  border: 1px solid rgba(var(--cat-rgb, 34, 101, 168), 0.62);
  border-radius: 999px;
  color: #ffffff;
  display: inline-block;
  font-size: 0.62rem;
  justify-self: start;
  line-height: 1;
  max-width: 100%;
  overflow: hidden;
  padding: 3px 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-item span:last-child {
  display: grid;
  gap: 3px;
}

.key-item em {
  color: var(--muted);
  font-size: 0.84rem;
  font-style: normal;
  font-weight: 750;
}

.pad-editor {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 16px;
}

.pad-editor summary {
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 950;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
}

.cat-recording,
.transport.start {
  --cat: #39bf73;
  --cat-rgb: 57, 191, 115;
  --cat-fill: #c9f1d9;
  --cat-soft: #e6f8ee;
  --cat-line: rgba(57, 191, 115, 0.34);
}

.cat-sound {
  --cat: #3a8cff;
  --cat-rgb: 58, 140, 255;
  --cat-fill: #cde1ff;
  --cat-soft: #e6f0ff;
  --cat-line: rgba(58, 140, 255, 0.34);
}

.cat-scene {
  --cat: #22c2bd;
  --cat-rgb: 34, 194, 189;
  --cat-fill: #c5f3ef;
  --cat-soft: #e3faf7;
  --cat-line: rgba(34, 194, 189, 0.34);
}

.cat-current,
.cat-sync {
  --cat: #36b5f2;
  --cat-rgb: 54, 181, 242;
  --cat-fill: #caecfb;
  --cat-soft: #e5f6fe;
  --cat-line: rgba(54, 181, 242, 0.34);
}

.cat-comedy,
.cat-support,
.cat-export {
  --cat: #f0b943;
  --cat-rgb: 240, 185, 67;
  --cat-fill: #f9e6b0;
  --cat-soft: #fff4d7;
  --cat-line: rgba(240, 185, 67, 0.38);
}

.cat-good {
  --cat: #66d061;
  --cat-rgb: 102, 208, 97;
  --cat-fill: #d0f0cb;
  --cat-soft: #eaf9e7;
  --cat-line: rgba(102, 208, 97, 0.34);
}

.cat-risk,
.scene-cut-button {
  --cat: #f05a45;
  --cat-rgb: 240, 90, 69;
  --cat-fill: #f8cfc6;
  --cat-soft: #fde7e1;
  --cat-line: rgba(240, 90, 69, 0.38);
}

.cat-edit,
.cat-timing,
.cat-full {
  --cat: #9aa8a0;
  --cat-rgb: 154, 168, 160;
  --cat-fill: #dce3df;
  --cat-soft: #f0f4f2;
  --cat-line: rgba(154, 168, 160, 0.34);
}

.cat-cue,
.cat-import {
  --cat: #b7d84b;
  --cat-rgb: 183, 216, 75;
  --cat-fill: #e5f2b8;
  --cat-soft: #f3f8dc;
  --cat-line: rgba(183, 216, 75, 0.36);
}

[data-icon]::before {
  color: var(--cat, var(--ink));
}

.top-button,
.file-loader,
.export-format,
.small-button,
.marker-button,
.next-beat-button,
.duration-button,
.transport.reset {
  background: linear-gradient(180deg, var(--cat-fill, #ffffff) 0%, var(--cat-soft, #edf4f1) 100%);
  border-color: var(--cat-line, rgba(17, 28, 23, 0.12));
  border-top: 3px solid var(--cat, rgba(17, 28, 23, 0.1));
}

.cockpit-topbar .top-button,
.cockpit-topbar .file-loader,
.cockpit-topbar .export-format {
  background:
    radial-gradient(circle at 50% 0%, rgba(var(--cat-rgb, 255, 255, 255), 0.35), transparent 62%),
    linear-gradient(180deg, rgba(var(--cat-rgb, 255, 255, 255), 0.2), rgba(255, 255, 255, 0.07));
  border-color: rgba(var(--cat-rgb, 255, 255, 255), 0.38);
  box-shadow:
    0 0 18px rgba(var(--cat-rgb, 255, 255, 255), 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.key-item.cat-recording,
.key-item.cat-sound,
.key-item.cat-scene,
.key-item.cat-current,
.key-item.cat-comedy,
.key-item.cat-good,
.key-item.cat-risk,
.key-item.cat-edit,
.key-item.cat-cue,
.key-item.cat-support {
  border-left-color: var(--cat);
}

.key-code b {
  background: var(--cat-soft, #edf4f1);
  border-color: var(--cat-line, var(--line));
  color: var(--cat, var(--ink));
}

/* Dark mixer-deck mode: one cohesive recording console, not a light admin page. */
.site-header {
  background: rgba(5, 13, 11, 0.96);
  border-bottom-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
}

.brand-link img,
.session-brand img {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
}

.site-nav a,
.builder-menu summary {
  color: var(--muted);
}

.site-nav a:hover,
.site-nav a.active,
.builder-menu summary:hover,
.builder-menu summary.active,
.mobile-page-menu {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.cockpit-shell {
  background:
    radial-gradient(circle at 30% 18%, rgba(34, 194, 189, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 36%);
}

.panel,
.timer-console,
.current-meta,
.runsheet-source,
.next-card,
.beat-item,
.session-log li,
.key-shell {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    var(--panel);
  border-color: var(--line);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: var(--ink);
}

.live-panel {
  background:
    radial-gradient(circle at 50% 0%, rgba(57, 191, 115, 0.08), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    #0c1915;
}

.runsheet-source,
.next-card,
.session-log,
.beat-note,
.quick-note span,
.custom-editor span {
  color: var(--muted);
}

.beat-item {
  box-shadow: none;
}

.beat-item strong {
  color: #d7fff5;
}

.beat-item span {
  color: #93bdb6;
}

.beat-item.active {
  background:
    radial-gradient(circle at 0% 0%, rgba(240, 90, 69, 0.28), transparent 52%),
    linear-gradient(90deg, rgba(240, 90, 69, 0.14), rgba(240, 185, 67, 0.06) 34%, rgba(57, 191, 115, 0.03)),
    rgba(16, 37, 31, 0.98);
  border-color: rgba(240, 90, 69, 0.38);
  border-left-color: var(--red);
  box-shadow:
    0 0 0 1px rgba(240, 90, 69, 0.16),
    0 0 22px rgba(240, 90, 69, 0.12);
  color: var(--ink);
}

.beat-item.active strong {
  color: #ffe0a3;
}

.beat-item.active span {
  color: #ffbba8;
}

.current-meta {
  background:
    radial-gradient(circle at 12% 0%, rgba(58, 140, 255, 0.16), transparent 48%),
    #091511;
}

.timer-console {
  background:
    radial-gradient(circle at 50% -8%, rgba(57, 191, 115, 0.2), transparent 48%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02)),
    #06110e;
}

.timer-console .current-meta {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.beat-clock {
  background: transparent;
  box-shadow: none;
}

.beat-progress {
  background: rgba(255, 255, 255, 0.11);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.45);
}

.top-button,
.file-loader,
.export-format,
.small-button,
.marker-button,
.next-beat-button,
.transport.reset {
  background:
    radial-gradient(circle at 50% -20%, rgba(var(--cat-rgb, 154, 168, 160), 0.54), rgba(var(--cat-rgb, 154, 168, 160), 0.16) 42%, transparent 72%),
    linear-gradient(180deg, #1a2925 0%, #0a1512 100%);
  border-color: rgba(var(--cat-rgb, 154, 168, 160), 0.46);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.26),
    0 0 18px rgba(var(--cat-rgb, 154, 168, 160), 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.top-button:hover,
.file-loader:hover,
.export-format:hover,
.small-button:hover,
.marker-button:hover,
.next-beat-button:hover,
.transport.reset:hover {
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.3),
    0 0 26px rgba(var(--cat-rgb, 154, 168, 160), 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.duration-control {
  background:
    radial-gradient(circle at 9% 0%, rgba(var(--cat-rgb, 154, 168, 160), 0.32), transparent 44%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025)),
    #0b1613;
  border: 1px solid rgba(var(--cat-rgb, 154, 168, 160), 0.4);
  border-radius: 12px;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  display: grid;
  gap: 9px;
  padding: 10px 12px 12px;
}

.duration-readout {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.duration-readout span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.duration-readout output {
  color: #fff7eb;
  font-size: 1.2rem;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

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

.duration-control input[type="range"] {
  appearance: none;
  background: transparent;
  border: 0;
  min-height: 30px;
  padding: 0;
}

.duration-control input[type="range"]::-webkit-slider-runnable-track {
  background:
    linear-gradient(90deg, #f05a45 0%, #f0b943 45%, #9aa8a0 50%, #39bf73 56%, #36b5f2 100%);
  border-radius: 999px;
  box-shadow:
    0 0 18px rgba(var(--cat-rgb, 154, 168, 160), 0.2),
    inset 0 1px 4px rgba(0, 0, 0, 0.48);
  height: 12px;
}

.duration-control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  background: #fff7eb;
  border: 3px solid var(--cat);
  border-radius: 999px;
  box-shadow:
    0 0 0 5px rgba(var(--cat-rgb, 154, 168, 160), 0.14),
    0 0 18px rgba(var(--cat-rgb, 154, 168, 160), 0.42);
  height: 30px;
  margin-top: -9px;
  width: 30px;
}

.duration-control input[type="range"]::-moz-range-track {
  background: linear-gradient(90deg, #f05a45 0%, #f0b943 45%, #9aa8a0 50%, #39bf73 56%, #36b5f2 100%);
  border-radius: 999px;
  height: 12px;
}

.duration-control input[type="range"]::-moz-range-thumb {
  background: #fff7eb;
  border: 3px solid var(--cat);
  border-radius: 999px;
  box-shadow: 0 0 18px rgba(var(--cat-rgb, 154, 168, 160), 0.42);
  height: 24px;
  width: 24px;
}

.duration-scale {
  color: var(--muted);
  display: flex;
  font-size: 0.68rem;
  font-weight: 850;
  justify-content: space-between;
  line-height: 1;
  text-transform: uppercase;
}

textarea,
input,
select {
  background: #081511;
  border-color: rgba(255, 255, 255, 0.13);
  color: var(--ink);
}

textarea::placeholder,
input::placeholder {
  color: rgba(255, 247, 235, 0.5);
}

.mobile-tabs {
  background: rgba(5, 13, 11, 0.86);
}

.mobile-tabs button {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.mobile-tabs button.active {
  background: rgba(240, 90, 69, 0.16);
  border-color: rgba(240, 90, 69, 0.72);
  color: var(--ink);
}

.key-item {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}

.quick-note textarea,
.custom-editor input,
.custom-editor select,
.mobile-page-menu select {
  background: #081511;
  border-color: rgba(255, 255, 255, 0.13);
  color: var(--ink);
}

/* Space-optimised cockpit mode: less ceremony, more control surface. */
.site-header {
  min-height: 56px;
  padding: 6px clamp(10px, 1.6vw, 20px);
}

.brand-link {
  min-width: 190px;
}

.brand-link img {
  max-height: 46px;
  width: 32px;
}

.brand-link strong {
  font-size: 0.95rem;
}

.brand-link small {
  font-size: 0.78rem;
}

.site-nav {
  gap: 4px;
}

.site-nav a,
.builder-menu summary {
  padding: 7px 9px;
}

.cockpit-shell {
  gap: 6px;
  min-height: calc(100dvh - 56px);
  padding: 6px;
}

.cockpit-topbar {
  grid-template-columns: minmax(156px, 0.8fr) auto auto minmax(122px, 0.52fr) minmax(366px, auto);
  min-height: 58px;
  padding: 6px;
}

.session-brand {
  gap: 8px;
}

.session-brand img {
  max-height: 36px;
  width: 26px;
}

.session-brand p {
  font-size: 0.66rem;
}

.session-brand h1 {
  font-size: 1rem;
}

.session-summary {
  gap: 2px;
  padding-left: 10px;
}

.session-summary span {
  -webkit-line-clamp: 1;
  line-clamp: 1;
}

.cockpit-topbar .status-chip,
.cockpit-topbar .master-clock,
.cockpit-topbar .top-button,
.cockpit-topbar .file-loader,
.cockpit-topbar .export-format {
  min-height: 34px;
}

.cockpit-topbar .master-clock {
  min-width: 116px;
}

.cockpit-topbar .master-clock strong {
  font-size: 1.2rem;
}

.topbar-actions {
  gap: 5px;
}

.top-button,
.file-loader,
.export-format,
.small-button {
  border-radius: 10px;
  min-height: 34px;
  padding: 6px 8px;
}

.transport,
.next-beat-button,
.duration-button,
.marker-button,
.sfx-button,
.custom-pad-button {
  border-radius: 10px;
}

.cockpit-grid {
  gap: 6px;
}

.panel {
  padding: 8px;
}

.panel-heading {
  align-items: center;
  border-bottom: 0;
  justify-content: flex-end;
  min-height: 0;
  margin: 0 0 6px;
  padding-bottom: 0;
}

.panel-heading p {
  display: none;
}

.panel-heading p,
.current-meta span,
.quick-note span,
.custom-editor span {
  font-size: 0.68rem;
}

.runsheet-source,
.next-card {
  margin-bottom: 6px;
  padding: 7px;
}

.next-card {
  display: none;
}

.current-meta {
  padding: 7px;
}

.current-meta strong {
  font-size: clamp(1.24rem, 2.5vw, 1.9rem);
}

.beat-note {
  font-size: 0.92rem;
}

.quick-note {
  margin: 6px 0;
}

textarea {
  min-height: 70px;
}

.back-to-top {
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  bottom: 18px;
  box-shadow: var(--shadow);
  color: white;
  cursor: pointer;
  font-weight: 900;
  opacity: 0;
  padding: 12px 16px;
  pointer-events: none;
  position: fixed;
  right: 18px;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 70;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .cockpit-topbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .session-brand {
    grid-column: span 2;
  }

  .cockpit-grid {
    grid-template-columns: minmax(260px, 0.85fr) minmax(370px, 1.2fr);
    grid-template-rows: minmax(0, 1fr) minmax(130px, auto) auto;
  }

  .log-panel {
    grid-column: 1 / 3;
    grid-row: 3;
    min-height: 180px;
  }

  .runsheet-panel {
    grid-row: 1;
  }

  .sfx-panel,
  .custom-panel {
    grid-column: 1 / 2;
  }

  .deck-panel {
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .custom-editor {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 821px) {
  body {
    display: block;
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .site-header {
    position: sticky;
  }

  .cockpit-shell {
    height: calc(100dvh - 56px);
    min-height: 0;
    overflow: hidden;
  }

  .cockpit-grid {
    min-height: 0;
  }

  .panel {
    min-height: 0;
    overflow: auto;
  }

  .beat-list,
  .session-log {
    min-height: 0;
  }
}

@media (min-width: 821px) and (max-height: 820px) {
  .site-header {
    min-height: 46px;
  }

  .site-nav a,
  .builder-menu summary {
    padding: 7px 9px;
  }

  .cockpit-shell {
    gap: 6px;
    padding: 6px;
  }

  .cockpit-topbar {
    gap: 5px;
    grid-template-columns: minmax(156px, 0.88fr) auto auto minmax(112px, 0.52fr) minmax(366px, auto);
  }

  .session-brand img {
    max-height: 34px;
    width: 24px;
  }

  .session-brand h1 {
    font-size: 0.98rem;
  }

  .master-clock strong {
    font-size: 1rem;
  }

  .file-loader,
  .top-button,
  .small-button {
    min-height: 36px;
    padding: 6px 8px;
  }

  .panel {
    padding: 8px;
  }

  .live-panel {
    gap: 4px;
  }

  .current-meta {
    padding: 0;
  }

  .current-meta span {
    font-size: 0.72rem;
  }

  .current-meta strong {
    font-size: 1rem;
  }

  .timer-console {
    min-height: 126px;
    padding: 8px 10px 7px;
  }

  .timer-console .current-meta {
    left: 12px;
    max-width: calc(100% - 208px);
    top: 12px;
  }

  .timer-console .current-meta span {
    display: none;
  }

  .timer-console .current-meta strong {
    font-size: 0.92rem;
  }

  .timer-reset {
    min-height: 30px;
    padding: 4px 7px;
    right: 10px;
    top: 10px;
  }

  .beat-clock {
    font-size: clamp(4rem, 13vh, 6rem);
    padding: 34px 8px 0;
  }

  .beat-remaining {
    font-size: 0.84rem;
    line-height: 1.1;
    min-height: 30px;
    right: 86px;
    top: 10px;
  }

  .beat-progress {
    height: 8px;
  }

  .beat-note {
    display: none;
  }

  .transport,
  .next-beat-button,
  .duration-button,
  .marker-button {
    font-size: 0.88rem;
    min-height: 34px;
    padding: 4px;
  }

  .transport.start {
    font-size: 0.96rem;
    min-height: 48px;
  }

  .marker-button {
    min-height: 42px;
  }

  .scene-cut-button {
    font-size: 1.32rem;
    min-height: 42px;
    padding: 6px;
  }

  .next-card {
    display: none;
  }

  .sfx-button,
  .custom-pad-button {
    min-height: 52px;
  }

  .panel-heading {
    margin-bottom: 4px;
    min-height: 26px;
    padding-bottom: 4px;
  }
}

@media (max-width: 820px) {
  html,
  body {
    background: var(--bg);
    display: block;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
  }

  .site-header {
    align-items: center;
    flex-direction: row;
    gap: 6px;
    min-height: 42px;
    padding: 5px 8px;
    position: relative;
  }

  .brand-link {
    gap: 7px;
    min-width: 116px;
  }

  .brand-link img {
    max-height: 34px;
    width: 24px;
  }

  .brand-link strong {
    font-size: 0.78rem;
  }

  .brand-link small {
    display: none;
  }

  .site-nav {
    display: none;
  }

  .mobile-page-menu {
    display: grid;
    flex: 1;
    gap: 0;
    min-width: 0;
  }

  .mobile-page-menu span {
    height: 1px;
    overflow: hidden;
    position: absolute;
    width: 1px;
  }

  .mobile-page-menu select {
    border-radius: 10px;
    font-size: 0.9rem;
    min-height: 34px;
    padding: 6px 8px;
  }

  .cockpit-shell {
    gap: 6px;
    min-height: 0;
    padding: 6px;
    overflow-x: clip;
    width: 100%;
  }

  .cockpit-topbar {
    align-items: stretch;
    gap: 5px;
    grid-template-columns: minmax(0, 1fr) minmax(78px, auto) minmax(100px, auto);
    min-height: 0;
    overflow: hidden;
    padding: 6px;
  }

  .session-brand {
    grid-column: 1;
    grid-row: 1;
  }

  .status-chip {
    grid-column: 2;
    grid-row: 1;
  }

  .master-clock {
    grid-column: 3;
    grid-row: 1;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .session-summary {
    display: none;
  }

  .session-brand img {
    max-height: 30px;
    width: 22px;
  }

  .session-brand p {
    display: none;
  }

  .session-brand h1 {
    font-size: 0.92rem;
  }

  .topbar-actions {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 3px;
    width: 100%;
  }

  .master-clock,
  .status-chip,
  .top-button,
  .file-loader,
  .export-format {
    min-width: 0;
    width: 100%;
  }

  .cockpit-topbar .status-chip {
    font-size: 0.72rem;
    gap: 5px;
    min-height: 40px;
    padding: 4px 6px;
  }

  .cockpit-topbar .status-chip span {
    height: 9px;
    width: 9px;
  }

  .cockpit-topbar .master-clock {
    min-height: 40px;
    padding: 4px 6px;
  }

  .cockpit-topbar .master-clock strong {
    font-size: 1rem;
  }

  .cockpit-topbar .master-clock span {
    font-size: 0.58rem;
  }

  .cockpit-topbar .top-button,
  .cockpit-topbar .file-loader,
  .cockpit-topbar .export-format {
    font-size: 0.68rem;
    min-height: 30px;
    padding: 5px 1px;
    white-space: nowrap;
  }

  .duration-control {
    gap: 7px;
    padding: 9px;
  }

  .duration-readout {
    display: grid;
    gap: 6px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .duration-readout output {
    font-size: 1rem;
  }

  .duration-scale {
    font-size: 0.56rem;
  }

  .mobile-tabs {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 3px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-width: 100%;
    overflow: hidden;
    padding: 3px;
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .mobile-tabs button {
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 7px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
    min-height: 32px;
    min-width: 0;
    padding: 5px 2px;
    white-space: nowrap;
  }

  .mobile-tabs button.active {
    background: rgba(240, 90, 69, 0.16);
    border-color: rgba(240, 90, 69, 0.72);
    color: var(--ink);
  }

  .cockpit-grid {
    display: block;
    max-width: 100%;
    overflow-x: clip;
  }

  .deck-track {
    --deck-button-height: 72px;
  }

  .deck-button {
    width: var(--button-width-mobile, 128px);
  }

  .panel {
    margin-bottom: 6px;
    padding: 8px;
  }

  body[data-active-tab="live"] [data-panel]:not([data-panel="live"]),
  body[data-active-tab="sfx"] [data-panel]:not([data-panel="sfx"]),
  body[data-active-tab="runsheet"] [data-panel]:not([data-panel="runsheet"]),
  body[data-active-tab="log"] [data-panel]:not([data-panel="log"]) {
    display: none;
  }

  .beat-clock {
    font-size: clamp(4rem, 17vw, 5.2rem);
    padding: 54px 8px 0;
  }

  .timer-console {
    min-height: 174px;
  }

  .timer-console .current-meta {
    left: 14px;
    max-width: calc(100% - 206px);
    top: 18px;
  }

  .timer-console .current-meta span {
    font-size: 0.62rem;
  }

  .timer-console .current-meta strong {
    font-size: 0.9rem;
  }

  .timer-reset {
    right: 12px;
    top: 16px;
  }

  .beat-remaining {
    font-size: 0.78rem;
    min-height: 30px;
    right: 86px;
    top: 16px;
  }

  .marker-row,
  .sfx-grid,
  .custom-pad-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .duration-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-editor {
    grid-template-columns: 1fr;
  }

  .scene-cut-button {
    font-size: 1.48rem;
    min-height: 56px;
  }
}

@media (max-width: 620px) {
  .brand-link {
    min-width: 0;
  }

  .cockpit-topbar {
    grid-template-columns: minmax(0, 1fr) minmax(76px, auto) minmax(100px, auto);
  }

  .mobile-tabs button {
    font-size: 0.7rem;
    min-height: 30px;
    padding-inline: 1px;
  }

  .transport-row,
  .beat-nav-row,
  .marker-row,
  .sfx-grid,
  .custom-pad-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .brand-link strong {
    font-size: 0.74rem;
  }

  .mobile-page-menu select {
    font-size: 0.86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
