/* QuickKit — clean, responsive UI */
:root {
  --side: #14293d;
  --side-ink: #c9d6e3;
  --paper: #f2f4f7;
  --card: #ffffff;
  --ink: #16212e;
  --muted: #5b6b7c;
  --line: #d9e0e8;
  --accent: #2457ff;
  --accent-ink: #ffffff;
  --sun: #ffc933;
  --good: #12805c;
  --bad: #c0392b;
  --side-w: 264px;
  --radius: 12px;
  --font-head: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}
h1, h2 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0 0 1rem; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

/* ---------- Icons ---------- */
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.big { width: 40px; height: 40px; color: var(--accent); }

/* ---------- Preloader ---------- */
#preloader {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--side);
  transition: opacity .4s ease, visibility .4s ease;
}
#preloader.done { opacity: 0; visibility: hidden; }
.pre-mark {
  width: 64px; height: 64px; border-radius: 18px; background: var(--sun); color: var(--side);
  display: grid; place-items: center; font: 800 2rem var(--font-head);
}
.pre-bar { width: 140px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.15); overflow: hidden; }
.pre-bar span { display: block; height: 100%; width: 40%; background: var(--sun); border-radius: 4px; animation: slide 1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* ---------- Processing overlay ---------- */
.busy { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; background: rgba(20,41,61,.55); backdrop-filter: blur(2px); }
.busy.hidden { display: none; }
.busy-card { background: var(--card); border-radius: 16px; padding: 28px 32px; width: min(360px, 88vw); text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.busy-card p { margin: 14px 0 0; font-weight: 600; }
.spinner { width: 44px; height: 44px; margin: 0 auto; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { margin-top: 14px; height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 950; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; max-width: 90vw;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; font-size: .95rem;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { background: var(--good); }
.toast.error { background: var(--bad); }
.toast.warn { background: #8a5a00; }

/* ---------- Layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 300;
  background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 20px 14px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font: 800 1.35rem var(--font-head); padding: 4px 8px 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--sun); color: var(--side); display: grid; place-items: center; font-size: 1.15rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--side-ink); text-decoration: none; font-size: .95rem; border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--sun); font-weight: 600; }
.nav-group { margin: 16px 12px 4px; font-size: .78rem; color: #8ea2b6; font-weight: 600; }
.side-note { margin: auto 8px 0; padding-top: 18px; font-size: .82rem; color: #8ea2b6; }

.topbar { display: none; }
.backdrop { display: none; }

.main { margin-left: var(--side-w); padding: 36px clamp(16px, 4vw, 48px) 24px; max-width: calc(var(--side-w) + 980px); outline: none; }
.page { max-width: 900px; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 62ch; margin-bottom: 1.5rem; }

/* ---------- Home ---------- */
.hero { margin: 8px 0 28px; max-width: 720px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); }
.hero p { font-size: 1.1rem; color: var(--muted); max-width: 58ch; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.tile svg.i { color: var(--accent); margin-bottom: 10px; }
.tile h2 { font-size: 1.05rem; margin-bottom: 4px; }
.tile p { color: var(--muted); font-size: .92rem; margin: 0; }
.tile-lg { grid-column: 1 / -1; background: var(--side); border-color: var(--side); color: #fff; padding: 24px; }
.tile-lg svg.i { color: var(--sun); width: 28px; height: 28px; }
.tile-lg h2 { font-size: 1.4rem; }
.tile-lg p { color: var(--side-ink); }

/* ---------- Dropzone ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 200px; padding: 28px 16px; text-align: center; cursor: pointer;
  background: var(--card); border: 2px dashed #9db0c4; border-radius: 16px;
  transition: background .15s, border-color .15s; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.dropzone:hover, .dropzone.dragover { background: #eaf0ff; border-color: var(--accent); }
.dz-title { margin: 8px 0 0; font-weight: 700; font-size: 1.1rem; }
.dz-sub { margin: 0; color: var(--muted); font-size: .92rem; }

/* ---------- Panels & controls ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.panel.controls, .controls { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; }
.controls.inner { padding: 0; width: 100%; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 600; min-width: 150px; flex: 1 1 150px; }
.field output { font-weight: 400; color: var(--muted); margin-left: 6px; }
.panel > .field { margin-bottom: 12px; }
input[type="number"], input[type="text"], select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-weight: 400; background: #fff; color: var(--ink);
}
.textarea { resize: vertical; margin: 6px 0 12px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 48px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.label { font-size: .9rem; font-weight: 600; margin: 0; }
.radio, .checks label { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; margin-top: 8px; }

.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); padding: 11px 20px; border-radius: 10px;
  min-height: 44px; transition: filter .15s;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--paper); filter: none; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
.chip-btn { border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .9rem; }
.chip-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn { background: none; border: 0; color: #fff; padding: 8px; cursor: pointer; border-radius: 8px; }

/* ---------- Results ---------- */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compare figure { margin: 0; }
.compare figcaption { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.frame { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); display: grid; place-items: center; min-height: 160px; background: #fff; }
.frame img { max-width: 100%; max-height: 420px; display: block; }
.checker { background-color: #fff; background-image: linear-gradient(45deg, #e3e8ee 25%, transparent 25%, transparent 75%, #e3e8ee 75%), linear-gradient(45deg, #e3e8ee 25%, transparent 25%, transparent 75%, #e3e8ee 75%); background-size: 18px 18px; background-position: 0 0, 9px 9px; }

.result-list, .file-list { display: flex; flex-direction: column; gap: 10px; }
.result-card { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--paper); flex: none; }
.result-info { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: .88rem; color: var(--muted); }
.result-info strong { color: var(--ink); font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { align-self: flex-start; margin-top: 2px; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.good { background: #d9f3e8; color: var(--good); }
.badge.bad { background: #fbe0dc; color: var(--bad); }
.file-row { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; margin: 0; }
.result-box { margin-top: 16px; padding: 14px; border-radius: 10px; background: var(--paper); }
.result-box p { font-weight: 600; }

/* ---------- Word counter ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat strong { display: block; font: 800 1.6rem var(--font-head); color: var(--accent); }
.stat span { font-size: .85rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; min-height: 30px; }
.chip { background: #e3ebff; color: #163ba8; padding: 4px 12px; border-radius: 999px; font-size: .88rem; }

/* ---------- Password ---------- */
.pw-box { display: flex; gap: 10px; }
.pw-box input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.1rem; }
.meter { height: 8px; border-radius: 8px; background: var(--line); margin: 14px 0 6px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; transition: width .25s, background .25s; }

/* ---------- QR ---------- */
.qr-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.qr-layout .panel { margin: 0; }
.qr-preview { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 260px; }
#qr-canvas { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }

/* ---------- SEO text & footer ---------- */
.seo { margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--line); max-width: 68ch; color: #34435a; }
.footer { margin-top: 56px; color: var(--muted); font-size: .88rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 200;
    background: var(--side); padding: 8px 12px; margin-left: 0;
  }
  .brand-sm { color: #fff; text-decoration: none; font: 800 1.2rem var(--font-head); }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; width: min(80vw, 300px); }
  .sidebar.open { transform: none; box-shadow: 8px 0 30px rgba(0,0,0,.3); }
  .backdrop.show { display: block; position: fixed; inset: 0; z-index: 250; background: rgba(0,0,0,.45); }
  .main { margin-left: 0; padding-top: 22px; }
}
@media (max-width: 640px) {
  .compare, .qr-layout { grid-template-columns: 1fr; }
  .dropzone { min-height: 170px; }
  .result-card { flex-wrap: wrap; }
  .pw-box { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
