/* Design tokens shared with the hub homepage (roquen4145.com): warm paper palette, one red-orange accent,
   system Korean-friendly font stack, 10px card radius, 1px hairline borders, 2px ink rules for section heads. */
:root {
  --bg: #f6f3ee; --card: #fffdf9; --fg: #1f1c18; --muted: #6b645b; --line: #ddd6ca; --line-soft: #ebe5da;
  --accent: #c8442b; --accent-fg: #ffffff; --accent-soft: #f8e9e3;
  --field: #f6f3ee; --focus: #1a5fd0;
  --warn-bg: #f7edcf; --warn-fg: #6d5410; --warn-line: #d3b55a;
  --err-bg: #f9e3dd; --err-fg: #8f2a17; --info-bg: #efeae1; --info-fg: #3d3830;
  --shadow: none;
  --r-card: 10px; --r-ctl: 8px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412; --card: #1f1c19; --fg: #efeae2; --muted: #a39b8f; --line: #35302a; --line-soft: #2a2622;
    --accent: #e8664c; --accent-fg: #1a0e0a; --accent-soft: #2e1d18;
    --field: #161412; --focus: #7aa8ff;
    --warn-bg: #332a10; --warn-fg: #e8cf84; --warn-line: #7a6320;
    --err-bg: #3a1c15; --err-fg: #ffb4a3; --info-bg: #26221e; --info-fg: #d6cfc4;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  word-break: keep-all; overflow-wrap: break-word; overflow-x: hidden; }
main { max-width: 56rem; margin: 0 auto;
  padding: max(var(--s4), env(safe-area-inset-top)) max(var(--s4), env(safe-area-inset-right)) max(var(--s5), env(safe-area-inset-bottom)) max(var(--s4), env(safe-area-inset-left)); }
.layout, .col { display: block; }
.col > * + * { margin-top: var(--s3); }

/* type */
h1 { font-size: clamp(1.75rem, 6vw, 2.6rem); line-height: 1.2; letter-spacing: -.02em; margin: 0 0 var(--s3); font-weight: 800; }
a.btn.back { margin: var(--s2) 0 var(--s5); font-size: .9375rem; font-weight: 600; background: transparent; color: var(--fg); border-color: var(--fg); padding: 0 var(--s4); }
a.btn.back:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
h2 { font-size: 1rem; margin: 0; }
.sub { color: var(--muted); font-size: .9rem; margin: 0 0 var(--s3); max-width: 60ch; }
.muted { color: var(--muted); font-size: .9rem; margin: var(--s1) 0; }
.small { font-size: .8125rem; }
code { font-family: var(--mono); font-size: .9em; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.top { padding: clamp(var(--s2), 4vw, var(--s5)) 0 var(--s4); }

/* cards + step headings */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s4); box-shadow: var(--shadow); }
.card[hidden], .optional[hidden] { display: none; }
h2.step { display: flex; align-items: center; gap: var(--s2); font-size: .85rem; font-weight: 600; letter-spacing: .06em; color: var(--muted); margin-bottom: var(--s3); padding-top: var(--s3); border-top: 2px solid var(--fg); }
.num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; font-family: var(--mono);
  background: var(--accent); color: var(--accent-fg); font-size: .8125rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* file picker */
.filebtn { display: flex; align-items: center; justify-content: center; min-height: 72px; padding: var(--s4); text-align: center;
  border: 2px dashed var(--accent); background: var(--accent-soft); color: var(--accent);
  border-radius: var(--r-ctl); font-weight: 700; font-size: 1.0625rem; cursor: pointer; }
.filebtn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.filebtn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.fileinfo { margin: var(--s3) 0 0; font-weight: 600; font-size: .875rem; overflow-wrap: anywhere; }
.fileinfo:empty { display: none; }
body.has-file #fileHint { display: none; }
body.has-file .filebtn { min-height: 48px; font-size: .9375rem; border-width: 1.5px; }
#fileHint { margin-top: var(--s3); }

/* preview */
.stage { position: relative; background: #000; border-radius: var(--r-ctl); overflow: hidden; line-height: 0; }
.stage video { width: 100%; max-height: 60vh; display: block; background: #000; }
.stage canvas { position: absolute; pointer-events: none; }
.pbar { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s2); }
.pbar button { min-height: 44px; min-width: 72px; }
.pbar input[type=range] { flex: 1; width: auto; }
.pbar span { min-width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; margin: 0; }
.capture-row { display: flex; gap: var(--s3); align-items: center; margin-top: var(--s3); }
.capture-row #capBtn { flex: 1 1 auto; white-space: nowrap; padding: 0 var(--s3); font-size: .9375rem; }
.capfmt { display: flex; align-items: center; gap: var(--s2); font-size: .8125rem; color: var(--muted); flex: none; }
.capfmt select { width: 5.5rem; min-height: 44px; padding: 0 var(--s2); font-size: .8125rem; }
.capresult img { display: block; width: 100%; max-height: 60vh; object-fit: contain; border-radius: var(--r-ctl); background: #000; margin-top: var(--s3); -webkit-touch-callout: default; }

/* start time: quiet when detected, loud when not */
.startbox { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--line-soft); }
.startrow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3); min-height: 44px; }
.startrow-k { color: var(--muted); font-size: .875rem; }
.startrow time { font-size: 1rem; font-weight: 600; letter-spacing: .01em; }
.startrow-tag { color: var(--muted); font-size: .8125rem; flex: 1 1 auto; }
.small-btn { min-height: 44px; min-width: 56px; padding: 0 var(--s4); font-size: .875rem; margin-left: auto; }
.startedit { margin-top: var(--s2); }
.startedit[data-need="true"] { margin-top: 0; padding: var(--s3); border: 1.5px solid var(--warn-line); background: var(--warn-bg); color: var(--warn-fg); border-radius: var(--r-ctl); }
.startedit[data-need="true"] .muted, .startedit[data-need="true"] .tznote { color: var(--warn-fg); }
.startedit-label { display: block; font-weight: 700; font-size: .9375rem; margin-bottom: var(--s2); }
.startedit[data-need="false"] .startedit-label { font-weight: 600; font-size: .8125rem; color: var(--muted); }
.startedit input[type=datetime-local] { font-family: var(--mono); font-size: 1rem; min-height: 48px; }
.tznote { font-size: .8125rem; color: var(--muted); margin: var(--s2) 0 0; }

/* controls */
input[type=datetime-local], select { width: 100%; font: inherit; padding: 10px var(--s3); border-radius: var(--r-ctl);
  border: 1px solid var(--line); background: var(--field); color: var(--fg); }
select { min-height: 44px; }
button, .btn { font: inherit; border-radius: var(--r-ctl); border: 1px solid var(--line); padding: 0 var(--s4); min-height: 44px; background: var(--card);
  color: var(--fg); cursor: pointer; text-decoration: none; text-align: center; display: inline-flex; align-items: center; justify-content: center; }
button.secondary { background: transparent; border-color: var(--line); font-weight: 600; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 700; }
button[aria-pressed="true"], button.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 700; }
button:disabled { opacity: .5; cursor: default; }
button.link { border: 0; background: none; color: var(--accent); padding: 0 var(--s2); font-weight: 600; }
button:focus-visible, .btn:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px; }
.row { display: flex; gap: var(--s3); margin-top: var(--s3); flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.msg { padding: var(--s3); border-radius: var(--r-ctl); margin: var(--s3) 0 0; font-size: .875rem; }
.msg.warn { background: var(--warn-bg); color: var(--warn-fg); }
.msg.error { background: var(--err-bg); color: var(--err-fg); }
.msg.info { background: var(--info-bg); color: var(--info-fg); }
.startedit .msg { margin-top: var(--s2); }

/* primary action */
.make { border-color: var(--accent); }
#exportBtn { width: 100%; min-height: 60px; font-size: 1.125rem; letter-spacing: -.01em; border-radius: var(--r-card); }
#exportBtn:disabled { box-shadow: none; }
.outsum { margin-top: var(--s3); padding: var(--s1) 0 var(--s1) var(--s3); border-left: 3px solid var(--accent-soft); font-size: .875rem; }
.outsum p { margin: var(--s1) 0; }
.outsum p:empty { display: none; }
.outsum p[data-state="warn"] { color: var(--err-fg); font-weight: 600; }
.estimate { color: var(--muted); }
.estimate small { display: block; font-size: .75rem; opacity: .9; }
.progress-wrap { margin-top: var(--s3); }
progress { width: 100%; height: 12px; accent-color: var(--accent); }
.progress-line { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.progress-line .muted { margin: 0; }
.progress-line button { min-height: 44px; }
.result { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--line-soft); }
.result h3 { margin: 0 0 var(--s2); font-size: 1rem; }
.result video { width: 100%; max-height: 60vh; border-radius: var(--r-ctl); background: #000; }

/* optional settings */
.optional { margin-top: var(--s5); }
.opt-title { font-size: .85rem; font-weight: 600; letter-spacing: .08em; color: var(--muted); padding-top: var(--s3); border-top: 2px solid var(--fg); }
.opt-sub { margin: 0 0 var(--s3); }
details.opt { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); margin-top: var(--s2); }
details.opt > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 56px; padding: var(--s2) var(--s4);
  cursor: pointer; list-style: none; border-radius: var(--r-card); }
details.opt > summary::-webkit-details-marker { display: none; }
details.opt > summary::after, details.fold > summary::before { content: ""; width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
details.opt[open] > summary::after { transform: rotate(45deg); }
.opt-main { display: flex; flex-direction: column; min-width: 0; }
.fold-title { font-weight: 650; }
.fold-hint { font-weight: 400; font-size: .875rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.fold-hint[data-valid="false"] { color: var(--err-fg); font-weight: 600; }
.opt-body { padding: 0 var(--s4) var(--s4); }
details.opt[open] > summary { padding-bottom: var(--s2); }
details.fold { border-top: 1px solid var(--line-soft); margin-top: var(--s3); }
details.fold > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s3); min-height: 44px; padding: 6px 0; cursor: pointer; list-style: none; font-weight: 600; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { transform: rotate(-45deg); }
details.fold[open] > summary::before { transform: rotate(45deg); }
details.fold > .enh-row:first-of-type { margin-top: 0; }

/* enhancement */
.enh details.fold { margin-left: 0; }
.enh-actions { margin: var(--s2) 0; }
.enh-actions button { min-height: 44px; }
.enh-status { margin: 0 0 var(--s1); font-size: .9rem; font-weight: 600; color: var(--muted); }
.enh-status[data-mode="preset"], .enh-status[data-mode="custom"] { color: var(--accent); }
.enh-row, .trim-row { display: block; font-size: .9rem; margin: var(--s2) 0; }
.enh-row output, .trim-row output { float: right; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range] { accent-color: var(--accent); }
.enh-row input[type=range], .trim-row input[type=range], .pbar input[type=range] { display: block; width: 100%; height: 44px; margin: 0; }
.check { display: flex; align-items: center; gap: var(--s3); min-height: 44px; font-size: .9rem; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }

/* trim */
.trimbar { position: relative; height: 8px; border-radius: 4px; background: var(--line); margin: var(--s2) 0 2px; overflow: hidden; }
.trimbar i { position: absolute; top: 0; bottom: 0; left: var(--a, 0%); width: calc(var(--b, 100%) - var(--a, 0%)); background: var(--accent); }
.trim-info { margin: var(--s2) 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.trim-info[data-valid="false"] { color: var(--err-fg); }

/* display settings */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); align-items: end; }
.grid label { display: flex; flex-direction: column; gap: var(--s1); font-size: .9rem; }
.grid output { color: var(--muted); font-variant-numeric: tabular-nums; }
.grid input[type=range] { height: 44px; margin: 0; }
.grid input[type=color] { width: 100%; height: 44px; padding: 3px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--field); }
.grid .check { flex-direction: row; align-items: center; }

/* legal footer: always visible, small */
footer.legal { margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; line-height: 1.6; }
footer.legal .legal-title { font-size: .8125rem; font-weight: 700; color: var(--fg); margin-bottom: var(--s2); }
footer.legal p { margin: 0 0 var(--s2); }
footer.legal ul { margin: 0; padding-left: 1.2em; }
footer.legal li { margin: 0 0 var(--s1); }

[hidden] { display: none !important; }

/* two columns on wide screens once a video is loaded */
@media (min-width: 900px) {
  body.has-file .layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
  body.has-file .col-a { position: sticky; top: var(--s4); }
  body.has-file .optional { margin-top: var(--s4); }
}
@media (max-width: 380px) {
  .capture-row { flex-wrap: wrap; }
  .capfmt { flex: 1 1 100%; }
  .capfmt select { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
