/* 레이아웃: 위에 제목과 주소 입력, 아래 왼쪽 주문서(라벨 | 입력 두 칸) + 오른쪽 미리보기·주문 요약. 주문 뒤에는 진행·완성 화면으로 바뀜
   배경: 옅은 페리윙클 바탕(--bg) 위에 흰 카드, 머리글은 흰 바탕 + 아래 선
   색: 페리윙클 #A3AEF0(선택), 버튼은 진한 페리윙클 #4F5BC0 + 흰 글씨. 글꼴은 IBM Plex Sans KR 하나, 숫자는 고정폭 숫자(tabular-nums) */
:root {
  --bg: #F7F8FE;
  --surface: #ffffff;
  --ink: #1b1d33;
  --muted: #575b73;
  --line: #e6e9f7;
  --line-2: #d5daf3;
  --field-line: #878fb3;  /* 입력칸·스위치 테두리(흰 바탕 대비 3:1 이상) */
  --select: #5f6bcc;      /* 선택 표시(밑줄·테두리) */
  --accent: #A3AEF0;
  --accent-soft: #F1F3FD;
  --accent-softer: #E5E9FB;
  --accent-strong: #7f8ce0;
  --on-accent: #232a63;
  --btn: #4F5BC0;
  --btn-hover: #434EAD;
  --on-btn: #ffffff;
  --accent-text: #3c4596;
  --link: #4a55b0;
  --warn: #c4242a;
  --live: #d93a3a;
  --sans: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); word-break: keep-all; -webkit-text-size-adjust: 100%; }
h1, h2 { margin: 0; letter-spacing: -0.03em; line-height: 1.3; text-wrap: balance; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent-strong) 60%, transparent); outline-offset: 2px; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1280px; margin: 0 auto; padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
@media (min-width: 720px) { .wrap { padding-left: 32px; padding-right: 32px; } }
.narrow { max-width: 820px; }
.mid { max-width: 1040px; }
a, .link { color: var(--link); }
.link { border: 0; background: none; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 머리글 ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { height: 64px; display: flex; align-items: center; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.brand b { font-size: 19px; letter-spacing: -0.02em; }
.brand span { font-size: 13px; color: var(--muted); }

/* ---------- 주문: 제목·주소 ---------- */
.intro { padding-block: 40px 32px; }
.intro h1 { font-size: clamp(22px, 2.4vw, 28px); font-weight: 700; }
.intro > .muted { margin-top: 14px; max-width: 640px; }
#urlBox { margin-top: 28px; }
/* 넓은 화면: 아래 주문서 카드와 같은 폭(오른쪽 미리보기 380px + 사이 32px을 뺀 폭). 미리보기가 아래로 내려가는 폭부터는 전체 폭 */
@media (min-width: 1036px) { #urlBox, .info { max-width: calc(100% - 412px); } }
.url { width: 100%; height: 52px; padding: 0 16px; border: 1.5px solid var(--accent-strong); border-radius: 8px; background: var(--surface); font-size: 16px; font-weight: 500; outline: none; }
.url:focus, .field input:focus, .field textarea:focus { border-color: var(--on-accent); }
.hint { margin-top: 12px; font-size: 14px; color: var(--muted); }
.info { margin-top: 28px; }
.info-card { margin-top: 14px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 18px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 14px; font-weight: 600; }
.field em { font-style: normal; font-weight: 500; font-size: 13px; color: var(--accent-text); margin-left: 4px; }
.field i { font-style: normal; font-weight: 400; font-size: 13px; color: var(--muted); margin-left: 4px; }
.field small, .note { font-size: 13px; color: var(--muted); }
.field input:not([type]), .field textarea, .feature-row input { width: 100%; padding: 8px 12px; border: 1px solid var(--field-line); border-radius: 8px; background: var(--surface); outline: none; }
.field textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.features { display: grid; gap: 8px; }
.feature-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr) 40px; gap: 8px; }
.x { border: 1px solid var(--field-line); background: var(--surface); border-radius: 8px; font-size: 20px; color: var(--muted); cursor: pointer; }
.x:disabled { opacity: .35; cursor: not-allowed; }
.color { grid-template-columns: auto auto 1fr; align-items: center; column-gap: 14px; }
.color > span { grid-column: 1 / -1; }
input[type="color"] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--field-line); border-radius: 8px; background: var(--surface); }
input[type="color"]:disabled { opacity: .35; }

/* ---------- 주문: 설정 시트 + 오른쪽 ---------- */
.work { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; padding-bottom: 80px; }
.sheet { flex: 999 1 560px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 32px 20px; }
.row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 24px; padding: 22px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.lab { font-size: 15px; font-weight: 600; padding-top: 8px; }
.lab small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 4px; }

.seg { display: flex; flex-wrap: wrap; width: max-content; max-width: 100%; border: 1px solid var(--field-line); border-radius: 8px; overflow: hidden; }
.seg button { position: relative; border: 0; border-right: 1px solid var(--line-2); background: var(--surface); padding: 8px 16px; font-size: 15px; text-align: left; cursor: pointer; min-height: 40px; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--accent-soft); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.seg button[aria-pressed="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--select); }
.tc { display: block; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg small { display: block; font-size: 13px; opacity: .85; }

.ratios { display: flex; flex-wrap: wrap; gap: 12px; }
.ratio { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-align: left; cursor: pointer; }
.ratio span { display: grid; }
.ratio b { font-size: 15px; }
.ratio small { font-size: 13px; color: var(--muted); }
.ratio[aria-pressed="true"] { border: 1.5px solid var(--select); background: var(--accent-soft); }
.ratio[aria-pressed="true"] b { color: var(--accent-text); }
.shape { display: block; border: 1.5px solid var(--accent-strong); border-radius: 3px; }
.shape.wide { width: 48px; height: 27px; }
.shape.tall { width: 20px; height: 36px; }
.ratio[aria-pressed="true"] .shape { background: var(--accent-softer); }

.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opt { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 15px; cursor: pointer; min-height: 40px; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.box { width: 18px; height: 18px; flex: none; display: grid; place-items: center; border: 1.5px solid var(--accent-strong); border-radius: 4px; }
.box svg { opacity: 0; }
.opt:has(input:checked) { border-color: var(--select); background: var(--accent-soft); }
.opt:has(input:checked) .box { background: var(--accent); border-color: var(--accent); }
.opt:has(input:checked) .box svg { opacity: 1; }
.opt:has(input:disabled) { color: #9a9db0; border-color: #eef0f7; cursor: not-allowed; }
.opt:has(input:disabled) .box { border-color: #d6d9e8; }
.opt:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent-strong) 60%, transparent); outline-offset: 2px; }
.opts + .note { margin-top: 10px; }

.switch { display: flex; align-items: flex-start; gap: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { flex: none; width: 44px; height: 26px; margin-top: 2px; border-radius: 13px; background: var(--field-line); position: relative; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid color-mix(in srgb, var(--accent-strong) 60%, transparent); outline-offset: 2px; }
.switch > span:last-child { display: grid; }
.switch b { font-size: 15px; font-weight: 600; }
.switch small { font-size: 13px; color: var(--muted); }

.drop { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 11px 14px; border: 1px dashed var(--field-line); border-radius: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop.on { border-style: solid; border-color: var(--select); background: var(--accent-soft); color: var(--ink); }
.pick { font-weight: 600; color: var(--link); border-bottom: 1px solid var(--accent); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--accent-strong); }

.err { margin-top: 6px; font-size: 13px; color: var(--warn); }
.err.banner { margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: #fdf0ee; white-space: pre-line; }
.invalid { border-color: var(--warn) !important; }

/* 오른쪽: 미리보기 · 주문 요약 */
.side { flex: 1 1 380px; min-width: 0; max-width: 460px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; }
.panel-head .mono { font-size: 13px; }
.monitor { position: relative; margin-top: 14px; aspect-ratio: 16 / 9; display: flex; flex-direction: column; justify-content: flex-end; padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--accent-soft); overflow: hidden; transition: aspect-ratio .3s; }
.monitor.tall { aspect-ratio: 9 / 16; width: 56%; margin-inline: auto; }
.pv-site { position: absolute; top: 12px; left: 14px; font-size: 12px; color: var(--muted); max-width: calc(100% - 28px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-bar { width: 36px; height: 4px; background: var(--accent); }
.pv-title { margin-top: 10px; font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.monitor + .note { margin-top: 10px; }
.cuts { display: flex; gap: 2px; height: 26px; margin-top: 16px; }
.cuts span { background: var(--accent-softer); }
.cuts span:first-child, .cuts span:last-child { background: var(--accent); }
.ruler { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); }
.ruler + .note { margin-top: 8px; }
.order-sum { display: flex; flex-direction: column; gap: 16px; }
.dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 16px; margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 14px; border-top: 1px solid var(--line); }
.total b { font-size: 26px; }
.primary { display: inline-flex; justify-content: center; align-items: center; gap: 10px; padding: 12px 20px; border: 0; border-radius: 8px; background: var(--btn); color: var(--on-btn); font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer; transition: filter .15s, transform .1s; }
.primary:hover { background: var(--btn-hover); }
.primary:active { transform: scale(.98); }
.primary:disabled { opacity: .6; cursor: progress; }
.ghost { display: inline-flex; justify-content: center; align-items: center; padding: 11px 18px; border: 1px solid var(--accent-strong); border-radius: 8px; background: var(--surface); color: var(--accent-text); font-weight: 600; text-decoration: none; cursor: pointer; }
.ghost:hover { background: var(--accent-soft); }
.ghost.small { justify-self: start; padding: 9px 14px; font-size: 14px; }
.fine { font-size: 13px; color: var(--muted); }

/* ---------- 진행 ---------- */
#progress, #result, #failed { padding-block: 40px 64px; }
/* 진행·완성·실패: 왼쪽 본문 + 오른쪽 주문 내용(주문 화면과 같은 왼쪽·오른쪽 끝선) */
.job { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 40px; align-items: start; }
.job:has(> aside[hidden]) { grid-template-columns: minmax(0, 1fr); }
.job-side { display: grid; gap: 16px; position: sticky; top: 20px; }
.job-side .actions { margin-top: 0; display: grid; }
.job-side .changes { margin-top: 0; padding-top: 16px; }
.live { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
.prog-head { margin-top: 14px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.prog-head h1 { font-size: clamp(22px, 2.4vw, 28px); }
.clock { text-align: right; display: grid; }
.clock b { font-size: 36px; line-height: 1; font-weight: 600; }
.clock span { font-size: 13px; }
.track4 { position: relative; display: flex; gap: 3px; height: 34px; margin-top: 32px; }
.track4 span { background: var(--accent-softer); overflow: hidden; }
.track4 i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .6s ease; }
.track4 .head { position: absolute; top: -6px; bottom: -6px; left: 0; width: 2px; background: var(--on-accent); transition: left .6s ease; }
.track4-labels { display: flex; gap: 3px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.steps { list-style: none; margin: 36px 0 20px; padding: 4px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.steps li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); font-size: 15px; color: var(--muted); }
.steps li:first-child { border-top: 0; }
.steps .t { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.steps .s { font-size: 13px; }
.steps li.done { color: var(--ink); }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps li.now .s { padding: 2px 10px; border-radius: 999px; background: var(--accent-softer); color: var(--accent-text); }
.small-text { font-size: 14px; }

/* ---------- 완성 ---------- */
#result h1, #failed h1 { margin-top: 8px; font-size: clamp(22px, 2.4vw, 28px); }
.player { margin-top: 24px; border-radius: 8px; overflow: hidden; background: var(--accent-soft); border: 1px solid var(--line); }
.player video { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 75vh; background: #000; } /* 영상이 오기 전에도 자리 확보 */
.player.tall video { aspect-ratio: 9 / 16; }
.player.tall { max-width: 420px; margin-inline: auto; }
.spec { margin-top: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.spec div { padding: 14px 18px; border-left: 1px solid var(--line); min-width: 0; }
.spec div:first-child { border-left: 0; }
.spec span { display: block; font-size: 13px; color: var(--muted); }
.spec b { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.actions { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px; }
.changes { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.changes h2 { font-size: 16px; font-weight: 600; letter-spacing: 0; }
.changes ul { margin: 10px 0 0; padding-left: 18px; font-size: 14px; color: var(--muted); display: grid; gap: 4px; }

/* ---------- 실패 ---------- */
.warn { font-size: 14px; font-weight: 600; color: var(--warn); }
.lead { margin-top: 14px; font-size: 17px; max-width: 40em; }
#failed .muted { margin-top: 8px; font-size: 14px; }

/* ---------- 결제 확인 창 ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(35, 42, 99, .22); }
.modal-box { width: min(440px, 100%); display: flex; flex-direction: column; gap: 18px; padding: 28px; border-radius: 10px; background: var(--surface); } /* 그림자 없이 뒤 배경을 어둡게 해서 구분 */
.modal-box h2 { font-size: 22px; font-weight: 700; }
.modal-box h2 + .muted { margin-top: 6px; font-size: 14px; }
.receipt { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px 0; }
.receipt div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; font-size: 14px; }
.receipt span:first-child { color: var(--muted); flex: none; }
.receipt span:last-child { text-align: right; font-weight: 500; overflow-wrap: anywhere; }
.modal .total { border-top: 0; padding-top: 0; }
.modal .total span { font-weight: 600; }
.modal .total b { font-size: 28px; }
.modal-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* 모바일 아래 고정 막대(주문 화면에서만) */
.mbar { display: none; }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 920px) {
  .job { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .job-side { position: static; }
  .side { position: static; max-width: none; }
  .order-sum .primary { display: none; } /* 결제는 아래 고정 막대에서 */
  #order { padding-bottom: 96px; }
  .mbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; align-items: center; gap: 14px; padding: 12px max(20px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: var(--surface); border-top: 1px solid var(--line); }
  .mbar > div { display: grid; flex: none; }
  .mbar span { font-size: 13px; }
  .mbar b { font-size: 19px; }
  .mbar .primary { flex: 1; padding: 11px; font-size: 15px; }
  .mbar.off { display: none; }
}
@media (max-width: 640px) {
  .sheet { padding: 4px 18px 16px; }
  .intro { padding-block: 28px 24px; }
  .row { grid-template-columns: 1fr; gap: 8px; padding: 16px 0; }
  .url { height: 48px; }
  .lab { padding-top: 0; }
  .seg { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .seg button { padding: 7px 6px; text-align: center; }
  .ratios { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ratio { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 12px; }
  .opts, .grid2 { grid-template-columns: 1fr; }
  .feature-row { grid-template-columns: minmax(0, 1fr) 40px; }
  .feature-row .f-text { grid-column: 1; }
  .feature-row .x { grid-row: 1 / span 2; grid-column: 2; }
  .info-card { padding: 18px; }
  .spec { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec div:nth-child(3) { border-left: 0; }
  .spec div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .clock { text-align: left; }
  .steps { padding: 4px 16px; }
  .steps li { grid-template-columns: 52px minmax(0, 1fr); }
  /* 휴대폰 글자: 한 단계 작게(입력칸은 아이폰 자동 확대를 막으려고 16px 유지) */
  .intro h1, .prog-head h1, #result h1, #failed h1 { font-size: 20px; }
  .intro > .muted, .lead { font-size: 15px; }
  .lab, .seg button, .opt, .ratio b, .switch b, .panel-head, .steps li { font-size: 14px; }
  .tc { font-size: 15px; }
  .hint, .check, .dl, .drop { font-size: 13px; }
  .url, .field input, .field textarea, .feature-row input { font-size: 16px; }
  .steps .s { grid-column: 2; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) {
  .track4 i, .track4 .head, .monitor, .switch .track, .switch .track::after { transition: none; }
}
