:root {
  --bg: #fff; --card: #f5f5f7; --fill: #e8e8ed; --text: #1d1d1f; --sub: #6e6e73; --line: #d2d2d7;
  --accent: #0071e3; --accent-bg: #e8f1fc; --danger: #e30000; --good: #1f9d3a; --radius: 18px;
  --paper: #fff; --paper-line: #d9d9de; --ln: #dcdce1; --nav: rgba(255, 255, 255, 0.78);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --card: #1c1c1e; --fill: #2c2c2e; --text: #f5f5f7; --sub: #98989d; --line: #3a3a3c;
    --accent: #2997ff; --accent-bg: #0f2540; --danger: #ff453a; --good: #30d158;
    --paper: #f5f5f7; --paper-line: #f5f5f7; --ln: #c7c7cc; --nav: rgba(22, 22, 23, 0.78);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.55 "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  letter-spacing: -0.01em; word-break: keep-all; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.ic { width: 1.2em; height: 1.2em; vertical-align: -0.22em; flex: none; stroke-width: 1.8; }
main { max-width: 1024px; margin: 0 auto; padding: 0 20px 40px; }
h1, h2 { letter-spacing: -0.025em; line-height: 1.2; }
h1 { font-size: clamp(32px, 5vw, 48px); font-weight: 700; margin: 0 0 12px; }
h2 { font-size: clamp(24px, 3.4vw, 32px); font-weight: 700; margin: 0 0 20px; }
.lead, .hint, .note { color: var(--sub); }
.lead { font-size: 19px; margin: 0; }
.hint { font-size: 15px; margin: 14px 0 8px; }
.note { font-size: 14px; }

/* 상단 메뉴: 반투명 유리 */
.top { position: sticky; top: 0; z-index: 5; background: var(--nav); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.top nav { display: flex; align-items: center; justify-content: space-between; max-width: 1024px; height: 52px; margin: 0 auto; padding: 0 20px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 19px; letter-spacing: -0.03em; color: var(--text); }
.logo:hover, .nav-link:hover { text-decoration: none; opacity: 0.7; }
.mark { width: 26px; height: 26px; color: var(--text); }
.mark rect { fill: currentColor; }
.mark path[fill="#fff"] { fill: var(--bg); }
.nav-link { font-size: 14px; color: var(--text); }

/* 첫 화면 */
.hero { text-align: center; padding: clamp(56px, 10vw, 112px) 0 clamp(40px, 7vw, 72px); }
.eyebrow { color: var(--accent); font-weight: 600; font-size: 17px; margin: 0 0 12px; }
.hero h1 { font-size: clamp(40px, 8vw, 80px); letter-spacing: -0.04em; line-height: 1.08; margin: 0; }
.hero-sub { font-size: clamp(19px, 2.4vw, 24px); color: var(--sub); max-width: 560px; margin: 20px auto 28px; line-height: 1.45; }
.perks { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 0; margin: 0; list-style: none; font-size: 15px; }
.perks li { display: flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--card); border-radius: 999px; }
.perks .ic { color: var(--accent); }

.group { padding: 32px 0; }
.group h2 { margin-bottom: 8px; }
.group-sub { color: var(--sub); margin: 0 0 20px; }
.group h2 + .tool-grid { margin-top: 20px; }

/* 도구 카드 */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tool-card { display: flex; flex-direction: column; padding: 0 22px 22px; background: var(--card); border-radius: var(--radius); color: var(--text); transition: transform 0.3s, box-shadow 0.3s; }
.tool-card:hover { text-decoration: none; transform: scale(1.02); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1); }
.tool-card .art { margin: 18px 0 14px; }
.tool-card b { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.tool-card small { color: var(--sub); font-size: 14px; margin-top: 2px; }

/* 미리보기 그림 */
.art { display: block; width: 100%; height: auto; overflow: visible; }
.art .paper { fill: var(--paper); stroke: var(--paper-line); stroke-width: 1; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08)); }
.art .ln { fill: var(--ln); }
.art .ln-s { stroke: var(--ln); stroke-width: 3; stroke-linecap: round; }
.art .blue { fill: #0071e3; } .art .orange { fill: #ff9500; } .art .green { fill: #28b84a; }
.art .red { fill: #ff3b30; } .art .ink { fill: #1d1d1f; } .art .black { fill: #000; } .art .white { fill: #fff; }
.art .sky { fill: #9fd0ff; } .art .sun { fill: #ffcc00; } .art .hill { fill: #34a853; }
.art .desk { fill: #8e8e93; }
.art .arrow { fill: none; stroke: var(--sub); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.art .shackle { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.art .pen { fill: none; stroke: #0050b3; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.art .seal { fill: none; stroke: #e30000; stroke-width: 1.6; }
.art text { font-family: inherit; text-anchor: middle; }
.art .lbl { font-size: 11px; font-weight: 700; fill: var(--sub); }
.art .good { fill: var(--good); }
.art .tag { font-size: 8.5px; font-weight: 700; fill: #fff; }
.art .num { font-size: 20px; font-weight: 700; fill: #1d1d1f; }
.art .wm { font-size: 13px; font-weight: 800; fill: #e30000; opacity: 0.75; }
.art .mono { font-size: 7px; font-weight: 600; fill: #1d1d1f; text-anchor: start; font-variant-numeric: tabular-nums; }
.art .seal-t { font-size: 8px; font-weight: 700; fill: #e30000; }
.art .after { transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
.tool-card:hover .art .after { transform: translateY(-4px); }
.art .lift .paper { filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.18)); }

/* 도구 화면 */
.tool-head { display: grid; grid-template-columns: 1fr minmax(200px, 300px); align-items: center; gap: 32px; padding: clamp(32px, 6vw, 64px) 0 32px; }
.tool-head .art { padding: 20px; background: var(--card); border-radius: var(--radius); }
@media (max-width: 640px) {
  .tool-head { grid-template-columns: 1fr; gap: 20px; }
  .tool-head .art { order: -1; padding: 8px 20px; }
  .tool-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .tool-card { padding: 0 14px 16px; }
  .tool-card .art { margin: 12px 0 10px; }
  .tool-card b { font-size: 16px; }
  .tool-card small { font-size: 13px; }
}
.panel { background: var(--card); border-radius: 24px; padding: clamp(16px, 3vw, 32px); margin: 0 0 16px; }

.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 48px 16px; background: var(--bg); border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer; text-align: center; transition: border-color 0.2s, background 0.2s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-bg); }
.drop .ic { width: 40px; height: 40px; color: var(--accent); margin-bottom: 4px; }
.drop b { font-size: 17px; font-weight: 600; }
.drop small { color: var(--sub); font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.cards.pages { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.card { background: var(--bg); border-radius: 14px; padding: 8px; cursor: grab; user-select: none; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); }
.card.sortable-ghost { opacity: 0.4; }
.card.deleted { opacity: 0.35; }
.card.deleted .thumb { outline: 2px solid var(--danger); }
.thumb { aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--card); border-radius: 8px; }
.thumb canvas { max-width: 100%; max-height: 100%; transition: transform 0.2s; }
.name { font-size: 12px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { font-size: 12px; color: var(--sub); margin-top: 4px; }
.tools { display: flex; gap: 4px; margin-top: 6px; }
.icon-btn { padding: 6px; line-height: 0; border-radius: 50%; }

button { font: inherit; font-size: 15px; color: var(--text); background: var(--fill); border: 0; border-radius: 999px; padding: 8px 16px; cursor: pointer; transition: opacity 0.2s, background 0.2s; }
button:hover { opacity: 0.8; }
button.primary { display: block; width: 100%; margin: 20px 0 4px; padding: 15px; font-size: 17px; font-weight: 600; color: #fff; background: var(--accent); }
button:disabled { opacity: 0.6; cursor: wait; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.bar .primary { width: auto; margin: 0; padding: 8px 18px; font-size: 15px; }

.opts { display: grid; gap: 18px; margin: 16px 0; padding: 20px; background: var(--bg); border-radius: var(--radius); }
.field { display: grid; gap: 8px; font-size: 15px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; }
input[type=text], input[type=number], input[type=password] { font: inherit; font-weight: 400; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); width: 100%; transition: border-color 0.2s, box-shadow 0.2s; }
input[type=text]:focus, input[type=number]:focus, input[type=password]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
/* 선택 버튼 묶음: 아이폰 세그먼트처럼 */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--fill); border-radius: 12px; font-weight: 500; justify-self: start; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: inline-block; padding: 6px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; transition: background 0.2s; }
.seg input:checked + span { background: var(--bg); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.preview { display: block; max-width: 100%; max-height: 520px; margin: 0 auto; border-radius: 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08); }
.result { font-weight: 700; color: var(--accent); text-align: center; }

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal-box { background: var(--bg); border-radius: 22px; padding: 20px; max-width: 100%; max-height: 100%; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.crop-stage { position: relative; display: inline-block; overflow: hidden; touch-action: none; cursor: crosshair; line-height: 0; }
.crop-stage canvas { max-width: 100%; max-height: 65vh; }
.crop-rect { position: absolute; border: 2px solid var(--accent); box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45); pointer-events: none; }

.info { margin-top: 56px; }
.info h2 { font-size: 24px; margin-bottom: 16px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; counter-reset: step; }
.steps li { counter-increment: step; padding: 20px; background: var(--card); border-radius: var(--radius); font-weight: 500; }
.steps li::before { content: counter(step); display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-bottom: 10px; border-radius: 50%; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 700; }
details { border-bottom: 1px solid var(--line); padding: 16px 0; }
details:first-of-type { border-top: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--sub); font-weight: 400; font-size: 22px; line-height: 1; transition: transform 0.2s; }
details[open] summary::after { transform: rotate(45deg); }
details p { margin: 10px 0 0; color: var(--sub); }
.ad-slot:empty { display: none; }

.foot { max-width: 1024px; margin: 40px auto 0; padding: 24px 20px 48px; border-top: 1px solid var(--line); font-size: 13px; color: var(--sub); }
.foot p { margin: 4px 0; }
.foot a { color: var(--text); }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); max-width: calc(100% - 32px); padding: 12px 20px; border-radius: 999px; background: rgba(29, 29, 31, 0.92); backdrop-filter: blur(12px); color: #fff; font-size: 15px; opacity: 0; pointer-events: none; transition: 0.3s; z-index: 20; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }

.redact-list { display: grid; gap: 16px; margin: 12px 0; }
.page-wrap { position: relative; line-height: 0; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1); }
.page-wrap canvas { width: 100%; height: auto; }
.box-layer { position: absolute; inset: 0; touch-action: none; cursor: crosshair; }
.box { position: absolute; background: #000; outline: 2px solid var(--danger); cursor: pointer; }
.stamp { position: absolute; cursor: move; outline: 1px dashed var(--accent); touch-action: none; }
.stamp img { display: block; width: 100%; pointer-events: none; }
.stamp .icon-btn { position: absolute; top: -14px; right: -14px; padding: 3px; background: var(--bg); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }
.stamp-handle { position: absolute; right: -8px; bottom: -8px; width: 16px; height: 16px; background: var(--accent); border-radius: 50%; cursor: nwse-resize; }
.sig-pad { width: 100%; height: auto; aspect-ratio: 3 / 1; background: #fff; border: 1px dashed var(--line); border-radius: 12px; touch-action: none; cursor: crosshair; }
.sig-current { display: flex; align-items: center; gap: 12px; margin: 12px 0; padding: 12px; background: var(--accent-bg); border-radius: var(--radius); font-size: 15px; }
.sig-current img { max-width: 140px; max-height: 60px; background: #fff; border-radius: 8px; padding: 4px; }
