:root {
  --bg: #17191b;
  --panel: #202225;
  --panel-2: #2a2d30;
  --line: #383b3e;
  --line-2: #55595d;
  --text: #f4f3ef;
  --muted: #a9adaf;
  --accent: #f5bd69;
  --accent-dim: #f5bd691c;
  --rev: #6fd3e8;
  --hold: #8a8e92;
  --stop: #ed9890;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
  font:
    13px/1.5 -apple-system,
    BlinkMacSystemFont,
    'Hiragino Sans',
    'Noto Sans JP',
    'Segoe UI',
    sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}
body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button,
a,
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
a {
  color: inherit;
  text-underline-offset: 4px;
}
svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
}
h1 {
  font-size: 19px;
  line-height: 1.5;
  font-weight: 600;
  text-wrap: balance;
}
h2 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}
h3,
h4 {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--muted);
}
p {
  text-wrap: pretty;
}
small,
.small {
  font-size: 11px;
  line-height: 1.5;
}
.hidden,
[hidden] {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.spacer {
  flex: 1;
}
.wide {
  width: 100%;
}
.sr-only,
.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link:focus {
  position: fixed;
  z-index: 100;
  padding: 12px;
  background: var(--accent);
  color: #17191b;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Buttons and inputs */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: var(--panel-2);
  text-decoration: none;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: #35393d;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #211a10;
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) {
  background: #ffcc83;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover:not(:disabled) {
  background: var(--panel-2);
}
.btn.icon {
  width: 32px;
  height: 32px;
  padding: 4px;
  flex: none;
}
.btn.tiny {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 12px;
}
.btn.tiny.icon {
  width: 28px;
  height: 28px;
  font-size: 15px;
}
.toggle-btn[aria-pressed='true'] {
  color: var(--accent);
  background: var(--accent-dim);
}
.text-btn {
  border: 0;
  padding: 4px 0;
  background: none;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 4px;
  line-height: 1.5;
  min-height: 28px;
}
.text-btn:hover {
  color: var(--accent);
}
select,
input[type='number'],
input[type='text'] {
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: var(--bg);
  padding: 4px 8px;
  min-height: 32px;
}
input[type='number'] {
  width: 76px;
  font-variant-numeric: tabular-nums;
}
select {
  max-width: 100%;
}
input[type='range'] {
  appearance: none;
  width: 100%;
  height: 24px;
  background: transparent;
  margin: 0;
  accent-color: var(--accent);
}
input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  background: #5a5e62;
  border-radius: 3px;
}
input[type='range']::-moz-range-track {
  height: 3px;
  background: #5a5e62;
  border-radius: 3px;
}
input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  border: 0;
  background: var(--text);
  cursor: pointer;
}
input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 0;
  background: var(--text);
  cursor: pointer;
}
input[type='range']:disabled {
  opacity: 0.4;
}
.toggle {
  width: 36px;
  height: 20px;
  position: relative;
  flex: none;
  display: inline-block;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  z-index: 1;
  cursor: pointer;
}
.toggle i {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: #585d61;
  pointer-events: none;
}
.toggle i:after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s;
}
.toggle input:checked + i {
  background: var(--accent);
}
.toggle input:checked + i:after {
  transform: translateX(16px);
  background: #26211a;
}
.toggle:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 12px;
}
.seg-btns {
  display: flex;
  flex-wrap: wrap;
}
.chip {
  flex: 1;
  min-height: 30px;
  border: 1px solid var(--line-2);
  background: transparent;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
}
.chip:first-child {
  border-radius: 5px 0 0 5px;
}
.chip:last-child {
  border-radius: 0 5px 5px 0;
}
.chip + .chip {
  border-left: 0;
}
.chip.on {
  background: var(--accent);
  color: #211a10;
  border-color: var(--accent);
}
.chip:focus-visible {
  position: relative;
  z-index: 1;
}

/* Top bar */
.topbar {
  height: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.brand svg {
  width: 24px;
  height: 20px;
  stroke: none;
}
.project-identity {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  width: clamp(160px, 22vw, 320px);
}
#projectName {
  min-width: 0;
  flex: 1;
  height: 30px;
  min-height: 30px;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-weight: 500;
  text-overflow: ellipsis;
}
#projectName:hover {
  border-color: var(--line);
}
#projectName:focus {
  border-color: var(--accent);
  outline: 0;
  background: var(--panel);
}
.save-status {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: none;
  max-width: 50%;
}
.save-status[data-state='error'] {
  color: var(--stop);
}
.history {
  display: flex;
  gap: 2px;
}
.top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.language-field select {
  border-color: transparent;
  background: transparent;
  font-size: 12px;
  padding: 4px 6px;
}
#projectBtn > svg {
  display: none;
}

/* Layout */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  grid-template-rows: minmax(260px, 1fr) 240px;
}
.panel {
  background: var(--panel);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.left {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}
.right {
  grid-column: 3;
  grid-row: 1;
  border-left: 1px solid var(--line);
}
.center {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  background: var(--bg);
}
.timeline-wrap {
  grid-column: 1 / -1;
  grid-row: 2;
  min-height: 0;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.mobile-nav {
  display: none;
}
.right .pane {
  display: none;
}
body[data-inspector='style'] #stylePane,
body[data-inspector='shot'] #shotPane {
  display: block;
}

/* Left rail */
.block {
  padding: 14px 16px;
}
.block.grow {
  flex: 1;
}
.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}
.drop {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 0 10px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px dashed var(--line-2);
  border-radius: 5px;
  background: transparent;
  text-align: left;
  line-height: 1.4;
}
.drop svg {
  grid-row: 1 / 3;
}
.drop strong {
  font-weight: 500;
}
.drop small {
  color: var(--muted);
  font-size: 11px;
}
.drop:hover,
.drop.over,
body.dragging .drop {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.privacy {
  padding: 14px 16px 18px;
  color: var(--muted);
  font-size: 11px;
}
.privacy .text-btn {
  font-size: 11px;
}
.music-info {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}
.music-name {
  word-break: break-word;
  font-weight: 500;
}
.music-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.music-meta .bpm {
  font: 18px/1.2 var(--mono);
  font-weight: 600;
}
.music-meta .conf {
  font-size: 11px;
  color: var(--muted);
}
.music-meta .conf::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  background: var(--hold);
}
.music-meta .conf.good::before {
  background: #7cc47f;
}
.music-meta .conf.low::before {
  background: var(--stop);
}
.field-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.field-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.field-row input[type='number'] {
  width: 70px;
}
.clip-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}
.clip {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.clip-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  min-height: 44px;
}
.clip-head:hover {
  background: var(--panel-2);
}
.clip-thumb {
  width: 56px;
  height: 36px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--bg);
}
.clip-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}
.clip-name small {
  display: block;
  color: var(--muted);
}
.clip-swatch {
  width: 4px;
  height: 28px;
  border-radius: 2px;
  flex: none;
}
.clip-body {
  margin-top: 8px;
  display: none;
}
.clip.open .clip-body {
  display: block;
}
.clip video {
  display: block;
  width: 100%;
  max-height: 150px;
  margin-bottom: 8px;
  background: #000;
}
.clip-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 0;
}

/* Preview */
.stage-wrap {
  flex: 1;
  min-height: 0;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.stage {
  flex: none;
  position: relative;
  background: #000;
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
}
.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.frame-progress {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  background: #0009;
  color: var(--text);
  font: 11px var(--mono);
  pointer-events: none;
}
.stage-empty {
  text-align: center;
  max-width: 420px;
  padding: 24px 12px;
  width: 100%;
}
.empty-viewer-icon {
  width: 46px;
  height: 38px;
  color: #727579;
  margin-bottom: 14px;
  stroke-width: 1.2;
}
.stage-empty p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}
.start-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 20px;
}
.start-actions .btn {
  min-height: 38px;
  padding-inline: 18px;
}
.transport {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  min-height: 46px;
}
.transport .play {
  background: #3d4145;
  border: 0;
  border-radius: 50%;
  margin: 0 2px;
}
.transport .mono {
  font-size: 12px;
  white-space: nowrap;
  margin-left: 8px;
}
.transport #beatLabel {
  min-width: 36px;
  margin-left: 6px;
}
.transport .status {
  margin-left: 10px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.transport-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.transport select {
  font-size: 12px;
  min-height: 30px;
  max-width: 120px;
}

/* Inspector */
.pane-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.pane-head h2 {
  font-size: 13px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pane-head .meta {
  font: 11px var(--mono);
  color: var(--muted);
  white-space: nowrap;
}
.group {
  padding: 12px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.group > h3 {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
details.group {
  padding: 0;
}
details.group > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  min-height: 40px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
details.group > summary::-webkit-details-marker {
  display: none;
}
details.group > summary::before {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  margin-right: 2px;
  transition: transform 0.15s;
}
details.group[open] > summary::before {
  transform: rotate(45deg);
}
details.group > .inner {
  padding: 0 16px 14px;
}
.pad {
  padding: 16px;
}
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 10px;
  margin: 8px 0;
}
.row.full {
  grid-template-columns: 1fr;
}
.row label {
  font-size: 12px;
}
.row .val {
  font: 11px var(--mono);
  text-align: right;
  color: var(--muted);
}
.slider-row {
  display: grid;
  grid-template-columns: 1fr 50px;
  gap: 8px;
  align-items: center;
}
.row .small {
  color: var(--muted);
}
.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.row-head .text-btn {
  font-size: 11px;
  min-height: 24px;
  color: var(--muted);
}
.style-cards {
  display: grid;
  gap: 6px;
}
.style-card {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: transparent;
  line-height: 1.5;
}
.style-card strong {
  font-weight: 600;
}
.style-card small {
  color: var(--muted);
}
.style-card:hover {
  background: var(--panel-2);
}
.style-card[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.nudge {
  display: grid;
  grid-template-columns: 28px 1fr 28px 56px;
  gap: 6px;
  align-items: center;
}
.nudge .val {
  font: 11px var(--mono);
  color: var(--muted);
  text-align: right;
}
.inline-fields {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.inline-fields label {
  font-size: 12px;
  color: var(--muted);
}
.clip-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.clip-pick button {
  position: relative;
  width: 64px;
  height: 44px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  background: var(--bg);
  overflow: hidden;
}
.clip-pick button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.clip-pick button i {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
}
.clip-pick button[aria-pressed='true'] {
  border-color: var(--accent);
}
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.pattern-btn {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 2px 5px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: transparent;
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
}
.pattern-btn svg {
  width: 40px;
  height: 22px;
  stroke-width: 1.8;
}
.pattern-btn:hover {
  background: var(--panel-2);
}
.pattern-btn[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text);
}
.inpoint video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 150px;
  object-fit: contain;
  background: #000;
  border-radius: 4px;
}
.clip-bar {
  position: relative;
  height: 8px;
  margin: 8px 0 2px;
  border-radius: 2px;
  background: #3a3e42;
}
.clip-bar .ab {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--accent);
  border-radius: 2px;
}
.clip-bar .act {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--text);
}
.ab-labels {
  display: flex;
  justify-content: space-between;
  font: 11px var(--mono);
  color: var(--muted);
}
.shot-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.shot-actions .btn {
  font-size: 12px;
}
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 12px;
  margin: 0;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

/* Timeline */
.timeline-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 12px;
  border-bottom: 1px solid var(--line);
  min-height: 36px;
}
.legend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}
.lg {
  width: 10px;
  height: 3px;
  display: inline-block;
  border-radius: 1px;
}
.lg.fwd {
  background: var(--accent);
}
.lg.rev {
  background: var(--rev);
}
.lg.hold {
  background: var(--hold);
}
.lg.hit {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.tl-box {
  min-height: 0;
  flex: 1;
  position: relative;
}
#timeline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

/* Dialogs */
.dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 22px 24px;
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - 36px);
  overflow: auto;
  box-shadow: 0 20px 80px #0006;
}
.dialog::backdrop {
  background: #0009;
}
.dialog-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 12px;
}
.dialog-heading .icon {
  margin: -6px -8px -6px 0;
  font-size: 18px;
}
.dialog p {
  margin: 10px 0;
  line-height: 1.7;
}
.dialog details {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.dialog .btn {
  min-height: 36px;
}
summary {
  cursor: pointer;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.dialog-actions .btn {
  flex: 1;
}
.busy-dialog {
  text-align: center;
}
.busy-dialog h2 {
  margin-bottom: 16px;
  overflow-wrap: anywhere;
}
.busy-dialog progress {
  width: 100%;
  height: 6px;
  accent-color: var(--accent);
  display: block;
  margin: 20px 0;
}
.busy-dialog .btn {
  margin-top: 8px;
  min-width: 120px;
}
.help-steps {
  padding-left: 22px;
}
.help-steps li {
  padding: 6px 0 10px 6px;
}
.help-steps h3 {
  color: var(--text);
  font-size: 13px;
}
.help-steps p {
  margin: 4px 0;
  color: var(--muted);
}
.dialog video {
  display: block;
  width: 100%;
  max-height: 45dvh;
  background: #000;
}
.shortcuts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 8px 0 0;
  align-items: center;
}
.shortcuts dt {
  white-space: nowrap;
}
.shortcuts dd {
  margin: 0;
}
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel-2);
  font: 11px var(--mono);
  text-align: center;
}
#exportOptions .group {
  padding: 10px 0;
}
#exportOptions .group:first-child {
  padding-top: 0;
}
.notice {
  padding: 10px 12px;
  background: #f5bd6910;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-size: 12px;
  margin: 12px 0;
}
.project-actions {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}
.project-new {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}
.toast,
.error-box {
  position: fixed;
  z-index: 100;
  left: 50%;
  transform: translateX(-50%);
  top: 60px;
  background: #303438;
  border: 1px solid var(--line-2);
  padding: 10px 16px;
  border-radius: 6px;
  box-shadow: 0 4px 30px #0006;
  max-width: calc(100vw - 32px);
  width: max-content;
  font-size: 13px;
}
.error-box {
  display: flex;
  align-items: center;
  gap: 16px;
  border-color: var(--stop);
  max-width: min(680px, calc(100vw - 32px));
}
.error-box span {
  flex: 1;
}

/* Medium desktop */
@media (min-width: 820px) and (max-width: 1099px) {
  .layout {
    grid-template-columns: 220px minmax(0, 1fr) 280px;
    grid-template-rows: minmax(240px, 1fr) 200px;
  }
  .topbar {
    gap: 8px;
  }
  .project-identity {
    width: 160px;
  }
  #saveBtn,
  #shortcutBtn,
  .transport .status,
  .timeline-tools .legend {
    display: none;
  }
  .block,
  .group {
    padding-inline: 12px;
  }
  .pane-head,
  details.group > summary,
  details.group > .inner {
    padding-inline: 12px;
  }
}
@media (min-width: 1600px) {
  .layout {
    grid-template-columns: 290px minmax(0, 1fr) 350px;
    grid-template-rows: minmax(300px, 1fr) 260px;
  }
}

/* Mobile */
@media (max-width: 819px) {
  :root {
    font-size: 14px;
  }
  body {
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }
  .topbar {
    height: auto;
    min-height: 0;
    padding: 6px 10px;
    gap: 4px 6px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    grid-template-rows: 44px 44px;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .brand {
    grid-column: 1;
    grid-row: 1;
    font-size: 14px;
  }
  .brand svg {
    width: 20px;
  }
  .top-right {
    display: contents;
  }
  #projectBtn {
    grid-column: 2;
    grid-row: 1;
    width: 44px;
    padding: 8px;
  }
  #projectBtn > span {
    display: none;
  }
  #projectBtn > svg {
    display: block;
  }
  .language-field {
    grid-column: 3;
    grid-row: 1;
  }
  .language-field select {
    min-height: 44px;
    font-size: 14px;
    max-width: 92px;
  }
  #exportBtn {
    grid-column: 4;
    grid-row: 1;
    min-height: 40px;
  }
  .project-identity {
    grid-column: 1 / 3;
    grid-row: 2;
    width: auto;
  }
  #projectName {
    height: 40px;
    min-height: 40px;
    font-size: 15px;
  }
  .history {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
  }
  .history .btn {
    width: 44px;
    height: 44px;
  }
  #saveBtn {
    grid-column: 4;
    grid-row: 2;
    min-height: 44px;
  }
  #shortcutBtn {
    display: none;
  }
  .layout {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }
  .panel {
    overflow: visible;
  }
  .center {
    order: 1;
    flex: none;
  }
  .stage-wrap {
    height: min(300px, 36dvh);
    min-height: 200px;
    padding: 10px;
  }
  .stage-empty {
    padding: 10px 0;
  }
  .stage-empty h1 {
    font-size: 17px;
  }
  .stage-empty p {
    font-size: 12px;
    max-width: 300px;
    margin: 6px auto 0;
  }
  .start-actions {
    gap: 14px;
    margin-top: 14px;
  }
  .transport {
    padding: 4px 8px;
    gap: 2px;
    min-height: 52px;
  }
  .transport .btn {
    min-width: 44px;
    min-height: 44px;
  }
  .transport .mono {
    font-size: 11px;
    margin-left: 4px;
  }
  #stepBackBtn,
  #stepFwdBtn,
  #beatLabel,
  .transport .status,
  #clickBtn {
    display: none;
  }
  .transport select {
    min-height: 44px;
    font-size: 13px;
    max-width: 96px;
  }
  .timeline-wrap {
    order: 2;
    height: 190px;
    flex: none;
    border-bottom: 1px solid var(--line);
  }
  .timeline-tools {
    padding: 2px 8px;
    gap: 6px;
    min-height: 48px;
  }
  .timeline-tools .legend {
    display: none;
  }
  .timeline-tools .btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 12px;
  }
  .mobile-nav {
    order: 3;
    display: flex;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    padding: 0 8px;
  }
  .mobile-nav button {
    flex: 1;
    min-height: 46px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--muted);
    font-size: 13px;
    padding: 0 4px;
  }
  .mobile-nav button.active {
    border-bottom-color: var(--accent);
    color: var(--text);
    font-weight: 600;
  }
  .left,
  .right {
    order: 4;
    display: none;
    border: 0;
    min-height: 40dvh;
  }
  body[data-mobile-panel='media'] .left {
    display: flex;
  }
  body[data-mobile-panel='shot'] .right,
  body[data-mobile-panel='style'] .right,
  body[data-mobile-panel='output'] .right {
    display: block;
  }
  .right .pane {
    display: none !important;
  }
  body[data-mobile-panel='shot'] #shotPane,
  body[data-mobile-panel='style'] #stylePane,
  body[data-mobile-panel='output'] #outputPane {
    display: block !important;
  }
  .pane-head {
    position: static;
  }
  .btn,
  .chip,
  .pattern-btn,
  .style-card,
  .text-btn,
  .clip-pick button {
    min-height: 44px;
  }
  .btn.icon {
    width: 44px;
    height: 44px;
  }
  .btn.tiny.icon {
    width: 44px;
    height: 44px;
  }
  .nudge {
    grid-template-columns: 44px 1fr 44px 56px;
  }
  .row {
    margin: 10px 0;
  }
  .row label,
  .field-row label {
    font-size: 13px;
  }
  input[type='number'],
  input[type='text'],
  select {
    font-size: 16px;
    min-height: 44px;
  }
  .slider-row input[type='range'] {
    height: 44px;
  }
  input[type='range']::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    margin-top: -8.5px;
  }
  input[type='range']::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }
  .clip-thumb {
    width: 64px;
    height: 42px;
  }
  .clip video {
    max-height: 200px;
  }
  .dialog {
    padding: 18px;
  }
  .error-box {
    align-items: flex-start;
    padding: 12px;
  }
  .toast,
  .error-box {
    top: 100px;
  }
  .frame-progress {
    font-size: 10px;
  }
}
@media (max-width: 399px) {
  .aspect-field {
    display: none;
  }
  .topbar {
    padding-inline: 6px;
  }
  .brand span {
    display: none;
  }
  .language-field select {
    max-width: 80px;
  }
  .timeline-tools {
    padding-inline: 4px;
  }
  .block,
  .group,
  .pane-head {
    padding-inline: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
