:root {
  color-scheme: dark;
  --bg: #17191e;
  --bg-raised: #1c1f25;
  --panel: #252930;
  --panel-strong: #31363f;
  --panel-soft: #20242a;
  --line: #515865;
  --line-soft: #393f49;
  --text: #f5f6fa;
  --text-soft: #c7ccd6;
  --text-dim: #aab1bd;
  --accent: #abbeff;
  --accent-strong: #c4cfff;
  --accent-ink: #101b40;
  --cyan: #a0caca;
  --danger: #ff6b71;
  --warning: #ffc857;
  --shadow: 0 18px 48px rgb(0 0 0 / 34%);
  --shadow-small: 0 9px 24px rgb(0 0 0 / 24%);
  --radius: 7px;
  --radius-small: 4px;
  /* 넓은 화면을 그대로 쓴다 — 악보는 가로로 길어서 폭이 곧 편집 편의다. */
  --shell: 2560px;
  --header-height: 62px;
  --ease: 180ms ease;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  /* main 이 flex:1 로 남는 세로 공간을 가져가게 하되, min-height 만 걸어둬서
     내용이 뷰포트보다 길면 예전처럼 페이지 자체가 그냥 늘어나 스크롤된다. */
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

button {
  color: inherit;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

a {
  color: inherit;
}

svg {
  display: block;
}

::selection {
  color: #071007;
  background: var(--accent);
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 12px;
  padding: 10px 14px;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform var(--ease);
}

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

:where(
    a,
    button,
    input,
    select,
    [role="button"]
  ):focus-visible {
  outline: 3px solid rgb(149 191 190 / 86%);
  outline-offset: 3px;
}

.app-shell {
  width: min(calc(100% - 24px), var(--shell));
  margin-inline: auto;
}

.app-header {
  position: sticky;
  z-index: 100;
  top: 0;
  min-height: var(--header-height);
  border-bottom: 1px solid rgb(255 255 255 / 7%);
  background: rgb(7 10 14 / 82%);
  box-shadow: 0 8px 28px rgb(0 0 0 / 14%);
  backdrop-filter: blur(18px) saturate(125%);
}

.header-inner {
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 8px 7px;
  align-content: center;
  gap: 4px;
  overflow: hidden;
  border: 1px solid rgb(174 210 181 / 52%);
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgb(174 210 181 / 15%), transparent 55%),
    #121a1e;
  box-shadow: inset 0 0 22px rgb(174 210 181 / 7%);
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 17px;
  width: 2px;
  background: var(--accent);
  border-radius: 99px;
  box-shadow: 0 0 9px rgb(174 210 181 / 50%);
}

.brand-mark span {
  display: block;
  height: 2px;
  background: #dce7e8;
  border-radius: 99px;
  opacity: 0.82;
}

.brand-copy {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1;
}

.local-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  margin-right: 5px;
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgb(174 210 181 / 9%), 0 0 12px rgb(174 210 181 / 58%);
}

.button,
.icon-button,
.play-button,
.text-button {
  appearance: none;
  border: 0;
  transition:
    color var(--ease),
    background-color var(--ease),
    border-color var(--ease),
    box-shadow var(--ease),
    transform var(--ease);
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.button-primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 5px 22px rgb(174 210 181 / 13%);
}

.button-primary:hover:not(:disabled) {
  background: #d6e8d6;
  border-color: #d6e8d6;
  box-shadow: 0 7px 26px rgb(174 210 181 / 21%);
}

.button-ghost {
  color: var(--text-soft);
  border-color: transparent;
  background: transparent;
}

.button-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--line);
  background: rgb(255 255 255 / 5%);
}

.button-secondary {
  color: var(--text);
  border-color: #3b4a59;
  background: #16202b;
  box-shadow: var(--shadow-small);
}

.button-secondary:hover:not(:disabled),
.button-subtle:hover:not(:disabled) {
  border-color: #596b7c;
  background: #1c2936;
}

.button-subtle {
  color: var(--text-soft);
  border-color: var(--line);
  background: #151d26;
}

.button-export {
  width: 100%;
  margin-top: 16px;
  color: #eafdc1;
  border-color: rgb(174 210 181 / 38%);
  background: rgb(174 210 181 / 9%);
}

.button-export:hover:not(:disabled) {
  color: #071007;
  border-color: var(--accent);
  background: var(--accent);
}

main.app-shell {
  padding-block: 22px 56px;
  /* body 가 준 남는 세로 공간을 여기서 받아 .step-body 의 flex: 1 로 넘긴다 —
     그 전까지는 부모가 flex 컨테이너가 아니어서 그 선언이 아무 효과가 없었다. */
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* 단계 화면(step-shell) 아래에는 그려질 내용이 없다 — 위 56px 하단 패딩은
   시작 화면·워크스페이스 화면에서나 쓸모 있는 여백이라, 단계 화면이 뜬
   동안은 순수한 죽은 공간이 된다. body.step-active 는 shell.js 의
   renderStepHeader() 가 단계가 활성인 동안 붙인다. */
body.step-active main.app-shell {
  padding-bottom: 0;
}

/* 3단계는 한 화면에 들어와야 한다. body 는 min-height: 100vh 라 내용이
   길면 페이지가 그냥 늘어나는데(시작 화면에서는 그게 맞다), 그러면 세로
   높이를 확정하는 조상이 하나도 없어 아래의 min-height: 0 · overflow 사슬이
   전부 무력해진다.

   3단계에서 실측한 증상: 조각이 늘면 .collect-side 의 overflow-y: auto 가
   한 번도 작동하지 않고 내용 높이만큼 자란다(24조각에서 1891px). 그 높이가
   .collect-layout 을 끌고 가고, .collect-stage 의 flex: 1 이 증가분을 전부
   흡수해(262 → 1587px, 캔버스는 37px 그대로) 그 아래 비교 띠가 1840px 지점,
   즉 뷰포트(493px) 밖으로 밀려 안 보였다.

   여기서 높이를 확정하면 그 사슬이 살아나 사이드바가 자기 안에서 스크롤한다.

   이 규칙을 step-active(= 다섯 단계 전부)에 걸었던 것이 1단계 겹침 버그였다.
   확정 높이는 .step-body 의 min-height: 0 과 짝이 되어 .step-body 를 내용보다
   짧게 줄어들게 만든다. 그런데 .step-body 는 overflow 가 visible 이라 넘친
   내용이 사라지지도 스크롤되지도 않고, main.app-shell 의 다음 형제 위에 그냥
   겹쳐 그려진다. 1단계에서 실측: 뷰포트 800x513 에서 .step-body 가 235px 로
   줄고 .source-layout(367px)이 132px 넘쳐, 복원 목록(#restorePanel, 107px)을
   107px — 즉 전부 — 덮었다. 슬롯이 늘어 목록이 길어지면 넓은 창에서도 같은
   일이 난다(목록이 자기 높이를 지키고 .step-body 만 줄어들기 때문).

   그래서 확정 높이는 그것이 필요한 단계만 요청한다 — 단계 정의의
   fillsScreen: true 를 셸의 setStepChromeActive() 가 이 클래스로 옮긴다.
   나머지 단계는 내용이 뷰포트보다 길면 예전처럼 문서가 스크롤된다. */
body.step-fills-screen {
  height: 100vh;
  height: 100dvh;
}

.empty-state {
  min-height: min(690px, calc(100vh - 170px));
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 0.78fr);
  align-items: center;
  gap: clamp(48px, 8vw, 128px);
  padding: clamp(40px, 7vw, 104px) clamp(0px, 3vw, 44px);
}

.empty-copy {
  max-width: 660px;
}

.eyebrow,
.section-kicker {
  display: inline-block;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.16em;
}

.empty-copy h1 {
  max-width: 660px;
  margin: 15px 0 22px;
  font-size: clamp(40px, 5.1vw, 74px);
  font-weight: 830;
  line-height: 1.08;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.empty-copy > p {
  max-width: 590px;
  margin: 0;
  color: var(--text-soft);
  font-size: clamp(15px, 1.45vw, 18px);
  line-height: 1.78;
  text-wrap: pretty;
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.feature-list span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  color: #c7d0d8;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 2%);
  font-size: 12px;
  font-weight: 650;
}

.feature-list span::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.drop-zone {
  position: relative;
  isolation: isolate;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 42px 32px;
  overflow: hidden;
  text-align: center;
  border: 1px dashed #465462;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgb(174 210 181 / 4%), transparent 42%),
    rgb(15 21 29 / 88%);
  box-shadow: var(--shadow), inset 0 0 0 1px rgb(255 255 255 / 2%);
  transition:
    border-color var(--ease),
    background-color var(--ease),
    transform var(--ease),
    box-shadow var(--ease);
}

.drop-zone::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgb(149 191 190 / 9%), transparent 68%);
  transform: translate(42%, -38%);
}

.drop-zone:hover,
.drop-zone.is-dragging,
.drop-zone.drag-over {
  border-color: var(--accent);
  background-color: #121b23;
  box-shadow:
    var(--shadow),
    inset 0 0 0 1px rgb(174 210 181 / 9%),
    0 0 48px rgb(174 210 181 / 5%);
  transform: translateY(-2px);
}

.drop-visual {
  display: grid;
  width: 86px;
  height: 86px;
  margin-bottom: 25px;
  place-items: center;
  color: var(--accent);
  border: 1px solid rgb(174 210 181 / 26%);
  border-radius: 50%;
  background: rgb(174 210 181 / 8%);
  box-shadow: inset 0 0 30px rgb(174 210 181 / 4%);
}

.drop-visual svg {
  width: 42px;
  height: 42px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-zone > strong {
  font-size: 19px;
  font-weight: 780;
}

.drop-zone > p {
  margin: 7px 0 20px;
  color: var(--text-soft);
  font-size: 13px;
}

.file-types {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.file-types span {
  padding: 4px 8px;
  color: #cbd5db;
  border: 1px solid #33404c;
  border-radius: 5px;
  background: #131b24;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 750;
}

.drop-zone > small {
  max-width: 300px;
  margin-top: 18px;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.55;
}

.empty-media-column {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.youtube-url-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background:
    linear-gradient(135deg, rgb(255 78 78 / 5%), transparent 48%),
    rgb(15 21 29 / 88%);
  box-shadow: var(--shadow-small);
}

.youtube-url-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}

.youtube-url-heading > div {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.youtube-url-heading strong {
  color: #e8edf0;
  font-size: 12px;
}

.youtube-url-heading small {
  color: var(--text-dim);
  font-size: 9px;
}

.youtube-mark {
  width: 27px;
  height: 21px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  border-radius: 6px;
  background: #ff4545;
  font-size: 8px;
  line-height: 1;
  box-shadow: 0 5px 16px rgb(255 69 69 / 18%);
}

.youtube-url-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.youtube-url-controls input,
.youtube-dialog-field input,
.capture-name-input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 8px 11px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #0b1219;
  font-size: 11px;
  transition:
    border-color var(--ease),
    box-shadow var(--ease),
    background-color var(--ease);
}

.youtube-url-controls input:hover,
.youtube-dialog-field input:hover,
.capture-name-input:hover {
  border-color: #475766;
}

.youtube-url-controls input:focus,
.youtube-dialog-field input:focus,
.capture-name-input:focus {
  border-color: var(--cyan);
  background: #0e1720;
  box-shadow: 0 0 0 3px rgb(149 191 190 / 11%);
}

.youtube-url-card > p {
  margin: 8px 2px 0;
  color: var(--text-dim);
  font-size: 9px;
  line-height: 1.5;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.inspector-column {
  position: sticky;
  top: calc(var(--header-height) + 20px);
  display: grid;
  gap: 14px;
  max-height: calc(100vh - var(--header-height) - 38px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #394756 transparent;
}

.panel,
.tracks-column {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(155deg, rgb(255 255 255 / 2.7%), transparent 34%),
    var(--panel);
  box-shadow: var(--shadow-small);
}

.panel {
  padding: 16px;
}

.transport-panel,
.view-panel {
  isolation: isolate;
}

.auto-track-card {
  display: grid;
  gap: 9px;
  padding: 12px;
  margin-top: 12px;
  border: 1px solid rgb(96 165 250 / 20%);
  border-radius: 10px;
  background: rgb(96 165 250 / 5%);
}

.auto-track-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.auto-track-heading > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.auto-track-heading strong {
  color: #dce7ed;
  font-size: 11px;
}

.auto-track-heading small,
.auto-track-card p {
  color: var(--text-dim);
  font-size: 9px;
  line-height: 1.5;
}

.auto-track-card p {
  margin: 0;
}

.auto-track-indicator {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-top: 4px;
  border-radius: 50%;
  background: #4c5a66;
  box-shadow: 0 0 0 4px rgb(76 90 102 / 10%);
}

.auto-track-card.is-active {
  border-color: rgb(174 210 181 / 34%);
  background: rgb(174 210 181 / 5%);
}

.auto-track-card.is-active .auto-track-indicator {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgb(174 210 181 / 12%);
  animation: auto-track-pulse 1.6s ease-in-out infinite;
}

@keyframes auto-track-pulse {
  50% {
    opacity: 0.42;
    transform: scale(0.78);
  }
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-header.compact {
  align-items: center;
  margin-bottom: 13px;
}

.panel-header h2,
.tracks-header h2 {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 780;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.panel-header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.panel-header-actions .text-button + .text-button {
  position: relative;
  padding-left: 11px;
}

.panel-header-actions .text-button + .text-button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 1px;
  height: 11px;
  background: var(--line);
  transform: translateY(-50%);
}

.text-button {
  padding: 4px;
  color: var(--text-soft);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: #4a5967;
  text-underline-offset: 3px;
}

.text-button:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.source-stage {
  position: relative;
  min-height: 172px;
  display: grid;
  overflow: hidden;
  place-items: center;
  border: 1px solid #26313b;
  border-radius: 10px;
  background:
    linear-gradient(45deg, #0b1016 25%, transparent 25%, transparent 75%, #0b1016 75%),
    linear-gradient(45deg, #0b1016 25%, #10171f 25%, #10171f 75%, #0b1016 75%);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
}

.source-stage canvas {
  display: block;
  max-width: 100%;
  max-height: min(39vh, 360px);
  object-fit: contain;
}

#sourceCanvas {
  position: relative;
  z-index: 1;
}

#sourceOverlay {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.source-meta {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 11px;
}

.file-meta-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.file-meta-copy strong,
.file-meta-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta-copy strong {
  color: #e2e9ed;
  font-size: 12px;
}

.file-meta-copy span {
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
}

.media-kind,
.frame-readout,
.count-badge {
  flex: 0 0 auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.media-kind {
  padding: 3px 6px;
  color: var(--accent);
  border: 1px solid rgb(174 210 181 / 25%);
  border-radius: 5px;
  background: rgb(174 210 181 / 7%);
  font-size: 8px;
}

.overlay-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 10px;
}

.overlay-legend:empty {
  display: none;
}

.overlay-legend > * {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  color: var(--text-dim);
  font-size: 10px;
}

.overlay-legend i,
.legend-color {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: var(--track-color, var(--accent));
}

.keyboard-hint {
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 8px;
  white-space: nowrap;
}

.transport-primary {
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-button,
.play-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #151e28;
}

.icon-button {
  width: 34px;
  height: 34px;
  color: var(--text-soft);
}

.play-button {
  width: 40px;
  height: 40px;
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.icon-button:hover:not(:disabled) {
  color: var(--text);
  border-color: #536372;
  background: #1d2935;
}

.play-button:hover:not(:disabled) {
  background: #d6e8d6;
  box-shadow: 0 0 23px rgb(174 210 181 / 17%);
}

.icon-button svg,
.play-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.play-button .pause-icon,
.play-button.is-playing .play-icon,
.play-button.playing .play-icon {
  display: none;
}

.play-button.is-playing .pause-icon,
.play-button.playing .pause-icon {
  display: block;
}

.timeline-wrap {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 3px;
}

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(
    to right,
    var(--accent) 0 var(--range-progress, 0%),
    #35414d var(--range-progress, 0%) 100%
  );
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 99px;
  background: #35414d;
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 99px;
  background: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -4.5px;
  appearance: none;
  border: 2px solid #272d2b;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgb(174 210 181 / 42%);
}

input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid #272d2b;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgb(174 210 181 / 42%);
}

.time-readout {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

#currentTime {
  color: #d3dbe0;
}

.timeline {
  min-width: 0;
  accent-color: var(--accent);
}

.transport-options {
  display: grid;
  grid-template-columns: 72px 112px 1fr;
  align-items: end;
  gap: 8px;
  padding-top: 12px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.compact-field {
  min-width: 0;
}

.field > span,
.zoom-row > label {
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 700;
}

.field input,
.field select,
.track-card input,
.track-card select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 6px 9px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #272e2b;
  font-size: 11px;
  transition:
    border-color var(--ease),
    box-shadow var(--ease),
    background-color var(--ease);
}

.field input:hover,
.field select:hover,
.track-card input:hover,
.track-card select:hover {
  border-color: #445362;
}

.field input:focus,
.field select:focus,
.track-card input:focus,
.track-card select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgb(149 191 190 / 11%);
  background: #101923;
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

select {
  color-scheme: dark;
}

.frame-readout {
  align-self: center;
  justify-self: end;
  color: var(--accent);
  font-size: 9px;
  white-space: nowrap;
}

.zoom-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 5px 10px;
}

.zoom-row output {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
}

.zoom-row input[type="range"] {
  min-width: 0;
}

.zoom-row .button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 10px;
}

.export-note {
  margin: 8px 2px 0;
  color: var(--text-dim);
  font-size: 9px;
  text-align: center;
}

.tracks-column {
  min-height: calc(100vh - var(--header-height) - 60px);
  padding: clamp(18px, 2vw, 28px);
}

.tracks-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}

.tracks-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.tracks-header h2 {
  margin-top: 3px;
  font-size: 25px;
}

.tracks-header p {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}

.count-badge {
  min-width: 24px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  color: var(--accent);
  border: 1px solid rgb(174 210 181 / 22%);
  border-radius: 6px;
  background: rgb(174 210 181 / 7%);
  font-size: 9px;
}

.track-list {
  display: grid;
  gap: 13px;
  margin-top: 14px;
}

.track-list:empty {
  margin: 0;
}

/* Dynamic track markup is intentionally permissive so generated cards stay cohesive. */
.track-card {
  --track-color: var(--accent);
  position: relative;
  overflow: hidden;
  border: 1px solid #293643;
  border-radius: 13px;
  background: #272e2b;
  box-shadow: 0 8px 24px rgb(0 0 0 / 17%);
}

.track-card::before {
  content: "";
  position: absolute;
  z-index: 3;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--track-color);
}

.track-card.is-solo,
.track-card.solo {
  border-color: color-mix(in srgb, var(--track-color) 54%, #33404b);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--track-color) 15%, transparent),
    0 10px 28px color-mix(in srgb, var(--track-color) 7%, transparent);
}

.track-card.is-muted,
.track-card.is-hidden,
.track-card[aria-disabled="true"] {
  border-color: #202a33;
}

.track-card.is-muted .track-preview-wrap,
.track-card.is-muted .track-preview,
.track-card.is-hidden .track-preview-wrap,
.track-card.is-hidden .track-preview,
.track-card[aria-disabled="true"] .track-preview-wrap,
.track-card[aria-disabled="true"] .track-preview {
  opacity: 0.3;
  filter: grayscale(0.75);
}

.track-card-header,
.track-header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px 11px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.track-title,
.track-heading,
.track-identity {
  min-width: 0;
  display: flex;
  flex: 1;
  align-items: center;
  gap: 9px;
}

.track-swatch,
.color-swatch {
  width: 9px;
  height: 22px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: var(--track-color);
}

.track-color {
  width: 9px;
  height: 24px;
  flex: 0 0 auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  background: var(--track-color);
}

.track-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.track-color::-webkit-color-swatch,
.track-color::-moz-color-swatch {
  border: 0;
  border-radius: 4px;
}

.track-index {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  font-weight: 800;
}

.track-name,
.track-name-input {
  min-width: 0;
  max-width: 280px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

input.track-name,
.track-name-input {
  height: 31px;
}

.track-actions,
.card-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
}

.track-action,
.track-actions button,
.card-actions button,
.visibility-button,
.delete-button {
  min-width: 31px;
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  color: var(--text-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #131c25;
  font-size: 9px;
  font-weight: 800;
  transition:
    color var(--ease),
    border-color var(--ease),
    background var(--ease);
}

.track-action svg,
.track-actions svg,
.card-actions svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.track-action:hover,
.track-actions button:hover,
.card-actions button:hover {
  color: var(--text);
  border-color: #4a5b6b;
  background: #1a2732;
}
.visibility-button[aria-pressed="true"],
.track-action.is-active {
  color: #061114;
  border-color: var(--cyan);
  background: var(--cyan);
}

.delete-button:hover,
.remove-track-button:hover,
.track-actions .danger:hover {
  color: #ffd8da;
  border-color: rgb(255 107 113 / 52%);
  background: rgb(255 107 113 / 12%);
}

.track-preview-wrap,
.track-canvas-wrap,
.crop-preview {
  position: relative;
  display: grid;
  min-height: 110px;
  overflow: auto hidden;
  place-items: center;
  background:
    linear-gradient(45deg, #090e13 25%, transparent 25%, transparent 75%, #090e13 75%),
    linear-gradient(45deg, #090e13 25%, #0e151c 25%, #0e151c 75%, #090e13 75%);
  background-position: 0 0, 7px 7px;
  background-size: 14px 14px;
  scrollbar-width: thin;
  scrollbar-color: #42515f transparent;
}

.track-preview-wrap canvas,
.track-canvas-wrap canvas,
canvas.track-preview,
canvas.track-canvas {
  display: block;
  width: auto;
  max-width: none;
  image-rendering: auto;
}

.track-preview-wrap .track-preview {
  min-height: 0;
  display: block;
  background: none;
}

.track-empty {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--text-dim);
  background: rgb(9 14 19 / 86%);
  font-size: 11px;
  text-align: center;
}

.track-card-footer,
.track-settings,
.crop-controls,
.track-editor,
.track-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
  padding: 10px 12px 12px 15px;
  border-top: 1px solid var(--line-soft);
  background: #101821;
}

.boundary-control {
  min-width: 0;
  display: grid;
  grid-column: span 2;
  grid-template-columns: auto minmax(70px, 1fr) 76px;
  align-items: center;
  gap: 8px;
}

.boundary-control > label:first-child {
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.boundary-control > input[type="range"] {
  width: 100%;
  min-width: 0;
}

.percent-input {
  display: flex;
  align-items: center;
  gap: 3px;
}

.percent-input input {
  width: 58px;
  min-width: 0;
  height: 31px;
  padding: 5px 4px 5px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
}

.percent-input span {
  color: var(--text-dim);
  font-size: 9px;
}

.track-card .field label,
.track-card label span,
.track-setting-label {
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 700;
}

.track-range,
.range-pair {
  grid-column: span 2;
}

.range-pair {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.track-color-input,
input[type="color"] {
  width: 34px;
  min-width: 34px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #272e2b;
}

.capture-queue {
  margin-top: 26px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
}

.capture-queue-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.capture-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.capture-title-row h2 {
  margin: 3px 0 0;
  font-size: 21px;
  font-weight: 780;
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.capture-queue-header p {
  margin: 5px 0 0;
  color: var(--text-dim);
  font-size: 11px;
}

.capture-clear-button {
  flex: 0 0 auto;
  margin-top: 16px;
}

.capture-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.capture-list:empty {
  display: none;
}

.queue-empty {
  min-height: 150px;
  display: grid;
  justify-items: center;
  align-content: center;
  padding: 26px 20px;
  margin-top: 14px;
  color: var(--text-dim);
  border: 1px dashed #34424f;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 24%, rgb(149 191 190 / 5%), transparent 45%),
    rgb(8 13 18 / 35%);
  text-align: center;
}

.queue-empty[hidden] {
  display: none;
}

.queue-empty-icon {
  position: relative;
  width: 40px;
  height: 34px;
  display: block;
  margin-bottom: 10px;
}

.queue-empty-icon i {
  position: absolute;
  width: 28px;
  height: 18px;
  border: 1px solid #435361;
  border-radius: 4px;
  background: #111923;
  box-shadow: 0 4px 10px rgb(0 0 0 / 20%);
}

.queue-empty-icon i:nth-child(1) {
  top: 0;
  left: 0;
}

.queue-empty-icon i:nth-child(2) {
  top: 7px;
  left: 6px;
}

.queue-empty-icon i:nth-child(3) {
  top: 14px;
  left: 12px;
  border-color: rgb(174 210 181 / 42%);
}

.queue-empty strong {
  color: #cad3d9;
  font-size: 12px;
}

.queue-empty p {
  max-width: 430px;
  margin: 5px 0 0;
  font-size: 10px;
}

/* PNG queue rows are generated by app.js. */
.capture-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px 18px minmax(116px, 190px) minmax(150px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 11px;
  overflow: hidden;
  border: 1px solid #2b3845;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 2%), transparent 35%),
    #0c131b;
  box-shadow: 0 8px 22px rgb(0 0 0 / 15%);
  transition:
    opacity var(--ease),
    border-color var(--ease),
    background-color var(--ease);
}

.capture-item.is-excluded {
  border-color: #222d37;
  background: #0a1016;
  opacity: 0.58;
}

.capture-item.is-excluded .capture-thumb {
  filter: grayscale(0.82);
}

.capture-item.needs-review {
  border-color: rgb(255 200 87 / 42%);
}

.capture-order {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  color: var(--accent);
  border: 1px solid rgb(174 210 181 / 21%);
  border-radius: 7px;
  background: rgb(174 210 181 / 7%);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.capture-grip {
  width: 18px;
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: #596774;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
}

.capture-grip:active {
  cursor: grabbing;
}

.capture-thumb {
  width: 100%;
  height: 76px;
  display: block;
  object-fit: contain;
  border: 1px solid #2d3944;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #303633 25%, transparent 25%, transparent 75%, #303633 75%),
    linear-gradient(45deg, #303633 25%, #19222c 25%, #19222c 75%, #303633 75%);
  background-position: 0 0, 6px 6px;
  background-size: 12px 12px;
}

.capture-copy {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 6px;
}

.capture-name-input {
  height: 34px;
  font-size: 11px;
  font-weight: 700;
}

.capture-meta {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 8px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capture-item-actions {
  min-width: 0;
  display: flex;
  grid-column: 3 / -1;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 1px;
}

.capture-include {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 9px;
  color: var(--text-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111a23;
  font-size: 9px;
  font-weight: 750;
  cursor: pointer;
}

.capture-include input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--accent);
}

.capture-move-button,
.capture-download-button,
.capture-remove-button {
  min-width: 30px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 8px;
  color: var(--text-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111a23;
  font-size: 9px;
  font-weight: 800;
  transition:
    color var(--ease),
    border-color var(--ease),
    background-color var(--ease);
}

.capture-move-button:hover:not(:disabled),
.capture-download-button:hover:not(:disabled) {
  color: var(--text);
  border-color: #536372;
  background: #192632;
}

.capture-download-button {
  margin-left: auto;
  color: #eafdc1;
  border-color: rgb(174 210 181 / 27%);
  background: rgb(174 210 181 / 6%);
}

.capture-remove-button:hover:not(:disabled) {
  color: #ffd8da;
  border-color: rgb(255 107 113 / 52%);
  background: rgb(255 107 113 / 12%);
}

.capture-item-actions svg,
.capture-grip svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stitch-options {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  padding: 14px;
  margin: 16px 0 0;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: rgb(8 13 18 / 42%);
}

.stitch-options legend {
  padding: 0 7px;
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 750;
}

.stitch-mode-help,
.stitch-result {
  grid-column: 1 / -1;
}

.stitch-mode-help,
.stitch-result {
  margin: 0;
  font-size: 10px;
  line-height: 1.55;
}

.stitch-mode-help {
  color: var(--text-soft);
}

.stitch-result {
  padding: 8px 10px;
  color: #dfe8ed;
  border: 1px solid rgb(96 165 250 / 24%);
  border-radius: 8px;
  background: rgb(96 165 250 / 8%);
}

.stitch-options .field.is-disabled {
  opacity: 0.48;
}

.print-options {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
  padding: 14px;
  margin: 12px 0 0;
  border: 1px solid rgb(174 210 181 / 18%);
  border-radius: 11px;
  background:
    linear-gradient(135deg, rgb(174 210 181 / 3%), transparent 42%),
    rgb(8 13 18 / 42%);
}

.print-options legend {
  padding: 0 7px;
  color: #dff5a8;
  font-size: 10px;
  font-weight: 750;
}

.print-help,
.print-export-button,
.print-result {
  grid-column: 1 / -1;
}

.print-help,
.print-result {
  margin: 0;
  font-size: 10px;
  line-height: 1.55;
}

.print-help {
  color: var(--text-soft);
}

.print-result {
  padding: 8px 10px;
  color: #e8f2d0;
  border: 1px solid rgb(174 210 181 / 22%);
  border-radius: 8px;
  background: rgb(174 210 181 / 6%);
}

.capture-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 8px;
  margin-top: 10px;
}

.capture-toolbar .button {
  width: 100%;
}

.youtube-stage,
.source-stage.youtube-stage {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 190px;
  overflow: hidden;
  background: #05070a;
  aspect-ratio: 16 / 9;
}

.youtube-frame {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.youtube-overlay {
  position: absolute;
  z-index: 2;
  top: 9px;
  right: 9px;
  bottom: auto;
  left: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  color: #e2e9ed;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 8px;
  background: rgb(7 10 14 / 82%);
  font-size: 9px;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(9px);
}

.youtube-reference-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 10px;
  margin: 9px 0 0;
  color: #c6d0d6;
  border: 1px solid rgb(255 200 87 / 22%);
  border-radius: 8px;
  background: rgb(255 200 87 / 6%);
  font-size: 9px;
  line-height: 1.5;
}

.youtube-reference-note::before {
  content: "!";
  width: 16px;
  height: 16px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  color: #161006;
  border-radius: 50%;
  background: var(--warning);
  font-size: 9px;
  font-weight: 900;
}

.youtube-dialog {
  width: min(520px, calc(100vw - 28px));
  max-width: none;
  padding: 0;
  color: var(--text);
  border: 1px solid #33414f;
  border-radius: 16px;
  outline: 0;
  background: transparent;
  box-shadow: 0 30px 90px rgb(0 0 0 / 65%);
}

.youtube-dialog::backdrop {
  background: rgb(2 5 8 / 74%);
  backdrop-filter: blur(6px);
}

.youtube-dialog-surface {
  overflow: hidden;
  border-radius: inherit;
  background:
    radial-gradient(circle at 100% 0, rgb(255 69 69 / 7%), transparent 19rem),
    var(--panel);
}

.youtube-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 20px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.youtube-dialog-header h2 {
  margin: 3px 0 0;
  font-size: 19px;
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.dialog-close-button {
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  color: var(--text-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #131c25;
  font-size: 22px;
  line-height: 1;
}

.dialog-close-button:hover {
  color: var(--text);
  border-color: #506171;
  background: #1a2732;
}

.youtube-dialog-body {
  padding: 18px 20px 6px;
}

.youtube-dialog-body > p:first-child {
  margin: 0 0 16px;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.65;
}

.youtube-dialog-field {
  gap: 7px;
}

.youtube-dialog-help {
  margin: 9px 1px 0;
  color: var(--text-dim);
  font-size: 9px;
  line-height: 1.55;
}

.youtube-dialog-error {
  padding: 8px 10px;
  margin: 10px 0 0;
  color: #ffdadd;
  border: 1px solid rgb(255 107 113 / 34%);
  border-radius: 7px;
  background: rgb(255 107 113 / 8%);
  font-size: 10px;
}

.youtube-dialog-actions {
  display: flex;
  justify-content: flex-end;
  padding: 14px 20px 20px;
}

.youtube-dialog-actions .button {
  min-width: 150px;
}

.toast {
  position: fixed;
  z-index: 500;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 11px 15px;
  color: #ecf2f4;
  border: 1px solid #40505e;
  border-radius: 10px;
  background: rgb(18 27 36 / 96%);
  box-shadow: 0 16px 45px rgb(0 0 0 / 45%);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity var(--ease),
    transform var(--ease);
  backdrop-filter: blur(12px);
}

.toast.is-visible,
.toast.show,
.toast[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}

.toast.error,
.toast.is-error {
  border-color: rgb(255 107 113 / 52%);
}

.media-buffer {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 1320px) {
  .local-badge {
    display: none;
  }
}

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

  .keyboard-hint {
    display: none;
  }

}

@media (max-width: 980px) {
  :root {
    --header-height: 68px;
  }

  .app-shell {
    width: min(calc(100% - 32px), var(--shell));
  }

  .local-badge {
    display: none;
  }

  .empty-state {
    grid-template-columns: minmax(0, 1fr);
    gap: 36px;
    padding-block: 52px 70px;
  }

  .empty-copy {
    max-width: 760px;
  }

  .drop-zone {
    min-height: 330px;
  }

  .empty-media-column {
    max-width: 760px;
  }

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

  .inspector-column {
    position: static;
    grid-template-columns: minmax(280px, 1.2fr) minmax(280px, 1fr);
    max-height: none;
    overflow: visible;
  }

  .source-panel {
    grid-row: span 2;
  }

  .source-stage canvas {
    max-height: 330px;
  }

  .tracks-column {
    min-height: 440px;
  }
}

@media (max-width: 720px) {
  :root {
    --header-height: auto;
  }

  body {
    font-size: 14px;
  }

  .app-shell {
    width: min(calc(100% - 24px), var(--shell));
  }

  .app-header {
    position: relative;
  }

  .header-inner {
    min-height: 0;
    flex-wrap: wrap;
    gap: 10px;
    padding-block: 12px;
  }

  main.app-shell {
    padding-top: 12px;
  }

  .empty-state {
    min-height: 0;
    padding-block: 44px 60px;
  }

  .empty-copy h1 {
    margin-block: 12px 17px;
    font-size: clamp(36px, 11vw, 56px);
  }

  .drop-zone {
    min-height: 290px;
    padding: 34px 18px;
  }

  .drop-visual {
    width: 72px;
    height: 72px;
  }

  .inspector-column {
    grid-template-columns: 1fr;
  }

  .source-panel {
    grid-row: auto;
  }

  .tracks-column {
    padding: 16px;
  }

  .tracks-header {
    align-items: flex-start;
    gap: 14px;
  }

  .tracks-header p {
    max-width: 390px;
  }

  .track-card-footer,
  .track-settings,
  .crop-controls,
  .track-editor,
  .track-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .boundary-control {
    grid-column: 1 / -1;
  }

  .capture-item {
    grid-template-columns: 30px 18px minmax(110px, 170px) minmax(130px, 1fr);
  }

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

@media (max-width: 500px) {
  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .empty-state {
    padding-top: 30px;
  }

  .feature-list {
    margin-top: 21px;
  }

  .panel {
    padding: 13px;
  }

  .transport-primary {
    gap: 5px;
  }

  .icon-button {
    width: 31px;
    height: 31px;
  }

  .play-button {
    width: 37px;
    height: 37px;
  }

  .transport-options {
    grid-template-columns: 68px 102px minmax(0, 1fr);
  }

  .tracks-header {
    display: grid;
  }

  .tracks-header .button {
    width: 100%;
  }

  .track-card-header,
  .track-header {
    align-items: flex-start;
  }

  .track-actions,
  .card-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .track-name,
  .track-name-input {
    max-width: 150px;
  }

  .panel-header-actions {
    gap: 4px;
  }

  .panel-header-actions .text-button {
    font-size: 10px;
  }

  .capture-queue-header {
    display: grid;
    gap: 4px;
  }

  .capture-clear-button {
    justify-self: start;
    margin-top: 0;
  }

  .capture-item {
    grid-template-columns: 30px 18px minmax(0, 1fr);
    align-items: start;
  }

  .capture-thumb,
  .capture-copy,
  .capture-item-actions {
    grid-column: 3;
  }

  .capture-thumb {
    height: auto;
    max-height: 150px;
  }

  .capture-item-actions {
    padding-top: 0;
  }

  .capture-download-button {
    margin-left: 0;
  }

  .stitch-options {
    grid-template-columns: 1fr;
  }

  .print-options {
    grid-template-columns: 1fr;
  }

  .capture-toolbar {
    grid-template-columns: 1fr;
  }

  .youtube-url-controls {
    grid-template-columns: 1fr;
  }

  .youtube-url-controls .button {
    width: 100%;
  }

  .youtube-dialog-header,
  .youtube-dialog-body {
    padding-inline: 16px;
  }

  .youtube-dialog-actions {
    padding: 12px 16px 16px;
  }

  .youtube-dialog-actions .button {
    width: 100%;
  }

  .toast {
    right: 16px;
    bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #5c6975;
    --line-soft: #414e5a;
    --text-soft: #c8d1d7;
    --text-dim: #a2afb9;
  }

  .panel,
  .tracks-column {
    border-width: 2px;
  }
}

/* ── 이음새 검수 · 줄바꿈 편집기 ─────────────────────────────────────────── */

.editor-section {
  display: grid;
  gap: 10px;
}

.row-editor-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 1.5vw, 26px);
}
.row-edit-panel {
  --panel-accent: var(--cyan);
  background: #101b24;
}
.row-preview-panel {
  --panel-accent: var(--accent);
  background: #171d18;
}
.row-editor-columns > .editor-section {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  padding: clamp(10px, 1vw, 18px);
  border: 1px solid #42505a;
  border-top: 3px solid var(--panel-accent);
  border-radius: var(--radius-small);
}
.row-editor-columns .editor-section h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid #394550;
  font-size: 16px;
}
.row-editor-columns h3 .section-tag {
  margin: 0;
  color: var(--panel-accent);
  background: color-mix(in srgb, var(--panel-accent) 12%, transparent);
}
.row-editor-columns .step-actions {
  margin-left: 0;
  flex-wrap: wrap;
}
.row-editor-columns .row-preview-list {
  grid-template-columns: minmax(0, 1fr);
  overflow-y: scroll;
}
.row-editor-columns .strip-wrap {
  overflow-x: scroll;
}
.row-editor-columns :is(.strip-wrap, .row-preview-list)::-webkit-scrollbar {
  width: 16px;
  height: 16px;
  background: #24313d;
}
.row-editor-columns :is(.strip-wrap, .row-preview-list)::-webkit-scrollbar-thumb {
  min-width: 32px;
  min-height: 32px;
  border: 3px solid #24313d;
  border-radius: 8px;
  background: #aebdca;
}
@supports not selector(::-webkit-scrollbar) {
  .row-editor-columns :is(.strip-wrap, .row-preview-list) {
    scrollbar-color: #aebdca #24313d;
  }
}

.editor-section h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.seam-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seam-chip {
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.seam-chip[data-verdict="error"] {
  border-color: rgba(220, 38, 38, 0.55);
  background: rgba(220, 38, 38, 0.08);
}

.seam-chip[data-verdict="suspect"] {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.08);
}

.seam-chip[data-edited="true"]::after {
  content: " ✎";
}

.seam-chip[data-review="true"]::before {
  content: "● ";
  color: #b45309;
}

.seam-chip[data-active="true"] {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.seam-detail {
  display: grid;
  gap: 8px;
}

.seam-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.seam-controls .field {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.seam-controls input {
  width: 92px;
}

.seam-meta {
  margin: 0;
  font-size: 12px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.seam-canvas-wrap,
.strip-wrap {
  overflow-x: auto;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  background: #fff;
}

.seam-canvas-wrap canvas {
  display: block;
  image-rendering: pixelated;
}

.strip-zoom-controls { display: flex; align-items: center; gap: 8px; }
.strip-zoom-controls output { min-width: 5ch; text-align: center; font-variant-numeric: tabular-nums; }
.strip-wrap { min-width: 0; max-width: 100%; }
.strip-wrap canvas {
  position: sticky;
  left: 0;
  display: block;
  touch-action: pan-x pan-y;
}
#addRowBreak[aria-pressed="true"] {
  outline: 2px solid var(--accent);
}

.seam-hint {
  margin: 0;
  font-size: 12px;
  opacity: 0.7;
}

.row-summary {
  margin: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.row-preview-list {
  display: grid;
  gap: 10px;
  max-height: 460px;
  overflow-y: auto;
}

.row-preview {
  margin: 0;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.row-preview[data-forced="true"] {
  border-color: rgba(220, 38, 38, 0.6);
}

.row-preview canvas {
  display: block;
  max-width: 100%;
}

.row-preview figcaption {
  padding: 4px 8px;
  font-size: 12px;
  opacity: 0.75;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.row-preview[data-forced="true"] figcaption {
  color: #b91c1c;
  opacity: 1;
}

.auto-track-mode {
  display: grid;
  gap: 4px;
  margin: 8px 0;
  font-size: 12px;
}

.auto-track-mode select {
  width: 100%;
}

.seam-empty {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.04);
  font-size: 13px;
}

.collect-availability {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

.section-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  vertical-align: middle;
}

.section-tag.is-preview {
  background: rgba(15, 23, 42, 0.08);
  color: #334155;
}

.seam-canvas-wrap canvas {
  cursor: ew-resize;
}

.zoom-field {
  display: grid;
  gap: 4px;
  margin: 0;
  font-size: 12px;
}

.zoom-field input[type="range"] {
  width: 100%;
}

.piece-list {
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.piece-row {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr 96px;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
}

.piece-row[data-active="true"] {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.06);
}

.piece-name {
  border: 0;
  background: none;
  padding: 2px 4px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  text-decoration: underline dotted;
}

.piece-size {
  font-size: 12px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.piece-scale {
  width: 100%;
}

.inspect-label {
  margin: 0;
  font-size: 12px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.inspect-wrap {
  overflow: auto;
  max-height: 380px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  background: #fff;
}

.inspect-wrap canvas {
  display: block;
  image-rendering: pixelated;
}

.seam-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 720px) {
  .seam-pair { grid-template-columns: 1fr; }
}

.seam-side {
  margin: 0;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.seam-side figcaption {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.seam-side-tag {
  font-weight: 400;
  font-size: 11px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.seam-compare-hint {
  margin: 0;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.08);
  font-size: 12px;
}

/* 이음새/조각 마크업이 4단계 화면(.step-body)에 복제돼 들어간다 — 높이
   제한이 없으면 조각 목록이나 확대 보기가 끝없이 늘어난다. */
.step-body {
  gap: 18px;
}

.step-body .piece-list {
  max-height: min(32vh, 320px);
}

.step-body .inspect-wrap {
  max-height: min(48vh, 560px);
}

.step-body .row-preview-list {
  max-height: min(60vh, 720px);
}

/* 조각 썸네일은 76px 라 1920×235 악보를 분간할 수 없다.
   눌러서 원본 크기로 펼치고 가로로 훑어볼 수 있게 한다. */
.capture-thumb-button {
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  display: block;
  min-width: 0;
}

.capture-item.is-zoomed .capture-thumb-button {
  cursor: zoom-out;
}

.capture-zoom {
  grid-column: 1 / -1;
  margin-top: 8px;
  overflow-x: auto;
  border: 1px solid #2d3944;
  border-radius: 8px;
  background: #fff;
}

.capture-zoom img {
  display: block;
  max-width: none;
  image-rendering: pixelated;
}

.capture-item.is-zoomed {
  border-color: rgb(126 231 135 / 55%);
}

/* 방금 넣은 조각이 어디에 들어갔는지 잠깐 표시한다. */
.capture-item.just-added {
  border-color: rgb(126 231 135 / 80%);
  box-shadow: 0 0 0 2px rgb(126 231 135 / 25%);
}

/* 줄이 아주 길면 가로로 스크롤한다 — 높이를 줄여 읽을 수 없게 만들지 않는다. */
.row-preview {
  overflow-x: auto;
  overflow-y: hidden;
}

.row-preview canvas {
  max-width: none;
}

/* 그리드 항목에 overflow 가 걸리면 자동 최소 높이가 0 이 되어, max-height 안에
   줄들이 욱여넣어지며 납작해진다. 각 줄은 내용 높이를 지키고 목록이 스크롤한다. */
.row-preview-list {
  grid-auto-rows: max-content;
  align-content: start;
}

.row-preview {
  min-height: 0;
}

.row-preview canvas {
  height: auto;
}

.snap-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin: 2px 0;
}

.drag-readout {
  margin: 0;
  min-height: 16px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: #1d4ed8;
}

.drag-readout:empty {
  min-height: 0;
}

/* 할당량 초과 안내 — 복원 목록보다 먼저 보여야 하는 경고이므로 눈에 띄게 둔다 */
.storage-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto 16px;
  max-width: 960px;
  padding: 12px 16px;
  border: 1px solid rgba(251, 113, 133, 0.5);
  border-radius: 10px;
  background: rgba(251, 113, 133, 0.12);
  font-size: 0.9rem;
}

/* 복원 목록 — 드롭존과 같은 폭에서 시작한다 */
.restore-panel {
  margin: 0 auto 24px;
  max-width: 960px;
  padding: 20px 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.restore-heading h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.restore-heading p {
  margin: 0 0 14px;
  font-size: 0.85rem;
  opacity: 0.7;
}

.restore-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.restore-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

.restore-item-main {
  flex: 1;
  min-width: 0;
}

.restore-item-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.restore-item-meta {
  font-size: 0.8rem;
  opacity: 0.65;
}

.restore-item-previous {
  font-size: 0.8rem;
  opacity: 0.75;
}

.toast-action {
  /* .toast 는 사라질 때 뒤 화면 클릭을 막지 않으려고 pointer-events:none 인데,
     이게 자식에게도 상속돼 버튼이 눈에는 보여도 눌리지 않는다. 여기서 되살린다. */
  pointer-events: auto;
  margin-left: 12px;
  padding: 4px 10px;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 0.85em;
}

/* 단계 셸 — 한 화면에 한 단계. 헤더가 어디에 있는지와 다음 행동을 이고 있다. */
.step-header {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-raised);
}

.step-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 750;
}

.step-title {
  font-size: 14px;
  font-weight: 750;
}

.step-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.step-context {
  font-size: 12.5px;
  color: var(--text-dim);
}

/* 단계 헤더의 상태 채널. 비어 있으면 자리를 차지하지 않는다. 분석 실패 사유는
   끝까지 읽어야 뭘 손으로 고쳐야 하는지 알 수 있으므로 줄임표로 자르지 않고
   접어서 다 보여준다(헤더의 min-height 안에서 두 줄까지 들어간다). */
.step-status:empty {
  display: none;
}

.step-status {
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 44ch;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgb(149 191 190 / 10%);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.4;
}

.step-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  align-items: center;
}

.step-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

/* 3단계 — 담는 동안 악보가 화면의 주인공이어야 한다.
   지금까지는 좌측 인스펙터의 작은 영상을 보며 버튼을 눌러야 했다. */
.collect-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.collect-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 16px 20px;
}

.collect-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collect-label {
  font-size: 12px;
  font-weight: 750;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}

.collect-hint {
  font-size: 11.5px;
  color: var(--text-dim);
}

.collect-zoom {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.collect-zoom-value {
  font-size: 12px;
  font-weight: 750;
  color: var(--text-soft);
  min-width: 42px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.collect-stage {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f8f5;
}

/* 확대/축소는 캔버스 픽셀을 다시 그리지 않고 화면에 보이는 크기만 키운다 —
   .collect-stage 가 overflow: hidden 이라 100% 를 넘긴 만큼은 가운데를 기준으로
   잘려 보인다. 매 프레임 다시 그려야 하는 drawStage() 쪽 비용과 무관하게 둔다. */
.collect-stage canvas {
  max-width: 100%;
  max-height: 100%;
  transition: transform var(--ease);
}

.collect-controls {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-wrap: wrap;
}

.collect-density {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}

.collect-density .button {
  border-radius: 0;
}

.collect-auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}
.collect-auto-toggle input {
  appearance: none;
  width: 30px;
  height: 18px;
  margin: 0;
  padding: 2px;
  border: 1px solid var(--text-dim);
  border-radius: 12px;
  background: var(--panel);
  cursor: pointer;
}
.collect-auto-toggle input::before {
  content: "";
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
}
.collect-auto-toggle input:checked { background: var(--accent); }
.collect-auto-toggle input:checked::before { transform: translateX(12px); background: var(--accent-ink); }
.collect-player-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 12px;
}
.collect-player-buttons .button { min-width: 5.5em; }
.collect-player-buttons input { flex: 1; min-width: 0; width: auto; accent-color: var(--accent); }
.collect-player-buttons output { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
#collectTimelineReadout { color: var(--text); font-variant-numeric: tabular-nums; }
.collect-timeline {
  margin-top: 10px;
}

.collect-side {
  display: flex;
  flex: none;
  flex-direction: column;
  width: 344px;
  border-left: 1px solid var(--line-soft);
  background: var(--bg-raised);
  overflow-y: auto;
}

.collect-preview {
  flex: none;
  padding: 13px 16px 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  border-bottom: 1px solid var(--line-soft);
}

.page-review { font-size: 12px; }
.page-review[hidden] { display: none; }
.review-status { color: var(--text-dim); }
.review-pages { display: grid; gap: 4px; max-height: 160px; overflow-y: auto; }
.page-review summary { cursor: pointer; }
.page-review label { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }
.page-review input { width: 6em; }

.collect-preview-label {
  font-size: 12px;
  font-weight: 750;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}

.collect-preview-frame {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #05070a;
  overflow: hidden;
}

.collect-preview-frame canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* 담을 때 놓친 구간·겹쳐 담은 조각이 있을 때만 나타난다(hidden 은 JS 가 토글). */
.collect-issues {
  margin: 12px 16px 0;
  border: 1px solid rgb(255 200 87 / 30%);
  background: rgb(255 200 87 / 8%);
  border-radius: 12px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.collect-issues-heading {
  font-size: 12px;
  font-weight: 700;
  color: var(--warning);
}

.collect-issue {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--text-dim);
}

/* 담은 조각 목록의 머리 — 제목과 [모두 지우기] 한 쌍. 아래 .collect-list 가
   자기 위쪽 패딩을 갖고 있으므로 여기는 아래 여백을 두지 않는다. */
.collect-list-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 16px 0;
}

.collect-list-clear {
  flex: none;
  font-size: 11px;
  padding: 4px 9px;
}

.collect-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.collect-list-empty {
  padding: 18px 4px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

.collect-piece {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.collect-piece-thumb {
  width: 52px;
  height: 30px;
  border-radius: 5px;
  background: #f7f8f5;
  object-fit: cover;
  flex: none;
}

.collect-piece-copy {
  min-width: 0;
  flex: 1;
}

.collect-piece-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.collect-piece-name {
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collect-piece-tag {
  font-size: 9.5px;
  font-weight: 750;
  padding: 1px 5px;
  border-radius: 999px;
  flex: none;
}

.collect-piece-tag[data-source="hand"] {
  color: var(--accent-ink);
  background: var(--accent);
}

.collect-piece-tag[data-source="auto"] {
  color: var(--text-soft);
  background: #22303c;
}

.collect-piece-meta {
  font-size: 10.5px;
  color: var(--text-dim);
}

.collect-piece-remove {
  flex: none;
}

.collect-timeline-track {
  position: relative;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(to right, rgb(174 210 181 / 15%) var(--played, 0%), transparent var(--played, 0%)), var(--panel-soft);
  border: 1px solid var(--line-soft);
  overflow: hidden;
  cursor: pointer;
}

.collect-timeline-bands,
.collect-timeline-marks,
.collect-timeline-head {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.collect-timeline-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgb(255 200 87 / 26%);
  border-left: 1px solid var(--warning);
  border-right: 1px solid var(--warning);
}

.collect-timeline-mark {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.collect-timeline-mark[data-source="hand"] {
  background: var(--cyan);
}

.collect-timeline-head {
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--text);
}

.collect-timeline-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-dim);
  padding-top: 6px;
}

.collect-timeline-legend-gap::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 2px;
  background: rgb(255 200 87 / 26%);
  border: 1px solid var(--warning);
  vertical-align: -1px;
}

.seam-cursor {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.seam-cursor-count {
  font-size: 12px;
  font-weight: 750;
  color: var(--warning);
  white-space: nowrap;
}

.seam-cursor-count[data-clear="true"] {
  color: var(--text-dim);
}

/* ── 2단계 악보 찾기 ─────────────────────────────────────────────────────── */

.detect-layout {
  display: flex;
  gap: 18px;
  min-height: 0;
  flex: 1;
}

.detect-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detect-side {
  width: 340px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detect-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.detect-label {
  font-size: 13px;
  font-weight: 750;
  color: var(--text);
}

.detect-hint {
  font-size: 12px;
  color: var(--text-dim);
}

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

.detect-time {
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.detect-stage {
  position: relative;
  /* Keep the source viewport independent of the cropped canvas's intrinsic height. */
  flex: none;
  width: 100%;
  aspect-ratio: var(--source-aspect, 16 / 9);
  max-height: 52vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #05070a;
  overflow: hidden;
}

.detect-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 범위 선의 위치·크기는 step2-detect.js 가 픽셀로 넣는다 — 무대는 남는 세로
   공간을 받아 늘어나므로 영상 비율과 다르고, object-fit: contain 이 만든 여백
   때문에 무대 기준 퍼센트로 얹으면 선이 실제 악보 위치에서 어긋난다. */
.detect-band {
  position: absolute;
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  background: rgb(174 210 181 / 10%);
}

.detect-handle {
  position: absolute;
  left: 50%;
  /* 선 위에 반쯤 걸터앉는 것이 기본이고, --handle-shift 는 선이 무대 끝에 붙어
     .detect-stage 의 overflow: hidden 에 잘릴 때 안쪽으로 들어오는 보정이다 —
     얼마나 밀지는 step2-detect.js 의 shiftHandle 이 픽셀로 재서 넣는다. */
  transform: translate(-50%, calc(-50% + var(--handle-shift, 0px)));
  top: 0;
  width: 54px;
  height: 15px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  cursor: ns-resize;
  padding: 0;
}

.detect-handle-bottom {
  top: auto;
  bottom: 0;
  transform: translate(-50%, calc(50% + var(--handle-shift, 0px)));
}

.detect-readout {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 11.5px;
  font-weight: 750;
  color: var(--text);
  background: rgb(12 17 24 / 88%);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
}

.detect-strip {
  flex: 1;
  min-height: 90px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f8f5;
  overflow: hidden;
}

.detect-strip canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.detect-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.detect-card-title {
  font-size: 13px;
  font-weight: 750;
}

.detect-card-hint,
.detect-card-foot {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

.detect-mode-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.detect-mode {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  font-family: inherit;
}

.detect-mode[aria-pressed="true"] {
  border-color: var(--accent);
  background: #131a10;
}

.detect-mode-name {
  font-size: 13px;
  font-weight: 750;
}

.detect-mode-badge {
  font-size: 10px;
  font-weight: 750;
  color: var(--accent-ink);
  background: var(--accent);
  padding: 2px 6px;
  border-radius: 999px;
  align-self: center;
}

.detect-mode-note {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: var(--text-dim);
}

.detect-thumbs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detect-thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #05070a;
  padding: 0;
  cursor: pointer;
}

.detect-thumb img {
  display: block;
  width: 100%;
}

.detect-thumb span {
  position: absolute;
  left: 5px;
  bottom: 4px;
  font-size: 9.5px;
  color: var(--text-soft);
  background: rgb(5 7 10 / 75%);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── 1단계 가져오기 ─────────────────────────────────────────────────────── */

.source-layout {
  width: min(760px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 0;
}

.source-lede {
  margin: 0;
  font-size: 14px;
  color: var(--text-soft);
}

.source-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.source-card-title {
  font-size: 13px;
  font-weight: 750;
}

.source-url-row {
  display: flex;
  gap: 10px;
}

.source-url-input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}

.source-url-input:focus {
  outline: none;
  border-color: var(--accent);
}

.source-progress {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.source-progress-head,
.source-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.source-progress-head span {
  font-size: 13.5px;
  font-weight: 750;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-raised);
  overflow: hidden;
}

.source-progress-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 120ms linear;
}

.source-error {
  margin: 0;
  font-size: 12.5px;
  color: var(--warning);
  line-height: 1.5;
}

.source-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.source-divider::before,
.source-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

/* 시작 화면의 드롭존은 그 화면의 주인공이라 420px 를 깔고 앉는다. 카드 안에서는
   주소 입력과 나란히 서는 두 번째 선택지이므로, 프로토타입처럼 한 줄짜리
   높이로 줄인다 — 그대로 두면 카드 하나가 화면을 통째로 차지한다. */
.source-drop {
  min-height: 0;
  gap: 8px;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  box-shadow: none;
}

.source-drop .drop-visual {
  width: auto;
  height: auto;
  margin-bottom: 0;
  color: var(--text-dim);
  border: 0;
  background: none;
  box-shadow: none;
}

.source-drop .drop-visual svg {
  width: 26px;
  height: 26px;
  stroke-width: 2.4;
}

.source-drop > strong {
  font-size: 13.5px;
  font-weight: 750;
}

.source-drop > p {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-dim);
}

.source-file-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.source-file {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.source-file:hover {
  border-color: var(--text-dim);
}

.source-file-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-file-size {
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.step-body:empty {
  flex: none;
}

.source-png-options > summary {
  cursor: pointer;
  padding-block: 10px;
  font-weight: 650;
}
.source-png-options .capture-toolbar {
  margin-top: 12px;
}
.rows-output {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.5fr);
  align-items: start;
  gap: 16px;
  margin-block: 14px;
}
.rows-output .print-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}
.rows-output .source-png-options { grid-column: 1 / -1; }
.paper-preview {
  min-width: 0;
  padding: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.paper-preview header, .paper-preview-nav, .paper-preview-zoom {
  display: flex;
  align-items: center;
  gap: 8px;
}
.paper-preview header { flex-wrap: wrap; justify-content: space-between; }
.paper-preview-zoom { flex-wrap: wrap; gap: 4px; }
.paper-preview-zoom output { min-width: 4ch; text-align: center; font-variant-numeric: tabular-nums; }
.paper-preview h2 { margin: 0; font-size: 16px; }
.paper-preview-nav output { font-variant-numeric: tabular-nums; }
.paper-preview-nav button { font-size: 20px; }
.paper-desk {
  container-type: size;
  height: clamp(200px, 65vh, 820px);
  overflow: auto;
  background: #202931;
  border-radius: 6px;
  margin-top: 8px;
}
.paper-sheet-space {
  width: max-content;
  min-width: 100%;
  padding: 12px;
  box-sizing: border-box;
}
.paper-desk canvas {
  display: block;
  margin-inline: auto;
  width: calc(min(100cqw - 24px, (100cqh - 24px) * var(--paper-ratio, 0.707)) * var(--paper-zoom, 1));
  height: auto;
  max-width: none;
  box-shadow: 0 2px 9px #0006;
}
.paper-desk::-webkit-scrollbar { width: 16px; height: 16px; background: #24313d; }
.paper-desk::-webkit-scrollbar-thumb {
  border: 3px solid #24313d;
  border-radius: 8px;
  background: #aebdca;
}
#paperInfo { margin: 8px 0 0; color: var(--text-soft); font-size: 12px; }
@media (max-width: 700px) {
  .rows-output { grid-template-columns: minmax(0, 1fr); }
}

/* ── 3단계 비교 띠 ─────────────────────────────────────────────────────────
   라이브 띠(.collect-stage) 바로 아래에서 담긴 조각을 같은 폭으로 보여준다.
   배율은 두 띠에 같이 적용된다(step3-collect.js 의 applyStageZoom) — 배율이
   다르면 겹쳐 보기가 아무것도 말해 주지 않는다. */

/* 라이브 띠와 남는 세로 공간을 반씩 나눈다. flex 를 주지 않으면 이 띠가
   내용 높이를 그대로 차지해 .collect-stage(flex: 1, min-height: 0)만
   찌그러진다 — 실측: 무대가 38px 로 주저앉았다. */
.collect-compare {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  margin-top: 10px;
}

.collect-compare-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
}

.collect-compare-label, #collectComparePin { white-space: nowrap; flex-shrink: 0; }

.collect-compare-label {
  font-size: 13px;
  font-weight: 750;
  color: var(--text);
}

.collect-compare-meta {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#collectComparePin {
  margin-left: auto;
  min-height: 30px;
  padding: 4px 9px;
  font-size: 12px;
}

/* 라이브 띠와 같은 높이 비중(flex: 1)을 준다 — 한쪽이 눌리면 어긋남의 크기를
   잘못 읽는다. overflow: hidden 도 라이브 쪽과 같아야 배율을 넘긴 만큼이
   같은 방식으로 잘린다. */
.collect-compare-stage {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--cyan);
  border-radius: var(--radius);
  background: #f7f8f5;
}

.collect-compare-stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* 지금 비교 중인 조각을 목록에서도 알아보게 한다. */
.collect-piece[data-compare="true"] {
  outline: 2px solid var(--cyan);
  outline-offset: -2px;
}

.collect-piece[data-compare="pinned"] {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* 조각 행의 "누르면 비교 띠에 고정" 영역. 썸네일과 글자를 감싸지만 행의
   가로 배치는 그대로여야 하므로, 옛 구조에서 두 자식이 갖고 있던
   flex 역할(썸네일 flex:none, 글자 flex:1)을 이 버튼이 이어받는다. */
.collect-piece-pick {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.collect-piece-pick:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 6px;
}

/* 라이브 띠·담긴 조각·차영상 셋이 언제나 함께 보여야 한다(사용자 요구).
   세 띠가 flex: 1 로 남는 세로 공간을 나누고, min-height 로 어느 하나가
   못 알아볼 만큼 눌리는 것을 막는다. 창이 세 띠 + 컨트롤 + 타임라인을
   담기에도 짧으면 그때는 페이지가 스크롤된다 — 그 상황에서는 무언가는
   양보해야 하고, 알아볼 수 없는 슬라이버 셋보다 스크롤이 낫다. */
.collect-diff {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  margin-top: 10px;
}

.collect-stage,
.collect-compare-stage {
  min-height: 72px;
}

.collect-diff-stage {
  /* 차영상은 어두운 바닥에 밝은 차이를 그린다 — 흰 바닥이면 안 보인다. */
  background: #05070a;
  border-color: var(--line);
}

.collect-stage canvas,
.collect-compare-stage img,
.collect-diff-stage canvas {
  display: block;
  flex: none;
  width: var(--score-strip-width, auto);
  max-width: none;
  max-height: none;
  transform: scale(var(--score-strip-zoom, 1));
  transition: transform var(--ease);
}

.collect-diff-stage canvas {
  height: var(--score-strip-height, auto);
}

.detect-play-overlay {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 1px solid #aab5ba;
  border-radius: 50%;
  background: rgb(10 18 23 / 85%);
  color: white;
  cursor: pointer;
  font-size: 17px;
}

.detect-card.needs-choice {
  border-color: #f39388;
  background-color: color-mix(in srgb, var(--panel), #f18274 12%);
  animation: detect-choice-pulse 2.4s ease-in-out infinite;
}
@keyframes detect-choice-pulse {
  0%, 100% { background-color: color-mix(in srgb, var(--panel), #f18274 8%); box-shadow: 0 0 0 1px rgb(241 130 116 / 30%); }
  50% { background-color: color-mix(in srgb, var(--panel), #f18274 19%); box-shadow: 0 0 0 3px rgb(241 130 116 / 65%), 0 0 16px rgb(241 130 116 / 16%); }
}
.detect-choice-required {
  display: none;
}
.needs-choice .detect-choice-required {
  display: inline;
  margin-left: 6px;
  color: #ffb2a8;
  font-size: 12px;
}
@media (prefers-reduced-motion: reduce) {
  .detect-card.needs-choice {
    animation: none;
    box-shadow: 0 0 0 2px rgb(241 130 116 / 50%);
  }
}

.detect-next-action {
  position: relative;
  display: inline-flex;
  flex: none;
}
.detect-next-hint {
  position: absolute;
  z-index: 101;
  right: 0;
  bottom: calc(100% + 7px);
  width: max-content;
  max-width: min(240px, 80vw);
  pointer-events: none;
  border-radius: 6px;
  padding: 5px 9px;
  background: #56332f;
  color: #fff1eb;
  font-size: 12px;
  line-height: 1.4;
  word-break: keep-all;
}
.detect-next-hint::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 32px;
  border: 5px solid transparent;
  border-top-color: #56332f;
}

.draft-settings, .draft-panel { display: grid; gap: .7rem; padding: 1rem; border: 1px solid #527e70; border-radius: .65rem; }
.draft-settings details label { display: inline-flex; gap: .5rem; align-items: center; margin: .4rem 1rem .2rem 0; }
.draft-settings input[type="number"] { width: 4rem; }
.draft-panel { margin-bottom: 1rem; }
.draft-panel p { margin: 0; }
.draft-panel progress { width: 100%; accent-color: #65b49a; }
.draft-panel[hidden], .draft-panel [hidden] { display: none; }

/* App navigation and shared editing tools */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid #e1e3ea;
  color: #161920;
  box-shadow: none;
  backdrop-filter: none;
}
.header-inner { width: min(calc(100% - 48px), 1600px); }
.brand { gap: 9px; }
.brand-copy { font: 720 23px/1 Inter, system-ui, sans-serif; letter-spacing: -.055em; }
.brand-mark { width: 24px; height: 27px; padding: 5px 0; gap: 3px; background: none; border: 0; border-radius: 0; box-shadow: none; }
.brand-mark span { background: #3455e8; height: 2px; opacity: 1; }
.brand-mark::after { background: #3455e8; left: 9px; top: 2px; bottom: 2px; width: 3px; box-shadow: none; }
.app-links { display: flex; align-items: center; gap: 24px; font-size: 13px; }
.app-links a { text-underline-offset: 4px; }
.local-badge { color: #4d5666; }
.status-dot { width: 6px; height: 6px; background: #4664d2; box-shadow: none; }
.button, .source-url-input { border-radius: 4px; }
.button-primary, .button-primary:hover:not(:disabled), .button-secondary { box-shadow: none; }
.button-secondary, .button-subtle { background: var(--panel); border-color: var(--line); }
.button-secondary:hover:not(:disabled), .button-subtle:hover:not(:disabled) { background: var(--panel-strong); border-color: var(--text-dim); }
.step-header { border-top: 1px solid var(--line-soft); }
.step-badge { border-radius: 3px; font-variant-numeric: tabular-nums; }
.step-title { font-size: 15px; letter-spacing: -.015em; }
.detect-band { border-color: #83d390; }
.detect-handle { background: #83d390; }
.draft-settings, .draft-panel { border-color: var(--line); border-radius: var(--radius-small); }
:where(a,button,input,select,[role="button"]):focus-visible { outline-color: #3455df; }

/* On the import page the score and the source controls form a single spread. */
body:has(.source-layout) {
  color-scheme: light;
  --bg: #f6f7fa; --bg-raised: #ffffff; --panel: #ffffff; --panel-soft: #f7f8fb;
  --panel-strong: #eef1fa; --line: #c5cad6; --line-soft: #e0e3ea;
  --text: #191c24; --text-soft: #4d5566; --text-dim: #596274;
  --accent: #3455df; --accent-ink: white; --warning: #86431f;
}
body:has(.source-layout) .step-header {
  width: min(1100px, 100%); margin-inline: auto; padding-inline: 0;
  background: transparent; border-top: 0;
}
body:has(.source-layout) .step-context,
body:has(.source-layout) .step-divider { display: none; }
body:has(.source-layout) .step-status { color: var(--text); }
body:has(.source-layout) .button-primary:hover:not(:disabled) { background: #2843bd; border-color: #2843bd; }
body:has(.source-layout) .restore-panel { width: min(1100px, 100%); max-width: none; border-color: var(--line-soft); background: var(--panel); }
body:has(.source-layout) .restore-item { border-color: var(--line-soft); }
.source-layout { width: min(1100px, 100%); padding: clamp(22px, 4vw, 58px) 0 35px; gap: 22px; }
.import-intro h1 { margin: 0; font: 690 clamp(36px, 4.4vw, 62px)/1.05 Inter, system-ui, sans-serif; letter-spacing: -.055em; }

.import-intro p { margin: 10px 0 6px; color: var(--text-soft); font-size: 16px; }
.import-spread { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(0,1fr); gap: clamp(16px, 2.5vw, 36px); align-items: stretch; }
.source-card { padding: clamp(18px, 2.1vw, 30px); gap: 14px; border-radius: 14px; }
.source-drop { min-height: 114px; border-radius: 9px; border-color: #c2cadd; background: #fafbfe; box-shadow: none; }
.source-drop::before { display: none; }
.source-drop:hover, .source-drop.drag-over, .source-drop.is-dragging { background: #edf1ff; transform: none; box-shadow: none; }
.source-drop .drop-visual { color: #3853be; }
.source-drop > strong { font-size: 18px; }
.source-drop > p { max-width: 34ch; font-size: 12px; }
.draft-settings { padding: 12px 0 0; border: 0; border-top: 1px solid var(--line-soft); border-radius: 0; font-size: 14px; }
.draft-settings > label { font-weight: 600; }
.draft-settings input { accent-color: var(--accent); }
.draft-settings summary { width: fit-content; cursor: pointer; font-size: 13px; color: var(--text-soft); }
.source-url-row { gap: 6px; padding: 4px; border: 1px solid #adb6ca; background: white; border-radius: 9px; }
.source-url-row:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.source-url-input { border: 0; background: transparent; font-size: 15px; padding-inline: 10px; }
.source-url-row .button { border-radius: 6px; padding-inline: 16px; }
.coffee-link { width: fit-content; color: var(--text-soft); font-size: 13px; text-underline-offset: 3px; }
.source-reference { display: grid; gap: 6px; }
.source-reference iframe { display: block; width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 8px; background: #14161b; }
.source-reference a { width: fit-content; color: var(--accent); font-size: 13px; }
.guide-cover { display: flex; flex-direction: column; align-self: start; width: 100%; background: #202638; color: #f7f8ff; border-radius: 14px; text-decoration: none; overflow: hidden; }
.guide-sample-title { padding: 16px 20px; font-size: 13px; font-weight: 600; }
.guide-plate { display: grid; align-items: center; padding: clamp(22px,3vw,42px); background-color: #323f65; background-image: radial-gradient(#707fa3 1px, transparent 1px); background-size: 12px 12px; }
.guide-sheet { position: relative; background: white; padding: 6px; box-shadow: 0 8px 18px #17214060; }
.guide-plate img { display: block; width: 100%; height: auto; filter: grayscale(1) contrast(1.07); }
.guide-cover > span { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; font-size: 14px; }
.guide-cover:hover > span { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 760px) {
  .header-inner { width: calc(100% - 28px); min-height: 54px; }
  .app-links .local-badge { display: none; }
  .import-spread { grid-template-columns: minmax(0,1fr); }
  .guide-plate { min-height: 0; padding: 16px; }
  .guide-sheet { width: min(100%, 360px); margin: auto; }
  .step-header { flex-wrap: wrap; gap: 8px; padding: 8px; }
  .step-context { overflow-wrap: anywhere; }
  .step-actions { flex-wrap: wrap; }
}
