/* NeuroPDF — design system */
:root {
  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --bg-soft: #eef0f4;
  --text: #16181d;
  --muted: #667085;
  --border: #e4e7ec;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef2ff;
  --ok: #16a34a;
  --err: #dc2626;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px -8px rgba(16,24,40,.10);
  --shadow-lg: 0 12px 40px -8px rgba(16,24,40,.18);
  --radius: 16px;
  --glass: rgba(255,255,255,.72);
}
:root[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-elev: #14171f;
  --bg-soft: #1b1f2a;
  --text: #e7eaf0;
  --muted: #8b93a5;
  --border: #262b38;
  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-soft: #1e2138;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 40px -8px rgba(0,0,0,.6);
  --glass: rgba(20,23,31,.72);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; line-height: 1.55;
  min-height: 100dvh; display: flex; flex-direction: column;
}
main { flex: 1; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.container { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }
.icon { width: 24px; height: 24px; }
.icon-sm { width: 18px; height: 18px; }
.icon-xs { width: 14px; height: 14px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 100; background: var(--bg-elev); padding: .5rem 1rem; border-radius: 8px; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: .55rem; font-size: 1.15rem; letter-spacing: -.02em; }
.brand-name b { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.brand-icon { width: 17px; height: 17px; }
.header-nav { display: flex; align-items: center; gap: .5rem; }
.nav-link { display: inline-flex; align-items: center; gap: .3rem; padding: .45rem .8rem; border-radius: 10px; border: none; background: none; cursor: pointer; color: var(--muted); font-weight: 500; transition: .18s; }
.nav-link:hover { color: var(--text); background: var(--bg-soft); }
.tools-menu { position: relative; }
.tools-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); width: 280px; max-height: 70vh; overflow: auto;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: .4rem; animation: pop .16s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.dropdown-item { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 9px; font-size: .92rem; color: var(--text); transition: .12s; }
.dropdown-item:hover { background: var(--accent-soft); color: var(--accent); }
.theme-toggle { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border); background: var(--bg-elev); border-radius: 10px; cursor: pointer; transition: .18s; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
:root[data-theme="dark"] .tt-moon { display: none; }
:root[data-theme="light"] .tt-sun { display: none; }
.tt-sun, .tt-moon { display: grid; }

/* hero */
.hero { padding: 4.5rem 0 2.5rem; text-align: center; }
.hero-title { font-size: clamp(2rem, 5vw, 3.3rem); line-height: 1.12; letter-spacing: -.03em; font-weight: 800; }
.grad { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { max-width: 620px; margin: 1.1rem auto 0; color: var(--muted); font-size: 1.08rem; }
.hero-badges { display: flex; gap: .6rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; font-weight: 600; color: var(--muted); background: var(--bg-elev); border: 1px solid var(--border); padding: .38rem .8rem; border-radius: 999px; }

/* tool grid */
.tools-section { padding-bottom: 2rem; }
.group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 2.2rem 0 .9rem; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.tool-card {
  position: relative; display: flex; flex-direction: column; gap: .45rem;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
  transition: transform .2s cubic-bezier(.2,.8,.3,1), box-shadow .2s, border-color .2s;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.tool-card:hover .tool-arrow { opacity: 1; transform: translateX(0); }
.tool-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; margin-bottom: .3rem; }
.tool-icon.big { width: 56px; height: 56px; border-radius: 15px; }
.ti-organize { background: #eef2ff; color: #4f46e5; }
.ti-convert { background: #ecfdf5; color: #059669; }
.ti-optimize { background: #fff7ed; color: #ea580c; }
.ti-security { background: #fef2f2; color: #dc2626; }
.ti-edit { background: #f5f3ff; color: #7c3aed; }
:root[data-theme="dark"] .ti-organize { background: #1e2138; color: #818cf8; }
:root[data-theme="dark"] .ti-convert { background: #12271f; color: #34d399; }
:root[data-theme="dark"] .ti-optimize { background: #2b1c10; color: #fb923c; }
:root[data-theme="dark"] .ti-security { background: #2b1416; color: #f87171; }
:root[data-theme="dark"] .ti-edit { background: #241b38; color: #a78bfa; }
.tool-name { font-weight: 700; letter-spacing: -.01em; }
.tool-desc { font-size: .86rem; color: var(--muted); }
.tool-arrow { position: absolute; top: 1.15rem; right: 1.15rem; color: var(--accent); opacity: 0; transform: translateX(-4px); transition: .2s; }

/* why */
.why { padding: 2.5rem 0 4rem; }
.why-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.why-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; }
.why-card h3 { font-size: 1rem; margin-bottom: .4rem; }
.why-card p { font-size: .9rem; color: var(--muted); }

/* tool page */
.tool-page { padding: 2rem 0 4rem; max-width: 860px; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 1.2rem; display: flex; gap: .5rem; }
.crumbs a:hover { color: var(--accent); }
.tool-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.6rem; }
.tool-head h1 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); letter-spacing: -.02em; }
.tool-lead { color: var(--muted); }
.panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.2rem; animation: fadeUp .3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

/* dropzone */
.dropzone {
  border: 2px dashed var(--border); border-radius: 14px; padding: 3rem 1.5rem;
  display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center;
  cursor: pointer; transition: .2s; background: var(--bg-soft);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag {
  border-color: var(--accent); background: var(--accent-soft);
}
.dropzone.drag { transform: scale(1.01); }
.dz-icon { width: 44px; height: 44px; color: var(--accent); }
.dz-title { font-weight: 700; font-size: 1.1rem; }
.dz-sub { color: var(--muted); font-size: .85rem; }
.dz-hint { color: var(--muted); font-size: .8rem; margin-top: .6rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; border: none; border-radius: 11px; padding: .6rem 1.25rem; font-weight: 600; cursor: pointer; transition: .18s; font-size: .95rem; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent); }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-lg { padding: .8rem 1.9rem; font-size: 1.02rem; border-radius: 13px; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* file list */
.file-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.file-item {
  display: flex; align-items: center; gap: .75rem; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 11px; padding: .6rem .85rem;
  animation: fadeUp .25s ease;
}
.file-item.dragging { opacity: .4; }
.file-item .fi-icon { color: var(--accent); flex: none; }
.fi-name { font-size: .92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fi-size { font-size: .78rem; color: var(--muted); }
.fi-grow { flex: 1; min-width: 0; }
.fi-remove { border: none; background: none; color: var(--muted); cursor: pointer; padding: .3rem; border-radius: 7px; display: grid; place-items: center; }
.fi-remove:hover { color: var(--err); background: var(--bg-elev); }
.fi-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); background: #fff; }
.fi-handle { cursor: grab; color: var(--muted); font-size: 1.1rem; user-select: none; padding: 0 .1rem; }

/* options */
.opts { display: flex; flex-direction: column; gap: .8rem; margin: 1.1rem 0; }
.input { border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); border-radius: 10px; padding: .55rem .8rem; font: inherit; width: 100%; max-width: 340px; transition: .15s; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input-xs { width: 64px; max-width: 64px; padding: .3rem .5rem; }
.opt-row { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; font-weight: 600; }
.opt-note { font-size: .82rem; color: var(--muted); }
.opt-radio { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.opt-radio input { margin-top: .3rem; accent-color: var(--accent); }
.opt-radio b { display: block; font-size: .95rem; }
.opt-radio small { color: var(--muted); }
.seg-group { display: flex; gap: .5rem; flex-wrap: wrap; }
.seg { flex: 1; min-width: 130px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: flex; flex-direction: column; gap: .1rem; border: 1.5px solid var(--border); border-radius: 12px; padding: .7rem .9rem; transition: .15s; }
.seg small { color: var(--muted); }
.seg input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.check-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.chk { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; font-size: .92rem; }
.chk input { accent-color: var(--accent); width: 16px; height: 16px; }
.work-hint { color: var(--muted); font-size: .88rem; margin-bottom: .9rem; }

/* organizer */
.organizer-bar { margin-bottom: .6rem; }
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .8rem; margin: .8rem 0 1.2rem; }
.page-cell { position: relative; border: 2px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg-soft); cursor: pointer; transition: .18s; aspect-ratio: 3/4; user-select: none; }
.page-cell canvas, .page-cell img { width: 100%; height: 100%; object-fit: contain; background: #fff; display: block; transition: transform .25s; }
.page-cell .pc-num { position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: .7rem; padding: .1rem .45rem; border-radius: 6px; }
.page-cell:hover { border-color: var(--accent); }
.page-cell.deleted { border-color: var(--err); }
.page-cell.deleted::after { content: ''; position: absolute; inset: 0; background: color-mix(in srgb, var(--err) 30%, transparent); }
.page-cell.deleted .pc-x { display: grid; }
.pc-x { display: none; position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; place-items: center; background: var(--err); color: #fff; border-radius: 8px; font-weight: 700; }
.page-cell.dragging { opacity: .35; }
.page-cell.dragover { border-color: var(--accent); transform: scale(1.03); }
.pc-rot { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; }
.pc-rot button { width: 26px; height: 26px; border: none; border-radius: 7px; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: .85rem; }
.pc-rot button:hover { background: var(--accent); }

/* editor */
.editor-toolbar { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: .45rem; margin-bottom: .8rem; position: sticky; top: 68px; z-index: 5; }
.etool { border: none; background: transparent; padding: .45rem .7rem; border-radius: 8px; cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--muted); transition: .12s; }
.etool:hover { color: var(--text); background: var(--bg-elev); }
.etool.active { background: var(--accent); color: #fff; }
.etool-sep { width: 1px; height: 22px; background: var(--border); margin: 0 .3rem; }
.etool-opt { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--muted); }
.etool-opt input[type=color] { width: 30px; height: 26px; border: none; background: none; cursor: pointer; padding: 0; }
.editor-pages { display: flex; flex-direction: column; gap: 1.2rem; align-items: center; max-height: 75vh; overflow: auto; border: 1px solid var(--border); border-radius: 12px; padding: 1rem; background: var(--bg-soft); }
.ed-page { position: relative; box-shadow: var(--shadow-lg); }
.ed-page canvas.pdf { display: block; background: #fff; }
.ed-overlay { position: absolute; inset: 0; }
.ed-obj { position: absolute; cursor: move; outline: 1.5px dashed transparent; }
.ed-obj:hover, .ed-obj.selected { outline-color: var(--accent); }
.ed-obj .ed-del { position: absolute; top: -12px; right: -12px; width: 22px; height: 22px; border: none; border-radius: 50%; background: var(--err); color: #fff; font-size: .75rem; cursor: pointer; display: none; place-items: center; line-height: 1; }
.ed-obj.selected .ed-del { display: grid; }
.ed-obj[data-type=text] { padding: 2px; white-space: pre; cursor: text; }
.ed-obj .ed-resize { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; background: var(--accent); border-radius: 4px; cursor: nwse-resize; display: none; }
.ed-obj.selected .ed-resize { display: block; }

/* progress */
.progress-wrap { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 2rem 0; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--bg-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-msg { font-weight: 600; }
.progress-track { width: min(420px, 100%); height: 10px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .35s ease; }
.progress-pct { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* result */
.result-ok, .result-err { display: flex; flex-direction: column; align-items: center; gap: .9rem; text-align: center; padding: 1.5rem 0; }
.result-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; animation: popIn .4s cubic-bezier(.2,1.4,.4,1); }
@keyframes popIn { from { transform: scale(.4); opacity: 0; } }
.result-icon.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.result-icon.err { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }
.result-icon .icon { width: 30px; height: 30px; }
.result-extra { color: var(--muted); }
.result-extra b { color: var(--ok); }

/* action bar */
.action-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.4rem; flex-wrap: wrap; }

/* about + footer */
.tool-about { margin-top: 2.5rem; color: var(--muted); font-size: .92rem; }
.tool-about h2 { color: var(--text); font-size: 1.05rem; margin-bottom: .5rem; }
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding: 2.5rem 0 1.5rem; background: var(--bg-elev); }
.footer-inner { display: grid; grid-template-columns: 1.2fr 2fr; gap: 2rem; }
.footer-brand p { color: var(--muted); font-size: .85rem; margin-top: .5rem; max-width: 300px; }
.footer-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .4rem .8rem; align-content: start; }
.footer-links a { font-size: .85rem; color: var(--muted); transition: .12s; }
.footer-links a:hover { color: var(--accent); }
.footer-note { margin-top: 2rem; font-size: .78rem; color: var(--muted); }

@media (max-width: 640px) {
  .footer-inner { grid-template-columns: 1fr; }
  .tool-head { flex-direction: column; align-items: flex-start; }
  .action-bar { flex-direction: column-reverse; align-items: stretch; }
  .action-bar .btn { width: 100%; }
  .hero { padding-top: 3rem; }
  .editor-toolbar { top: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
