:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  color: #213136;
  background: #eef1eb;
  line-height: 1.55;
  --line: #cbd4cb;
  --muted: #4f6259;
  --surface: #fdfdf8;
  --primary: #1b5540;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.layout { width: min(100% - 2rem, 72rem); margin: 2.75rem auto 4rem; }
.page-intro { margin-bottom: 1.75rem; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 5vw, 2.7rem); line-height: 1.2; letter-spacing: -.035em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.page-intro p, #source-status, #patch-summary, #work-summary { color: var(--muted); margin-top: .4rem; }
.panel { border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); padding: 1.25rem; }
.import-panel { margin-bottom: 1rem; }
.file-grid, .work-grid { display: grid; gap: 1rem; }
.file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: .8rem 0; }
label, .label-text, .list-title { font-size: .9rem; font-weight: 650; display: block; }
input[type=file] { display: block; width: 100%; margin-top: .3rem; }
button, input, textarea { color: inherit; font: inherit; }
button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .45rem;
  cursor: pointer;
  padding: .43rem .7rem;
}
button:hover:not(:disabled) { background: #e9efe5; border-color: #7e9383; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid #17634b; outline-offset: 3px; }
video { margin-top: .8rem; display: block; width: min(100%, 34rem); max-height: min(45vh, 22rem); background: #18201d; }
#message, #video-error { border-left: .22rem solid #4d7765; padding: .45rem .75rem; margin-bottom: 1rem; background: #f7faf6; }
#message[data-error=true], #video-error { border-color: #a24a37; color: #812a1b; }
#video-error { margin: .7rem 0 0; }
.work-header, .cue-header, .work-footer { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.mode-switch { display: flex; gap: .35rem; }
.mode-switch [aria-pressed=true], .primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.mode-switch [aria-pressed=true]:hover:not(:disabled), .primary:hover:not(:disabled) { background: #164633; color: #fff; }
#patch-controls { margin-top: .9rem; padding: .75rem; background: #f2f5ee; border-radius: .45rem; }
.work-grid { grid-template-columns: minmax(10rem, 1fr) minmax(0, 2fr); margin: 1rem 0; }
#cue-list { list-style: none; margin: .35rem 0 0; padding: .2rem; max-height: 26rem; overflow-y: auto; }
#cue-list li:not(:first-child) { margin-top: .3rem; }
.cue-button { display: block; width: 100%; text-align: left; overflow: hidden; padding: .45rem .55rem; }
.cue-button span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cue-button small { display: block; color: var(--muted); }
.cue-button[aria-current=true] { background: #e4eee5; border-color: #5b7c6a; }
.cue-detail { border: 1px solid var(--line); border-radius: .55rem; padding: .9rem; min-width: 0; }
.timestamp { color: var(--muted); font: .82rem / 1.5 ui-monospace, monospace; overflow-wrap: anywhere; }
.label-text { margin-top: .8rem; }
.quoted { white-space: pre-wrap; overflow-wrap: anywhere; padding: .5rem .65rem; background: #f2f5ee; border-radius: .35rem; margin: .25rem 0 .85rem; }
textarea { background: #fff; border: 1px solid var(--line); border-radius: .35rem; padding: .55rem; resize: vertical; width: 100%; margin: .35rem 0 .45rem; }
fieldset { margin: 0; min-width: 0; border: 1px solid var(--line); border-radius: .35rem; }
legend { font-weight: 650; padding: 0 .25rem; }
.choice { display: flex; align-items: flex-start; gap: .5rem; padding: .45rem .2rem; font-weight: 500; }
.choice input { margin-top: .37rem; }
.choice span { white-space: pre-wrap; overflow-wrap: anywhere; }
.conflict { color: #812a1b; margin-bottom: .35rem; font-size: .9rem; }
.work-footer { border-top: 1px solid var(--line); padding-top: .9rem; }

@media (max-width: 43rem) {
  .layout { margin: 1.35rem auto 2rem; }
  .file-grid, .work-grid { grid-template-columns: 1fr; }
  #cue-list { max-height: 13rem; }
}
