/* ==========================================================================
   Toolshub — midnight red design system
   ========================================================================== */

:root {
  /* Color */
  --ink: #fff5f6;
  --ink-soft: #c5b6bb;
  --paper: #09090c;
  --surface: #131216;
  --line: #30242a;
  --line-strong: #57404a;
  --primary: #ff294f;
  --primary-dark: #ff91a2;
  --primary-tint: #281017;
  --accent: #ff607b;
  --accent-tint: #2d111a;
  --error: #ff8190;
  --error-tint: #35141c;

  /* Type */
  --font-display: "Space Grotesk", "Segoe UI", Arial, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;

  /* Scale */
  --step-1: clamp(0.85rem, 0.82rem + 0.15vw, 0.95rem);
  --step0: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
  --step1: clamp(1.2rem, 1.1rem + 0.5vw, 1.4rem);
  --step2: clamp(1.5rem, 1.3rem + 0.9vw, 1.9rem);
  --step3: clamp(2rem, 1.7rem + 1.6vw, 2.9rem);
  --step4: clamp(2.5rem, 2rem + 2.6vw, 3.8rem);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.4), 0 0 30px rgba(255, 41, 79, 0.07);
  --content-w: 1120px;
  --focus: 3px solid #ff91a2;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: dark; }
select { color-scheme: dark; }
select option { background: var(--surface); color: var(--ink); }
body.is-navigating main { visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  position: relative;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 0, rgba(255, 49, 83, 0.045), transparent 50rem),
    radial-gradient(ellipse at 12% -12%, rgba(255, 34, 73, 0.18), transparent 38rem),
    radial-gradient(ellipse at 96% 34%, rgba(130, 14, 44, 0.13), transparent 34rem),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.15;
  margin: 0 0 0.5em;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--step4); }
.hero h1, .page-header h1 {
  background: linear-gradient(105deg, #fff7f8 5%, #ff8b9c 58%, #ff294f 100%);
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
h2 { font-size: var(--step2); }
h3 { font-size: var(--step1); }
p { margin: 0 0 1em; max-width: 68ch; }
p.lede { font-size: var(--step1); color: var(--ink-soft); max-width: 60ch; }
a { color: #ff9baa; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: #ffd5db; }
ul, ol { max-width: 68ch; }
code, kbd { font-family: var(--font-mono); background: var(--primary-tint); padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.9em; }

:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.75em 1.25em;
  z-index: 1000;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.container {
  width: 100%;
  max-width: var(--content-w);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}

/* ---------- Header / nav ---------- */
.site-header {
  border-bottom: 1px solid rgba(255, 104, 129, 0.18);
  background: rgba(9, 9, 12, 0.96);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 0.9rem;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 30px; height: 30px; flex: none;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: linear-gradient(145deg, #ff607b, #b90831);
  box-shadow: 0 0 18px rgba(255, 41, 79, 0.3), inset 0 1px rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: -0.08em;
}

.nav-links {
  display: flex;
  flex-shrink: 0;
  min-width: fit-content;
  align-items: center;
  gap: 1.6rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: var(--step-1);
  font-weight: 500;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: #ff91a2; }
.nav-links a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }
.nav-dropdown { position: relative; }
.nav-submenu {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: -1rem;
  display: none;
  min-width: 220px;
  margin: 0;
  padding: 0.45rem;
  list-style: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(19, 18, 22, 0.98);
  box-shadow: var(--shadow);
}
.nav-dropdown:hover > .nav-submenu,
.nav-dropdown:focus-within > .nav-submenu { display: block; }
.nav-submenu a { display: block; padding: 0.65rem 0.75rem; border-radius: 4px; }
.nav-submenu a:hover, .nav-submenu a:focus-visible { background: var(--primary-tint); }

.nav-toggle {
  display: none;
  border: 1px solid var(--line-strong);
  background: rgba(19, 18, 22, 0.98);
  border-radius: var(--radius-sm);
  padding: 0.45em 0.6em;
  cursor: pointer;
}
.nav-toggle svg { display: block; width: 20px; height: 20px; }

@media (max-width: 1100px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    position: absolute;
    inset-inline: 0;
    top: 100%;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 0.5rem clamp(1.25rem, 4vw, 2.5rem) 1rem;
    gap: 0;
    display: none;
  }
  .nav-links.is-open { display: flex; }
  .nav-links > li { border-top: 1px solid var(--line); }
  .nav-links > li > a { display: block; min-height: 44px; padding: 0.75em 0.1em; white-space: nowrap; }
  .nav-submenu {
    position: static;
    display: block;
    min-width: 0;
    padding: 0 0 0.5rem 0.9rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .nav-links .nav-submenu a { min-height: 44px; padding: 0.65em 0.1em; font-size: 0.92em; white-space: nowrap; }
}
.nav-links a { white-space: nowrap; }
.nav-toggle { min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }

/* ---------- Calculator tools ---------- */
.calculator-panel {
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid rgba(255, 95, 119, 0.2);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.calculator-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.calculator-panel > .field + .calculator-fields,
.calculator-panel > .calculator-fields + .field { margin-top: 1rem; }
.calculator-panel > .btn { margin-top: 1rem; }
.calculator-panel input, .calculator-panel select {
  width: 100%;
  min-width: 0;
  padding: 0.7em 0.8em;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.calculator-panel select,
.field select,
.typing-controls .field select,
.unit-tool select,
.qr-tool select,
.contact-form select { color-scheme: dark; }
select option { background: var(--surface); color: var(--ink); }
.calculator-panel input:focus, .calculator-panel select:focus { border-color: var(--primary); }
.calculator-result {
  margin-top: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--primary-tint);
}
.calculator-result output { display: block; color: var(--ink); font-family: var(--font-display); font-size: var(--step2); font-weight: 700; overflow-wrap: anywhere; }
.calculator-result p { margin: 0.35rem 0 0; }
.scientific-calculator { max-width: 430px; }
.calculator-display { display: block; width: 100%; margin-bottom: 0.8rem; text-align: right; font-family: var(--font-mono) !important; font-size: 1.5rem !important; }
.scientific-calculator > .calculator-keys { margin-top: 1rem; }
.calculator-keys { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; }
.calculator-keys button {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.calculator-keys button:hover { border-color: var(--primary); background: var(--primary-tint); }
.calculator-keys .key-equals { background: linear-gradient(115deg, #dc2044, #a30d2d); color: #fff; }
.calculator-error { margin: 0.65rem 0 0; color: var(--error); min-height: 1.5em; }

@media (max-width: 600px) {
  .calculator-fields { grid-template-columns: 1fr; }
  .calculator-keys { gap: 0.35rem; }
  .calculator-keys button { min-height: 44px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--step-1);
  padding: 0.75em 1.3em;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn-primary {
  background: linear-gradient(115deg, #dc2044 0%, #cf183c 55%, #a30d2d 100%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 24, 62, 0.2);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}
.btn-primary:hover:not(:disabled) {
  color: #fff;
  filter: saturate(1.15) brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 11px 30px rgba(255, 24, 62, 0.35);
}
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: #ff9baa; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { color: #fff; text-decoration: underline; }
.btn-sm { padding: 0.5em 0.9em; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding-block: clamp(2rem, 5vw, 3.5rem) clamp(1.5rem, 4vw, 2.5rem);
}
.hero::before {
  position: absolute;
  z-index: -1;
  top: 8%;
  left: 22%;
  width: min(60vw, 620px);
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 29, 69, 0.12), transparent 70%);
  content: "";
  pointer-events: none;
}
.hero-grid {
  display: grid;
  gap: 1.25rem;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffb1bd;
  background: linear-gradient(110deg, rgba(255, 41, 79, 0.16), rgba(42, 15, 24, 0.75));
  border: 1px solid rgba(255, 78, 105, 0.22);
  padding: 0.35em 0.8em;
  border-radius: 999px;
  margin-bottom: 1rem;
}
.hero h1 { max-width: 16ch; }
.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  margin-top: 1.25rem;
  font-size: var(--step-1);
  color: var(--ink-soft);
}
.trust-row li { display: flex; align-items: center; gap: 0.5em; list-style: none; }
.trust-row svg { width: 16px; height: 16px; flex: none; color: var(--primary); }
.trust-row ul { padding: 0; margin: 0; display: contents; }

/* ---------- Dropzone / tool ---------- */
.tool-panel {
  background: linear-gradient(145deg, rgba(24, 21, 26, 0.96), rgba(15, 14, 18, 0.98));
  border: 1px solid rgba(255, 95, 119, 0.18);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: clamp(1.1rem, 3vw, 1.75rem);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.tool-panel:focus-within { border-color: rgba(255, 83, 112, 0.45); box-shadow: var(--shadow), 0 0 36px rgba(255, 41, 79, 0.09); }

.dropzone {
  border: 2px dashed #65404b;
  border-radius: 14px;
  padding: clamp(1.75rem, 5vw, 3rem) 1.25rem;
  text-align: center;
  background: linear-gradient(145deg, rgba(255, 41, 79, 0.06), rgba(16, 14, 18, 0.92));
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); background: linear-gradient(145deg, rgba(255, 41, 79, 0.16), rgba(25, 14, 19, 0.95)); }
.dropzone.is-dragover { border-color: var(--primary); background: linear-gradient(145deg, rgba(255, 41, 79, 0.19), rgba(25, 14, 19, 0.96)); }
.dropzone-icon {
  width: 46px; height: 46px;
  margin-inline: auto 0.75rem;
  color: var(--primary);
}
.dropzone p { margin: 0 auto; color: var(--ink-soft); }
.dropzone strong { color: var(--ink); }
.dropzone .btn {
  min-height: 48px;
  margin-block: 1rem 0.5rem;
  padding-inline: 1.6em;
  box-shadow: 0 8px 22px rgba(220, 32, 68, 0.24);
}
.dropzone .btn:hover:not(:disabled) { box-shadow: 0 10px 28px rgba(220, 32, 68, 0.38); }
.dropzone .btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 3px 10px rgba(220, 32, 68, 0.28); }
.dropzone .btn:focus-visible { outline: var(--focus); outline-offset: 4px; }
.dropzone .hint { font-size: var(--step-1); }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.privacy-note {
  display: flex;
  gap: 0.7em;
  align-items: flex-start;
  background: linear-gradient(105deg, rgba(255, 41, 79, 0.13), rgba(25, 15, 19, 0.92));
  border: 1px solid rgba(255, 105, 128, 0.24);
  border-radius: var(--radius-sm);
  padding: 0.8em 1em;
  margin-top: 1rem;
  font-size: var(--step-1);
  color: #ffc0c9;
}
.privacy-note svg { width: 18px; height: 18px; flex: none; margin-top: 0.15em; }

.limits-note {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 0.6rem;
}

/* ---------- Controls ---------- */
.tool-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.control label, .control legend {
  display: block;
  font-weight: 600;
  font-size: var(--step-1);
  margin-bottom: 0.4rem;
  padding: 0;
  border: 0;
}
.control .control-help {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 0.35rem;
}
.control fieldset { border: 0; padding: 0; margin: 0; }

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}
.range-row { display: flex; align-items: center; gap: 0.75rem; }
.range-value {
  font-family: var(--font-mono);
  font-weight: 600;
  min-width: 3.2em;
  text-align: right;
}

.format-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.format-options label {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-weight: 500;
  font-size: var(--step-1);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.55em 0.75em;
  cursor: pointer;
}
.format-options input { accent-color: var(--primary); }
.format-options label:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); }

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ---------- Queue / results ---------- */
.queue {
  margin-top: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.queue-empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 1.5rem 1rem;
  font-size: var(--step-1);
}

.file-row {
  border: 1px solid rgba(255, 101, 126, 0.18);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 0.9rem;
  align-items: center;
  background: var(--surface);
}
.file-row.has-error { border-color: var(--error); background: var(--error-tint); }
.file-thumb {
  width: 52px; height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--paper);
  border: 1px solid var(--line);
}
.file-meta { min-width: 0; }
.file-name {
  font-weight: 600;
  font-size: var(--step-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 0.25rem;
  font-family: var(--font-mono);
}
.file-stats .savings { color: var(--primary-dark); font-weight: 700; }
.file-stats .savings.is-negative { color: var(--error); }
.file-progress {
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  margin-top: 0.5rem;
  overflow: hidden;
}
.file-progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #c90832, #ff7188);
  box-shadow: 0 0 12px rgba(255, 41, 79, 0.45);
  width: 0%;
  transition: width 0.2s ease;
}
.file-status {
  font-size: 0.8rem;
  margin-top: 0.3rem;
  color: var(--ink-soft);
}
.file-status.is-error { color: var(--error); }
.file-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: stretch;
}
.file-actions .btn { white-space: nowrap; }
.file-preview-toggle { font-size: 0.8rem; }

.queue-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  margin-top: 1.5rem;
  padding-top: 1.25rem;
}
.queue-summary .stat { font-size: var(--step-1); color: var(--ink-soft); }
.queue-summary .stat strong { color: var(--ink); font-family: var(--font-mono); }
.queue-summary-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Compare (before/after) panel */
.compare {
  margin-top: 0.75rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.75rem;
  grid-column: 1 / -1;
}
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.compare-cell { text-align: center; }
.compare-cell img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: repeating-conic-gradient(#292329 0% 25%, #17151a 0% 50%) 50% / 16px 16px;
}
.compare-cell figcaption { font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.35rem; }
@media (max-width: 520px) {
  .compare-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .file-row { grid-template-columns: 44px 1fr; }
  .file-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
}

/* Toast / status */
[role="status"].global-status,
[role="alert"].global-status {
  font-size: var(--step-1);
}

/* ---------- Content pages ---------- */
.page-header {
  padding-block: clamp(2rem, 5vw, 3rem) 1rem;
  border-bottom: 1px solid var(--line);
}
.prose { padding-block: clamp(1.5rem, 4vw, 2.5rem); }
.prose h2 { margin-top: 1.8em; }
.prose h2:first-child { margin-top: 0; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25em 0 1.75em;
  font-size: var(--step-1);
}
.prose th, .prose td {
  text-align: left;
  padding: 0.6em 0.8em;
  border: 1px solid var(--line);
  vertical-align: top;
}
.prose th { background: var(--paper); font-family: var(--font-display); }
.callout {
  background: var(--accent-tint);
  border: 1px solid #f0d6a8;
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
}
.callout h3 { margin-top: 0; }
.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.related-links a {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.6em 1em;
  text-decoration: none;
  font-size: var(--step-1);
  font-weight: 500;
}
.related-links a:hover { border-color: var(--primary-dark); }

/* ---------- Contact form ---------- */
.contact-form {
  display: grid;
  gap: 1.1rem;
  max-width: 560px;
  margin-top: 1.5rem;
}
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: var(--step-1);
}
.field input, .field select, .field textarea {
  width: 100%;
  font: inherit;
  padding: 0.65em 0.8em;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field .required { color: var(--error); }
.field-help { font-size: 0.82rem; color: var(--ink-soft); margin-top: 0.3rem; }
.unit-tool {
  max-width: 850px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid rgba(255, 95, 119, 0.2);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.unit-tool h2 { font-size: var(--step1); }
.unit-tool select, .unit-tool input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 0.7em 0.8em;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.unit-tool select:focus, .unit-tool input:focus { border-color: var(--primary); }
.unit-category { max-width: 360px; }
.unit-conversion-grid {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(180px, 1.3fr) auto minmax(180px, 1.3fr);
  align-items: end;
  gap: 0.85rem;
  margin-top: 1rem;
}
.unit-swap {
  min-width: 48px;
  min-height: 48px;
  padding: 0.4em;
  font-size: 1.4rem;
}
.unit-settings {
  display: flex;
  align-items: end;
  gap: 1rem;
  margin-top: 1rem;
}
.unit-settings .field { width: min(180px, 50%); }
.unit-result {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-top: 1.5rem;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--primary-tint);
}
.unit-result-label {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  font-size: var(--step-1);
}
.unit-result output {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--primary-dark);
  font-family: var(--font-display);
  font-size: var(--step2);
  font-weight: 700;
}
.unit-result .btn { grid-column: 2; grid-row: 2; }
.unit-status {
  min-height: 1.5em;
  margin: 0.6rem 0 0;
  color: var(--primary-dark);
  font-size: 0.9rem;
}
.unit-status.is-error { color: var(--error); }
.unit-about { margin-top: 2.5rem; }
.password-tool {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid rgba(255, 95, 119, 0.2);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.password-section { min-width: 0; }
.password-section h2 { font-size: var(--step1); }
.password-section > p { color: var(--ink-soft); font-size: var(--step-1); }
.password-tool .field { margin-top: 1rem; }
.password-tool input[type="password"],
.password-tool input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 0.7em 0.8em;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.password-tool input[readonly] {
  font-family: var(--font-mono);
  font-size: var(--step-1);
}
.password-tool input:focus { border-color: var(--primary); }
.password-length input { width: 100%; accent-color: var(--primary); }
.password-options {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.password-options legend { padding-inline: 0.35rem; font-family: var(--font-display); font-weight: 600; }
.password-options label {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: var(--step-1);
}
.password-options input { margin-top: 0.35em; accent-color: var(--primary); }
.password-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.8rem; }
.password-status {
  min-height: 1.5em;
  margin: 0.5rem 0 0;
  color: var(--primary-dark);
  font-size: 0.9rem;
}
.password-status.is-error { color: var(--error); }
.password-strength {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.password-strength-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  font-size: var(--step-1);
}
.password-strength progress {
  display: block;
  width: 100%;
  height: 0.7rem;
  margin-top: 0.7rem;
  accent-color: var(--primary);
}
.password-strength[data-strength="weak"] progress { accent-color: var(--error); }
.password-strength[data-strength="fair"] progress { accent-color: var(--accent); }
.password-strength[data-strength="good"] progress { accent-color: #789b4a; }
.password-strength[data-strength="strong"] progress,
.password-strength[data-strength="very-strong"] progress { accent-color: var(--primary); }
.password-tips { margin: 0.75rem 0 0; padding-left: 1.25rem; font-size: var(--step-1); }
.password-tips li + li { margin-top: 0.3rem; }
.password-privacy {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: var(--step-1);
}
.document-tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding-block: 2rem;
}
.document-tool-card, .document-tool {
  min-width: 0;
  padding: clamp(1.1rem, 3vw, 1.6rem);
  border: 1px solid rgba(255, 95, 119, 0.2);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.document-tool-card {
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.document-tool-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 78, 106, 0.5);
  box-shadow: var(--shadow), 0 0 28px rgba(255, 41, 79, 0.1);
}
.document-tool-card h2, .document-tool h2 { font-size: var(--step1); }
.document-tool-card p { min-height: 4.8em; color: var(--ink-soft); }
.document-tool-card .btn { margin-top: 0.35rem; text-decoration: none; }
.document-tool { max-width: 780px; margin: 2rem auto; }
.document-tool .field { margin-block: 1rem; }
.document-tool input[type="file"],
.document-tool input[type="text"],
.document-tool input[type="range"] { width: 100%; }
.document-tool input[type="file"] {
  display: block;
  width: 100%;
  padding: 0.55rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
}
.file-selection {
  margin: 0.45rem 0 0;
  color: var(--primary-dark);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}
.document-tool input[type="file"]:hover { border-color: var(--primary-dark); }
.document-tool input[type="file"]:active { border-color: var(--primary); }
.document-tool input[type="file"]:focus-visible { outline: var(--focus); outline-offset: 3px; }
.document-tool input[type="file"]::file-selector-button {
  margin-right: 0.9rem;
  padding: 0.65em 1em;
  border: 1px solid rgba(255, 95, 119, 0.45);
  border-radius: var(--radius-sm);
  background: linear-gradient(115deg, #281017, #3a1420);
  color: #ffb2bf;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.document-tool input[type="file"]::file-selector-button:hover {
  border-color: var(--primary);
  background: var(--primary-tint);
  color: var(--ink);
}
.document-tool input[type="file"]::file-selector-button:active { transform: translateY(1px); }
.document-tool input[type="file"]::file-selector-button:focus-visible { outline: var(--focus); outline-offset: 2px; }
.document-tool input[type="text"] {
  padding: 0.7em 0.8em;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.document-tool input:focus { border-color: var(--primary); }
.document-options {
  display: grid;
  gap: 0.65rem;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.document-options legend { padding-inline: 0.35rem; font-weight: 600; }
.document-options label { display: flex; gap: 0.6rem; align-items: flex-start; }
.document-options input { margin-top: 0.4em; accent-color: var(--primary); }
.document-tool .btn + .btn { margin-left: 0.5rem; }
.document-status {
  min-height: 1.5em;
  margin: 0.7rem 0 0;
  color: var(--primary-dark);
  font-size: var(--step-1);
}
.document-status.is-error { color: var(--error); }
.document-warning {
  margin-top: 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid #f0d6a8;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  font-size: var(--step-1);
}
.document-preview-wrap { padding-block: 1rem; }
.document-preview {
  max-width: 850px;
  margin: 1rem auto;
  padding: clamp(1.5rem, 5vw, 3.2rem);
  border: 1px solid var(--line);
  background: white;
  color: #111;
  box-shadow: var(--shadow);
}
.document-preview img { max-width: 100%; height: auto; }
.document-preview table { width: 100%; border-collapse: collapse; }
.document-preview th, .document-preview td { border: 1px solid #aaa; padding: 0.35rem; }
.document-related { margin-top: 1rem; }
.typing-test {
  max-width: 900px;
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.typing-test > h2 { font-size: var(--step1); }
.typing-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem;
  margin: 1rem 0;
}
.typing-controls .field { min-width: 180px; }
.typing-controls .field select {
  width: 100%;
  font: inherit;
  padding: 0.65em 0.8em;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
.typing-timer {
  margin: 0 0 0.65rem auto;
  color: var(--ink-soft);
}
.typing-timer strong {
  color: var(--primary-dark);
  font-family: var(--font-mono);
  font-size: var(--step2);
}
.typing-prompt {
  min-height: 170px;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: clamp(1rem, 0.94rem + 0.3vw, 1.15rem);
  line-height: 1.9;
  overflow-wrap: anywhere;
}
.typing-prompt .is-correct { color: var(--primary-dark); }
.typing-prompt .is-incorrect {
  color: var(--error);
  background: var(--error-tint);
  border-radius: 2px;
}
.typing-prompt .is-current {
  border-left: 2px solid var(--accent);
  margin-left: -2px;
}
#typing-input {
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  resize: vertical;
  font: 1rem/1.6 var(--font-mono);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
#typing-input:focus { border-color: var(--primary); }
#typing-input:disabled { background: var(--paper); cursor: not-allowed; }
.typing-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}
.typing-stat {
  display: grid;
  gap: 0.2rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.typing-stat span { color: var(--ink-soft); font-size: var(--step-1); }
.typing-stat strong { font-family: var(--font-display); font-size: var(--step1); }
.typing-result {
  margin-top: 1.25rem;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--primary-tint);
}
.typing-result h2 { font-size: var(--step1); }
.typing-result p { margin-bottom: 0.35rem; }
.typing-result .typing-final-speed {
  color: var(--primary-dark);
  font-family: var(--font-display);
  font-size: var(--step2);
}
.typing-final-speed strong { font-size: var(--step3); }
.qr-tool {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.8fr);
  align-items: start;
  gap: clamp(1.5rem, 4vw, 3rem);
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid rgba(255, 95, 119, 0.2);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.qr-tool h2 { font-size: var(--step1); }
.qr-tool form { display: grid; gap: 1rem; }
.qr-fields { display: grid; gap: 1rem; }
.qr-fields[hidden] { display: none; }
.qr-checkbox {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: var(--step-1);
}
.qr-checkbox input { accent-color: var(--primary); }
.optional { color: var(--ink-soft); font-size: 0.85em; font-weight: 400; }
.qr-options {
  min-width: 0;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.qr-options legend { padding-inline: 0.35rem; font-family: var(--font-display); font-weight: 600; }
.qr-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.qr-option-grid .field { min-width: 0; }
.qr-option-grid .field input[type="range"] { width: 100%; accent-color: var(--primary); }
.qr-option-grid .field input[type="color"] {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0.2rem;
  cursor: pointer;
}
.qr-preview-column {
  position: sticky;
  top: 6rem;
  text-align: center;
}
.qr-preview {
  display: grid;
  min-height: 280px;
  place-items: center;
  padding: 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
}
.qr-empty {
  margin: 0;
  color: var(--ink-soft);
}
.qr-preview-image {
  display: block;
  width: min(100%, 320px);
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
}
.qr-output-size {
  margin: 0.6rem 0 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.qr-downloads {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
}
.qr-downloads .btn { width: 100%; }
.qr-reset { margin-top: 0.6rem; }
.qr-status {
  min-height: 1.5em;
  margin: 0.7rem 0 0;
  color: var(--primary-dark);
  font-size: 0.9rem;
}
.qr-status.is-error { color: var(--error); }
.field-error { min-height: 1.35em; margin: 0.35rem 0 0; color: var(--error); font-size: 0.9rem; }
.config-flag {
  border: 1px dashed var(--accent);
  background: var(--accent-tint);
  border-radius: var(--radius-sm);
  padding: 0.8em 1em;
  font-size: var(--step-1);
  margin-top: 1rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid rgba(255, 104, 129, 0.18);
  margin-top: 3rem;
  padding-block: 2rem;
  color: var(--ink-soft);
  font-size: var(--step-1);
}
.footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
.footer-links a { color: var(--ink-soft); text-decoration: none; }
.footer-links a:hover { color: var(--primary-dark); text-decoration: underline; }
.footer-note { margin-top: 1rem; font-size: 0.82rem; }
.footer-credit { margin: 0.35rem 0 0; font-size: 0.82rem; }
.footer-credit span { color: var(--ink); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .btn-primary:hover:not(:disabled), .document-tool-card:hover { transform: none; }
}

@media (max-width: 680px) {
  .unit-conversion-grid { grid-template-columns: 1fr; }
  .unit-swap { justify-self: center; transform: rotate(90deg); }
}

@media (max-width: 520px) {
  .typing-timer { margin-left: 0; }
  .typing-stats { grid-template-columns: 1fr; }
  .qr-option-grid { grid-template-columns: 1fr; }
  .unit-result { grid-template-columns: 1fr; }
  .unit-result-label { grid-column: 1; }
  .unit-result .btn { grid-column: 1; grid-row: auto; justify-self: start; }
  .password-tool { grid-template-columns: 1fr; }
  .password-privacy { grid-column: 1; }
  .document-tool-grid { grid-template-columns: 1fr; }
  .document-tool-card p { min-height: 0; }
  .document-tool .btn + .btn { margin: 0.65rem 0 0; }
}

@media (max-width: 760px) {
  .qr-tool { grid-template-columns: 1fr; }
  .qr-preview-column { position: static; }
}

/* ---------- Ad slot (reserved, never inline with tool controls) ---------- */
.ad-slot {
  min-height: 100px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin-block: 2rem;
}

@media print {
  body.printing-word > * { display: none !important; }
  body.printing-word #main,
  body.printing-word #word-preview-wrap,
  body.printing-word #word-preview { display: block !important; }
  body.printing-word #main > :not(#word-preview-wrap),
  body.printing-word #word-preview-wrap > h2 { display: none !important; }
  body.printing-word #word-preview-wrap { width: 100%; max-width: none; margin: 0; padding: 0; }
  body.printing-word #word-preview {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    color: #000;
  }
}


/* ---------- Performance: defer rendering of below-the-fold sections ---------- */
.prose, .site-footer {
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}
