/* Shape rule: panels and tiles 16px, controls 12px, page thumbnails 8px, tags full pill.
   One accent colour. Layers: header 10, mobile action bar 20. */

@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
/* Hangul only, so English visitors never download the 2 MB file. */
@font-face {
  font-family: "Pretendard Variable";
  src: url("fonts/PretendardVariable.woff2") format("woff2-variations");
  font-weight: 45 920;
  font-display: swap;
  unicode-range: U+1100-11FF, U+3130-318F, U+A960-A97F, U+AC00-D7AF, U+D7B0-D7FF;
}

:root {
  --bg: #f4f5f7;
  --surface: #fcfcfd;
  --surface-2: #eceef1;
  --text: #15181c;
  --muted: #5a626d;
  --line: #dfe3e8;
  --accent: #0b7a5f;
  --accent-ink: #fbfdfc;
  --accent-soft: #e1f2ec;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgb(21 32 43 / .05), 0 10px 28px -14px rgb(21 32 43 / .18);
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1012; --surface: #16191c; --surface-2: #1f2327; --text: #e9ecef; --muted: #98a1ab;
    --line: #282d33; --accent: #41c99d; --accent-ink: #062a1f; --accent-soft: #11332a; --danger: #ff8a80;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1012; --surface: #16191c; --surface-2: #1f2327; --text: #e9ecef; --muted: #98a1ab;
  --line: #282d33; --accent: #41c99d; --accent-ink: #062a1f; --accent-soft: #11332a; --danger: #ff8a80;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Geist", "Pretendard Variable", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
h1, h2, h3, p, ul, fieldset { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; }
.wrap { max-width: 1120px; margin-inline: auto; padding-inline: 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 10; background: var(--bg); }
.top .wrap { height: 64px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.top h1 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.01em; }
.spacer { flex: 1; }
.iconbtn {
  height: 40px; min-width: 40px; padding: 0 10px; border-radius: 12px; border: 1px solid transparent;
  background: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); font-size: .875rem; font-weight: 500;
  transition: background .2s, color .2s;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn:active { transform: scale(.97); }

/* ---------- buttons ---------- */
.btn {
  height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 550; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .15s var(--ease), background .2s, border-color .2s, opacity .2s;
}
.btn:hover { border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 90%, var(--text)); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn.wide { width: 100%; }
.btn.small { height: 38px; padding: 0 12px; font-size: .875rem; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 550; font-size: .875rem; }
.link:hover { text-decoration: underline; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: center; padding-block: 36px 28px; }
.hero h2 { font-size: clamp(1.9rem, 4.2vw, 3rem); line-height: 1.08; letter-spacing: -.035em; font-weight: 620; text-wrap: balance; }
.hero p { margin-top: 14px; color: var(--muted); font-size: 1.0625rem; max-width: 34ch; }

.drop {
  min-height: 208px; border-radius: 16px; padding: 24px; text-align: center;
  background: var(--surface); border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
  display: grid; place-content: center; justify-items: center; gap: 12px;
  transition: background .2s, border-color .2s, transform .25s var(--ease);
}
.drop .ic.big { width: 34px; height: 34px; color: var(--accent); }
.drop strong { font-weight: 600; font-size: 1.0625rem; }
.drop span { color: var(--muted); font-size: .875rem; }
body.dragging .drop { background: var(--accent-soft); border-color: var(--accent); transform: scale(1.01); }
.stage > .drop { min-height: 360px; }

.held {
  border-radius: 16px; padding: 16px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); display: grid; grid-template-columns: 84px 1fr auto; gap: 16px; align-items: center;
}
.held .thumb { pointer-events: none; }
.held b { display: block; font-weight: 600; overflow-wrap: anywhere; word-break: break-all; }
.held small { color: var(--muted); font-size: .875rem; }
.held .next { margin-top: 8px; color: var(--accent); font-weight: 550; font-size: .9375rem; display: flex; align-items: center; gap: 6px; }

.facts { display: flex; flex-wrap: wrap; gap: 10px 28px; padding-block: 4px 28px; color: var(--muted); font-size: .9375rem; }
.facts li { display: flex; align-items: center; gap: 8px; }
.facts .ic { color: var(--accent); }

.block { padding-block: 14px; }
.block > header { display: flex; align-items: baseline; gap: 14px; margin-bottom: 12px; }
.block h3 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.01em; }
.block header .spacer + * { margin-left: 0; }

.presets { display: flex; flex-wrap: wrap; gap: 10px; }
.preset {
  display: inline-flex; align-items: center; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); overflow: hidden; transition: border-color .2s, transform .2s var(--ease);
}
.preset:hover { border-color: var(--accent); transform: translateY(-1px); }
.preset button { background: none; border: 0; height: 44px; display: inline-flex; align-items: center; gap: 8px; }
.preset .go { padding: 0 6px 0 12px; font-weight: 550; }
.preset .go .ic { color: var(--accent); }
.preset .go small { color: var(--muted); font-weight: 400; }
.preset .del { padding: 0 10px; color: var(--muted); }
.preset .del:hover { color: var(--danger); }
.empty { color: var(--muted); font-size: .9375rem; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 12px; }
.tile {
  position: relative; display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: center;
  padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
  transition: transform .25s var(--ease), border-color .2s, box-shadow .25s;
}
.tile .chip { font-style: normal; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tile .chip .ic { width: 22px; height: 22px; }
.tile b { display: block; font-weight: 600; letter-spacing: -.01em; }
.tile span { display: block; color: var(--muted); font-size: .875rem; line-height: 1.35; margin-top: 2px; }
a.tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: var(--shadow); }
a.tile:active { transform: scale(.985); }
.tile.soon { background: none; border-style: dashed; }
.tile.soon .chip { background: var(--surface-2); color: var(--muted); }
.tile.soon b { color: var(--muted); }
.tag { font-style: normal; position: absolute; top: 12px; right: 12px; font-size: .75rem; font-weight: 550; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 9px; }

.foot { padding-block: 36px 44px; color: var(--muted); font-size: .875rem; }

/* ---------- workspace ---------- */
.back { margin-left: -8px; }
.work { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; padding-block: 12px 48px; }
.panel {
  position: sticky; top: 76px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; display: grid; gap: 18px; box-shadow: var(--shadow);
}
.filebar { display: flex; align-items: center; gap: 10px; min-width: 0; }
.filebar .ic { color: var(--accent); }
.filebar b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filebar small { color: var(--muted); white-space: nowrap; }

.field { display: grid; gap: 8px; }
.field > label, .field > legend { font-weight: 550; font-size: .9375rem; }
.field small { color: var(--muted); font-size: .8125rem; }
.field small.err { color: var(--danger); }
.input, select.input {
  height: 46px; width: 100%; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.row { display: flex; gap: 8px; }
.row > .input { flex: 1; min-width: 0; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 38px; border-radius: 9px;
  font-size: .875rem; font-weight: 550; color: var(--muted); transition: background .2s, color .2s, box-shadow .2s;
}
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(21 32 43 / .12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.check { display: flex; align-items: center; gap: 10px; font-size: .9375rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.presetbar { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }

.cta { display: grid; gap: 10px; }
.sum { color: var(--muted); font-size: .875rem; min-height: 1.4em; }
.alert { display: flex; gap: 8px; align-items: flex-start; color: var(--danger); font-size: .9375rem; }

/* result */
.done { display: grid; gap: 14px; }
.done .ok { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.0625rem; }
.done .ok .ic { width: 26px; height: 26px; color: var(--accent); }
.outs { display: grid; gap: 6px; max-height: 280px; overflow: auto; }
.outs > div {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 2px; align-items: center; padding: 8px 6px 8px 12px;
  border-radius: 12px; background: var(--bg); font-size: .9375rem;
}
.outs b { grid-column: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outs small { grid-column: 1; color: var(--muted); font-size: .8125rem; }
.outs .iconbtn { grid-row: 1 / span 2; color: var(--accent); }
.outs .iconbtn:first-of-type { grid-column: 2; }
.outs .iconbtn:last-of-type { grid-column: 3; }

.preview { display: grid; gap: 22px; }
.preview h2 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.01em; }
.preview section { display: grid; gap: 12px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.preview header { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.preview header b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview header small { color: var(--muted); font-size: .8125rem; white-space: nowrap; }

/* page thumbnails */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 18px 14px; }
.pg { background: none; border: 0; padding: 0; display: grid; gap: 6px; justify-items: center; transition: opacity .25s; }
.pg > small { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.thumb {
  position: relative; width: 100%; aspect-ratio: var(--ar, .707); border-radius: 8px; overflow: hidden;
  background: #fff linear-gradient(100deg, transparent 30%, rgb(21 32 43 / .05) 50%, transparent 70%) 0 0 / 200% 100%;
  box-shadow: 0 0 0 1px var(--line), 0 6px 14px -8px rgb(21 32 43 / .3);
  transition: box-shadow .2s, transform .25s var(--ease);
}
.thumb img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0;
  transform: rotate(var(--rot, 0deg)) scale(var(--sc, 1)); transition: opacity .3s, transform .35s var(--ease);
}
.thumb.ready { background: #fff; }
.thumb.ready img { opacity: 1; }
.pg:hover .thumb { transform: translateY(-2px); }
.pg.in .thumb { box-shadow: 0 0 0 2px var(--accent), 0 6px 14px -8px rgb(21 32 43 / .3); }
.pg.in > small { color: var(--accent); font-weight: 600; }
.pg.dim { opacity: .38; }
.pg.cut .thumb { box-shadow: 0 0 0 2px var(--danger); }
.pg.cut .thumb img { opacity: .25; }
.pg.cut > small { color: var(--danger); text-decoration: line-through; }
.badge {
  position: absolute; top: 6px; left: 6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 600; display: none; place-items: center;
}
.pg[data-g] .badge { display: grid; }
.cutmark { position: absolute; inset: 0; display: none; place-items: center; color: var(--danger); }
.cutmark .ic { width: 28px; height: 28px; }
.pg.cut .cutmark { display: grid; }

/* merge list */
.mlist { display: grid; gap: 10px; }
.mitem {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
}
.mitem b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mitem small { display: block; color: var(--muted); font-size: .8125rem; }
.mitem .input { height: 38px; margin-top: 8px; max-width: 220px; font-size: .875rem; }
.mitem .acts { display: flex; }
.addmore { margin-top: 4px; justify-self: start; }

@media (prefers-reduced-motion: no-preference) {
  .thumb:not(.ready) { animation: shimmer 1.4s linear infinite; }
  @keyframes shimmer { to { background-position: -200% 0; } }
  .done { animation: rise .4s var(--ease); }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 22px; padding-block: 16px 22px; }
  .work { grid-template-columns: 1fr; gap: 20px; padding-bottom: 150px; }
  .panel { position: static; order: -1; box-shadow: none; }
  .cta {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .panel.finished .cta { position: static; padding: 0; border: 0; }
  .stage > .drop { min-height: 240px; }
}
@media (max-width: 560px) {
  .wrap { padding-inline: 16px; }
  .tiles { grid-template-columns: 1fr; gap: 8px; }
  .tile { padding: 12px 14px; }
  .pages { grid-template-columns: repeat(3, 1fr); gap: 14px 10px; }
  .held { grid-template-columns: 64px 1fr auto; gap: 12px; }
  .facts { gap: 8px 20px; font-size: .875rem; }
  .mitem { grid-template-columns: 44px minmax(0, 1fr); }
  .mitem .acts { grid-column: 1 / -1; justify-content: flex-end; margin-top: -6px; }
}
