/* Layout: one working column. Nav, title, drop zone, options in labelled groups, page board grouped by output file, save area, viewer. */
:root {
  --bg: #f3f5f6; --surface: #ffffff; --ink: #17242b; --muted: #5d6c74; --line: #d8dfe2;
  --accent: #0d6b74; --accent-ink: #ffffff; --accent-soft: #e1f0f1;
  --ok: #1f7a46; --warn: #9a5b00; --err: #b3261e;
  --font-body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #111a1e; --surface: #18242a; --ink: #e4ecef; --muted: #93a4ab; --line: #2b3a41;
  --accent: #5cc2cb; --accent-ink: #0b1b1e; --accent-soft: #173a3e; --ok: #6fcf97; --warn: #e0a84a; --err: #f08a80; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #111a1e; --surface: #18242a; --ink: #e4ecef; --muted: #93a4ab; --line: #2b3a41;
  --accent: #5cc2cb; --accent-ink: #0b1b1e; --accent-soft: #173a3e; --ok: #6fcf97; --warn: #e0a84a; --err: #f08a80; color-scheme: dark }

* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere }
.wrap { max-width: 1040px; margin: 0 auto; padding-block: 22px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 20px }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums }
a { color: var(--accent) }
nav.top { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 14px; border-bottom: 1px solid var(--line); padding-bottom: 12px; align-items: baseline }
nav.top .brand { font-weight: 700; color: var(--ink); text-decoration: none; margin-right: auto }
nav.top a { color: var(--muted); text-decoration: none } nav.top a:hover { color: var(--accent) }
nav.top a[aria-current] { color: var(--ink); font-weight: 600 }
h1 { font-size: 27px; line-height: 1.3; margin: 0; letter-spacing: -0.01em; text-wrap: balance }
.lead { margin: 4px 0 0; color: var(--muted); max-width: 64ch }
button, .btn { font: inherit; font-weight: 500; border-radius: 6px; padding: 7px 14px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px }
button:hover, .btn:hover { border-color: var(--accent) }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
button:disabled { opacity: .45; cursor: default }
select, input[type=number], input[type=text] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px }
input[type=number] { width: 5.5em } input[type=text] { width: 11em }

/* drop zone */
.drop { position: relative; border: 1.5px dashed var(--line); border-radius: 10px; background: var(--surface); padding: 26px 20px;
  display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; cursor: pointer; transition: border-color .15s, background .15s }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft) }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100% }
.sheet { width: 54px; height: 72px; border: 1.5px solid var(--ink); border-radius: 3px; position: relative; background: var(--bg); transform: rotate(-4deg) }
.sheet::before { content: ""; position: absolute; left: 9px; right: 9px; top: 12px; height: 32px; background: repeating-linear-gradient(var(--muted) 0 1.5px, transparent 1.5px 8px) }
.sheet::after { content: ""; position: absolute; top: 0; bottom: 0; left: 30px; width: 1.5px; background: var(--accent); opacity: .7 }
.drop strong { display: block; font-size: 17px } .drop span { color: var(--muted) }

/* options */
.opts { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 22px }
.opts fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0 }
.opts legend { font-size: 12px; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 0; margin-bottom: 4px }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; line-height: 1.4 }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 2px 0 0; flex: 0 0 auto }
.check small { display: block; color: var(--muted); font-size: 12.5px }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px }
.row label { color: var(--muted) }
.row.sub { padding-left: 24px } .row.off { opacity: .5 }

/* work area */
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between }
.bar .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
#summary { font-weight: 600 }
.addmore { position: relative; overflow: hidden } .addmore input { position: absolute; inset: 0; opacity: 0; cursor: pointer }
.notice { background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between }
.busy { display: flex; align-items: center; gap: 10px; color: var(--accent); font-size: 14px }
.spin { width: 14px; height: 14px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite }
@keyframes spin { to { transform: rotate(360deg) } }
.group { display: flex; flex-direction: column; gap: 10px }
.group h3 { margin: 0; font-size: 15px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap }
.gcount { font-weight: 400; color: var(--muted); font-size: 13px }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; cursor: grab; position: relative; min-width: 0 }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) }
.card.over { border-color: var(--accent); background: var(--accent-soft) }
.card.dragging { opacity: .4 }
.card.removed .thumbbox { opacity: .3 } .card.removed .pn { text-decoration: line-through }
.thumbbox { aspect-ratio: 1 / 1.414; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--bg); border-radius: 4px; max-width: 100% }
.thumbbox img { max-width: 100%; max-height: 100%; background: #fff; border: 1px solid var(--line); transition: transform .2s; pointer-events: none }
.cap { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; min-width: 0 }
.pn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.bs { display: flex; flex-wrap: wrap; gap: 4px }
.b { font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums }
.b.busy { color: var(--accent); background: var(--accent-soft) } .b.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent) }
.tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px }
.tools button { padding: 3px 0; font-size: 13px; justify-content: center; border-radius: 5px; white-space: nowrap; min-width: 0 }
.tools .del { font-size: 12px }

.save { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px }
.save .bar h2 { margin: 0; font-size: 16px }
.out { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line) }
.oname { font-weight: 600; min-width: 0; overflow-wrap: anywhere } .osize { color: var(--muted); font-size: 13px }
.onote { grid-column: 1 / -1; margin: 0; font-size: 13px; color: var(--muted) } .onote.warn { color: var(--warn) }
textarea { width: 100%; min-height: 200px; font: 13px/1.6 var(--font-mono); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px }

.viewer { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px }
.vhead { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden }
.seg button { border: 0; border-radius: 0; padding: 6px 14px }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink) }
.stage { overflow: auto; max-height: 80vh; border: 1px solid var(--line); border-radius: 6px; background: #fff }
.stage img { display: block; width: 100%; max-width: none; cursor: zoom-in }
.stage.zoom img { width: auto; cursor: zoom-out }
.hint { font-size: 13px; color: var(--muted); margin: 0 }

.intro { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px }
.intro h2 { margin: 0 0 4px; font-size: 15px } .intro p { margin: 0; color: var(--muted); font-size: 14px }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; max-width: calc(100% - 32px); z-index: 20 }

/* ads + footer */
.ad { display: flex; flex-direction: column; gap: 4px; min-height: 100px }
.ad-label { font-size: 11px; letter-spacing: .08em; color: var(--muted) }
.ad.placeholder ins { display: none !important }
.ad.placeholder::after { content: "광고 영역"; display: flex; align-items: center; justify-content: center; min-height: 90px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 13px }
footer { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px }

/* home */
.hero { display: flex; flex-direction: column; gap: 6px; padding-block: 6px }
.hero h1 { font-size: 32px }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px }
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; transition: border-color .15s, background .15s }
.tool:has(input:checked) { border-color: var(--accent); background: var(--accent-soft) }
.tool label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer }
.tool input { accent-color: var(--accent); width: 18px; height: 18px; margin: 3px 0 0; flex: 0 0 auto }
.tool strong { display: block; font-size: 15.5px }
.tool p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5 }
.tool .solo { font-size: 13px; margin-top: auto; padding-left: 28px }
.icon { width: 34px; height: 34px; flex: 0 0 auto; color: var(--accent) }
.startbar { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; box-shadow: 0 6px 24px color-mix(in srgb, var(--ink) 14%, transparent); z-index: 5 }
.startbar .chosen { font-size: 14px; color: var(--muted); min-width: 0 }
.startbar .chosen b { color: var(--ink) }
.presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px }
.presets span { color: var(--muted) }
.presets button { padding: 4px 12px; font-size: 13.5px; border-radius: 99px }

@media (max-width: 560px) { .drop { grid-template-columns: 1fr; text-align: center } .sheet { margin: 0 auto } .hero h1 { font-size: 26px } .out { grid-template-columns: 1fr auto } .out .osize { grid-row: 1; grid-column: 2 } .out button { grid-column: 1 / -1; justify-content: center } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important } }
