/* ═══════════════════════════════════════════════════════════════
   qtool · Design System v1.0
   ─────────────────────────────────────────────────────────────
   Source of truth. Mobile-first. Light + dark via [data-theme].
   Loaded on every page.
   ═══════════════════════════════════════════════════════════════ */

/* ─── FONTS (self-hosted by backend) ───────────────────────────
   Backend serves these from /static/fonts/ (Aeza VPS, no Google CDN).
   Designer-time fallback: system stack via var(--font) when files
   are missing. Production: backend deploys the listed TTFs.
*/
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter/Inter-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter/Inter-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter/Inter-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter/Inter-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter/Inter-ExtraBold.woff2') format('woff2');
  font-weight: 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter/Inter-Black.woff2') format('woff2');
  font-weight: 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/static/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/static/fonts/jetbrains-mono/JetBrainsMono-Medium.ttf') format('truetype');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url('/static/fonts/instrument-serif/InstrumentSerif-Italic.ttf') format('truetype');
  font-weight: 400; font-style: italic; font-display: swap;
}

/* ─── TOKENS ─── */
:root, [data-theme="light"] {
  --bg:           #FAFAF7;
  --bg-soft:      #F2F1ED;
  --bg-card:      #FFFFFF;
  --bg-hover:     #F5F4EF;
  --bg-inverted:  #0A0A0E;

  --fg:           #0A0A0A;
  --fg-muted:     #5E5E5E;
  --fg-subtle:    #999999;
  --fg-inverted:  #FAFAF7;

  --border:       #ECEAE2;
  --border-strong:#D8D6CF;

  --accent:       #FF5B22;
  --accent-soft:  #FFEDE5;
  --accent-fg:    #C24010;
  --success:      #3DAA6D;
  --warning:      #C58A1B;

  --kbd-bg:       #F2F1ED;
  --kbd-fg:       #6B6862;

  --shadow-sm:    0 1px 0 rgba(0,0,0,0.04);
  --shadow-md:    0 16px 40px -8px rgba(0,0,0,0.08);
  --shadow-lg:    0 28px 70px -12px rgba(0,0,0,0.14);
}

[data-theme="dark"] {
  --bg:           #0A0A0E;
  --bg-soft:      #14141A;
  --bg-card:      #16161D;
  --bg-hover:     #1F1F26;
  --bg-inverted:  #FAFAF7;

  --fg:           #F4F4F0;
  --fg-muted:     #9FA0A5;
  --fg-subtle:    #5E5F66;
  --fg-inverted:  #0A0A0E;

  --border:       rgba(255,255,255,0.10);
  --border-strong:rgba(255,255,255,0.18);

  --accent:       #FF6B3D;
  --accent-soft:  rgba(255,107,61,0.14);
  --accent-fg:    #FF9070;
  --success:      #4DC885;

  --kbd-bg:       rgba(255,255,255,0.08);
  --kbd-fg:       #8E8E96;

  --shadow-sm:    0 1px 0 rgba(0,0,0,0.4);
  --shadow-md:    0 16px 40px -8px rgba(0,0,0,0.5);
  --shadow-lg:    0 28px 70px -12px rgba(0,0,0,0.6);
}

:root {
  --font:    'Inter', system-ui, -apple-system, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, Menlo, monospace;
  --serif:   'Instrument Serif', Georgia, serif;
  --radius:  10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --container: 1180px;
  --ease:    cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ─── RESET ─── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-feature-settings: 'cv11', 'ss01';
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background 220ms var(--ease), color 220ms var(--ease);
}
::selection { background: var(--accent); color: #fff; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font: inherit; }

/* ─── LAYOUT ─── */
.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }
@media (min-width: 720px)  { .container { padding: 0 32px; } }

.section { padding: 56px 0; }
@media (min-width: 720px)  { .section { padding: 88px 0; } }
@media (min-width: 1024px) { .section { padding: 112px 0; } }

.section--bordered { border-bottom: 1px solid var(--border); }
.section--soft     { background: var(--bg-soft); }

/* ─── LOGO ─── */
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.04em;
  color: var(--fg);
  line-height: 1;
}
.logo__mark {
  width: 30px; height: 30px;
  background: var(--fg);
  border-radius: 8px;
  display: inline-grid; place-items: center;
  position: relative;
  flex: 0 0 auto;
}
.logo__mark::before {
  content: 'q';
  font-family: var(--font);
  font-size: 18px; font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--bg);
  line-height: 1;
  transform: translateY(-1px);
}
.logo__mark::after {
  content: '';
  position: absolute;
  right: 6px; bottom: 6px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.logo__word { display: inline-flex; align-items: center; }
.logo__word .dot {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 4px;
}
/* Default: wordmark only. .logo--mark = standalone Q-mark (favicon, mobile, og:image) */
.logo .logo__mark { display: none; }
.logo--mark .logo__mark { display: inline-grid; }
.logo--mark .logo__word { display: none; }

/* ─── NAV ─── */
.nav {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav__inner {
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.nav__links { display: none; gap: 4px; }
@media (min-width: 880px) { .nav__links { display: flex; } }
.nav__link {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-muted);
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.nav__link:hover { background: var(--bg-hover); color: var(--fg); }
.nav__link[aria-current="page"] { background: var(--bg-hover); color: var(--fg); }
.nav__actions { display: flex; align-items: center; gap: 8px; }
.nav__burger { display: inline-flex; }
@media (min-width: 880px) { .nav__burger { display: none; } }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 14px; font-weight: 500;
  background: var(--fg); color: var(--bg);
  border: 1px solid var(--fg);
  transition: opacity 120ms var(--ease), transform 60ms var(--ease);
  white-space: nowrap;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: translateY(1px); }
.btn--ghost  { background: transparent; color: var(--fg); border-color: var(--border); }
.btn--ghost:hover { background: var(--bg-hover); border-color: var(--border-strong); opacity: 1; }
.btn--accent { background: var(--accent); color: #FFFFFF; border-color: var(--accent); }
.btn--lg     { padding: 14px 22px; font-size: 15px; border-radius: 11px; }
.btn--sm     { padding: 6px 12px; font-size: 13px; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--fg);
  transition: background 120ms var(--ease), border-color 120ms var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .sun, .icon-btn .moon { display: none; }
[data-theme="light"] .icon-btn .moon { display: block; }
[data-theme="dark"]  .icon-btn .sun  { display: block; }

.kbd {
  display: inline-flex; align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 7px;
  background: var(--kbd-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--kbd-fg);
}

/* ─── TYPE ─── */
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.eyebrow .mark { color: var(--accent); }

.display {
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.98;
  margin: 0;
  color: var(--fg);
  text-wrap: balance;
}
h1.display { font-size: clamp(40px, 7vw, 88px); }
h2.display { font-size: clamp(32px, 5vw, 56px); }
h3.display { font-size: clamp(24px, 3vw, 32px); }
.display .accent { color: var(--accent); }
.display .italic { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--accent); }

.lede {
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.55;
  color: var(--fg-muted);
  max-width: 56ch;
  margin: 0;
  text-wrap: pretty;
}

.prose { max-width: 70ch; }
.prose p { margin: 0 0 1em; font-size: 17px; line-height: 1.65; color: var(--fg); }
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 600; }
.prose em { font-family: var(--serif); font-style: italic; color: var(--accent); }
.prose h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 32px 0 12px; }
.prose h3 { font-size: 20px; font-weight: 600; margin: 28px 0 8px; }
.prose ul, .prose ol { padding-left: 20px; }
.prose li { margin: 6px 0; }
.prose code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-soft); padding: 2px 6px; border-radius: 4px; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-feature-settings: 'tnum' 1, 'lnum' 1; }

/* ─── BADGES & CHIPS ─── */
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--bg-card);
}
.badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 22%, transparent);
}
.badge--accent { color: var(--accent-fg); border-color: var(--accent); background: var(--accent-soft); }
.badge--accent .dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  color: var(--fg);
  transition: all 120ms var(--ease);
}
.chip:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.chip .arrow { color: var(--fg-subtle); }
.chip .target { color: var(--accent); }

.tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}
.tag--hot  { background: var(--accent); color: #fff; }
.tag--soon { background: var(--kbd-bg); color: var(--kbd-fg); }
.tag--beta { background: color-mix(in oklab, var(--success) 18%, transparent); color: var(--success); }

.kind-convert  { background: rgba(60, 130, 246, 0.12); color: #2563EB; }
.kind-process  { background: rgba(255, 91, 34, 0.12); color: var(--accent-fg); }
.kind-utility  { background: rgba(123, 90, 247, 0.12); color: #6E45E2; }
.kind-generate { background: rgba(61, 170, 109, 0.14); color: #1F8348; }
[data-theme="dark"] .kind-convert  { color: #6CA0FF; }
[data-theme="dark"] .kind-utility  { color: #9F84F5; }
[data-theme="dark"] .kind-generate { color: #6DDDA0; }

/* ─── SEARCH (command palette) ─── */
.search { position: relative; max-width: 660px; margin: 0 auto; }
.search__field {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 200ms var(--ease), border-color 200ms var(--ease);
}
.search:focus-within .search__field, .search--open .search__field {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.search__icon { width: 20px; height: 20px; color: var(--fg-subtle); flex: 0 0 auto; }
.search__input {
  flex: 1; border: none; outline: none; background: transparent;
  color: var(--fg); font-size: 17px; font-family: inherit;
}
.search__input::placeholder { color: var(--fg-subtle); }
.search__clear { display: none; color: var(--fg-subtle); padding: 4px; }
.search--has-value .search__clear { display: inline-flex; }

.suggest {
  display: none;
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  text-align: left;
  max-height: 480px;
  overflow: hidden;
  flex-direction: column;
}
.search--open .suggest { display: flex; }
.suggest__head {
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-subtle);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.suggest__head .pill {
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent-fg);
  border-radius: 999px;
}
.suggest__body { flex: 1; overflow-y: auto; padding: 6px; }
.suggest__group + .suggest__group { margin-top: 4px; }
.suggest__group-title {
  padding: 8px 10px 4px;
  font-size: 10px; font-weight: 600;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex; align-items: center; gap: 6px;
}
.suggest__group-title .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
}
.suggest__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--fg);
}
.suggest__item:hover, .suggest__item[aria-selected="true"] { background: var(--bg-hover); }
.suggest__item .ico {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.suggest__item .ico svg { width: 14px; height: 14px; }
.suggest__item .title { flex: 1; font-size: 14px; font-weight: 500; }
.suggest__item .cat { font-size: 12px; color: var(--fg-subtle); }
.suggest__footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-subtle);
}
.suggest__footer .kbd { font-size: 10px; padding: 2px 6px; }
.suggest__empty { padding: 32px 16px; text-align: center; color: var(--fg-subtle); font-size: 14px; }

/* ─── CARDS ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: border-color 120ms var(--ease), transform 160ms var(--ease);
}
.card--hover:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card__title { font-size: 15px; font-weight: 600; flex: 1; }
.card__count { font-family: var(--mono); font-size: 11px; color: var(--fg-subtle); }

/* ─── TOOL CARD (used in lists / category) ─── */
.tool {
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--fg);
  transition: border-color 120ms var(--ease), transform 160ms var(--ease);
}
.tool:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.tool__title {
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.tool__title .arrow { color: var(--fg-subtle); font-weight: 400; }
.tool__title .to { color: var(--accent); }
.tool__meta {
  font-size: 12px; color: var(--fg-muted);
  display: flex; align-items: center; gap: 8px;
}
.tool__tags { display: flex; gap: 6px; margin-top: 4px; }

/* ─── DROPZONE ─── */
.dz {
  background: var(--bg-card);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 40px 28px;
  text-align: center;
  transition: all 160ms var(--ease);
  min-height: 320px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 18px;
}
.dz[data-dragover="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-style: solid;
}
.dz__icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-fg);
}
.dz__icon svg { width: 28px; height: 28px; }
.dz__title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.dz__hint { font-size: 14px; color: var(--fg-muted); }
.dz__meta {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: center;
  margin-top: 8px;
  font-family: var(--mono); font-size: 11px;
  color: var(--fg-subtle);
}
.dz__meta b { color: var(--fg); font-weight: 500; }

/* ─── PROGRESS / FILE ROW (in dropzone) ─── */
.dz[data-state="uploading"], .dz[data-state="ready"], .dz[data-state="processing"],
.dz[data-state="done"], .dz[data-state="failed"] {
  text-align: left; align-items: stretch; justify-content: flex-start;
  border-style: solid;
}

/* ─── PARAMS (per-operation form, inline in dropzone "ready" state) ─── */
.params {
  display: grid; gap: 14px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.params:empty { display: none; }
.param {
  display: grid; gap: 8px;
  font-size: 13px;
}
.param--row {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.param__label {
  font-weight: 500;
  color: var(--fg);
  display: inline-flex; align-items: baseline; gap: 8px;
}
.param__hint {
  font-family: var(--mono); font-size: 11px;
  color: var(--fg-subtle); font-weight: 400;
}
.param__input,
.param__color {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: var(--font); font-size: 14px;
  color: var(--fg);
  transition: border-color 120ms var(--ease);
}
.param__input:focus,
.param__color:focus {
  outline: none;
  border-color: var(--accent);
}
.param__input::placeholder { color: var(--fg-subtle); }
.param__color {
  height: 40px; padding: 4px;
  cursor: pointer;
}
.param__chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.param__chip {
  position: relative; cursor: pointer;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  color: var(--fg);
  transition: all 120ms var(--ease);
}
.param__chip input { position: absolute; opacity: 0; pointer-events: none; }
.param__chip:hover { border-color: var(--fg-muted); }
.param__chip--active,
.param__chip:has(input:checked) {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.param__toggle {
  appearance: none; -webkit-appearance: none;
  width: 40px; height: 24px;
  background: var(--border-strong);
  border-radius: 999px;
  position: relative; cursor: pointer;
  transition: background 120ms var(--ease);
  flex: 0 0 auto;
}
.param__toggle::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: var(--bg-card);
  border-radius: 50%;
  transition: transform 120ms var(--ease);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.param__toggle:checked { background: var(--accent); }
.param__toggle:checked::after { transform: translateX(16px); }
.dz__file {
  display: flex; align-items: center; gap: 14px;
}
.dz__file-ico {
  width: 42px; height: 50px;
  border: 1.5px solid var(--fg);
  border-radius: 6px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--fg); flex: 0 0 auto;
  background: var(--bg-card);
}
.dz__file-name { font-size: 15px; font-weight: 500; word-break: break-word; }
.dz__file-meta { font-family: var(--mono); font-size: 11px; color: var(--fg-muted); margin-top: 2px; }
.progress {
  height: 6px; background: var(--bg-soft); border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress__bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--accent);
  width: 0%;
  transition: width 200ms ease;
  border-radius: 999px;
}
.progress__label {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg-muted);
}

/* ─── TABLE ─── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 14px 16px; text-align: left; vertical-align: top; }
.table thead th {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: var(--bg-hover); }

/* ─── FAQ ─── */
.faq { border-top: 1px solid var(--border); }
.faq__item { border-bottom: 1px solid var(--border); }
.faq__q {
  width: 100%;
  display: flex; align-items: center; gap: 16px;
  padding: 22px 0;
  text-align: left;
  font-size: 18px; font-weight: 600;
  color: var(--fg);
}
.faq__q-toggle {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--fg-subtle);
  margin-left: auto;
  flex: 0 0 auto;
  width: 18px; text-align: center;
}
.faq__a {
  display: none;
  padding: 0 0 24px;
  font-size: 16px; line-height: 1.6;
  color: var(--fg-muted);
  max-width: 70ch;
}
.faq__item[data-open="true"] .faq__a { display: block; }
.faq__item[data-open="true"] .faq__q-toggle::before { content: '−'; }
.faq__item:not([data-open="true"]) .faq__q-toggle::before { content: '+'; }

/* ─── CATEGORY GRID (home) ─── */
.cats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 600px) { .cats { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 920px) { .cats { grid-template-columns: repeat(4, 1fr); } }

.cat-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 120ms var(--ease), transform 160ms var(--ease);
}
.cat-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.cat-card__head { display: flex; align-items: center; gap: 10px; }
.cat-card__ico {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bg-soft);
  display: grid; place-items: center;
  color: var(--fg);
}
.cat-card__ico svg { width: 18px; height: 18px; }
.cat-card__name { font-size: 15px; font-weight: 600; flex: 1; }
.cat-card__count {
  font-family: var(--mono); font-size: 11px;
  color: var(--fg-subtle);
  padding: 2px 7px;
  background: var(--bg-soft);
  border-radius: 4px;
}
.cat-card__list { font-size: 13px; color: var(--fg-muted); line-height: 1.55; }
.cat-card__more {
  margin-top: auto;
  font-size: 13px; font-weight: 600;
  color: var(--accent);
}

/* ─── FOOTER ─── */
.footer {
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  padding: 56px 0 28px;
}
.footer__cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  margin-bottom: 40px;
}
@media (min-width: 720px) { .footer__cols { grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; } }
.footer__brand .lede { margin-top: 14px; font-size: 14px; max-width: 36ch; }
.footer__col h4 {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0 0 16px;
}
.footer__col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.footer__col a { font-size: 14px; color: var(--fg); }
.footer__col a:hover { color: var(--accent); }
.footer__bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 16px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-subtle);
}
.footer__bottom .spacer { flex: 1; }

/* ─── BREADCRUMBS ─── */
.crumbs {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 16px 0;
  flex-wrap: wrap;
}
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { color: var(--fg-subtle); }
.crumbs .current { color: var(--fg); }

/* ─── PRICING CARDS ─── */
.tiers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 720px) { .tiers { grid-template-columns: repeat(3, 1fr); } }
.tiers--5col {
  grid-template-columns: 1fr;
  max-width: 1180px; margin: 0 auto;
}
@media (min-width: 720px)  { .tiers--5col { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .tiers--5col { grid-template-columns: repeat(5, 1fr); gap: 10px; } }
.tier--compact { padding: 22px 20px; gap: 14px; }
.tier--compact .tier__price .v { font-size: 32px; }
.tier--compact .tier__list { gap: 8px; }
.tier--compact .tier__list li { font-size: 13px; }
.tier__badge {
  display: none;
  position: absolute; top: -12px; left: 18px;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 10px;
  background: var(--accent); color: #fff;
  border-radius: 999px;
}
.tier--featured { position: relative; }
.tier--featured .tier__badge { display: inline-block; }
/* Hide the older ::before badge when an explicit .tier__badge is used. */
.tier--featured:has(.tier__badge)::before { content: none; }
.compare td:first-child { font-weight: 500; color: var(--fg); }
.compare td { font-size: 13px; }
@media (max-width: 720px) {
  .compare { min-width: 720px; }
}
.tier {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  display: flex; flex-direction: column; gap: 18px;
}
.tier--featured { border-color: var(--accent); position: relative; }
.tier--featured::before {
  content: 'Популярный';
  position: absolute; top: -12px; left: 22px;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 10px;
  background: var(--accent); color: #fff;
  border-radius: 999px;
}
.tier__name { font-size: 14px; color: var(--fg-muted); }
.tier__price { display: flex; align-items: baseline; gap: 6px; }
.tier__price .v { font-size: 48px; font-weight: 800; letter-spacing: -0.04em; }
.tier__price .u { font-size: 14px; color: var(--fg-muted); }
.tier__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.tier__list li {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 14px; color: var(--fg);
}
.tier__list li::before {
  content: ''; width: 14px; height: 14px;
  margin-top: 4px;
  background: var(--accent-soft);
  border-radius: 50%;
  flex: 0 0 auto;
}

/* ─── MOBILE SHEET ─── */
.sheet {
  display: none;
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  padding: 24px 20px;
  flex-direction: column; gap: 20px;
}
.sheet[data-open="true"] { display: flex; }
.sheet__head { display: flex; justify-content: space-between; align-items: center; }
.sheet a.sheet__link {
  font-size: 24px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--fg);
}

/* ─── DASHBOARD (5 tabs: Overview / Usage / Billing / API Keys / Settings) ─── */
.dash { background: var(--bg); }
.dash__shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 40px;
  padding-top: 32px;
  padding-bottom: 80px;
  align-items: start;
}
.dash__side {
  position: sticky; top: 80px;
  display: flex; flex-direction: column; gap: 20px;
}
.tabs {
  display: flex; flex-direction: column; gap: 2px;
  background: transparent;
}
.tabs__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px; font-weight: 500;
  color: var(--fg-muted);
  transition: all 120ms var(--ease);
}
.tabs__item svg { width: 16px; height: 16px; flex: 0 0 auto; }
.tabs__item:hover { background: var(--bg-soft); color: var(--fg); }
.tabs__item[aria-current="page"] {
  background: var(--fg);
  color: var(--bg);
}
.dash__plan {
  padding: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.dash__main { min-width: 0; }
.dash__pane { display: block; }
.dash__pane[hidden] { display: none; }

.pane__head { margin-bottom: 32px; }
.pane__section { margin-top: 40px; }
.pane__section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.pane__h {
  font-size: 18px; font-weight: 700; letter-spacing: -0.02em;
  margin: 0 0 16px;
}

.stat-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.stat__label {
  font-family: var(--mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 8px;
}
.stat__big {
  font-size: 36px; font-weight: 800; letter-spacing: -0.03em;
  line-height: 1;
}
.stat__sub { font-size: 13px; margin-top: 4px; }
.stat__link {
  display: inline-block; margin-top: 4px;
  color: var(--accent); font-size: 13px; font-weight: 600;
}
.stat .progress { margin-top: 12px; }

/* User menu (details/summary dropdown) */
.user-menu { position: relative; }
.user-menu__trigger {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  background: var(--bg-card);
}
.user-menu__trigger::-webkit-details-marker { display: none; }
.user-menu__trigger::marker { content: ''; }
.user-menu__email { color: var(--fg); }
.user-menu[open] .user-menu__trigger { border-color: var(--border-strong); }
.user-menu__panel {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 40;
}
.user-menu__item {
  display: block; padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px; color: var(--fg);
}
.user-menu__item:hover { background: var(--bg-soft); }
.user-menu__item--danger { color: var(--accent); }
.user-menu__sep { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--fg); color: var(--bg);
  display: inline-grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
}

/* Key-value rows for settings/billing */
.kv { display: grid; gap: 14px; }
.kv__row {
  display: grid; grid-template-columns: 1fr auto;
  gap: 16px; align-items: center;
}
.kv__k { font-size: 14px; font-weight: 500; color: var(--fg); }
.kv__v { font-size: 14px; color: var(--fg-muted); text-align: right; }

/* Segmented control */
.seg {
  display: inline-flex; gap: 0;
  padding: 3px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 12px;
}
.seg__btn {
  padding: 6px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--fg-muted);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: all 120ms var(--ease);
}
.seg__btn:hover { color: var(--fg); }
.seg__btn--active {
  background: var(--bg-card);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

/* Bar chart (decorative — backend can swap for real chart lib) */
.chart { padding: 20px; }
.chart__bars {
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  gap: 3px;
  align-items: end;
  height: 180px;
}
.chart__bars span {
  background: var(--fg);
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  opacity: 0.85;
}
.chart__bars span:nth-last-child(-n+3) { background: var(--accent); }
.chart__axis {
  display: flex; justify-content: space-between;
  margin-top: 12px;
  font-size: 11px;
}

/* Horizontal top-bar list */
.topbar { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.topbar li {
  display: grid;
  grid-template-columns: 160px 1fr 60px;
  gap: 12px; align-items: center;
}
.topbar__name { font-size: 14px; font-weight: 500; }
.topbar__bar {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}
.topbar__bar::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--w, 0%);
  background: var(--fg);
  border-radius: 999px;
}
.topbar__num { text-align: right; font-size: 13px; font-weight: 600; }

/* API key card */
.key { padding: 18px; display: grid; gap: 12px; }
.key__head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; flex-wrap: wrap;
}
.key__value {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  word-break: break-all;
}
.key__meta {
  display: flex; gap: 20px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 11px;
  color: var(--fg-muted);
}

/* Code block */
.code {
  margin: 0;
  padding: 16px 18px;
  background: var(--bg-inverted);
  color: var(--fg-inverted);
  border-radius: var(--radius);
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}
[data-theme="dark"] .code { background: var(--bg-soft); color: var(--fg); }

/* Mobile dashboard: sidebar → top, tabs → horizontal scroll bar */
@media (max-width: 860px) {
  .dash__shell {
    grid-template-columns: 1fr;
    gap: 20px;
    padding-top: 16px;
  }
  .dash__side {
    position: static;
    flex-direction: column-reverse;
  }
  .tabs {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
    margin: 0 -20px;
    padding-left: 20px; padding-right: 20px;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs__item {
    flex: 0 0 auto;
    padding: 8px 14px;
    font-size: 13px;
  }
  .tabs__item span { white-space: nowrap; }
  .dash__plan { display: none; }
  .topbar li { grid-template-columns: 120px 1fr 50px; }
  .user-menu__email { display: none; }
}

/* ─── AUTH (signup / login / forgot / reset / confirm-email) ─── */
.auth {
  min-height: calc(100vh - 64px);
  display: grid; place-items: center;
  padding: 40px 20px 80px;
  background:
    radial-gradient(60% 50% at 20% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%),
    var(--bg);
}
.auth__card {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}
/* .auth__mark — REMOVED 2026-05-14. Brand rule: only one logo per page.
   The squircle q-mark is for miniatures (favicon / OG / app-icon) only,
   never next to the wordmark in nav. Auth cards rely on title + lede. */
.auth__title {
  font-size: 28px; font-weight: 800; letter-spacing: -0.03em;
  margin: 0 0 8px;
}
.auth__lede {
  font-size: 14px; color: var(--fg-muted);
  margin: 0 0 24px;
}
.auth__form {
  display: grid; gap: 16px;
}
.field {
  display: grid; gap: 6px;
}
.field__label {
  font-size: 13px; font-weight: 500;
  color: var(--fg);
}
.field__input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-family: var(--font); font-size: 15px;
  color: var(--fg);
  transition: border-color 120ms var(--ease);
}
.field__input:focus {
  outline: none;
  border-color: var(--accent);
}
.field__hint {
  font-size: 12px; color: var(--fg-muted);
}
.field--pw { position: relative; }
.field--pw .field__toggle-pw {
  position: absolute; right: 10px; top: 32px;
  background: transparent; border: 0;
  font-family: var(--mono); font-size: 11px;
  color: var(--fg-muted);
  cursor: pointer;
}
.check {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; line-height: 1.5;
}
.check input {
  margin-top: 2px;
  accent-color: var(--accent);
}
.check__text { color: var(--fg-muted); }
.check__text a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--border-strong); }
.row-split {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
}
.auth__submit { width: 100%; padding: 13px 16px; font-size: 15px; }
.auth__divider {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 0;
  font-family: var(--mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-subtle);
}
.auth__divider::before, .auth__divider::after {
  content: ''; flex: 1;
  border-top: 1px solid var(--border);
}
.auth__foot {
  text-align: center; margin-top: 24px;
  font-size: 13px; color: var(--fg-muted);
}
.auth__foot a { color: var(--fg); font-weight: 600; }

.notice {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px; line-height: 1.5;
  margin-bottom: 16px;
}
.notice--err {
  background: var(--accent-soft);
  color: var(--accent-fg);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.notice--ok {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
}
.notice--info {
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
}

/* ─── UTIL ─── */
.rule { border: none; border-top: 1px solid var(--border); margin: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.text-center { text-align: center; }
.muted { color: var(--fg-muted); }
.subtle { color: var(--fg-subtle); }

/* ═══════════════════════════════════════════════════════════════════════
   MOTION — keyframes, micro-interactions, accessibility.
   Restraint: short durations (180–540ms), one decisive accent per surface,
   nothing infinite except subtle status pulses.
   Accessibility: a single `prefers-reduced-motion: reduce` block at the
   bottom collapses every animation/transition to ~instant.
   ═══════════════════════════════════════════════════════════════════════ */

@keyframes qt-spin            { to { transform: rotate(360deg); } }
@keyframes qt-pulse-dot       { 0%,100% { box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 22%, transparent); }
                                 50%    { box-shadow: 0 0 0 7px color-mix(in oklab, var(--success) 8%,  transparent); } }
@keyframes qt-stagger-in      { from { opacity: 0; transform: translateY(8px); }
                                 to   { opacity: 1; transform: none; } }
@keyframes qt-fade-in         { from { opacity: 0; } to { opacity: 1; } }
@keyframes qt-progress-shimmer { from { background-position: 0 0; } to { background-position: 40px 0; } }
@keyframes qt-check-draw      { to { stroke-dashoffset: 0; } }
@keyframes qt-glow-pulse      { 0%,100% { opacity: .42; transform: translate(-50%, -50%) scale(1); }
                                 50%    { opacity: .60; transform: translate(-50%, -50%) scale(1.08); } }
@keyframes qt-shake           { 0%,100% { transform: translateX(0); }
                                 20% { transform: translateX(-3px); } 40% { transform: translateX(3px); }
                                 60% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }

/* Live indicator in the hero badge — soft 2.4s pulse */
.badge .dot { animation: qt-pulse-dot 2.4s ease-in-out infinite; }

/* Spinner — used in dropzone "processing" state and any inline loader */
.spinner {
  width: 18px; height: 18px; flex: 0 0 auto;
  border: 2px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: qt-spin 0.9s linear infinite;
  display: inline-block; vertical-align: middle;
}
.spinner--sm { width: 14px; height: 14px; border-width: 1.6px; }
.spinner--lg { width: 28px; height: 28px; border-width: 2.5px; }

/* Progress bar — moving stripes during active states; bar width transitions remain on JS */
.dz[data-state="uploading"] .progress__bar,
.dz[data-state="processing"] .progress__bar {
  background-image: linear-gradient(115deg,
    var(--accent)                                        0   12px,
    color-mix(in srgb, var(--accent) 78%, white)         12px 24px);
  background-size: 40px 100%;
  animation: qt-progress-shimmer 1.1s linear infinite;
}

/* State-block fade-in — re-triggers via .replay class toggled in app.js */
.dz [data-when].replay {
  animation: qt-fade-in 320ms var(--ease) both;
}
.dz[data-state="failed"] [data-when="failed"].replay {
  animation: qt-fade-in 320ms var(--ease) both, qt-shake 360ms ease 320ms 1;
}

/* Checkmark draw — used inside .dz__file-ico on done state */
.check-draw {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
  display: block;
}
.check-draw__ring { stroke-dasharray: 64; stroke-dashoffset: 64;
  animation: qt-check-draw 480ms cubic-bezier(.22,1,.36,1) 80ms forwards; }
.check-draw__tick { stroke-dasharray: 22; stroke-dashoffset: 22;
  animation: qt-check-draw 320ms cubic-bezier(.22,1,.36,1) 360ms forwards; }

/* Params reveal — smooth height + opacity when "ready" expands */
.dz[data-state="ready"] .params { animation: qt-stagger-in 260ms var(--ease) both; }

/* Catalog stagger — cat-card row reveals in sequence on first paint */
.cats .cat-card { animation: qt-stagger-in 420ms cubic-bezier(.22,1,.36,1) both; }
.cats .cat-card:nth-child(1) { animation-delay: 0ms; }
.cats .cat-card:nth-child(2) { animation-delay: 40ms; }
.cats .cat-card:nth-child(3) { animation-delay: 80ms; }
.cats .cat-card:nth-child(4) { animation-delay: 120ms; }
.cats .cat-card:nth-child(5) { animation-delay: 160ms; }
.cats .cat-card:nth-child(6) { animation-delay: 200ms; }
.cats .cat-card:nth-child(7) { animation-delay: 240ms; }

/* Suggest results — soft fade-in per group (re-renders on each search input) */
.suggest__group { animation: qt-fade-in 200ms var(--ease) both; }

/* Hero — single radial accent glow behind H1, slow breathing pulse.
   The hero <header> needs `section--hero` to position it correctly. */
.section--hero { position: relative; overflow: clip; isolation: isolate; }
.section--hero > .container { position: relative; z-index: 1; }
.hero-glow {
  position: absolute; left: 50%; top: 38%;
  width: min(880px, 86vw); aspect-ratio: 1;
  background: radial-gradient(closest-side,
    color-mix(in oklab, var(--accent) 24%, transparent) 0%,
    color-mix(in oklab, var(--accent) 8%,  transparent) 45%,
    transparent 72%);
  transform: translate(-50%, -50%);
  filter: blur(8px);
  pointer-events: none;
  z-index: 0;
  animation: qt-glow-pulse 6.5s ease-in-out infinite;
}

/* ─── DROPDOWNS, SHEETS & TOGGLES ───
   Each surface here previously toggled via `display: none → block` which is
   an instant cut. We override the base rules to always-rendered + opacity +
   transform + visibility, so open/close becomes a real transition. The base
   rules above stay in place (they're the structural shape); these rules win
   purely by appearing later in the stylesheet. */

/* allow animating to/from height: auto (FAQ, generic collapsibles).
   Chrome 129+, Safari 17.5+, Firefox 129+ (all current as of 2026-05). */
:root { interpolate-size: allow-keywords; }

/* Mobile sheet — slide-in from the right + backdrop fade. */
.sheet {
  display: flex;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(6%);
  background: color-mix(in oklab, var(--bg) 96%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  transition:
    opacity     220ms var(--ease),
    visibility  220ms var(--ease),
    transform   320ms cubic-bezier(.22,1,.36,1);
}
.sheet[data-open="true"] {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: none;
}
/* sheet links — staggered slide-in once the sheet is open */
.sheet[data-open="true"] .sheet__link {
  animation: qt-stagger-in 340ms cubic-bezier(.22,1,.36,1) both;
}
.sheet[data-open="true"] .sheet__link:nth-of-type(1) { animation-delay:  60ms; }
.sheet[data-open="true"] .sheet__link:nth-of-type(2) { animation-delay: 100ms; }
.sheet[data-open="true"] .sheet__link:nth-of-type(3) { animation-delay: 140ms; }
.sheet[data-open="true"] .sheet__link:nth-of-type(4) { animation-delay: 180ms; }
.sheet[data-open="true"] .sheet__link:nth-of-type(5) { animation-delay: 220ms; }
.sheet[data-open="true"] .sheet__link:nth-of-type(6) { animation-delay: 260ms; }

/* Burger icon — soft rotate when the sheet opens (cue, not a true morph). */
.nav__burger svg { transition: transform 240ms cubic-bezier(.22,1,.36,1); }
body:has(.sheet[data-open="true"]) .nav__burger svg { transform: rotate(90deg); }

/* Search suggest dropdown — fade + slight Y-slide. */
.suggest {
  display: flex;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transition:
    opacity    160ms var(--ease),
    visibility 160ms var(--ease),
    transform  220ms cubic-bezier(.22,1,.36,1);
}
.search--open .suggest {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: none;
}

/* Dashboard tab panel — fade-and-slide whenever JS un-hides one. */
.dash__pane:not([hidden]) {
  animation: qt-stagger-in 260ms cubic-bezier(.22,1,.36,1) both;
}

/* Pricing seg-control — sliding thumb under the active button.
   Assumes exactly 2 buttons; if a 3rd appears, extend the :has() rule. */
.seg { position: relative; isolation: isolate; }
.seg::before {
  content: ''; position: absolute; z-index: 0;
  top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px);
  background: var(--bg-card);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform 280ms cubic-bezier(.22,1,.36,1);
}
.seg:has(.seg__btn:nth-child(2).seg__btn--active)::before {
  transform: translateX(calc(100% + 0px));
}
.seg__btn { position: relative; z-index: 1; background: transparent !important; box-shadow: none !important; }
.seg__btn--active { color: var(--fg); }

/* Theme toggle — sun/moon cross-fade with rotate + scale.
   Override the earlier `display: none/block` rules: keep both icons in the
   DOM (visibility/opacity does the hiding), then animate between states. */
[data-theme-toggle] { position: relative; }
.icon-btn[data-theme-toggle] .sun,
.icon-btn[data-theme-toggle] .moon {
  display: block;
  position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px;
  transition:
    opacity   220ms var(--ease),
    transform 320ms cubic-bezier(.22,1,.36,1);
}
[data-theme="light"] .icon-btn[data-theme-toggle] .sun   { opacity: 0; transform: rotate( 45deg) scale(.55); }
[data-theme="light"] .icon-btn[data-theme-toggle] .moon  { opacity: 1; transform: rotate(  0deg) scale(1); }
[data-theme="dark"]  .icon-btn[data-theme-toggle] .sun   { opacity: 1; transform: rotate(  0deg) scale(1); }
[data-theme="dark"]  .icon-btn[data-theme-toggle] .moon  { opacity: 0; transform: rotate(-45deg) scale(.55); }

/* FAQ accordion — smooth height + opacity, no max-height hacks.
   Relies on interpolate-size (declared at :root above). */
.faq__a {
  display: block;
  height: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    height  280ms cubic-bezier(.22,1,.36,1),
    padding 240ms var(--ease),
    opacity 200ms var(--ease);
}
.faq__item[data-open="true"] .faq__a {
  height: auto;
  padding: 0 0 24px;
  opacity: 1;
}
.faq__q-toggle { transition: transform 220ms cubic-bezier(.22,1,.36,1), color 160ms var(--ease); }
.faq__item[data-open="true"] .faq__q-toggle { color: var(--accent-fg); transform: rotate(180deg); }

/* Reduced motion — collapses every animation/transition to ~instant
   (≈0ms is more reliable than 0; iteration-count: 1 stops infinite loops) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:        0.001ms !important;
    animation-delay:           0ms      !important;
    animation-iteration-count: 1        !important;
    transition-duration:       0.001ms !important;
    scroll-behavior: auto !important;
  }
  .hero-glow { animation: none; opacity: 0.42; }
  .check-draw__ring, .check-draw__tick { stroke-dashoffset: 0; }
  .badge .dot { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   GLOBAL TOUCH + RESPONSIVE POLISH                                    §15
   ─────────────────────────────────────────────────────────────────────
   Phone-first touch targets (≥44px on `<600px`), tablet-portrait gap
   (768–919px), topbar 2-line reflow, blog headings clamp, demo-only
   chips hidden on phone, auth padding tightened. Appended *after* base
   rules so cascade wins on phone-only overrides.
   ═══════════════════════════════════════════════════════════════════════ */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }

@media (max-width: 600px) {
  /* Touch targets ≥44px on phone (Apple HIG / Material 48dp floor) */
  .btn        { min-height: 44px; padding: 11px 18px; }
  .btn--lg    { min-height: 48px; padding: 14px 22px; }
  .btn--sm    { min-height: 38px; padding: 9px 14px; }
  .icon-btn   { width: 40px; height: 40px; }
  .chip       { min-height: 36px; padding: 8px 14px; }
  .param__chip{ min-height: 38px; padding: 9px 16px; }
  .tabs__item { min-height: 40px; }
  .field__input { padding: 12px 14px; min-height: 44px; }
  .field--pw .field__toggle-pw { top: 38px; min-height: 32px; padding: 4px 8px; }

  /* Dropzone — fit 320–414 viewports without horizontal scroll */
  .dz { padding: 28px 18px; min-height: 260px; gap: 14px; }
  .dz__icon { width: 48px; height: 48px; border-radius: 12px; }
  .dz__icon svg { width: 22px; height: 22px; }
  .dz__title { font-size: 18px; }
  .dz__hint  { font-size: 13px; }
  .dz__meta  { gap: 10px 14px; font-size: 10px; }

  /* Designer-only demo strip under the dropzone — hide for real users */
  .dz > div:last-child:has([data-demo-state]) { display: none; }

  /* Params — chips wrap, inputs comfortable on phone */
  .params { padding: 12px 14px; gap: 12px; }
  .param  { font-size: 14px; }
  .param__input,
  .param__color { padding: 12px 12px; font-size: 15px; }

  /* Auth — narrower cards, smaller display title */
  .auth        { padding: 28px 16px 60px; min-height: calc(100vh - 56px); }
  .auth__card  { padding: 28px 22px; }
  .auth__title { font-size: 24px; }
  .auth__lede  { font-size: 13px; margin-bottom: 20px; }

  /* Dashboard topbar — reflow into 2 lines: name+num row, then bar */
  .topbar li {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name num" "bar bar";
    gap: 6px 12px;
  }
  .topbar__name { grid-area: name; }
  .topbar__num  { grid-area: num; }
  .topbar__bar  { grid-area: bar; }

  /* Hero — H1 shrinks proportionally so 360px viewport doesn't break the line */
  .section--hero { padding-top: 32px; padding-bottom: 16px; }
  h1.display     { font-size: clamp(34px, 9vw, 56px); }

  /* Blog post headings (inline-styled in blog.html — override per element) */
  .section article > h2 { font-size: clamp(22px, 6vw, 28px) !important; line-height: 1.15; }
  .section article > p  { font-size: 15px !important; }

  /* Pricing 5-col card stacks tall on phone; pull padding in */
  .tier--compact { padding: 18px 16px; }

  /* FAQ — smaller question text */
  .faq__q { font-size: 16px; padding: 18px 0; }
  .faq__a { font-size: 15px; }

  /* Crumbs — wrap cleanly */
  .crumbs { font-size: 10px; padding: 12px 0; }
}

/* Tablet portrait — fill the 768–919 gap between phone-2col and laptop-4col */
@media (min-width: 768px) and (max-width: 919px) {
  .cats { grid-template-columns: repeat(3, 1fr); }
  .dash__shell { grid-template-columns: 200px 1fr; gap: 28px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   FILE-DROP / UPLOAD / PROCESSING / DOWNLOAD MICRO-MOTION              §16
   ─────────────────────────────────────────────────────────────────────
   Triggered on a real user dropping/uploading/finishing. Short
   (≤460ms) and self-extinguishing — nothing infinite except the
   subtle download cue and the loading dots.
   ═══════════════════════════════════════════════════════════════════════ */

@keyframes qt-dz-pulse {
  0%, 100% { box-shadow: 0 0 0 0   color-mix(in srgb, var(--accent) 22%, transparent); }
  50%      { box-shadow: 0 0 0 12px color-mix(in srgb, var(--accent) 0%,  transparent); }
}
@keyframes qt-dz-icon-bounce {
  0%   { transform: scale(.7) translateY(6px); opacity: 0; }
  60%  { transform: scale(1.08) translateY(0); opacity: 1; }
  100% { transform: scale(1)    translateY(0); opacity: 1; }
}
@keyframes qt-file-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes qt-dots { to { width: 1.1em; } }
@keyframes qt-download-cue {
  0%, 100% { transform: translateY(0);   box-shadow: 0 0 0 0  color-mix(in srgb, var(--accent) 28%, transparent); }
  50%      { transform: translateY(-1px); box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 0%, transparent); }
}
@keyframes qt-success-burst {
  0%   { transform: scale(.6); opacity: 0; }
  60%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}
@keyframes qt-toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0);    }
}

/* Drag-over: subtle ring breathes outward; icon bounces in once */
.dz[data-dragover="true"] {
  animation: qt-dz-pulse 1.4s ease-in-out infinite;
}
.dz[data-dragover="true"] .dz__icon {
  animation: qt-dz-icon-bounce 320ms cubic-bezier(.22,1,.36,1) both;
}

/* On every state transition the file row slides in (layered with .replay fade) */
.dz [data-when].replay .dz__file {
  animation: qt-file-slide-in 360ms cubic-bezier(.22,1,.36,1) both;
}

/* Animated loading dots — replaces literal "…".
   Markup: <span class="dots-anim" aria-hidden="true"></span>
   Width animation + steps() so the AT tree still reads the surrounding word. */
.dots-anim {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  width: 0;
  animation: qt-dots 1.5s steps(4) infinite;
}
.dots-anim::after { content: '...'; white-space: nowrap; }

/* Done-state download button — soft pulse cue. Stops on hover/focus. */
.dz[data-state="done"] a.btn--accent {
  animation: qt-download-cue 2s ease-in-out infinite;
}
.dz[data-state="done"] a.btn--accent:hover,
.dz[data-state="done"] a.btn--accent:focus-visible {
  animation: none;
}

/* Success icon container bursts in alongside the check-draw stroke */
.dz[data-state="done"] .dz__file-ico {
  animation: qt-success-burst 420ms cubic-bezier(.22,1,.36,1) both;
}

/* Generic toast — used by app.js for "Скачивание началось" etc. */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--bg-inverted); color: var(--fg-inverted);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  z-index: 100;
  transition: opacity 220ms var(--ease), transform 320ms cubic-bezier(.22,1,.36,1);
}
.toast--show {
  opacity: 1; transform: translate(-50%, 0); pointer-events: auto;
}

/* Reduced-motion overrides for the new ones */
@media (prefers-reduced-motion: reduce) {
  .dz[data-dragover="true"],
  .dz[data-dragover="true"] .dz__icon,
  .dz[data-state="done"] a.btn--accent,
  .dz[data-state="done"] .dz__file-ico,
  .dz [data-when].replay .dz__file,
  .dots-anim,
  .toast { animation: none !important; transition-duration: 0.001ms !important; }
  .dots-anim { width: 1.1em; }
}
