/* Code Match: footage first, setup in a dialog, moments alongside the video. */
body[data-workspace="code"] { overflow: auto; }
body[data-workspace="code"] .app-shell { height: auto; min-height: 100vh; }
body[data-workspace="code"] .topbar { grid-template-columns: auto minmax(0,1fr) auto; gap: 16px; padding: 12px 20px; }
body[data-workspace="code"] .topbar .tabs { min-width: 0; width: auto; }
body[data-workspace="code"] .topbar .tab { min-width: 0; padding: 10px 14px; }
body[data-workspace="code"] .topbar-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
#codeView.active { display: grid; grid-template-columns: minmax(0,1fr) 280px; grid-template-rows: auto 1fr; gap: 16px; padding: 16px 20px 24px; height: auto; min-height: 0; overflow: visible; }
#codeView .code-workbar { grid-column: 1/-1; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }
.code-match-heading { display: grid; gap: 4px; min-width: 0; }
.code-match-heading strong { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-match-heading span { color: #aeb8c5; font-size: 13px; }
.code-workbar-actions { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
#codeView .panel-button, #codeView .primary-button { min-height: 36px; width: auto; margin: 0; border-radius: 7px; padding: 8px 12px; font-size: 14px; box-shadow: none; }
#codeView .stage-column { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; padding: 0; overflow: visible; }
#codeView .stage-guide { display: none; }
#codeView .video-shell { height: auto; min-height: 0; max-height: none; padding: 0; border-radius: 8px; background: #03060a; overflow: hidden; }
#codeView #stage { position: relative; width: 100%; height: auto; aspect-ratio: 16/9; min-height: 0; max-height: none; background: #03060a; }
#codeView #stage video, #codeView #stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#codeView .empty-state { position: absolute; inset: 0; padding: 20px; text-align: center; }
#codeView #stageUploadButton { display: inline-flex; width: auto; justify-content: center; margin: 12px auto 0; padding: 10px 18px; }
#codeView .transport { display: grid; grid-template-columns: 36px 40px 36px minmax(40px,1fr) 72px 94px; gap: 8px; padding: 8px 0; border: 0; background: transparent; border-radius: 0; }
#codeView .transport button { width: 100%; min-width: 0; height: 36px; min-height: 36px; border-radius: 6px; }
#codeView .transport input, #codeView .transport select, #codeView .transport output { grid-column: auto; min-width: 0; width: 100%; }
#codeView .transport output { font-size: 13px; font-variant-numeric: tabular-nums; }
.code-clock-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: #aeb8c5; font-size: 13px; }
#codeMatchClock { color: #f4f7fb; margin-left: 6px; font-variant-numeric: tabular-nums; }
#codeJumpForm { display: flex; align-items: center; gap: 6px; }
#codeJumpForm input { width: 82px; padding: 6px 8px; border-radius: 6px; }
#codeFeedback { min-height: 24px; color: #9ee9c6; font-size: 14px; }
#codeView .code-tray { display: block; padding: 12px 0 0; border: 0; border-top: 1px solid #293340; border-radius: 0; background: none; box-shadow: none; overflow: visible; }
#codeView .code-tray-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 0 10px; width: auto; }
#codeView .code-tray-head strong { font-size: 14px; }
#codeView .code-mode-toggle { margin: 0; font-size: 13px; }
#codeView .code-tray .code-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(145px,1fr)); grid-auto-flow: row; grid-auto-columns: auto; gap: 8px; overflow: visible; max-height: none; }
#codeView .code-tray .code-card { display: block; min-width: 0; border: 1px solid #344351; border-radius: 8px; box-shadow: none; }
#codeView .code-tray .code-button { position: relative; min-height: 86px; height: 100%; width: 100%; padding: 12px 30px 12px 12px; border-radius: 7px; text-align: left; align-items: start; color: #fff; background: #17222d !important; border-left: 4px solid var(--code-color); }
#codeView .code-button strong { font-size: 14px; line-height: 1.3; }
#codeView .code-button-state { font-size: 12px; color: #c2cbd4; font-weight: 500; }
#codeView .code-button-category { display: none; }
#codeView .code-edit-button { display: none; }
#codeView .code-button kbd { position: absolute; right: 8px; top: 10px; font-size: 12px; border: 1px solid #54606b; border-radius: 4px; padding: 1px 5px; color: #dce7ed; }
#codeView .code-card.timing { border-color: #ff9d8d; }
#codeView .code-card.timing .code-button { background: #442824 !important; box-shadow: inset 0 0 0 1px #ff9d8d; }
#codeView .code-card.timing .code-button-state { color: #ffb6a9; }
#codeView > .right-panel { position: static; display: block; width: auto; min-width: 0; height: auto; max-height: none; padding: 14px; border: 1px solid #293340; border-radius: 8px; transform: none; background: #0e151e; overflow: visible; }
#codeView .right-panel > .accent { display: none; }
#codeView .right-panel .panel-section { padding: 0; border: 0; background: none; box-shadow: none; border-radius: 0; }
#codeView .right-panel h2 { font-size: 14px; letter-spacing: 0; text-transform: none; margin: 0 0 12px; }
#codeView .event-list { max-height: 65vh; overflow-y: auto; }
#codeView .event-item { padding: 12px 0; background: none; border: 0; border-bottom: 1px solid #293340; border-radius: 0; gap: 6px; }
#codeView .event-head { display: grid; gap: 4px; }
#codeView .event-title { font-size: 14px; }
#codeView .event-meta { font-size: 12px; line-height: 1.5; }
#codeView .event-note-input { min-height: 38px; height: 38px; padding: 7px 9px; border-radius: 6px; font-size: 14px; resize: vertical; }
.code-event-actions { display: flex; gap: 8px; }
#codeView .mini-button { width: auto; min-height: 30px; font-size: 12px; border-radius: 5px; }
#codeView.code-focus { grid-template-columns: minmax(0,1fr); }
#codeView.code-focus > .right-panel { display: none; }
#codeSetup { width: min(620px,calc(100vw - 32px)); max-height: 88vh; padding: 20px; color: #f4f7fb; background: #121b26; border: 1px solid #41505f; border-radius: 12px; }
#codeSetup::backdrop { background: rgb(0 0 0 / 65%); }
#codeSetup header { display: flex; align-items: center; justify-content: space-between; }
#codeSetup header h2 { font-size: 20px; margin: 0; }
#codeSetup .left-panel { display: block; position: static; width: 100%; height: auto; max-height: none; padding: 0; transform: none; background: none; border: 0; overflow: visible; }
#codeSetup .panel-section { padding: 16px 0; border: 0; border-bottom: 1px solid #344351; border-radius: 0; background: none; }
#codeSetup .code-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#codeSetup label { display: grid; gap: 6px; font-size: 14px; }
#codeSetup .code-setup-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
#codeSetup .code-clock-setup { padding-top: 16px; }
#codeSetup p { font-size: 14px; color: #b6c2cd; line-height: 1.5; }
#codeSetup input { min-width: 0; width: 100%; }
#codeSetup input[type=color] { height: 36px; }
#codeSetup :focus-visible, #codeView :focus-visible { outline: 2px solid #9ee9c6; outline-offset: 3px; }
@media(max-width:1100px) {
  body[data-workspace="code"] .topbar { display: flex; flex-wrap: wrap; }
  body[data-workspace="code"] .topbar .tabs { flex: 1 1 360px; }
  #codeView.active { grid-template-columns: minmax(0,1fr) 240px; padding: 12px; }
  #codeView .code-workbar { flex-wrap: wrap; }
  .code-keyboard-hint { display: none; }
}
@media(max-width:760px) {
  #codeView.active { grid-template-columns: minmax(0,1fr); }
  #codeView .code-workbar-actions { flex-shrink: 1; }
  #codeView .code-tray-head { flex-wrap: wrap; }
  #codeView .transport { grid-template-columns: 32px 36px 32px minmax(40px,1fr) 64px; }
  #codeView .transport output { grid-column: 1/-1; text-align: right; }
  #codeView .code-tray .code-grid { grid-template-columns: repeat(auto-fit,minmax(135px,1fr)); }
  #codeView .event-list { max-height: none; }
  #codeSetup .code-form { grid-template-columns: 1fr; }
  body[data-workspace="code"] .topbar .tabs { flex-basis: 100%; order: 3; }
}

#codeSetup .left-panel::before, #codeSetup .left-panel::after { display: none; content: none; }
#codeView .code-tray-head { display: flex; }
#codeView > .right-panel .log-section > * { display: block; }
#codeView > .right-panel .log-section > .code-event-actions { display: flex; }
#codeView > .right-panel .log-section h2 { pointer-events: none; }
#codeView > .right-panel .log-section h2::after { display: none; }
#codeView .code-clock-row #codeJumpTime { color: #f4f7fb; background: #17222d; border: 1px solid #41505f; }
#codeSetup .panel-button[aria-pressed=true] { border-color: #9ee9c6; color: #9ee9c6; }
#codeView .code-button kbd:empty { display: none; }
body[data-workspace="code"] .app-shell { grid-template-rows: auto 1fr; overflow: visible; }
body[data-workspace="code"] .workspace { overflow: visible; }
body[data-workspace="code"] .topbar { height: auto; min-height: 66px; }
#codeView .stage-column { position: static; inset: auto; transform: none; width: 100%; max-width: none; grid-column: 1; grid-row: 2; }
#codeView > .right-panel { grid-column: 2; grid-row: 2; align-self: start; }
#codeView .code-workbar { grid-row: 1; }
@media(max-width:760px) { #codeView > .right-panel { grid-column: 1; grid-row: 3; } }
