/* LipiLens — "ink on paper" visual system */
:root {
  color-scheme: light;
  --paper: #f4efe6;
  --paper-2: #ebe4d6;
  --card: #fffdf8;
  --ink: #1b1a17;
  --ink-2: #4a463e;
  --ink-3: #807a6e;
  --rule: #d9d0bf;
  --accent: #e2482c;
  --accent-ink: #ffffff;
  --accent-soft: #fbe3dc;
  --ok: #2f7d55;
  --ok-soft: #e1f0e7;
  --radius: 14px;
  --shadow: 0 1px 0 var(--rule), 0 12px 30px -18px rgba(27, 26, 23, 0.35);
  --display: 'Fraunces', Georgia, serif;
  --body: 'Inter', 'Hind Siliguri', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--body);
  background-image: radial-gradient(var(--rule) 0.6px, transparent 0.6px); background-size: 22px 22px;
}
a { color: inherit; }
img, svg { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.12; letter-spacing: -0.01em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
p { margin: 0 0 1em; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px;
  border-radius: 999px; border: 1.5px solid var(--ink); font: 600 15px var(--body); text-decoration: none; cursor: pointer;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--ink { background: var(--ink); color: var(--paper); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--card); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 var(--ink); }
.btn--accent:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn--accent:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn--wide { width: 100%; margin-top: 18px; min-height: 54px; font-size: 16px; }
.btn--sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn.is-busy { pointer-events: none; opacity: 0.85; }
.btn.is-busy::before { content: ''; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Top bar ---- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule); }
.topbar__in { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font: 700 20px var(--display); text-decoration: none; }
.logo__mark { width: 30px; height: 30px; }
.topnav { display: flex; align-items: center; gap: 10px; position: relative; }
.menu__toggle { background: none; border: 1.5px solid var(--rule); border-radius: 999px; height: 40px; padding: 0 16px; font: 500 14px var(--body); color: var(--ink); cursor: pointer; }
.menu__toggle:hover, .menu__toggle[aria-expanded='true'] { border-color: var(--ink); }
.topnav__cta { display: none; height: 40px; align-items: center; padding: 0 16px; border-radius: 999px; background: var(--ink); color: var(--paper); text-decoration: none; font: 600 14px var(--body); }
@media (min-width: 640px) { .topnav__cta { display: inline-flex; } }
.menu {
  position: absolute; right: 0; top: 52px; width: min(92vw, 640px); background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: grid; gap: 14px; grid-template-columns: 1fr;
}
.menu[hidden] { display: none; }
@media (min-width: 640px) { .menu { grid-template-columns: repeat(3, 1fr); } }
.menu__title { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin: 0 0 6px; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; text-decoration: none; font-size: 14px; }
.menu a:hover, .menu a.is-active { background: var(--paper-2); }
.glyph { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 7px; background: var(--paper-2); font: 600 11px var(--mono); }

/* ---- Hero ---- */
.hero { padding: 56px 0 40px; }
.hero__grid { display: grid; gap: 40px; align-items: center; }
@media (min-width: 900px) { .hero__grid { grid-template-columns: 1.15fr 0.85fr; } .hero { padding: 88px 0 64px; } }
.eyebrow { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin-bottom: 18px; }
.hero h1 em { font-style: italic; color: var(--accent); }
.lede { font-size: 18px; color: var(--ink-2); max-width: 56ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }

.specimen { position: relative; height: 340px; max-width: 420px; width: 100%; justify-self: center; }
.specimen__paper {
  position: absolute; inset: 0 60px 50px 0; background: var(--card); border: 1px solid var(--rule); border-radius: 6px;
  padding: 34px 28px; box-shadow: var(--shadow); transform: rotate(-3deg); overflow: hidden;
}
.specimen__line { display: block; height: 10px; border-radius: 3px; background: var(--ink); opacity: 0.8; margin-bottom: 16px; }
.w90 { width: 90%; } .w85 { width: 85%; } .w80 { width: 80%; } .w70 { width: 70%; } .w55 { width: 55%; } .w40 { width: 40%; }
.specimen__beam, .drop__beam {
  position: absolute; left: 0; right: 0; height: 46px; top: -46px;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 22%, transparent) 80%, var(--accent));
  animation: scan 3.2s cubic-bezier(.6, 0, .4, 1) infinite;
}
@keyframes scan { 0% { top: -46px; } 60%, 100% { top: 100%; } }
.specimen__out {
  position: absolute; right: 0; bottom: 0; width: 240px; background: var(--ink); color: var(--paper); border-radius: 10px;
  padding: 16px 18px; transform: rotate(2deg); box-shadow: 0 20px 40px -20px rgba(0,0,0,.6); font-size: 14px;
}
.specimen__out .mono { font-size: 11px; color: var(--accent); display: block; margin-bottom: 6px; }
.specimen__out p { margin: 0; font-family: var(--mono); line-height: 1.7; }
@media (prefers-reduced-motion: reduce) { .specimen__beam, .drop__beam { animation: none; display: none; } }

/* ---- Tool shelves ---- */
.shelf { padding: 32px 0; border-top: 1px solid var(--rule); }
.shelf__head { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: baseline; margin-bottom: 20px; }
.shelf__num { font: 500 13px var(--mono); color: var(--accent); }
.shelf__head h2 { margin: 0; }
.shelf__head p { grid-column: 2; margin: 4px 0 0; color: var(--ink-3); }
.cards { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .cards { grid-template-columns: repeat(4, 1fr); } }
.card {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 20px; min-height: 168px; background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--radius); text-decoration: none; transition: transform .18s, box-shadow .18s, border-color .18s;
}
.card:hover { transform: translateY(-3px); box-shadow: 6px 6px 0 var(--ink); border-color: var(--ink); }
.card__glyph { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: var(--ink); color: var(--paper); font: 600 15px var(--mono); margin-bottom: 8px; }
.card:hover .card__glyph { background: var(--accent); }
.card__name { font: 700 18px var(--display); }
.card__desc { color: var(--ink-2); font-size: 14px; }
.card__go { position: absolute; top: 18px; right: 18px; font-size: 18px; color: var(--ink-3); transition: transform .18s, color .18s; }
.card:hover .card__go { transform: translateX(3px); color: var(--accent); }

.how { padding: 48px 16px 24px; border-top: 1px solid var(--rule); }
.steps { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 18px; }
@media (min-width: 760px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps li { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 22px; }
.steps li > span { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--ink); font: 500 14px var(--mono); margin-bottom: 12px; }
.steps h3 { font-size: 19px; margin-bottom: 6px; }
.steps p { color: var(--ink-2); margin: 0; font-size: 15px; }

/* ---- Tool page ---- */
.toolhead { padding: 40px 0 24px; }
.crumbs { font: 12px var(--mono); color: var(--ink-3); margin-bottom: 14px; }
.crumbs a { text-decoration: none; } .crumbs a:hover { color: var(--accent); }
.toolhead h1 { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: clamp(1.9rem, 4.4vw, 3rem); }
.toolhead__glyph { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 13px; background: var(--accent); color: #fff; font: 600 18px var(--mono); transform: rotate(-4deg); }
.toolgrid { display: grid; gap: 28px; padding-bottom: 56px; }
@media (min-width: 980px) { .toolgrid { grid-template-columns: minmax(0, 1fr) 300px; } }
.toolgrid__main { min-width: 0; }
.toolgrid__side { display: flex; flex-direction: column; gap: 16px; }

.tool { background: var(--card); border: 1px solid var(--rule); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); }
@media (min-width: 640px) { .tool { padding: 26px; } }
.drop { position: relative; overflow: hidden; border: 2px dashed var(--rule); border-radius: 16px; background: var(--paper); transition: border-color .15s, background .15s; }
.drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop__inner { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 42px 16px; cursor: pointer; }
.drop__icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 16px; background: var(--ink); color: var(--paper); font: 600 20px var(--mono); margin-bottom: 8px; transition: transform .2s; }
.drop:hover .drop__icon { transform: rotate(-6deg) scale(1.05); }
.drop__title { font: 600 18px var(--body); }
.drop__title u { text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.drop__hint { font: 12px var(--mono); color: var(--ink-3); }
.drop__beam { opacity: 0; }
.drop.is-working .drop__beam { opacity: 1; }

.files { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.files:empty { display: none; }
.files li { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); font-size: 14px; }
.files li[draggable='true'] { cursor: grab; }
.files img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--paper-2); }
.files .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .size { font: 12px var(--mono); color: var(--ink-3); }
.files button { border: 0; background: none; color: var(--ink-3); font-size: 18px; cursor: pointer; padding: 4px 6px; }
.files button:hover { color: var(--accent); }

.options { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field small { font-weight: 400; color: var(--ink-3); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--rule); border-radius: 10px; background: var(--paper);
  color: var(--ink); font: 15px var(--body);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); outline: none; }
.field--range input { padding: 0; min-height: 30px; accent-color: var(--accent); border: 0; background: none; }
.field--range output { font: 500 13px var(--mono); color: var(--accent); margin-left: 6px; }
.field--color input { padding: 4px; height: 44px; cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; align-self: end; min-height: 44px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.segmented { display: inline-flex; gap: 4px; padding: 4px; background: var(--paper-2); border-radius: 999px; margin: 16px 0 0; flex-wrap: wrap; }
.tool--split .segmented { margin-top: 0; margin-bottom: 14px; }
.segmented button { border: 0; background: none; padding: 8px 16px; border-radius: 999px; font: 500 14px var(--body); color: var(--ink-2); cursor: pointer; }
.segmented button.is-on { background: var(--ink); color: var(--paper); }

/* ---- Results ---- */
.result { margin-top: 20px; background: var(--card); border: 1px solid var(--rule); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); animation: rise .3s ease-out; }
@media (min-width: 640px) { .result { padding: 26px; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.result__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.result__title { font: 700 18px var(--display); margin: 0; }
.result__meta { font: 12px var(--mono); color: var(--ink-3); }
.result__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.result textarea { width: 100%; min-height: 220px; padding: 16px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--paper); color: var(--ink); font: 15px/1.7 var(--body); resize: vertical; }
.result + .result { margin-top: 14px; }
.result--error { border-color: var(--accent); background: var(--accent-soft); }
.result--error p { margin: 0; color: var(--ink); }
.compare { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .compare { grid-template-columns: 1fr 1fr; } }
.compare figure { margin: 0; border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; background: var(--paper); }
.compare img { width: 100%; height: 220px; object-fit: contain; background: repeating-conic-gradient(var(--paper-2) 0 25%, var(--paper) 0 50%) 0 0/16px 16px; }
.compare figcaption { display: flex; justify-content: space-between; padding: 8px 12px; font: 12px var(--mono); color: var(--ink-2); }
.saving { display: flex; align-items: center; gap: 14px; margin: 16px 0; padding: 14px 16px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.saving b { font: 700 28px var(--display); }
.saving.is-bigger { background: var(--accent-soft); color: var(--accent); }
.confidence { display: inline-flex; align-items: center; gap: 8px; font: 12px var(--mono); color: var(--ink-3); }
.confidence i { display: block; width: 70px; height: 6px; border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.confidence i::after { content: ''; display: block; height: 100%; width: var(--v); background: var(--ok); }
.progress { height: 4px; border-radius: 2px; background: var(--paper-2); overflow: hidden; margin-top: 14px; }
.progress span { display: block; height: 100%; width: 30%; background: var(--accent); animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

/* ---- QR ---- */
.tool--split { display: grid; gap: 24px; }
@media (min-width: 760px) { .tool--split { grid-template-columns: 1fr 280px; } }
.qr-preview { display: flex; flex-direction: column; gap: 12px; }
.qr-preview__frame { aspect-ratio: 1; display: grid; place-items: center; border: 2px dashed var(--rule); border-radius: 16px; background: var(--paper); padding: 16px; text-align: center; color: var(--ink-3); font-size: 14px; }
.qr-preview__frame img { width: 100%; height: auto; image-rendering: pixelated; }
.qr-preview__actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.qr-data { font-family: var(--mono); word-break: break-all; padding: 16px; background: var(--paper); border: 1.5px solid var(--rule); border-radius: 12px; }

/* ---- Word counter ---- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; margin-bottom: 16px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(6, 1fr); } }
.stats div { background: var(--paper); padding: 14px 10px; text-align: center; }
.stats b { display: block; font: 700 26px var(--display); }
.stats span { font: 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.bigtext { width: 100%; min-height: 260px; padding: 18px; border: 1.5px solid var(--rule); border-radius: 14px; background: var(--paper); color: var(--ink); font: 16px/1.7 var(--body); resize: vertical; }
.bigtext:focus { outline: none; border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chips button { border: 1.5px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 8px 14px; font: 500 13px var(--body); cursor: pointer; }
.chips button:hover { border-color: var(--ink); }
.chips .chip--ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.keywords { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.keywords:empty { display: none; }
.keywords::before { content: 'Top words'; width: 100%; font: 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.keywords span { font: 13px var(--mono); padding: 4px 10px; border-radius: 6px; background: var(--paper-2); }
.keywords b { color: var(--accent); margin-left: 6px; }

/* ---- FAQ & side ---- */
.faq { margin-top: 40px; }
.faq details { border-top: 1px solid var(--rule); padding: 14px 0; }
.faq details:last-child { border-bottom: 1px solid var(--rule); }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; font: 500 18px var(--mono); color: var(--accent); }
.faq details[open] summary::after { content: '–'; }
.faq details p { margin: 10px 0 0; color: var(--ink-2); }
.side-card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px; }
.side-card__title { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-bottom: 10px; }
.side-card a { display: flex; align-items: center; gap: 10px; padding: 8px 0; text-decoration: none; font-size: 15px; border-bottom: 1px solid var(--rule); }
.side-card a:last-child { border-bottom: 0; }
.side-card a:hover { color: var(--accent); }
.side-card--note { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.side-card--note .side-card__title { color: var(--accent); }
.side-card--note p:last-child { margin: 0; font-size: 14px; opacity: .85; }

/* ---- Ads ---- */
.ad { margin: 24px 0; text-align: center; min-height: 90px; }
.ad__label { display: block; font: 10px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-bottom: 4px; }
.ad--placeholder { display: grid; place-items: center; border: 1.5px dashed var(--rule); border-radius: 12px; color: var(--ink-3); font: 12px var(--mono); }
.ad--sidebar { margin: 0; min-height: 250px; }
.ad--home_top { margin-top: 0; }

/* ---- Prose / footer ---- */
.prose { max-width: 760px; padding-bottom: 64px; font-size: 17px; }
.prose h2 { margin-top: 1.6em; font-size: 1.4rem; }
.prose a { color: var(--accent); }
.prose li { margin-bottom: 6px; }
.contact-mail { margin-top: 24px; }
.foot { background: var(--ink); color: var(--paper); margin-top: 40px; padding: 48px 0 24px; }
.foot .logo__mark rect { fill: var(--paper); }
.foot .logo__mark path:not([stroke='var(--accent)']) { stroke: var(--ink); }
.foot__grid { display: grid; gap: 28px; grid-template-columns: 1fr 1fr; }
@media (min-width: 860px) { .foot__grid { grid-template-columns: 1.6fr repeat(4, 1fr); } }
.foot__brand { grid-column: 1 / -1; }
@media (min-width: 860px) { .foot__brand { grid-column: auto; } }
.foot__brand p { opacity: .7; font-size: 14px; margin-top: 12px; max-width: 32ch; }
.foot__title { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 10px; }
.foot__grid a:not(.logo) { display: block; text-decoration: none; opacity: .8; font-size: 14px; padding: 3px 0; }
.foot__grid a:hover { opacity: 1; color: var(--accent); }
.foot__base { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; border-top: 1px solid rgba(255,255,255,.12); margin-top: 36px; padding-top: 18px; font: 12px var(--mono); opacity: .6; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 50; animation: rise .2s; }

/* =========================================================
   v2 — category colours, icon tiles, mega menu, PDF studio
   ========================================================= */
:root {
  --c-extract: #e2482c; --s-extract: #fbe3dc;
  --c-pdf: #b3264f; --s-pdf: #f7dde5;
  --c-image: #1f7a6d; --s-image: #d9eeea;
  --c-utility: #a86a12; --s-utility: #f5e8cf;
}
[data-cat='extract'] { --c: var(--c-extract); --s: var(--s-extract); }
[data-cat='pdf'] { --c: var(--c-pdf); --s: var(--s-pdf); }
[data-cat='image'] { --c: var(--c-image); --s: var(--s-image); }
[data-cat='utility'] { --c: var(--c-utility); --s: var(--s-utility); }

.i { width: 20px; height: 20px; flex: none; }
.tile { display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 11px; background: var(--s, var(--paper-2)); color: var(--c, var(--ink)); transition: transform .2s, background .2s, color .2s; }
.tile--sm { width: 30px; height: 30px; border-radius: 9px; }
.tile--sm .i { width: 17px; height: 17px; }
.tile--lg { width: 48px; height: 48px; border-radius: 13px; margin-bottom: 8px; }
.tile--lg .i { width: 24px; height: 24px; }

/* Top bar */
.topnav { gap: 6px; }
.topnav__link { display: none; padding: 8px 12px; border-radius: 999px; text-decoration: none; font: 500 14px var(--body); color: var(--ink-2); }
.topnav__link:hover { color: var(--ink); background: var(--paper-2); }
@media (min-width: 900px) { .topnav__link { display: inline-flex; } }
.menu__toggle { display: inline-flex; align-items: center; gap: 8px; }
.menu__toggle .i { width: 18px; height: 18px; }
.menu__toggle[aria-expanded='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.topnav__cta { gap: 8px; }
.topnav__cta .i { width: 18px; height: 18px; }

/* Mega menu */
.mega { position: absolute; left: 0; right: 0; top: 100%; padding-top: 10px; }
.mega[hidden] { display: none; }
.mega::before { content: ''; position: fixed; inset: 64px 0 0; background: rgba(27, 26, 23, .28); backdrop-filter: blur(2px); z-index: -1; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.mega__panel {
  position: relative; background: var(--card); border: 1px solid var(--rule); border-radius: 22px; box-shadow: 0 30px 60px -30px rgba(27, 26, 23, .45);
  max-height: calc(100vh - 92px); overflow: auto; animation: drop .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes drop { from { opacity: 0; transform: translateY(-8px) scale(.99); } }
.mega__search { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 10px; padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--rule); color: var(--ink-3); }
.mega__search input { flex: 1; min-width: 0; border: 0; background: none; font: 16px var(--body); color: var(--ink); outline: none; }
.mega__search kbd { font: 12px var(--mono); padding: 2px 8px; border: 1px solid var(--rule); border-radius: 6px; color: var(--ink-3); }
.mega__grid { display: grid; gap: 8px 22px; padding: 18px 16px 8px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .mega__grid { grid-template-columns: 1fr 1fr; padding: 20px 22px 10px; } }
@media (min-width: 1080px) { .mega__grid { grid-template-columns: 1fr 2fr 1fr; } .mega__col--utility { grid-column: 3; } .mega__col--image { grid-column: 1; } }
@media (min-width: 1080px) { .mega__col--extract { grid-column: 1; grid-row: 1; } .mega__col--pdf { grid-column: 2; grid-row: 1 / span 2; } .mega__col--image { grid-row: 2; } .mega__col--utility { grid-row: 1; } }
.mega__col { min-width: 0; margin-bottom: 10px; }
.mega__col[hidden] { display: none; }
.mega__head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px; font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); }
.mega__dot { width: 8px; height: 8px; border-radius: 3px; background: var(--c); }
.mega__count { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--s); color: var(--c); }
.mega__list { display: grid; gap: 2px; }
@media (min-width: 720px) { .mega__col--pdf .mega__list { grid-template-columns: 1fr 1fr; column-gap: 6px; } }
.mi { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; text-decoration: none; transition: background .15s; }
.mi:hover, .mi:focus-visible, .mi.is-active { background: var(--paper); }
.mi:hover .tile, .mi.is-active .tile { background: var(--c); color: #fff; transform: rotate(-5deg); }
.mi__txt { min-width: 0; display: flex; flex-direction: column; }
.mi__txt b { display: flex; align-items: center; gap: 6px; font: 600 14.5px var(--body); }
.mi__txt em { font: 500 9.5px var(--mono); font-style: normal; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: #fff; }
.mi__txt small { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi[hidden] { display: none; }
.mega__empty { padding: 30px 20px; text-align: center; color: var(--ink-3); }
.mega__foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: 14px 22px; border-top: 1px solid var(--rule); background: var(--paper); font: 12px var(--mono); color: var(--ink-3); border-radius: 0 0 22px 22px; }
.mega__foot a { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); text-decoration: none; font-weight: 500; }
.mega__foot a .i { width: 16px; height: 16px; }
.mega__foot a:hover { color: var(--accent); }
@media (max-width: 719px) {
  .mega { position: fixed; top: 64px; padding: 0; }
  .mega .wrap { padding: 0; }
  .mega__panel { border-radius: 0; border-left: 0; border-right: 0; max-height: calc(100vh - 64px); }
  .mega__foot { border-radius: 0; }
}
body.menu-open { overflow: hidden; }

/* Cards & heads with icons */
.card { --c: var(--ink); }
.card:hover .tile { background: var(--c); color: #fff; transform: rotate(-5deg); }
.card__go { display: grid; }
.card__go .i { width: 18px; height: 18px; }
.toolhead__glyph { background: var(--c, var(--accent)); }
.toolhead__glyph .i { width: 28px; height: 28px; }
.drop__icon { background: var(--c, var(--ink)); color: #fff; }
.drop__icon .i { width: 30px; height: 30px; }
.side-card a .tile { margin-right: 2px; }
.side-card a:hover .tile { background: var(--c); color: #fff; }
.foot__grid--5 { grid-template-columns: 1fr 1fr; }
@media (min-width: 860px) { .foot__grid--5 { grid-template-columns: 1.4fr repeat(5, 1fr); } }

/* PDF tools */
.hint { font-size: 13px; color: var(--ink-3); margin: 12px 0 0; }
.field__label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.levels { display: grid; gap: 10px; margin-top: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .levels { grid-template-columns: repeat(3, 1fr); } }
.level input, .pills input, .posgrid input, .sig-fonts input, .sigpad__colors input { position: absolute; opacity: 0; pointer-events: none; }
.level span { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px 16px; border: 1.5px solid var(--rule); border-radius: 14px; background: var(--paper); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.level small { color: var(--ink-3); font-size: 13px; line-height: 1.4; }
.level input:checked + span { border-color: var(--ink); box-shadow: 4px 4px 0 var(--accent); }
.level input:focus-visible + span, .pills input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pills { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; font-size: 13px; color: var(--ink-2); }
.pills > span { margin-right: 4px; font-weight: 500; }
.pills span span, .pills label > span { display: inline-block; padding: 8px 16px; border: 1.5px solid var(--rule); border-radius: 999px; background: var(--paper); cursor: pointer; font-size: 14px; color: var(--ink); }
.pills input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.posgrid-wrap { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.posgrid { display: grid; grid-template-columns: repeat(3, 30px); grid-template-rows: 30px 30px; column-gap: 6px; row-gap: 44px; padding: 8px 10px; border: 1.5px solid var(--rule); border-radius: 8px; background: var(--paper); }
.posgrid span { display: block; width: 30px; height: 30px; border-radius: 6px; border: 1.5px dashed var(--rule); cursor: pointer; }
.posgrid input:checked + span { background: var(--accent); border: 0; }
.wm-preview { position: relative; height: 150px; margin-top: 16px; border: 1px solid var(--rule); border-radius: 12px; background: #fff repeating-linear-gradient(#fff 0 18px, #eee 18px 20px); overflow: hidden; display: grid; place-items: center; }
.wm-preview span { font: 700 34px Helvetica, Arial, sans-serif; white-space: nowrap; transform: rotate(-30deg); }

/* Page thumbnails */
.thumbs { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); margin-top: 18px; }
.thumbs:empty { display: none; }
.thumbs-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; }
.thumbs-bar[hidden] { display: none; }
.thumb { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px 8px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--paper); cursor: pointer; user-select: none; transition: border-color .15s, transform .15s, opacity .15s; }
.thumb__img { display: grid; place-items: center; width: 100%; height: 130px; }
.thumb canvas { max-width: 100%; max-height: 130px; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); background: #fff; transition: transform .25s; }
.thumb__n { font: 12px var(--mono); color: var(--ink-3); }
.thumb.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.thumb.is-selected::after { content: '✓'; position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; }
.thumbs[data-select-style='delete'] .thumb.is-selected canvas { opacity: .35; }
.thumbs[data-select-style='delete'] .thumb.is-selected::after { content: '×'; font-size: 16px; }
.thumb.is-dragging { opacity: .4; }
.thumb.is-over { border-color: var(--ink); transform: scale(1.03); }
.thumb__acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.thumb:hover .thumb__acts, .thumb:focus-within .thumb__acts { opacity: 1; }
@media (hover: none) { .thumb__acts { opacity: 1; } }
.thumb__acts button { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--rule); background: var(--card); color: var(--ink); cursor: pointer; }
.thumb__acts button:hover { background: var(--ink); color: var(--paper); }
.thumb__acts .i { width: 15px; height: 15px; }
.thumbs[data-thumbs='organize'] .thumb { cursor: grab; }

/* Editor */
.editor { margin-top: 0; }
.editor[hidden] { display: none; }
.editor__bar { position: sticky; top: 72px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; background: var(--ink); color: var(--paper); border-radius: 16px; box-shadow: var(--shadow); }
.editor__tools { display: flex; flex-wrap: wrap; gap: 2px; }
.editor__tools button { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; border: 0; border-radius: 10px; background: none; color: inherit; font: 500 13px var(--body); cursor: pointer; opacity: .8; }
.editor__tools button:hover { opacity: 1; background: rgba(255, 255, 255, .08); }
.editor__tools button.is-on { opacity: 1; background: var(--accent); color: #fff; }
.editor__tools .i { width: 18px; height: 18px; }
@media (max-width: 760px) { .editor__tools span { display: none; } }
.editor__props { display: flex; align-items: center; gap: 4px; padding-left: 8px; border-left: 1px solid rgba(255, 255, 255, .15); }
.editor__props input[type=color] { width: 34px; height: 34px; padding: 2px; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.editor__props select, .editor__props button { height: 34px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 8px; background: transparent; color: inherit; font: 13px var(--body); padding: 0 8px; cursor: pointer; }
.editor__props select option { color: #000; }
.editor__props button.is-on { background: var(--paper); color: var(--ink); }
.editor__props button:disabled { opacity: .35; cursor: default; }
.editor__props .i { width: 16px; height: 16px; }
.editor__save { display: flex; gap: 6px; margin-left: auto; }
.editor__save .btn--ghost { color: var(--paper); border-color: rgba(255, 255, 255, .35); }
.editor__save .btn--ghost:hover { background: rgba(255, 255, 255, .08); }
.editor__save .btn--accent { box-shadow: none; }
.editor__hint { margin: 12px 4px; font: 13px var(--mono); color: var(--ink-3); }
.editor__pages { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 18px 0 8px; }
.epage { position: relative; max-width: 100%; box-shadow: 0 4px 24px -8px rgba(0, 0, 0, .35); background: #fff; touch-action: pan-y; }
.epage canvas { display: block; width: 100%; height: auto; }
.epage__layer { position: absolute; inset: 0; }
.epage__n { position: absolute; left: -2px; top: -22px; font: 11px var(--mono); color: var(--ink-3); }
.editor[data-tool='text'] .epage__layer, .editor[data-tool='whiteout'] .epage__layer, .editor[data-tool='highlight'] .epage__layer, .editor[data-tool='sign'] .epage__layer, .editor[data-tool='image'] .epage__layer { cursor: crosshair; }
.el { position: absolute; box-sizing: border-box; outline: 1px dashed transparent; }
.el:hover { outline-color: rgba(226, 72, 44, .55); }
.el.is-sel { outline: 1.5px solid var(--accent); }
.el--text { min-width: 20px; padding: 0; line-height: 1.25; white-space: pre; font-family: Helvetica, Arial, sans-serif; cursor: move; }
.el--text[contenteditable='true'] { cursor: text; outline: 1.5px solid var(--accent); }
.el--rect { cursor: move; }
.el--image { cursor: move; }
.el--image img { width: 100%; height: 100%; display: block; pointer-events: none; }
.el__handle { position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 3px; background: var(--accent); border: 2px solid #fff; cursor: nwse-resize; display: none; }
.el.is-sel .el__handle { display: block; }
.el--text .el__handle { display: none !important; }

/* Signature dialog */
.sigpad { width: min(680px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 20px; background: var(--card); color: var(--ink); box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .6); }
.sigpad::backdrop { background: rgba(27, 26, 23, .5); backdrop-filter: blur(3px); }
.sigpad form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.sigpad header { display: flex; justify-content: space-between; align-items: center; font: 700 20px var(--display); }
.sigpad header button { border: 0; background: none; color: var(--ink-3); cursor: pointer; }
.sigpad .segmented { margin: 0; align-self: flex-start; }
.sigpad canvas { width: 100%; height: auto; aspect-ratio: 64 / 22; border: 1.5px dashed var(--rule); border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; }
.sig-type { width: 100%; height: 52px; padding: 0 14px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--paper); color: var(--ink); font: 18px var(--body); }
.sig-fonts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.sig-fonts span { display: grid; place-items: center; height: 64px; border: 1.5px solid var(--rule); border-radius: 12px; background: #fff; color: #1b1a17; font-size: 26px; cursor: pointer; }
.sig-fonts input:checked + span { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sigpad__colors { display: flex; gap: 8px; }
.sigpad__colors span { display: block; width: 26px; height: 26px; border-radius: 50%; cursor: pointer; box-shadow: 0 0 0 2px var(--card), 0 0 0 3px transparent; }
.sigpad__colors input:checked + span { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }
.sigpad footer { display: flex; justify-content: flex-end; gap: 8px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
/* keep menu text inside its column */
.mi { min-width: 0; }
.mega__list { min-width: 0; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .mega__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .mega__col--pdf .mega__list { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (min-width: 1080px) { .mega__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); } }

/* =========================================================
   v3 — AI tools, blog, how-to, AI category colour
   ========================================================= */
:root { --c-ai: #5b3fd1; --s-ai: #e7e1fb; }
[data-cat='ai'] { --c: var(--c-ai); --s: var(--s-ai); }
.tool--ai { display: flex; flex-direction: column; gap: 16px; }
.tool--ai .btn--wide { margin-top: 4px; }
.tool--ai .btn--wide .i { width: 18px; height: 18px; }
.field--big textarea { min-height: 180px; font-size: 16px; line-height: 1.6; resize: vertical; }
.field--big .counter { font: 12px var(--mono); color: var(--ink-3); text-align: right; }
.field--inline { max-width: 320px; }
.chipset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chipset legend { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.chipset input { position: absolute; opacity: 0; pointer-events: none; }
.chipset span { display: inline-block; padding: 8px 14px; border: 1.5px solid var(--rule); border-radius: 999px; background: var(--paper); font-size: 14px; cursor: pointer; transition: all .15s; }
.chipset span:hover { border-color: var(--ink-3); }
.chipset input:checked + span { background: var(--c-ai); border-color: var(--c-ai); color: #fff; }
.chipset input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ai-note { margin: 0; text-align: center; font: 12px var(--mono); color: var(--ink-3); }
.ai-out { padding: 18px 20px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--paper); line-height: 1.75; max-height: 560px; overflow: auto; }
.ai-out h2, .ai-out h3, .ai-out h4 { font-family: var(--display); margin: 1em 0 .4em; } .ai-out h2 { font-size: 1.5rem; } .ai-out h3 { font-size: 1.2rem; } .ai-out h4 { font-size: 1.05rem; }
.ai-out ul { padding-left: 20px; margin: .4em 0; } .ai-out p { margin: 0; }
.ai-out > p > :first-child { margin-top: 0; }
.segmented--sm { margin: 0; } .segmented--sm button { padding: 6px 12px; font-size: 13px; }

.howto { margin-top: 36px; padding: 22px; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); }
.howto h2 { font-size: 1.35rem; }
.howto ol { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 12px; }
.howto li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; color: var(--ink-2); }
.howto li::before { content: counter(s); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--paper); font: 500 13px var(--mono); }
.prose--tool { max-width: none; padding: 8px 0 0; margin-top: 28px; }
.prose img { max-width: 100%; height: auto; border-radius: 12px; }
.prose code { font-family: var(--mono); font-size: .9em; background: var(--paper-2); padding: 2px 6px; border-radius: 5px; }
.prose blockquote { margin: 1em 0; padding: 4px 18px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.prose table { border-collapse: collapse; width: 100%; } .prose td, .prose th { border: 1px solid var(--rule); padding: 8px; }
.wrap--narrow { max-width: 780px; }
.post-title { font-size: clamp(1.9rem, 4.5vw, 2.9rem); }
.post-meta { font: 13px var(--mono); color: var(--ink-3); }
.posts { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .posts { grid-template-columns: repeat(3, 1fr); } }
.wrap--narrow .posts { grid-template-columns: 1fr; }
.post-card { display: flex; flex-direction: column; gap: 6px; padding: 20px; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); text-decoration: none; transition: transform .18s, box-shadow .18s; }
.post-card:hover { transform: translateY(-3px); box-shadow: 6px 6px 0 var(--ink); }
.post-card b { font: 700 19px/1.25 var(--display); }
.post-card span:last-child { color: var(--ink-2); font-size: 14px; }
.post-card__date { font: 12px var(--mono); color: var(--accent); }
.shelf__head p a { color: var(--accent); }

/* Menu layout with 5 categories */
@media (min-width: 1080px) {
  .mega__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr); }
  .mega__col--extract { grid-column: 1; grid-row: 1; }
  .mega__col--image { grid-column: 1; grid-row: 2; }
  .mega__col--utility { grid-column: 1; grid-row: 3; }
  .mega__col--ai { grid-column: 2; grid-row: 1 / span 3; }
  .mega__col--pdf { grid-column: 3; grid-row: 1 / span 3; }
}

/* v4 — tables in AI output, AI menu column in 2 lists */
.ai-table { overflow-x: auto; margin: 6px 0; }
.ai-table table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--card); }
.ai-table th, .ai-table td { border: 1px solid var(--rule); padding: 7px 10px; text-align: left; white-space: nowrap; }
.ai-table th { background: var(--paper-2); font-weight: 600; }
@media (min-width: 720px) { .mega__col--ai .mega__list { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 6px; } }
@media (min-width: 1080px) {
  .mega__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 2fr); }
}

/* v5 — homepage SEO intro */
.about-home { display: grid; gap: 28px; padding-top: 40px; padding-bottom: 24px; border-top: 1px solid var(--rule); }
@media (min-width: 900px) { .about-home { grid-template-columns: 1.2fr 1fr; } }
.about-home p { color: var(--ink-2); font-size: 16.5px; }
.about-home a { color: var(--accent); }
.faq--home { margin-top: 0; }
