@font-face {
  font-family: "Bricolage";
  src: url("vendor/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage";
  src: url("vendor/fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-display: swap; unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #f3f5f8; --surface: #ffffff; --surface-2: #e9edf3; --ink: #1b2430; --muted: #5b6675;
  --line: #d6dce5; --accent: #2f5da8; --accent-ink: #ffffff; --accent-soft: #e3ebf8;
  --hi: #e0a526; --ok: #2e8b57; --danger: #c0392b; --danger-soft: #fbe9e7;
  --radius: 10px; --radius-lg: 16px; --shadow: 0 1px 2px rgba(27,36,48,.06), 0 8px 24px -12px rgba(27,36,48,.18);
  --font: "Bricolage", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #141a22; --surface: #1c2430; --surface-2: #232d3b; --ink: #e8ecf1; --muted: #98a3b3;
  --line: #2d3848; --accent: #7aa3e6; --accent-ink: #0f1620;
  --accent-soft: #22304a; --hi: #e9b949; --ok: #5fbf8a; --danger: #ee7b6c; --danger-soft: #3d2420;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141a22; --surface: #1c2430; --surface-2: #232d3b; --ink: #e8ecf1; --muted: #98a3b3;
    --line: #2d3848; --accent: #7aa3e6; --accent-ink: #0f1620; --accent-soft: #22304a;
    --hi: #e9b949; --ok: #5fbf8a; --danger: #ee7b6c; --danger-soft: #3d2420;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.main:focus { outline: none; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5;
  min-height: 100dvh; display: flex; flex-direction: column;
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
h1, h2, h3 { line-height: 1.15; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--hi); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Chrome */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; max-width: 1080px; width: 100%; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.offline-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); padding: 5px 10px; border-radius: 999px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.icon-btn:hover { background: var(--surface-2); }
.main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 8px 16px 48px; }
.footer { border-top: 1px solid var(--line); padding: 24px 16px 40px; color: var(--muted); font-size: .9rem; }
.footer p { max-width: 68ch; margin: 0 auto; }
.footer-small { font-size: .8rem; margin-top: 8px !important; }

/* Home */
.hero { padding: 28px 0 20px; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 3rem); font-weight: 700; letter-spacing: -0.025em; max-width: 18ch; }
.hero p { color: var(--muted); max-width: 52ch; margin-top: 12px; font-size: 1.05rem; }
.search { position: relative; margin: 20px 0 28px; }
.search input {
  width: 100%; padding: 16px 18px 16px 50px; font-size: 1.1rem; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow);
}
.search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
.search svg { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.cat { margin-bottom: 28px; }
.cat h2 { font-size: 1rem; font-weight: 600; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.cat h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tool-card {
  display: flex; gap: 14px; align-items: flex-start; padding: 14px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s;
}
.tool-card:hover { border-color: var(--accent); }
.tool-card:active { transform: scale(.99); }
.tool-card .ic { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tool-card .ic svg { width: 22px; height: 22px; }
.tool-card strong { display: block; font-weight: 600; }
.tool-card span { display: block; color: var(--muted); font-size: .88rem; line-height: 1.35; margin-top: 2px; }
.empty { color: var(--muted); padding: 24px 0; }

/* Tool page */
.tool-head { display: flex; align-items: flex-start; gap: 14px; padding: 10px 0 20px; }
.back { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; margin-top: 2px; }
.back:hover { background: var(--surface-2); }
.tool-head h1 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); font-weight: 700; letter-spacing: -0.02em; }
.tool-head p { color: var(--muted); margin-top: 4px; max-width: 60ch; }
.tool-body { display: grid; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
.panel h2 { font-size: 1rem; margin-bottom: 12px; }
.panel + .panel { margin-top: 0; }
.two-col { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .two-col.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); } }

/* Controls */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-size: .9rem; font-weight: 600; color: var(--ink); }
.field .hint { font-size: .82rem; color: var(--muted); font-weight: 400; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); min-height: 42px;
}
.input:focus { border-color: var(--accent); outline: none; }
textarea.input { min-height: 140px; resize: vertical; font-family: var(--mono); font-size: .92rem; line-height: 1.5; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 44px; height: 42px; padding: 2px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; min-height: 42px; border-radius: var(--radius);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: .88rem; }
.btn svg { width: 18px; height: 18px; flex: none; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { padding: 8px 14px; border: 0; background: var(--surface); color: var(--muted); font-weight: 600; }
.seg button + button { border-left: 1.5px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* Dropzone */
.drop {
  display: grid; place-items: center; text-align: center; gap: 8px; padding: 28px 16px; border: 2px dashed var(--line); border-radius: var(--radius-lg);
  background: var(--bg); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.drop strong { color: var(--ink); font-weight: 600; }
.drop svg { width: 34px; height: 34px; }
.drop-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

/* Preview */
.checker { background-color: #fff; background-image: linear-gradient(45deg, #d8dde5 25%, transparent 25%), linear-gradient(-45deg, #d8dde5 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d8dde5 75%), linear-gradient(-45deg, transparent 75%, #d8dde5 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.preview { border-radius: var(--radius); border: 1px solid var(--line); min-height: 160px; display: grid; place-items: center; overflow: hidden; }
.preview img, .preview canvas { max-width: 100%; max-height: 420px; display: block; }
.meta { font-size: .85rem; color: var(--muted); }
.result-line { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }

/* Camera */
.cam { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .guide { position: absolute; inset: 12% 8%; border: 2px dashed rgba(255,255,255,.7); border-radius: 8px; pointer-events: none; }
.cam .shutter { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: 64px; height: 64px; border-radius: 50%; border: 4px solid #fff; background: rgba(255,255,255,.25); }
.cam .shutter:hover { background: rgba(255,255,255,.5); }

/* Page thumbnails */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.page {
  position: relative; display: grid; gap: 6px; padding: 8px; border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--surface); cursor: grab; user-select: none;
}
.page.dragging { opacity: .4; }
.page.over { border-color: var(--accent); background: var(--accent-soft); }
.page.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.page canvas, .page img { width: 100%; height: auto; display: block; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.2); background: #fff; }
.page .num { font-size: .8rem; color: var(--muted); text-align: center; }
.page .acts { display: flex; justify-content: center; gap: 4px; }
.page .acts button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.page .acts button:hover { background: var(--surface-2); }
.page .acts button svg { width: 15px; height: 15px; }
.page .badge { position: absolute; top: 4px; left: 4px; background: var(--accent); color: var(--accent-ink); font-size: .7rem; font-weight: 700; padding: 2px 6px; border-radius: 6px; }

/* Lists */
.filelist { display: grid; gap: 8px; }
.fileitem { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.fileitem .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fileitem .size { color: var(--muted); font-size: .85rem; }

/* Password list */
.pw-list { display: grid; gap: 8px; }
.pw { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); }
.pw code { flex: 1; font-family: var(--mono); font-size: 1.05rem; word-break: break-all; }
.strength { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.strength > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .2s; }

/* Misc */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .95rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }
.stat { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius); background: var(--bg); border: 1px solid var(--line); }
.stat b { font-size: 1.4rem; font-weight: 700; } .stat span { font-size: .82rem; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
code.inline { font-family: var(--mono); background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: .9em; }
.swatch { width: 100%; aspect-ratio: 2.2; border-radius: var(--radius); border: 1px solid var(--line); }
.qr-out { display: grid; place-items: center; padding: 16px; background: #fff; border-radius: var(--radius); border: 1px solid var(--line); }
.qr-out svg, .qr-out img { width: min(100%, 320px); height: auto; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 420px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: .95rem; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
