/* ================= Theme ================= */
:root {
  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --text: #141827;
  --muted: #5b6275;
  --border: #e3e6ef;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef0ff;
  --success: #059669;
  --danger: #dc2626;
  --c-image: #0ea5e9;
  --c-image-soft: #e0f4fe;
  --c-pdf: #e11d48;
  --c-pdf-soft: #ffe4ea;
  --c-other: #8b5cf6;
  --c-other-soft: #efe9ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1017; --surface: #161a24; --surface-2: #1d2230; --text: #e8eaf2; --muted: #9aa1b5;
    --border: #2a3040; --primary: #818cf8; --primary-2: #6366f1; --primary-soft: #23264a;
    --c-image-soft: #0c2a3a; --c-pdf-soft: #3a1220; --c-other-soft: #271d45;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1017; --surface: #161a24; --surface-2: #1d2230; --text: #e8eaf2; --muted: #9aa1b5;
  --border: #2a3040; --primary: #818cf8; --primary-2: #6366f1; --primary-soft: #23264a;
  --c-image-soft: #0c2a3a; --c-pdf-soft: #3a1220; --c-other-soft: #271d45;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
}

/* ================= Base ================= */
*, *::before, *::after { box-sizing: border-box; }
[hidden], .hidden { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.02em; }
img { max-width: 100%; }
code { background: var(--surface-2); padding: .1em .4em; border-radius: 6px; font-size: .9em; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 860px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.ico { width: 1.25em; height: 1.25em; flex: none; }

/* ================= Header ================= */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.6) blur(12px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; color: var(--text); }
.logo:hover { text-decoration: none; }
.main-nav { display: flex; gap: 4px; margin-left: auto; }
.nav-item { position: relative; }
.nav-item > a { display: block; padding: 8px 14px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: .95rem; }
.nav-item > a:hover { background: var(--surface-2); text-decoration: none; }
.nav-drop { position: absolute; top: 100%; left: 0; min-width: 230px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(6px); transition: .15s; }
.nav-drop a { display: block; padding: 7px 12px; border-radius: 8px; color: var(--text); font-size: .93rem; }
.nav-drop a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.nav-item:hover .nav-drop, .nav-item:focus-within .nav-drop { opacity: 1; visibility: visible; transform: none; }
.header-actions { display: flex; gap: 6px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; cursor: pointer; font-size: 1rem; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.nav-toggle { display: none; }

@media (max-width: 820px) {
  .nav-toggle { display: inline-grid; }
  .header-actions { margin-left: auto; }
  .main-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 16px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 64px); overflow: auto; }
  .nav-open .main-nav { display: flex; }
  .nav-drop { position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none; border: 0; padding: 0 0 8px 12px; display: grid; grid-template-columns: 1fr 1fr; min-width: 0; }
}

/* ================= Hero ================= */
.home-hero { text-align: center; padding: 64px 0 40px; background: radial-gradient(1000px 400px at 50% -10%, var(--primary-soft), transparent 70%); }
.home-hero h1 { font-size: clamp(2rem, 5vw, 3.3rem); margin: 0 0 16px; font-weight: 850; }
.grad { background: linear-gradient(90deg, #6366f1, #ec4899); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 720px; margin: 0 auto; }
.search-wrap { position: relative; max-width: 560px; margin: 28px auto 18px; }
.search-wrap .ico { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-wrap input { width: 100%; padding: 16px 20px 16px 50px; font-size: 1.05rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); outline: none; }
.search-wrap input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; color: var(--muted); font-size: .93rem; font-weight: 500; }

.tool-hero { padding: 36px 0 24px; text-align: center; background: linear-gradient(180deg, var(--primary-soft), transparent); }
.tool-hero.cat-image { background: linear-gradient(180deg, var(--c-image-soft), transparent); }
.tool-hero.cat-pdf { background: linear-gradient(180deg, var(--c-pdf-soft), transparent); }
.tool-hero.cat-other { background: linear-gradient(180deg, var(--c-other-soft), transparent); }
.tool-hero h1 { font-size: clamp(1.8rem, 4.2vw, 2.6rem); margin: 8px 0 10px; font-weight: 800; }
.breadcrumb { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; font-size: .88rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }

/* ================= Cards ================= */
.cat-section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 1.5rem; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tool-card { display: flex; gap: 14px; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); transition: transform .15s, box-shadow .15s, border-color .15s; }
.tool-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: transparent; }
.tc-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; flex: none; }
.tc-icon .ico { width: 24px; height: 24px; }
.cat-image .tc-icon { background: var(--c-image-soft); color: var(--c-image); }
.cat-pdf .tc-icon { background: var(--c-pdf-soft); color: var(--c-pdf); }
.cat-other .tc-icon { background: var(--c-other-soft); color: var(--c-other); }
.tc-body { display: flex; flex-direction: column; min-width: 0; }
.tc-name { font-weight: 700; }
.tc-desc { color: var(--muted); font-size: .88rem; line-height: 1.4; }
.no-results { text-align: center; color: var(--muted); padding: 30px 16px; }

.features { margin-top: 64px; text-align: center; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 20px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.feature .ico { width: 34px; height: 34px; color: var(--primary); }
.feature h3 { margin: 10px 0 6px; }
.feature p { margin: 0; color: var(--muted); font-size: .95rem; }

/* ================= Tool box ================= */
.tool-box { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 24px; margin-top: 8px; }
.tool-loading { text-align: center; color: var(--muted); padding: 40px; }
.noscript { text-align: center; color: var(--danger); }
.tool-box > * + * { margin-top: 18px; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: .9rem; margin: 14px 0 0; text-align: center; }
.privacy-note .ico { color: var(--success); }

.dropzone { border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--border)); border-radius: 16px; padding: 40px 20px; text-align: center; cursor: pointer; background: var(--primary-soft); transition: .15s; outline: none; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 70%, var(--primary) 8%); }
.dropzone.compact { padding: 18px; }
.dropzone.compact .dz-icon, .dropzone.compact .dz-sub { display: none; }
.dz-icon .ico { width: 46px; height: 46px; color: var(--primary); }
.dz-title { font-size: 1.15rem; font-weight: 700; margin-top: 6px; }
.dz-sub { color: var(--muted); font-size: .92rem; margin: 2px 0 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; font: inherit; font-weight: 650; font-size: .96rem; border-radius: 11px; border: 1px solid transparent; cursor: pointer; transition: .15s; white-space: nowrap; color: var(--text); background: var(--surface-2); }
.btn:hover:not(:disabled) { filter: brightness(1.06); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: linear-gradient(135deg, var(--primary-2), #8b5cf6); color: #fff; box-shadow: 0 4px 14px rgba(99, 102, 241, .35); }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-lg { padding: 14px 26px; font-size: 1.05rem; }
.btn-sm { padding: 7px 12px; font-size: .88rem; }

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 18px; padding: 18px; background: var(--surface-2); border-radius: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; }
.field-label { font-weight: 650; }
.hint { color: var(--muted); font-size: .82rem; }
.field input[type=number], .field input[type=text], .field input[type=date], .field select, .text-input, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); width: 100%; outline: none;
}
.field input:focus, .field select:focus, textarea:focus, .text-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field input[type=color] { width: 100%; height: 42px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; font-size: .93rem; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.checks { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.slider { display: flex; align-items: center; gap: 10px; }
.slider input { flex: 1; accent-color: var(--primary); }
.slider output { min-width: 48px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-list:empty { display: none; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.fi-num { width: 24px; text-align: center; color: var(--muted); font-weight: 700; font-size: .85rem; }
.thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; background: var(--surface-2); flex: none; }
.thumb-pdf { display: grid; place-items: center; color: #fff; background: var(--c-pdf); font-weight: 800; font-size: .8rem; }
.fi-info { flex: 1; min-width: 0; }
.fi-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-meta { color: var(--muted); font-size: .85rem; }
.fi-actions { display: flex; gap: 6px; }
.fi-actions .icon-btn { width: 34px; height: 34px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.results:empty { display: none; }
.results { border: 1px solid color-mix(in srgb, var(--success) 40%, var(--border)); background: color-mix(in srgb, var(--success) 6%, var(--surface)); border-radius: 14px; padding: 16px; }
.result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.result-title { font-weight: 750; color: var(--success); font-size: 1.05rem; }
.result-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; }
.result-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.result-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.ri-name { flex: 1; min-width: 0; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-size { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.good { color: var(--success); font-weight: 700; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary-2), #ec4899); transition: width .2s; }

.thumb-doc { background: #2563eb; }
.doc-preview { max-height: 380px; overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.pp-editor { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: start; }
.pp-stage { text-align: center; }
.pp-canvas { width: 260px; max-width: 100%; height: auto; border-radius: 6px; box-shadow: var(--shadow-lg); cursor: grab; touch-action: none; background: #fff; }
.pp-canvas:active { cursor: grabbing; }
.pp-side { display: flex; flex-direction: column; gap: 14px; }
.pp-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
@media (max-width: 680px) { .pp-editor { grid-template-columns: 1fr; } }

/* crop */
.crop-preview { text-align: center; }
.crop-stage { position: relative; display: inline-block; line-height: 0; box-shadow: var(--shadow-lg); }
.crop-canvas { width: 320px; max-width: 100%; height: auto; }
.crop-box { position: absolute; border: 2px dashed var(--primary); box-shadow: 0 0 0 9999px rgba(15, 23, 42, .45); pointer-events: none; }
.crop-stage { overflow: hidden; }

/* organize */
.org-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.org-grid:empty { display: none; }
.org-card { background: var(--surface-2); border: 2px solid transparent; border-radius: 12px; padding: 10px; text-align: center; cursor: grab; transition: border-color .15s, opacity .15s; }
.org-card.dragging { opacity: .4; }
.org-card.over { border-color: var(--primary); }
.org-thumb { height: 170px; display: grid; place-items: center; overflow: hidden; }
.org-thumb img { max-width: 100%; max-height: 160px; box-shadow: var(--shadow); background: #fff; transition: transform .2s; }
.org-num { font-weight: 700; font-size: .85rem; margin: 6px 0; color: var(--muted); }
.org-btns { display: flex; justify-content: center; gap: 4px; }
.org-btns .icon-btn { width: 30px; height: 30px; font-size: .85rem; }

/* sign */
.sig-creator h3, .sig-placer h3 { margin: 0 0 12px; font-size: 1.1rem; }
.sig-creator > * + *, .sig-placer > * + * { margin-top: 12px; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 4px; gap: 4px; }
.tab { border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 600; padding: 7px 16px; border-radius: 8px; cursor: pointer; }
.tab.active { background: var(--surface); box-shadow: var(--shadow); color: var(--primary); }
.sig-pad { width: 100%; max-width: 600px; aspect-ratio: 3 / 1; height: auto; display: block; background: #fff; border: 2px dashed var(--border); border-radius: 12px; touch-action: none; cursor: crosshair; }
.sig-stage { position: relative; line-height: 0; max-width: 640px; margin: 0 auto; box-shadow: var(--shadow-lg); user-select: none; }
.sig-page { width: 100%; height: auto; }
.sig-box { position: absolute; border: 2px dashed var(--primary); cursor: move; touch-action: none; background: rgba(99, 102, 241, .06); }
.sig-overlay { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.sig-handle { position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; cursor: nwse-resize; }

/* text tools */
textarea { min-height: 220px; resize: vertical; line-height: 1.55; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.output-line { display: flex; gap: 8px; }
.output-line input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.15rem; padding: 14px; letter-spacing: .02em; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter > div { height: 100%; transition: width .2s, background .2s; }
.qr-wrap { display: grid; grid-template-columns: 1fr 280px; gap: 22px; align-items: start; }
.qr-box { display: grid; place-items: center; padding: 22px; border-radius: 14px; border: 1px solid var(--border); min-height: 240px; text-align: center; color: var(--muted); }
.qr-box img, .qr-box canvas { width: 100%; max-width: 236px; height: auto; image-rendering: pixelated; }
.age-big { text-align: center; padding: 18px; border-radius: 14px; background: var(--primary-soft); }
.age-big b { font-size: clamp(1.4rem, 4vw, 2rem); color: var(--primary); }
.preview-img { max-height: 220px; display: block; margin: 0 auto; border-radius: 10px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; min-height: 160px; word-break: break-all; }
@media (max-width: 680px) {
  .qr-wrap { grid-template-columns: 1fr; }
  .tool-box { padding: 16px; border-radius: 16px; }
  .file-item { flex-wrap: wrap; }
  .fi-info { flex-basis: calc(100% - 80px); }
  .fi-actions { margin-left: auto; }
}

/* ================= Content ================= */
.content { margin-top: 48px; }
.content h2 { font-size: 1.5rem; margin: 36px 0 12px; }
.content p, .content li { color: var(--muted); }
.prose p, .prose li { color: var(--text); }
.steps { padding-left: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.steps li { counter-increment: s; position: relative; padding: 14px 16px 14px 58px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--text); }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.faq { display: grid; gap: 10px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 16px; }
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 650; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.faq summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--primary); }
.faq details[open] summary::after { content: "−"; }
.faq summary::-webkit-details-marker { display: none; }
.faq details p { margin: 0 0 14px; }
.related { margin-top: 48px; }
.related h2 { font-size: 1.5rem; }
.ad-slot { margin: 24px 0; min-height: 90px; }

/* ================= Footer ================= */
.site-footer { margin-top: 80px; background: var(--surface); border-top: 1px solid var(--border); padding: 48px 0 24px; font-size: .93rem; }
.footer-grid { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 28px; }
.footer-grid h3 { font-size: .95rem; margin: 0 0 12px; }
.footer-grid a:not(.logo) { display: block; color: var(--muted); padding: 3px 0; }
.footer-brand p { color: var(--muted); margin: 12px 0 0; }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 32px; padding-top: 20px; color: var(--muted); text-align: center; }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-brand { grid-column: 1 / -1; } }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #111827; color: #fff; padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: .2s; z-index: 200; max-width: calc(100% - 32px); font-weight: 550; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
