/* 칠판은 곧 영상 화면이다. 자막 띠가 안내를 말하고, 분필 받침이 조작부다. 빨간 펜은 "아직 영상에 없는 수정"에만 쓴다. */
:root {
  color-scheme: light;
  --board: #22443b; --board-lit: #2c564a; --board-deep: #17312a; --band: #0c1b17;
  --chalk: #f4f6f0; --chalk-dim: #b7cbc1; --yellow: #f5d76e; --coral: #f0a08c;
  --desk: #edf1ee; --metal: #c5cec9; --sheet: #fff; --ink: #14231e; --soft: #55675f; --rule: #d3dcd7; --pen: #0f6a5d; --red: #c8402f;
  --sans: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--desk); color: var(--ink); font: 16px/1.6 var(--sans); word-break: keep-all; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary, label.check { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; }
.board :focus-visible, .job :focus-visible, .toast :focus-visible { outline-color: var(--yellow); }
a { color: var(--pen); }
h2 { font-size: 20px; line-height: 1.35; margin: 0 0 12px; letter-spacing: -.02em; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; z-index: 20; }
.skip:focus { top: 12px; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 14px var(--gutter); max-width: 1480px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.03em; color: var(--ink); text-decoration: none; }
.link { background: none; border: 0; padding: 8px 2px; color: var(--soft); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.link:hover { color: var(--ink); }

/* ---------- 칠판 ---------- */
.home { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); }
.board { position: relative; display: grid; grid-template-rows: 1fr auto; min-height: min(62vh, 600px); color: var(--chalk); border: 11px solid var(--metal); border-radius: 8px 8px 0 0; overflow: hidden;
  background:
    linear-gradient(101deg, transparent 18%, rgba(255,255,255,.035) 26%, transparent 37%, transparent 58%, rgba(255,255,255,.03) 66%, transparent 78%),
    radial-gradient(110% 95% at 28% 18%, var(--board-lit) 0, var(--board) 52%, var(--board-deep) 100%);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.35), inset 0 0 60px rgba(0,0,0,.25); transition: filter .2s; }
.board.over { filter: brightness(1.22); }
.board.over::after { content: ""; position: absolute; inset: 14px 14px 84px; border: 3px dashed var(--yellow); border-radius: 8px; pointer-events: none; }
.board-in { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: center; gap: 16px; padding: 28px clamp(20px, 5vw, 72px); }
.board h1 { font: 700 clamp(44px, 5.3vw, 76px)/1.14 "Gaegu", var(--sans); margin: 0; letter-spacing: -.01em; }
.chalk-line { display: block; white-space: nowrap; }
.underline { display: block; width: min(430px, 86%); height: auto; margin: 2px 0 30px; overflow: visible; }
.underline path, .doodle path { fill: none; stroke: var(--chalk); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.underline path { stroke: var(--yellow); stroke-width: 6; }
.doodle { width: 100%; max-width: 470px; justify-self: end; height: auto; opacity: .95; }
.doodle .d2 path, .doodle .d5 path { stroke: var(--coral); }
.doodle .d4 path { stroke: var(--yellow); fill: rgba(245,215,110,.16); }
.board-act { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.chalk { background: var(--yellow); color: #1b2a24; border: 0; border-radius: 6px; padding: 14px 32px; font-size: 18px; font-weight: 700; }
.chalk:hover:not(:disabled) { background: #ffe68a; }
a.chalk { text-decoration: none; display: inline-block; }
.lost { margin-top: 28px; }
.board-hint { color: var(--chalk-dim); }
.band { margin: 0; min-height: 70px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px 24px; background: var(--band); font-size: clamp(16px, 1.7vw, 21px); font-weight: 500; line-height: 1.45; }
.band.bad { color: #ffc2b4; }
.board-line { position: absolute; left: 0; bottom: 0; height: 5px; width: 0; background: var(--yellow); transition: width .2s; }

.tray { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; padding: 11px 20px; background: linear-gradient(#e2e8e4, #cbd4cf); border: 1px solid #b4bfb9; border-top: 0; border-radius: 0 0 8px 8px; box-shadow: 0 12px 24px -16px rgba(20,40,33,.5); }
.sticks { display: flex; gap: 8px; }
.sticks i { display: block; width: 46px; height: 9px; border-radius: 5px; background: #fbfcf9; box-shadow: inset 0 -2px 2px rgba(0,0,0,.12); }
.sticks i:nth-child(2) { width: 30px; background: var(--yellow); }
.sticks i:nth-child(3) { width: 38px; background: var(--coral); }
.tray .check { flex: 1; }
.check { display: inline-flex; gap: 9px; align-items: center; min-height: 32px; }
.check input { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--pen); }
.model-note { margin: 12px 2px 0; color: var(--soft); font-size: 15px; }
.model-note.warn { color: var(--red); font-weight: 600; }

/* ---------- 소개 ---------- */
.show { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: start; padding: 56px 0 20px; }
.demo { margin: 0; }
.demo video { width: 100%; aspect-ratio: 16/9; display: block; background: var(--board-deep); border-radius: 6px; }
.demo figcaption { margin-top: 10px; color: var(--soft); font-size: 15px; }
.what dl { margin: 0; }
.what dl > div { padding: 10px 0; border-top: 1px solid var(--rule); }
.what dt { font-weight: 700; }
.what dd { margin: 0; color: var(--soft); font-size: 15px; }
.promise { margin: 12px 0 0; padding-top: 12px; border-top: 2px solid var(--ink); font-weight: 600; }

/* ---------- 작업 화면 ---------- */
.work { display: grid; grid-template: "stage side" auto "sheet side" 1fr / minmax(0, 1fr) 300px; gap: 24px 32px; max-width: 1480px; margin: 0 auto; padding: 0 var(--gutter) 130px; align-items: start; }
.stage { grid-area: stage; }
.side { grid-area: side; position: sticky; top: 16px; }
.sheet { grid-area: sheet; }
.screen { position: relative; background: var(--band); border: 9px solid var(--metal); border-radius: 8px 8px 0 0; }
.screen canvas, .screen video { display: block; width: 100%; aspect-ratio: 16/9; max-height: 72vh; object-fit: contain; background: var(--band); }
.screen.played canvas { display: none; }
.back { position: absolute; right: 12px; top: 12px; }
.stage-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 12px 16px; background: linear-gradient(#e2e8e4, #cbd4cf); border: 1px solid #b4bfb9; border-top: 0; border-radius: 0 0 8px 8px; }
.go { background: var(--board); color: var(--chalk); border: 0; border-radius: 6px; padding: 12px 26px; font-size: 17px; font-weight: 700; text-decoration: none; display: inline-block; line-height: 1.4; }
.go:hover:not(:disabled) { background: var(--board-lit); }
.go.small { padding: 9px 20px; font-size: 16px; }
.go.second { background: none; color: var(--ink); box-shadow: inset 0 0 0 2px var(--board); padding: 12px 20px; }
.go.second:hover:not(:disabled) { background: rgba(34,68,59,.1); }
.est { margin: 0; color: var(--ink); font-size: 15px; }
#doneAct { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#doneAct:empty { display: none; }
#doneAct span { font-size: 14px; color: var(--soft); }
.reset { margin-left: auto; }
.stale { margin: 10px 2px 0; color: var(--red); font-weight: 600; }

.side { background: none; }
.side > summary { display: none; font-weight: 700; padding: 12px 2px; }
fieldset { border: 0; border-top: 2px solid var(--ink); margin: 0 0 22px; padding: 10px 0 0; min-width: 0; }
legend { float: left; width: 100%; font-weight: 700; margin-bottom: 10px; padding: 0; }
legend + * { clear: both; }
.sub { background: var(--sheet); border: 1px solid #b9c5bf; border-radius: 6px; padding: 8px 14px; font-size: 15px; white-space: nowrap; text-decoration: none; color: var(--ink); line-height: 1.4; }
.sub:hover:not(:disabled) { border-color: var(--soft); background: #fbfdfb; }
.pair { display: flex; gap: 8px; }
select { flex: 1; min-width: 0; background: var(--sheet); border: 1px solid #b9c5bf; border-radius: 6px; padding: 8px 9px; font-size: 15px; }
.range { display: block; margin-top: 12px; font-size: 15px; }
.range span { display: flex; justify-content: space-between; }
.range output { color: var(--soft); }
.range input { width: 100%; accent-color: var(--pen); }
.side .check { margin-top: 10px; font-size: 15px; }
.way { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--rule); padding: 9px 2px; line-height: 1.45; }
.way:last-child { border-bottom: 0; }
.way b { font-weight: 600; }
.way small { display: block; color: var(--soft); font-size: 14px; }
.way:hover b { color: var(--pen); text-decoration: underline; text-underline-offset: 4px; }

/* ---------- 콘티 ---------- */
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px; }
.sheet-head { display: flex; align-items: center; gap: 16px; padding: 14px 20px 10px; }
.sheet-head input { flex: 1; min-width: 0; border: 0; border-bottom: 2px solid transparent; border-radius: 0; font-size: 23px; font-weight: 800; letter-spacing: -.03em; padding: 2px 0; background: none; }
.sheet-head input:hover { border-color: var(--rule); }
.sheet-head input:focus { outline: 0; border-color: var(--pen); }
.sheet-total { color: var(--soft); font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet-cols, .row { display: grid; grid-template-columns: 64px minmax(200px, 320px) minmax(0, 1fr); }
.sheet-cols { border-block: 2px solid var(--ink); font-size: 14px; font-weight: 600; }
.sheet-cols span { padding: 5px 16px; }
.sheet-cols span:first-child { padding: 5px 0; text-align: center; }
.sheet-cols span + span { border-left: 1px solid var(--rule); }
.rows { list-style: none; margin: 0; padding: 0; }
.row { border-bottom: 1px solid var(--rule); content-visibility: auto; contain-intrinsic-size: auto 220px; position: relative; }
.row:last-child { border-bottom: 0; }
.row > * { padding: 16px; }
.row.off .cut { opacity: .5; }
.row.late::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; padding: 0; background: var(--red); }
.row.now { background: #f3f8f4; }
.tc { font-size: 14px; color: var(--soft); font-variant-numeric: tabular-nums; display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 16px 4px; }
.tc label { display: grid; place-items: center; width: 40px; height: 36px; }
.tc input { width: 19px; height: 19px; margin: 0; accent-color: var(--pen); }
.cut { border-inline: 1px solid var(--rule); margin: 0; min-width: 0; }
.cut button { display: block; width: 100%; padding: 0; border: 1px solid var(--rule); background: var(--desk); border-radius: 2px; overflow: hidden; }
.cut button:hover { border-color: var(--pen); }
.cut canvas { width: 100%; aspect-ratio: 16/9; display: block; }
.cut figcaption { margin-top: 6px; font-size: 14px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lines { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.line-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; font-size: 14px; color: var(--soft); min-height: 32px; }
.play { border: 0; background: none; color: var(--pen); font-size: 14px; font-weight: 600; padding: 6px 8px; margin-right: -8px; }
.play:hover { text-decoration: underline; text-underline-offset: 3px; }
.lines textarea { width: 100%; border: 0; border-bottom: 1px dashed #b9c5bf; border-radius: 0; padding: 2px 0 8px; resize: none; line-height: 1.75; background: none; overflow: hidden; field-sizing: content; min-height: 3.4em; }
.lines textarea:hover { border-bottom-color: var(--soft); }
.lines textarea:focus { outline: 0; border-bottom: 2px solid var(--pen); padding-bottom: 7px; }
.note { padding: 12px 20px; background: #fdf6da; border-bottom: 1px solid #eadfae; font-size: 15px; }

/* ---------- 진행 / 알림 ---------- */
.job { position: fixed; inset: auto 0 0 0; background: var(--band); color: #fff; z-index: 10; }
.job-in { display: flex; gap: 14px; align-items: center; padding: 11px var(--gutter); max-width: 1480px; margin: 0 auto; }
.job-in b { white-space: nowrap; }
.job-in span { flex: 1; color: #b9cdc3; font-size: 15px; font-variant-numeric: tabular-nums; }
.job .sub { background: none; border-color: #52665e; color: #fff; }
.job .sub:hover { background: #1c342c; }
.job.bad { background: #5a211b; }
.job.bad .job-in span { color: #ffd9d0; }
.bar { height: 5px; background: #2a403a; }
.bar i { display: block; height: 100%; width: 0; background: var(--yellow); transition: width .25s; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; gap: 16px; align-items: center; max-width: min(640px, calc(100vw - 32px)); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 8px; z-index: 12; box-shadow: 0 10px 30px rgba(10,24,18,.35); }
.toast .link { color: var(--yellow); white-space: nowrap; padding: 4px 0; }

dialog { border: 0; border-radius: 10px; padding: 26px 28px; width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); color: var(--ink); box-shadow: 0 24px 70px rgba(10,24,18,.4); }
dialog::backdrop { background: rgba(12,27,23,.55); }
dialog p { margin: 0 0 12px; }
dialog textarea, dialog input[type=password] { width: 100%; border: 1px solid #b9c5bf; border-radius: 6px; padding: 9px 11px; }
dialog table { width: 100%; border-collapse: collapse; margin: 0 0 14px; }
dialog th { text-align: left; width: 92px; vertical-align: top; padding: 8px 10px 8px 0; border-top: 1px solid var(--rule); }
dialog td { padding: 8px 0; border-top: 1px solid var(--rule); }
.steps { padding-left: 20px; margin: 0; }
.steps li { margin-bottom: 14px; }
.steps p { margin-bottom: 8px; }
.dlg-act { display: flex; justify-content: flex-end; gap: 14px; align-items: center; margin-top: 14px; }
.err { color: var(--red); min-height: 1.4em; }

footer { max-width: 1240px; margin: 0 auto; padding: 34px var(--gutter) 48px; color: var(--soft); font-size: 14px; }
footer p { margin: 0 0 6px; max-width: 92ch; }

/* ---------- 첫 화면이 그려지는 순간 ---------- */
@media (prefers-reduced-motion: no-preference) {
  .chalk-line { animation: write .75s cubic-bezier(.5,.1,.4,1) both; }
  .chalk-line + .chalk-line { animation-delay: .55s; }
  .underline path, .doodle path { stroke-dasharray: 1000; animation: draw 1.1s ease-in-out both; }
  .underline path { animation-delay: 1.15s; animation-duration: .7s; }
  .doodle .d1 path { animation-delay: .5s; } .doodle .d2 path { animation-delay: 1s; } .doodle .d3 path { animation-delay: 1.25s; } .doodle .d4 path { animation-delay: 1.7s; } .doodle .d5 path { animation-delay: 2s; }
  @keyframes write { from { clip-path: inset(-10% 100% -10% 0); } to { clip-path: inset(-10% -60% -10% 0); } }
  @keyframes draw { from { stroke-dashoffset: 1000; } to { stroke-dashoffset: 0; } }
}

@media (max-width: 1100px) {
  .work { grid-template-columns: minmax(0, 1fr) 260px; gap: 20px 24px; }
  .sheet-cols { display: none; }
  .sheet-head { border-bottom: 2px solid var(--ink); }
  .row { grid-template-columns: 56px minmax(0, 1fr); }
  .tc { grid-row: span 2; border-right: 1px solid var(--rule); }
  .cut { border: 0; padding-bottom: 0; max-width: 420px; }
}
@media (max-width: 820px) {
  .board-in { grid-template-columns: minmax(0, 1fr); padding: 34px 22px 26px; }
  .doodle { display: none; }
  .board { min-height: 0; border-width: 8px; }
  .board h1 { font-size: clamp(32px, 9.4vw, 64px); }
  .underline { margin-bottom: 24px; }
  .board-hint { display: none; }
  .chalk { width: 100%; }
  .sticks { display: none; }
  .tray { padding: 10px 14px; }
  .tray .sub { width: 100%; }
  .show { grid-template-columns: minmax(0, 1fr); padding-top: 36px; }
  .work { grid-template: "stage" auto "side" auto "sheet" auto / minmax(0, 1fr); gap: 16px; }
  .side { position: static; background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px; padding: 0 16px; }
  .side > summary { display: list-item; }
  .side-in { padding: 8px 0; }
  .stage-bar .go { flex: 1 1 100%; text-align: center; }
  .reset { margin-left: 0; }
  .sheet-head { flex-wrap: wrap; gap: 2px 16px; padding: 12px 14px 8px; }
  .sheet-head input { flex-basis: 100%; }
  .row > * { padding: 12px; }
  .row { grid-template-columns: 46px minmax(0, 1fr); }
  .tc { padding: 12px 2px; }
  .job-in { flex-wrap: wrap; gap: 2px 12px; }
  .job-in span { order: 3; flex-basis: 100%; }
  .job-in b { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (forced-colors: active) { .chalk, .go, .sub { border: 1px solid ButtonText; } }
/* 뺀 장면은 자리만 작게 남긴다 */
.row.off .lines { display: none; }
.row.off .cut { grid-column: 2 / -1; display: flex; align-items: center; gap: 14px; border-inline-end: 0; max-width: none; padding-block: 10px; }
.row.off .cut button { width: 112px; flex: none; }
.row.off .cut figcaption { margin: 0; }
.row.off .tc { padding-block: 10px; gap: 0; }
