/* FreeToolBox main stylesheet
   Tokens → base → layout → components → pages → tool workspace → utilities */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  --blue-50: #f3f7ff;
  --blue-100: #e6eeff;
  --blue-200: #cddcff;
  --blue-500: #2a7bff;
  --blue-600: #1d5cf2;
  --blue-700: #1749c9;
  --purple-500: #7b4dff;
  --purple-600: #6d3fe0;
  --purple-100: #efe9ff;
  --teal-500: #17c29a;

  --ink: #0e1a3d;
  --ink-2: #24335f;
  --muted: #4a5675;
  --line: #e1e8f7;
  --line-strong: #c9d5ef;
  --surface: #ffffff;
  --surface-alt: #f5f8ff;
  --navy: #0e1a3d;

  --success: #0f7f55;
  --success-bg: #e7f8f0;
  --danger: #c62f3c;
  --danger-bg: #fdecee;
  --warning: #8a5a00;
  --warning-bg: #fff6e0;

  --brand-gradient: linear-gradient(135deg, #1d5cf2 0%, #4b55f0 55%, #6d3fe0 100%);
  --hero-gradient: radial-gradient(80% 60% at 85% 10%, rgba(123, 77, 255, .10), transparent 60%),
                   radial-gradient(70% 70% at 0% 0%, rgba(42, 123, 255, .12), transparent 60%),
                   linear-gradient(180deg, #f3f7ff 0%, #ffffff 100%);

  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-xs: .8125rem;
  --text-sm: .9375rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: clamp(1.875rem, 1.4rem + 1.8vw, 2.5rem);
  --text-hero: clamp(2.25rem, 1.5rem + 3.2vw, 3.75rem);

  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(14, 26, 61, .06), 0 1px 3px rgba(14, 26, 61, .06);
  --shadow: 0 8px 24px -8px rgba(29, 59, 143, .18);
  --shadow-lg: 0 24px 48px -16px rgba(29, 59, 143, .25);

  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --dur-fast: 150ms;
  --dur: 220ms;

  --header-h: 72px;
  --container: 1200px;
  --gutter: 16px;

  --z-header: 40;
  --z-menu: 50;
}

@media (min-width: 768px) {
  :root { --gutter: 24px; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* The hidden attribute always wins over component display rules (grid, flex). */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

h1, h2, h3, h4 {
  margin: 0 0 var(--space-3);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -.01em; }

p { margin: 0 0 var(--space-4); }
img, svg { max-width: 100%; }
img { height: auto; display: block; }

a { color: var(--blue-600); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--blue-700); }

:focus-visible {
  outline: 3px solid var(--blue-500);
  outline-offset: 2px;
  border-radius: 6px;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .1em .35em;
  overflow-wrap: anywhere;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--space-8); }
.section--alt { background: var(--surface-alt); }
@media (min-width: 1024px) {
  .section { padding-block: var(--space-9); }
}

.section-head {
  max-width: 44rem;
  margin: 0 auto var(--space-7);
  text-align: center;
}
.section-head p { color: var(--muted); font-size: var(--text-lg); margin: 0; }
.section-head--left { margin-inline: 0; text-align: start; }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  top: -100px;
  z-index: 100;
  background: var(--ink);
  color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-weight: 700;
}
.skip-link:focus { top: var(--space-3); color: #fff; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) ease, box-shadow var(--dur) ease;
}
.site-header.is-scrolled { border-bottom-color: var(--line); box-shadow: var(--shadow-sm); }

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -.02em;
  flex: none;
}
.brand img { width: 40px; height: 40px; }
.brand-name span { color: var(--blue-600); }
.brand:hover { color: var(--ink); }

.main-nav { margin-inline-start: auto; }
.nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-list a {
  display: inline-flex;
  white-space: nowrap;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}
.nav-list a:hover { color: var(--blue-600); background: var(--blue-50); }
/* Short section names, used only when the full names don't fit (main.js adds .is-short). */
.nav-short { display: none; }
.site-header.is-short .nav-full { display: none; }
.site-header.is-short .nav-short { display: inline; }
.site-header.is-short .nav-list a { padding: 0 var(--space-2); }
.nav-list a[aria-current] {
  color: var(--blue-600);
  box-shadow: inset 0 -3px 0 var(--blue-600);
  border-radius: 0;
}

.menu-toggle {
  display: none;
  margin-inline-start: auto;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}
.menu-toggle .icon { width: 24px; height: 24px; }
.menu-toggle .icon-close { display: none; }
.menu-toggle[aria-expanded="true"] .icon-open { display: none; }
.menu-toggle[aria-expanded="true"] .icon-close { display: block; }

@media (max-width: 1080px) {
  .menu-toggle { display: inline-flex; }
  .main-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    z-index: var(--z-menu);
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    padding: var(--space-3) var(--gutter) var(--space-5);
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    display: none;
  }
  .main-nav.is-open { display: block; }
  .nav-list { flex-direction: column; align-items: stretch; gap: 0; }
  .nav-list a { width: 100%; min-height: 52px; font-size: var(--text-base); border-bottom: 1px solid var(--line); border-radius: 0; }
  .nav-list li:last-child a { border-bottom: 0; }
  .nav-list a[aria-current] { box-shadow: inset 4px 0 0 var(--blue-600); padding-inline-start: var(--space-4); }
  [dir="rtl"] .nav-list a[aria-current] { box-shadow: inset -4px 0 0 var(--blue-600); }
}
/* Same layout when a long translation doesn't fit on one line (main.js adds .is-compact). */
.site-header.is-compact .menu-toggle { display: inline-flex; }
.site-header.is-compact .main-nav {
  position: fixed;
  inset: var(--header-h) 0 auto 0;
  z-index: var(--z-menu);
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--gutter) var(--space-5);
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  display: none;
}
.site-header.is-compact .main-nav.is-open { display: block; }
.site-header.is-compact .nav-list { flex-direction: column; align-items: stretch; gap: 0; }
.site-header.is-compact .nav-list a { width: 100%; min-height: 52px; font-size: var(--text-base); border-bottom: 1px solid var(--line); border-radius: 0; }
.site-header.is-compact .nav-list li:last-child a { border-bottom: 0; }
.site-header.is-compact .nav-list a[aria-current] { box-shadow: inset 4px 0 0 var(--blue-600); padding-inline-start: var(--space-4); }
[dir="rtl"] .site-header.is-compact .nav-list a[aria-current] { box-shadow: inset -4px 0 0 var(--blue-600); }

/* ---------- Language menu ---------- */
.lang-menu { position: relative; flex: none; }
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink-2);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  list-style: none;
}
.lang-toggle::-webkit-details-marker { display: none; }
.lang-toggle:hover { border-color: var(--blue-600); color: var(--blue-600); }
.lang-toggle .icon { width: 18px; height: 18px; }
.lang-toggle .lang-chevron { width: 14px; height: 14px; transition: transform var(--dur-fast) ease; }
.lang-menu[open] .lang-chevron { transform: rotate(180deg); }
/* Centred under the button, with every language name centred, so mixed left-to-right and
   right-to-left names line up in one straight column. */
.lang-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-menu);
  min-width: max(100%, 150px);
  margin: 0;
  padding: var(--space-2);
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.lang-list a {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 44px;
  padding: 0 var(--space-3);
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 600;
  text-decoration: none;
}
.lang-list a:hover { background: var(--blue-50); color: var(--blue-600); }
.lang-list a[aria-current] { color: var(--blue-600); background: var(--blue-50); }
@media (max-width: 1080px) {
  .lang-menu { order: 2; margin-inline-start: auto; }
  .menu-toggle { order: 3; margin-inline-start: 0; }
  .header-inner { gap: var(--space-3); }
}
.site-header.is-compact .lang-menu { order: 2; margin-inline-start: auto; }
.site-header.is-compact .menu-toggle { order: 3; margin-inline-start: 0; }
.site-header.is-compact .header-inner { gap: var(--space-3); }
@media (max-width: 480px) {
  .lang-toggle { padding: 0; width: 44px; justify-content: center; }
  .lang-toggle .lang-current, .lang-toggle .lang-chevron { display: none; }
  .brand { font-size: 1.15rem; }
  .brand img { width: 34px; height: 34px; }
}

/* ---------- Other languages ---------- */
:root:lang(ur), :root:lang(ar) {
  --font: "Plus Jakarta Sans", "Noto Naskh Arabic", ui-sans-serif, system-ui, Tahoma, sans-serif;
}
/* Arabic script reads smaller than Latin at the same size. */
html:is(:lang(ur), :lang(ar)) { font-size: 106.25%; }
/* Plus Jakarta Sans has no Cyrillic letters. */
:root:lang(ru) {
  --font: "Noto Sans", ui-sans-serif, system-ui, sans-serif;
}
:root:lang(hi) {
  --font: "Plus Jakarta Sans", "Noto Sans Devanagari", ui-sans-serif, system-ui, sans-serif;
}
/* Tight tracking breaks joined Arabic letters and Devanagari conjuncts. */
:root:is(:lang(ur), :lang(ar), :lang(hi)) :is(h1, h2, h3, .brand, .calc-value, .hero h1) { letter-spacing: 0; }
:root:is(:lang(ur), :lang(ar)) :is(h1, h2, h3) { line-height: 1.45; }
:root:is(:lang(ur), :lang(ar)) .hero h1 { line-height: 1.35; }
[dir="rtl"] .select { background-position: left .8rem center; }
/* Brand name, code and email fields stay left-to-right inside right-to-left pages. */
[dir="rtl"] .brand-name, [dir="rtl"] code, [dir="rtl"] pre, [dir="rtl"] input[type="email"] { direction: ltr; unicode-bidi: isolate; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: #fff;
  --btn-fg: var(--ink);
  --btn-border: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 48px;
  padding: 0 1.4rem;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 700;
  font-size: var(--text-base);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, box-shadow var(--dur) ease, transform var(--dur-fast) ease;
}
.btn:hover { color: var(--btn-fg); border-color: var(--blue-600); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; }

.btn-primary {
  --btn-bg: var(--blue-600);
  --btn-fg: #fff;
  --btn-border: var(--blue-600);
  box-shadow: 0 8px 20px -8px rgba(29, 92, 242, .6);
}
.btn-primary:hover:not(:disabled) { --btn-bg: var(--blue-700); --btn-border: var(--blue-700); color: #fff; }

.btn-success {
  --btn-bg: var(--success);
  --btn-fg: #fff;
  --btn-border: var(--success);
  box-shadow: 0 8px 20px -8px rgba(15, 127, 85, .55);
}
.btn-success:hover:not(:disabled) { --btn-bg: #0b6a46; --btn-border: #0b6a46; color: #fff; }

.btn-danger { --btn-fg: var(--danger); --btn-border: #f1c4c9; }
.btn-danger:hover { --btn-bg: var(--danger-bg); border-color: var(--danger); }

.btn-sm { min-height: 40px; padding: 0 1rem; font-size: var(--text-sm); }
.btn-lg { min-height: 56px; padding: 0 1.8rem; font-size: var(--text-lg); }
.btn-block { width: 100%; }
/* Long labels (e.g. in Urdu) wrap instead of pushing the page sideways on small phones. */
.btn-block, .result-actions .btn { white-space: normal; text-align: center; line-height: 1.2; max-width: 100%; }
@media (max-width: 380px) {
  .btn-lg { padding: 0 1.1rem; }
  .btn { white-space: normal; text-align: center; line-height: 1.2; max-width: 100%; }
}

.btn-icon {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .icon { display: none; }

.spinner {
  width: 1.1em;
  height: 1.1em;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Hero ---------- */
.hero {
  background: var(--hero-gradient);
  padding-block: var(--space-7) var(--space-8);
  overflow: hidden;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  align-items: center;
}
@media (min-width: 960px) {
  .hero { padding-block: var(--space-8); }
  .hero-grid { grid-template-columns: 1.05fr 1fr; gap: var(--space-7); }
}

.hero h1 {
  font-size: var(--text-hero);
  line-height: 1.08;
  letter-spacing: -.035em;
  margin-bottom: var(--space-4);
}
.hero h1 .accent { color: var(--blue-600); }
/* Plus Jakarta Sans gives the full stop wide side bearings; tuck it in at display sizes. */
.hero h1 .stop { margin-inline-start: -.1em; }
.hero-lead {
  font-size: var(--text-lg);
  color: var(--muted);
  max-width: 34rem;
  margin-bottom: var(--space-5);
}
.hero-art { position: relative; justify-self: center; width: 100%; max-width: 560px; }
.hero-art img { width: 100%; }
/* Clickable area over the drop zone drawn in hero-illustration.svg (viewBox 560 × 440, zone at 166,146 244×140). */
.hero-art-link {
  position: absolute;
  left: 29.64%;
  top: 33.18%;
  width: 43.57%;
  height: 31.82%;
  border-radius: 12px;
  transition: background-color .2s ease, box-shadow .2s ease;
}
.hero-art-link:hover { background-color: rgb(29 92 242 / .06); box-shadow: 0 0 0 2px rgb(29 92 242 / .35); }

.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  list-style: none;
  margin: var(--space-5) 0 0;
  padding: 0;
}
.trust-row li {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-2);
}
.trust-row .icon { color: var(--blue-600); width: 22px; height: 22px; }

/* ---------- Tool search ---------- */
.tool-search { position: relative; max-width: 36rem; }
.search-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: #fff;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 6px;
  padding-inline-start: var(--space-4);
  box-shadow: var(--shadow);
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur) ease;
}
.search-field:focus-within { border-color: var(--blue-600); box-shadow: 0 0 0 4px rgba(29, 92, 242, .15), var(--shadow); }
.search-field > .icon { color: var(--muted); width: 22px; height: 22px; }
.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--text-base);
  min-height: 44px;
}
.search-field input::placeholder { color: #7b86a3; }
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
.search-field .btn { min-height: 44px; padding-inline: 1.2rem; }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  list-style: none;
  margin: 0;
  max-height: 22rem;
  overflow-y: auto;
}
.search-results[hidden] { display: none; }
.search-results a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  min-height: 52px;
}
.search-results a:hover, .search-results a:focus-visible { background: var(--blue-50); }
.search-results small { display: block; color: var(--muted); font-weight: 400; font-size: var(--text-xs); line-height: 1.4; }
.search-results .tool-icon { width: 36px; height: 36px; border-radius: 10px; }
.search-results .tool-icon .icon { width: 18px; height: 18px; }
.search-empty { padding: var(--space-3); color: var(--muted); font-size: var(--text-sm); margin: 0; }

/* ---------- Tool icon tiles ---------- */
.tool-icon {
  --tone-a: #2a7bff;
  --tone-b: #1d5cf2;
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--tone-a), var(--tone-b));
  color: #fff;
  box-shadow: 0 8px 16px -8px var(--tone-b);
  flex: none;
}
.tool-icon .icon { width: 26px; height: 26px; stroke-width: 2.2; }
.tool-icon--lg { width: 72px; height: 72px; border-radius: 20px; }
.tool-icon--lg .icon { width: 36px; height: 36px; }

.tone-blue   { --tone-a: #3a9bff; --tone-b: #1d5cf2; }
.tone-purple { --tone-a: #8b6cff; --tone-b: #6d3fe0; }
.tone-violet { --tone-a: #a77bff; --tone-b: #7d3fe0; }
.tone-indigo { --tone-a: #6f7dff; --tone-b: #4338ca; }
.tone-green  { --tone-a: #3bd68a; --tone-b: #0f9a5f; }
.tone-teal   { --tone-a: #2bd4c0; --tone-b: #0b8f8a; }
.tone-orange { --tone-a: #ffa24c; --tone-b: #f06a1d; }
.tone-amber  { --tone-a: #ffc94a; --tone-b: #e08a00; }
.tone-red    { --tone-a: #ff6b6b; --tone-b: #e5384a; }
.tone-rose   { --tone-a: #ff6f9c; --tone-b: #d6336c; }
.tone-sky    { --tone-a: #4fc3ff; --tone-b: #0e8ad6; }
.tone-pink   { --tone-a: #f78bd8; --tone-b: #c2389b; }

/* ---------- Tool cards ---------- */
.tool-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}
/* Homepage grids: fixed column counts by width, and cards marked data-hide="…" are hidden at those counts so rows are always full. */
.tool-grid-wrap { container: tools / inline-size; }
@container tools (width < 516px) {
  .tool-grid--fill > [data-hide~="1"] { display: none; }
}
@container tools (516px <= width < 782px) {
  .tool-grid--fill { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-grid--fill > [data-hide~="2"] { display: none; }
}
@container tools (782px <= width < 1048px) {
  .tool-grid--fill { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tool-grid--fill > [data-hide~="3"] { display: none; }
}
@container tools (width >= 1048px) {
  .tool-grid--fill { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tool-grid--fill > [data-hide~="4"] { display: none; }
}
.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  height: 100%;
  padding: var(--space-5);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: border-color var(--dur) ease, box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.tool-card:hover { border-color: var(--blue-200); box-shadow: var(--shadow); transform: translateY(-2px); }
.tool-card:focus-within { border-color: var(--blue-600); }
.tool-card h3 { margin: var(--space-1) 0 0; font-size: var(--text-lg); }
.tool-card h3 a { color: var(--ink); text-decoration: none; }
.tool-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.tool-card h3 a:focus-visible { outline: none; }
.tool-card:has(a:focus-visible) { outline: 3px solid var(--blue-500); outline-offset: 2px; }
.tool-card p { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.tool-card .badge { align-self: flex-start; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .65rem;
  border-radius: var(--radius-pill);
  background: var(--blue-50);
  color: var(--blue-700);
  font-size: var(--text-xs);
  font-weight: 700;
}
.badge--purple { background: var(--purple-100); color: var(--purple-600); }

.more-link { text-align: center; margin-top: var(--space-6); display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); }

/* ---------- Steps ---------- */
.steps {
  display: grid;
  gap: var(--space-5);
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}
@media (min-width: 768px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
}
.step {
  position: relative;
  padding: var(--space-6) var(--space-5) var(--space-5);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  counter-increment: step;
}
.step::before {
  content: counter(step);
  position: absolute;
  top: var(--space-5);
  inset-inline-end: var(--space-5);
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--blue-100);
}
.step .tool-icon { margin-bottom: var(--space-4); }
.step h3 { font-size: var(--text-xl); }
.step p { color: var(--muted); margin: 0; }

/* ---------- Benefits ---------- */
.benefits-grid { display: grid; gap: var(--space-7); align-items: center; }
@media (min-width: 960px) {
  .benefits-grid { grid-template-columns: .9fr 1.1fr; }
}
.benefits-art {
  background: linear-gradient(160deg, var(--blue-100), var(--purple-100));
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-4);
}
.benefit-list {
  display: grid;
  gap: var(--space-5) var(--space-6);
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 600px) {
  .benefit-list { grid-template-columns: repeat(2, 1fr); }
}
.benefit { display: flex; gap: var(--space-4); }
.benefit-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--blue-50);
  color: var(--blue-600);
  flex: none;
}
.benefit h3 { font-size: var(--text-base); margin-bottom: var(--space-1); }
.benefit p { color: var(--muted); font-size: var(--text-sm); margin: 0; }

/* ---------- FAQ ---------- */
.faq-list { max-width: 50rem; margin-inline: auto; display: grid; gap: var(--space-3); }
.faq-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--dur) ease, box-shadow var(--dur) ease;
}
.faq-item[open] { border-color: var(--blue-200); box-shadow: var(--shadow-sm); }
.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 60px;
  padding: var(--space-3) var(--space-5);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary .icon { color: var(--blue-600); transition: transform var(--dur) var(--ease-out); }
.faq-item[open] summary .icon { transform: rotate(180deg); }
.faq-item summary:focus-visible { outline-offset: -3px; border-radius: var(--radius); }
.faq-answer { padding: 0 var(--space-5) var(--space-4); color: var(--muted); }
.faq-answer p { margin: 0; }

/* ---------- CTA band ---------- */
.cta-band {
  background: var(--brand-gradient);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255, 255, 255, .88); max-width: 36rem; margin: 0 auto var(--space-5); }
.cta-band .btn { --btn-bg: #fff; --btn-fg: var(--blue-700); --btn-border: #fff; }
.cta-band .btn:hover { --btn-bg: var(--blue-50); color: var(--blue-700); }

/* ---------- Page header & breadcrumbs ---------- */
.page-head {
  background: var(--hero-gradient);
  padding-block: var(--space-6) var(--space-7);
  border-bottom: 1px solid var(--line);
}
.page-head h1 { margin-bottom: var(--space-3); }
.page-head p { color: var(--muted); font-size: var(--text-lg); max-width: 46rem; margin: 0; }

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
  font-size: var(--text-sm);
  color: var(--muted);
}
.breadcrumbs li:not(:last-child)::after { content: "/"; margin-inline-start: var(--space-2); color: var(--line-strong); }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--blue-600); }
.breadcrumbs [aria-current] { color: var(--ink); font-weight: 600; }

/* ---------- Blog ---------- */
.post-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), border-color var(--dur) ease;
}
.post-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--blue-200); }
.post-card:has(a:focus-visible) { outline: 3px solid var(--blue-500); outline-offset: 2px; }
.post-cover {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 7;
  background: linear-gradient(135deg, var(--blue-100), var(--purple-100));
}
.post-body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.post-body h2, .post-body h3 { font-size: var(--text-lg); margin: 0; }
.post-body h2 a, .post-body h3 a { color: var(--ink); text-decoration: none; }
.post-body h2 a::after, .post-body h3 a::after { content: ""; position: absolute; inset: 0; }
.post-body h2 a:focus-visible, .post-body h3 a:focus-visible { outline: none; }
.post-body p { color: var(--muted); font-size: var(--text-sm); margin: 0; }
.post-meta { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: var(--text-xs); color: var(--muted); }
.post-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.post-meta .icon { width: 14px; height: 14px; }

.pagination {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-7);
  list-style: none;
  padding: 0;
}
.pagination a, .pagination span {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 700;
  color: var(--ink);
}
.pagination [aria-current] { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }

/* Article layout */
/* minmax(0, 1fr) stops a wide code block or table from stretching the column past the screen. */
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-7); }
@media (min-width: 1024px) {
  .article-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
.article-aside { display: grid; gap: var(--space-5); align-content: start; }
@media (min-width: 1024px) {
  .article-aside { position: sticky; top: calc(var(--header-h) + var(--space-5)); }
}

.prose { max-width: 44rem; font-size: 1.0625rem; line-height: 1.75; color: var(--ink-2); }
.prose h2 { font-size: var(--text-xl); margin-top: var(--space-6); }
.prose h3 { margin-top: var(--space-5); }
.prose ul, .prose ol { padding-inline-start: 1.3rem; margin: 0 0 var(--space-4); }
.prose li { margin-bottom: var(--space-2); }
.prose li::marker { color: var(--blue-600); }
.prose pre {
  background: var(--navy);
  color: #e6ecff;
  padding: var(--space-4);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: 1.6;
}
.prose pre code { background: none; border: 0; padding: 0; color: inherit; overflow-wrap: normal; }
.prose blockquote { margin: var(--space-5) 0; padding: var(--space-3) var(--space-5); border-inline-start: 4px solid var(--blue-600); background: var(--surface-alt); border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: var(--space-5); font-size: var(--text-sm); }
/* Wide tables scroll inside themselves on phones instead of pushing the page sideways. */
@media (max-width: 700px) {
  .prose table { display: block; width: max-content; max-width: 100%; overflow-x: auto; }
}
.prose th, .prose td { border: 1px solid var(--line); padding: var(--space-2) var(--space-3); text-align: start; }
.prose img { border-radius: var(--radius); }

.side-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.side-card h2 { font-size: var(--text-lg); }
.side-card .tool-icon { margin-bottom: var(--space-3); }
.side-card p { color: var(--muted); font-size: var(--text-sm); }

.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.link-list a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 48px;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--text-sm);
}
.link-list a:hover { background: var(--blue-50); color: var(--blue-700); }
.link-list .tool-icon { width: 36px; height: 36px; border-radius: 10px; box-shadow: none; }
.link-list .tool-icon .icon { width: 18px; height: 18px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: var(--space-2); }
.field + .field, .field + .field-row, .field-row + .field { margin-top: var(--space-4); }
.field-row { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); align-items: start; }
.field-row + .field-row { margin-top: var(--space-4); }
.field-row > .field + .field { margin-top: 0; }
.field-row > .field { min-width: 0; }
.field > .btn { max-width: 100%; white-space: normal; text-align: center; line-height: 1.2; }

.label, label.label { font-weight: 700; font-size: var(--text-sm); color: var(--ink); }
.label .req { color: var(--danger); }
.hint { font-size: var(--text-xs); color: var(--muted); margin: 0; }

.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: .7rem .9rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: var(--text-base);
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none;
  padding-inline-end: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a5675' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  background-size: 18px;
  cursor: pointer;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(29, 92, 242, .15);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.field-error { display: flex; align-items: center; gap: .35rem; color: var(--danger); font-size: var(--text-sm); font-weight: 600; margin: 0; }
.field-error .icon { width: 16px; height: 16px; }

.input-color {
  width: 48px;
  min-height: 48px;
  padding: 4px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}
.color-field { display: flex; align-items: center; gap: var(--space-3); }

/* Range with a live value */
.range-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.range-head output { font-weight: 800; color: var(--blue-600); font-variant-numeric: tabular-nums; }
input[type="range"] {
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  accent-color: var(--blue-600);
  cursor: pointer;
}

/* Switch built on a checkbox */
.switch {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
}
.switch input {
  appearance: none;
  position: relative;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
  transition: background-color var(--dur) ease;
  cursor: pointer;
  flex: none;
}
.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease-out);
}
.switch input:checked { background: var(--blue-600); }
.switch input:checked::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked::after { transform: translateX(-18px); }

/* Segmented control built on radio buttons */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 0;
  margin: 0;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}
.segmented legend { padding: 0; margin-bottom: var(--space-2); font-weight: 700; font-size: var(--text-sm); float: left; width: 100%; }
.segmented label {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 40px;
  padding: 0 var(--space-3);
  border-radius: 8px;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:checked) { background: #fff; color: var(--blue-700); box-shadow: var(--shadow-sm); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--blue-500); outline-offset: 1px; }
.fieldset-wrap { border: 0; margin: 0; padding: 0; min-width: 0; }
.fieldset-wrap > legend { font-weight: 700; font-size: var(--text-sm); padding: 0; margin-bottom: var(--space-2); }

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: var(--text-sm);
  font-weight: 600;
}
.alert .icon { margin-top: 1px; }
.alert p { margin: 0; }
.alert[hidden] { display: none; }
.alert-error { background: var(--danger-bg); border-color: #f5c2c8; color: var(--danger); }
.alert-success { background: var(--success-bg); border-color: #b9e8d3; color: var(--success); }
.alert-info { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-700); }
.alert-warning { background: var(--warning-bg); border-color: #f3d998; color: var(--warning); }

/* ---------- Ad slots ---------- */
.ad-slot { margin-block: var(--space-6); text-align: center; overflow: hidden; }
.ad-slot--placeholder {
  display: grid;
  place-items: center;
  min-height: 100px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: repeating-linear-gradient(-45deg, #fafcff, #fafcff 10px, #f4f7fe 10px, #f4f7fe 20px);
  color: #7b86a3;
  font-size: var(--text-xs);
  font-weight: 700;
}
.ad-slot--tool.ad-slot--placeholder, .ad-slot--blog.ad-slot--placeholder { min-height: 250px; }
@media (min-width: 768px) {
  .ad-slot--home.ad-slot--placeholder { min-height: 120px; }
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--navy);
  color: #c7d1ec;
  padding-block: var(--space-8) var(--space-5);
  margin-top: auto;
}
.footer-grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
}
@media (min-width: 1024px) {
  .footer-grid { grid-template-columns: 1.3fr repeat(6, minmax(0, 1fr)); }
}
.footer-brand .brand { color: #fff; }
.footer-brand .brand-name span { color: #8fb0ff; }
.footer-brand p { margin-top: var(--space-3); font-size: var(--text-sm); max-width: 22rem; }
.site-footer h2 { color: #fff; font-size: var(--text-sm); font-weight: 700; letter-spacing: 0; margin-bottom: var(--space-3); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.site-footer a { color: #c7d1ec; text-decoration: none; font-size: var(--text-sm); display: inline-flex; min-height: 32px; align-items: center; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer h2 a { color: #fff; font-size: inherit; min-height: 0; }
.site-footer :focus-visible { outline-color: #8fb0ff; }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid rgba(255, 255, 255, .12);
  font-size: var(--text-xs);
  color: #9aa6c8;
}
.footer-bottom p { margin: 0; }

/* ---------- Tool page ---------- */
.section--tool { padding-top: var(--space-6); }
.result-note { margin-top: var(--space-4); }
.tool-hero { display: flex; gap: var(--space-4); align-items: flex-start; }
.tool-hero > div { min-width: 0; }
/* Long single words (Spanish "almacenamiento", Russian "температуры") break with a hyphen instead of spilling out. */
.tool-hero h1 { margin-bottom: var(--space-2); overflow-wrap: break-word; hyphens: auto; }
/* Small phones: the icon sits above the title so the title gets the full width. */
@media (max-width: 400px) {
  .tool-hero { flex-direction: column; gap: var(--space-3); }
  .tool-hero .tool-icon--lg { width: 56px; height: 56px; border-radius: 16px; }
  .tool-hero .tool-icon--lg .icon { width: 28px; height: 28px; }
}

.tool-layout { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
}
.tool-aside { display: grid; gap: var(--space-5); }
@media (min-width: 1100px) {
  .tool-aside { position: sticky; top: calc(var(--header-h) + var(--space-5)); }
}

.workspace {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}
@media (min-width: 768px) {
  .workspace { padding: var(--space-6); }
}
.noscript-note { margin: 0; }

/* Drop zone */
.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: var(--space-3);
  min-height: 300px;
  padding: var(--space-6) var(--space-4);
  border: 2px dashed #8fb0ff;
  border-radius: var(--radius);
  background: var(--surface-alt);
  text-align: center;
  transition: background-color var(--dur) ease, border-color var(--dur) ease;
}
.dropzone.is-dragover { background: var(--blue-100); border-color: var(--blue-600); }
.dropzone-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fff;
  color: var(--blue-600);
  box-shadow: var(--shadow);
}
.dropzone-icon .icon { width: 34px; height: 34px; }
.dropzone-title { font-size: var(--text-xl); font-weight: 800; margin: 0; }
.dropzone-sub { color: var(--muted); margin: 0; font-size: var(--text-sm); }
.dropzone .btn { margin-top: var(--space-2); }
.dropzone-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Editor: preview + settings */
.editor { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .editor { grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); align-items: start; }
}
.editor[hidden] { display: none; }

.file-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  margin-bottom: var(--space-4);
}
.file-bar .tool-icon { width: 40px; height: 40px; border-radius: 10px; box-shadow: none; }
.file-bar .tool-icon .icon { width: 20px; height: 20px; }
.file-bar .file-name { font-weight: 700; overflow-wrap: anywhere; min-width: 0; flex: 1; line-height: 1.3; }
.file-bar .file-name small { display: block; font-weight: 500; color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }

.preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  /* Checkerboard to show transparency */
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eef2fb 25%, transparent 25%),
    linear-gradient(-45deg, #eef2fb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2fb 75%),
    linear-gradient(-45deg, transparent 75%, #eef2fb 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.preview img, .preview canvas {
  max-width: 100%;
  max-height: 520px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.preview-caption { margin: var(--space-2) 0 0; text-align: center; font-size: var(--text-xs); color: var(--muted); }

.settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.settings > h2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
  margin: 0;
}
.settings > h2 .icon { color: var(--blue-600); }
.settings .field + .field, .settings .field-row + .field, .settings .field + .field-row { margin-top: 0; }
.settings-actions { display: grid; gap: var(--space-3); padding-top: var(--space-2); }
/* Long translated labels (e.g. Russian "Конвертировать") wrap or move to their own row instead of spilling out. */
.settings-actions .btn { min-width: 0; white-space: normal; text-align: center; line-height: 1.2; padding-inline: 1rem; }

/* Result */
.result {
  margin-top: var(--space-5);
  padding: var(--space-5);
  border-radius: var(--radius);
  border: 1px solid #b9e8d3;
  background: linear-gradient(180deg, var(--success-bg), #fff 70%);
}
.result[hidden] { display: none; }
.result-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.result-head h2 { margin: 0; font-size: var(--text-xl); }
.result-head .icon { color: var(--success); width: 28px; height: 28px; }
.result-body { display: grid; gap: var(--space-5); align-items: center; }
@media (min-width: 700px) {
  .result-body { grid-template-columns: minmax(0, 1fr) auto; }
}
.result-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-3);
  margin: 0;
}
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); }
.stat dt { font-size: var(--text-xs); color: var(--muted); font-weight: 600; }
.stat { min-width: 0; }
.stat dd { margin: 0; font-weight: 800; font-size: var(--text-lg); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat dd.good { color: var(--success); }
.stat dd.warn { color: var(--warning); }

/* ---------- Student calculators ---------- */
.calc { display: grid; gap: var(--space-5); }
@media (min-width: 900px) {
  .calc:not(.calc--stack) { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .calc:not(.calc--stack) .calc-result { position: sticky; top: calc(var(--header-h) + var(--space-4)); }
}
.calc-form { min-width: 0; }
.calc-form .settings-actions { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }

.calc-result {
  min-width: 0;
  padding: var(--space-5);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--blue-50), #fff 75%);
}
.calc-result > h2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
  margin: 0 0 var(--space-4);
}
.calc-result > h2 .icon { color: var(--blue-600); }
.calc-headline { display: grid; gap: var(--space-1); margin-bottom: var(--space-4); }
.calc-value {
  font-size: clamp(2.25rem, 1.8rem + 2vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.calc-headline.is-good .calc-value { color: var(--success); }
.calc-headline.is-warn .calc-value { color: var(--warning); }
.calc-headline.is-bad .calc-value { color: var(--danger); }
.calc-caption { color: var(--muted); font-weight: 600; font-size: var(--text-sm); }
.calc-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 110px), 1fr)); }
.calc-note { margin: var(--space-4) 0 0; color: var(--ink-2); line-height: 1.6; }
.calc-empty {
  margin: 0;
  padding: var(--space-6) var(--space-4);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
}

/* Repeatable rows: courses, semesters, subjects, assessments */
.calc-rows { display: grid; gap: var(--space-3); list-style: none; margin: 0; padding: 0; }
.calc-row {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.calc-row-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font-weight: 700; font-size: var(--text-sm); }
.calc-row-head .btn-icon { width: 40px; min-height: 40px; }
.calc-row-head .btn-icon:disabled { visibility: hidden; }
.calc-row-fields { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 110px), 1fr)); }
.calc-row-fields .field-wide { grid-column: 1 / -1; }
/* Rows lay out by the width of the form, not the screen: the form is narrow beside the result. */
.calc-form { container-type: inline-size; }
@container (min-width: 560px) {
  .calc-row-fields { grid-template-columns: var(--cols, repeat(auto-fit, minmax(110px, 1fr))); }
  .calc-row-fields .field-wide { grid-column: auto; }
}
.calc-row .field-error { grid-column: 1 / -1; }
.calc-add { justify-self: start; }

/* Tables: grade scales and the study timetable */
.table-scroll { overflow-x: auto; margin-top: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.calc-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.calc-table th, .calc-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.calc-table thead th { background: var(--surface-alt); font-weight: 700; white-space: nowrap; }
.calc-table tbody tr:last-child > * { border-bottom: 0; }
.calc-table tr.is-current > * { background: var(--blue-50); font-weight: 700; }
.calc-table td.num, .calc-table th.num { text-align: end; font-variant-numeric: tabular-nums; }

/* Progress meter (attendance, word limit) */
.meter { position: relative; height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: var(--space-4); }
.meter-mark { position: absolute; top: 0; bottom: 0; inset-inline-start: var(--mark); width: 3px; margin-inline-start: -1.5px; background: var(--ink); }
.meter > span { display: block; height: 100%; width: var(--value, 0%); border-radius: inherit; background: var(--blue-600); transition: width var(--dur) ease; }
.meter.is-good > span { background: var(--success); }
.meter.is-warn > span { background: #e0a100; }
.meter.is-bad > span { background: var(--danger); }
.meter-labels { display: flex; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-1); font-size: var(--text-xs); color: var(--muted); }

.check-grid { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.check-chip { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--space-3); border: 1.5px solid var(--line-strong); border-radius: 999px; background: #fff; font-weight: 600; font-size: var(--text-sm); cursor: pointer; }
.check-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.check-chip:has(input:checked) { border-color: var(--blue-600); background: var(--blue-50); color: var(--blue-700); }
.check-chip:has(input:focus-visible) { outline: 3px solid var(--blue-500); outline-offset: 2px; }

.word-input { min-height: 280px; }

/* Study timetable */
.timetable tbody th { white-space: nowrap; width: 1%; }
.timetable td { min-width: 112px; }
.timetable .slot { margin-bottom: 0; }
.slot { display: block; padding: .35rem .5rem; border-radius: 8px; margin-bottom: .35rem; background: var(--blue-50); border-inline-start: 4px solid var(--slot, var(--blue-600)); font-size: var(--text-xs); line-height: 1.35; }
.slot strong { display: block; font-size: var(--text-sm); color: var(--ink); overflow-wrap: break-word; }
.slot-time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.slot--break { background: transparent; border-inline-start-color: var(--line-strong); color: var(--muted); }

/* Unit converters */
.input-lg { min-height: 52px; font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
[dir="rtl"] .input-lg { text-align: right; }
.convert-units { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: var(--space-3); }
.convert-swap { width: 44px; min-height: 44px; margin-bottom: 2px; }
.calc-subhead { margin: var(--space-5) 0 0; font-size: var(--text-base); }
@container (max-width: 420px) {
  .convert-units { grid-template-columns: minmax(0, 1fr); }
  .convert-swap { justify-self: center; transform: rotate(90deg); margin: 0; }
}

/* Phones: less nested padding so fields and tables have room. */
@media (max-width: 599px) {
  .workspace:has(> .calc) { padding: var(--space-3); }
  .calc-form.settings, .calc-result { padding: var(--space-4); }
  .calc-row { padding: var(--space-3); padding-inline-end: var(--space-2); }
  .calc-row .select { padding-inline-end: 2rem; background-position: right .55rem center; }
  [dir="rtl"] .calc-row .select { background-position: left .55rem center; }
  .calc-table th, .calc-table td { padding: .5rem .45rem; }
  .calc-table thead th { white-space: normal; }
}

@media print {
  body.page-tool .site-header, body.page-tool .site-footer, body.page-tool .page-head, body.page-tool .tool-aside,
  body.page-tool .tool-content, body.page-tool .ad-slot, body.page-tool .calc-form, body.page-tool .calc-print-hide { display: none !important; }
  body.page-tool .workspace, body.page-tool .calc-result { border: 0; box-shadow: none; padding: 0; background: none; }
  .table-scroll { overflow: visible; border: 0; }
  .timetable { font-size: 10pt; }
  .timetable td { min-width: 0; }
  .slot { break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Thumbnail lists (Image to PDF, PDF to Image, favicons) */
.thumb-list {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}
.thumb {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.thumb-media {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: var(--surface-alt);
  border-radius: 8px;
  overflow: hidden;
}
.thumb-media img, .thumb-media canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
.thumb-title { font-size: var(--text-xs); font-weight: 700; overflow-wrap: anywhere; line-height: 1.3; margin: 0; }
.thumb-title small { display: block; font-weight: 500; color: var(--muted); }
.thumb-actions { display: flex; gap: var(--space-1); justify-content: flex-end; flex-wrap: wrap; }
.thumb-actions .btn { width: 40px; min-height: 40px; }
.thumb-actions .btn .icon { width: 18px; height: 18px; }

/* PDF page grids (Split, Rotate, Organize) */
.thumb-list--pages { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.thumb-list--pages .thumb-media { transition: transform .2s ease; }
.thumb-list--pages .thumb-media canvas, [data-files] .thumb-media canvas { box-shadow: 0 0 0 1px var(--line-strong); }
.thumb.is-removed { opacity: .45; }
.page-grid-hint { margin: 0 0 var(--space-3); }
.pdf-text { min-height: 320px; font-size: var(--text-sm); line-height: 1.6; white-space: pre-wrap; }
@media (prefers-reduced-motion: reduce) { .thumb-list--pages .thumb-media { transition: none; } }

.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.file-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-3); background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.file-list span { font-weight: 700; font-size: var(--text-sm); min-width: 0; overflow-wrap: anywhere; }
.file-list small { display: block; font-weight: 500; color: var(--muted); }

/* Radio cards with a title and a short explanation (Split, Compress PDF) */
.choice-list { display: grid; gap: var(--space-2); }
.choice {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}
.choice input { margin: .2rem 0 0; width: 18px; height: 18px; flex: none; accent-color: var(--blue-600); }
.choice strong { display: block; font-size: var(--text-sm); }
.choice small { display: block; color: var(--muted); font-size: var(--text-xs); line-height: 1.4; margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--blue-600); background: var(--blue-50); }
.choice:has(input:focus-visible) { outline: 3px solid var(--blue-500); outline-offset: 1px; }

.add-more {
  display: grid;
  place-items: center;
  gap: var(--space-2);
  aspect-ratio: auto;
  min-height: 150px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--blue-600);
  font-weight: 700;
  font-size: var(--text-sm);
}
.add-more:hover { border-color: var(--blue-600); background: var(--blue-50); }

/* Favicon previews */
.favicon-sizes { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: var(--space-5); padding: var(--space-5); }
.favicon-sizes figure { margin: 0; display: grid; justify-items: center; gap: var(--space-2); }
.favicon-sizes canvas { max-width: none; max-height: none; box-shadow: var(--shadow-sm); }
.favicon-sizes figcaption { font-size: var(--text-xs); font-weight: 700; color: var(--muted); background: #fff; padding: 0 .4rem; border-radius: 6px; }
.thumb-media .icon { width: 32px; height: 32px; color: var(--muted); }

/* Tool content below the workspace */
.tool-content { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-7); margin-top: var(--space-7); }
.how-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); counter-reset: how; }
.how-list li {
  position: relative;
  padding: var(--space-3) var(--space-4);
  padding-inline-start: 3.6rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  counter-increment: how;
  min-height: 56px;
  display: flex;
  align-items: center;
}
.how-list li::before {
  content: counter(how);
  position: absolute;
  inset-inline-start: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: 800;
  font-size: var(--text-sm);
}
.privacy-note {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--blue-50);
  color: var(--ink-2);
  font-size: var(--text-sm);
}
.privacy-note .icon { color: var(--blue-600); width: 24px; height: 24px; }
.privacy-note p { margin: 0; }

/* Code output (favicon HTML) */
.code-block { position: relative; }
.code-block pre {
  margin: 0;
  background: var(--navy);
  color: #e6ecff;
  padding: var(--space-4);
  padding-right: 6.5rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: var(--text-xs);
  line-height: 1.7;
}
.code-block .btn { position: absolute; top: var(--space-2); right: var(--space-2); --btn-bg: rgba(255,255,255,.1); --btn-fg: #fff; --btn-border: rgba(255,255,255,.2); }

/* Cropper container */
.crop-stage { max-height: 520px; background: #f5f8ff; border-radius: var(--radius); overflow: hidden; }
.crop-stage img { display: block; max-width: 100%; }

/* Rotate/flip button grid */
.button-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); gap: var(--space-2); }
.button-grid .btn { border-radius: var(--radius-sm); min-height: 48px; padding: 0 var(--space-3); font-size: var(--text-sm); }

/* ---------- Contact ---------- */
.contact-grid { display: grid; gap: var(--space-7); }
@media (min-width: 960px) {
  .contact-grid { grid-template-columns: 1.4fr 1fr; }
}
.form-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow);
}
@media (min-width: 768px) {
  .form-card { padding: var(--space-6); }
}
.hp-field { position: absolute; inset-inline-start: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- 404 ---------- */
.not-found { text-align: center; padding-block: var(--space-9); }
.not-found .big { font-size: clamp(4rem, 10vw, 7rem); font-weight: 800; line-height: 1; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; margin: 0; }

/* ---------- Utilities ---------- */
.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;
}
.muted { color: var(--muted); }
.stack > * + * { margin-top: var(--space-4); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-5 { margin-top: var(--space-5); }
.text-center { text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .spinner { animation-duration: 1.4s !important; animation-iteration-count: infinite !important; }
}

/* Cropper.js positions its handles from the left, so keep its box left-to-right in RTL pages. */
[dir="rtl"] [data-crop-stage], [dir="rtl"] .cropper-container { direction: ltr; }

/* ---------- Developer tools ---------- */
.code-input, .code-output {
  font-family: var(--mono);
  font-size: .875rem;
  line-height: 1.55;
  min-height: 240px;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  direction: ltr;
  text-align: left;
}
.code-input--short { min-height: 120px; }
.code-output { background: var(--surface-alt); }
.code-output:focus { background: #fff; }
.code-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.code-head h2 { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-lg); margin: 0; }
.code-head h2 .icon { color: var(--blue-600); }
.code-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.code-stats { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; margin: var(--space-3) 0 0; padding: 0; font-size: var(--text-xs); color: var(--muted); }
.code-stats li { padding: .2rem .6rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-variant-numeric: tabular-nums; }
.code-stats li.good { color: var(--success); border-color: #b9e8d3; background: var(--success-bg); }
.calc-result .alert { margin-bottom: var(--space-3); }
.calc-result .alert:last-child { margin-bottom: 0; }
.mode-row { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-4); }
.mode-row > .field, .mode-row > .fieldset-wrap { flex: 1 1 180px; }
.check-list { display: grid; gap: var(--space-2); }

/* Regex tester */
.regex-field { display: flex; align-items: stretch; direction: ltr; }
.regex-field .regex-slash { display: grid; place-items: center; padding: 0 .6rem; font-family: var(--mono); font-weight: 700; color: var(--muted); background: var(--surface-alt); border: 1.5px solid var(--line-strong); }
.regex-field .regex-slash:first-child { border-inline-end: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.regex-field .regex-slash:last-child { border-inline-start: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.regex-field .input { border-radius: 0; font-family: var(--mono); }
.regex-view {
  font-family: var(--mono);
  font-size: .875rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  direction: ltr;
  text-align: left;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  max-height: 360px;
  overflow: auto;
}
.regex-view mark { background: #ffe58f; color: inherit; border-radius: 3px; box-shadow: 0 0 0 1px #f0c94a; }
.regex-view mark:nth-of-type(even) { background: #c7ddff; box-shadow: 0 0 0 1px #8fb0ff; }
.calc-table code { font-size: .8125rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Meta tags: search result preview */
.serp { padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; font-family: Arial, sans-serif; direction: ltr; text-align: left; margin-bottom: var(--space-4); }
.serp-url { font-size: .8125rem; color: #202124; overflow-wrap: anywhere; }
.serp-title { font-size: 1.25rem; color: #1a0dab; line-height: 1.3; margin: .2rem 0; overflow-wrap: anywhere; }
.serp-desc { font-size: .875rem; color: #4d5156; line-height: 1.55; margin: 0; overflow-wrap: anywhere; }
.counter { font-size: var(--text-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.warn { color: var(--warning); font-weight: 700; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }

/* QR codes */
.qr-preview { display: grid; place-items: center; padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.qr-preview canvas { width: 100%; max-width: 280px; height: auto; image-rendering: pixelated; }
.color-row { display: flex; align-items: center; gap: var(--space-2); }

/* Three short inputs side by side (aggregate weights) */
.field-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
