/* GETtheTOOLS. Design tokens first, then base styles, then each part of the page.
   Direction: DESIGN.md, architectural grid-rail minimalism. An achromatic scale, a framed sidebar and
   workspace shell, hairline section strips, hatched dividers and a dot field behind the home hero.
   Dark is the default canvas and light is a full peer. Green, amber and red appear only as success,
   warning and error states. */

@font-face { font-family: "Geist"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../vendor/fonts/geist-variable.woff2") format("woff2"); }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../vendor/fonts/geist-mono-variable.woff2") format("woff2"); }

:root {
  --font-sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;

  --bg: #0a0a0a;
  --surface: #171717;
  --surface-2: #262626;
  --ink: #fafafa;
  --ink-2: #d4d4d4;
  --muted: #a1a1a1;
  /* --line separates content that is not a control. --line-strong frames controls, so it clears 3:1. */
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: #737373;
  --ring: #a1a1a1;
  --ring-focus: color-mix(in srgb, var(--ring) 65%, transparent);
  --dot: color-mix(in srgb, var(--ink) 22%, transparent);
  --hatch: repeating-linear-gradient(135deg, transparent 0 8px, var(--line) 8px 9px);

  /* Inverted controls are the accent of an achromatic system: the foreground on the background. */
  --accent: #fafafa;
  --accent-hover: #e5e5e5;
  --on-accent: #0a0a0a;
  --accent-soft: #262626;
  --accent-ink: #fafafa;

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.16);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger: #ff6467;
  --on-danger: #0a0a0a;
  --danger-soft: rgba(255, 100, 103, 0.16);
  --code-bg: #171717;

  --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 1px 2px rgba(0, 0, 0, 0.4);

  --r-s: 6px;
  --r-m: 10px;
  --r-l: 14px;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 80px;

  --max: 1360px;
  --sidebar-w: 264px;
  --sidebar-rail-w: 64px;
  --gutter: 16px;
  --nav-h: 48px;
  --strip-h: 40px;
  --hatch-h: 32px;

  --t-1: 100ms;
  --t-2: 200ms;
  --t-3: 300ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: dark;
}

/* Light keeps the same structure on a white canvas. Muted text is a step darker than #737373 because it
   also sits on surface-2 bands and tinted notices, where #737373 falls below 4.5:1. */
[data-theme="light"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --ink: #0a0a0a;
  --ink-2: #404040;
  --muted: #6b6b6b;
  --line: #e5e5e5;
  --line-strong: #868686;
  --ring: #767676;
  --ring-focus: color-mix(in srgb, var(--ring) 85%, transparent);
  --dot: color-mix(in srgb, var(--ink) 20%, transparent);
  --hatch: repeating-linear-gradient(135deg, transparent 0 8px, var(--line) 8px 9px);

  --accent: #0a0a0a;
  --accent-hover: #262626;
  --on-accent: #ffffff;
  --accent-soft: #f5f5f5;
  --accent-ink: #0a0a0a;

  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b42318;
  --on-danger: #ffffff;
  --danger-soft: #fef2f2;
  --code-bg: #f5f5f5;

  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-hover: 0 1px 2px rgba(0, 0, 0, 0.06);

  color-scheme: light;
}

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

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
/* Layout rules below set display on many elements; the hidden attribute must still win. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + var(--s-4)); }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 0.18em; text-decoration-thickness: 1px; transition: text-decoration-color var(--t-1) var(--ease); }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
h1[tabindex="-1"]:focus { outline: none; }
h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.3; letter-spacing: -0.025em; text-wrap: balance; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
ul, ol { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button:not(:disabled), [role="button"]:not([aria-disabled="true"]), select:not(:disabled), a[href], label.check, .segmented span, summary { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; }
svg, img, canvas, video { display: block; max-width: 100%; }
.icon { flex: none; display: inline-block; vertical-align: middle; }

/* Shell and rails: a framed outer boundary with sidebar + workspace separated by 1px hairlines. */
.app-shell { display: flex; width: 100%; max-width: var(--max); min-height: 100vh; min-height: 100dvh; margin: 0 auto; }
@media (min-width: 1360px) {
  .app-shell { border-inline: 1px solid var(--line); }
}
.shell-main { display: flex; flex-direction: column; flex: 1 1 0%; min-width: 0; container-type: inline-size; container-name: shell; }
.container { width: 100%; margin: 0 auto; padding: 0 var(--gutter); }
.page { display: flex; flex-direction: column; flex: 1; width: 100%; margin: 0 auto; padding: 0 var(--gutter); }
/* Space left on a short page goes before the closing hatch, so the hatch always meets the footer. */
.page::before { content: ""; order: 99; flex: 1 1 auto; min-height: var(--s-7); }
.page::after { content: ""; order: 100; flex: none; height: var(--hatch-h); margin: 0 calc(var(--gutter) * -1); border-block: 1px solid var(--line); background: var(--hatch); }
.hatch { flex: none; height: var(--hatch-h); margin: 0 calc(var(--gutter) * -1); border-block: 1px solid var(--line); background: var(--hatch); }
/* A 40px hairline strip that names the band below it. */
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); min-height: var(--strip-h); border-bottom: 1px solid var(--line); }
.section-bar h2 { font-size: 12px; font-weight: 700; letter-spacing: 0.025em; text-transform: uppercase; }
.section-bar__link { flex: none; font-size: 12px; color: var(--muted); }
.section-bar__link:hover { color: var(--ink); }

.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; display: inline-flex; align-items: center; min-height: 44px; padding: 8px 12px; background: var(--ink); color: var(--bg); border-radius: var(--r-s); }
.skip:focus { left: 8px; }
.kbd { display: inline-block; font-family: var(--font-mono); font-size: 11px; line-height: 1; padding: 4px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--surface); }

/* ---------- Sidebar, header and footer ---------- */

.sidebar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  border-right: 1px solid var(--line);
  transition: width var(--t-2) var(--ease), flex-basis var(--t-2) var(--ease);
}
.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
  height: var(--nav-h);
  padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--line);
}
.sidebar__head .sidebar__close { display: none; }
.sidebar__search-wrap { flex: none; padding: 10px 12px 4px; }
.side-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-s);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  transition: border-color var(--t-1) var(--ease), color var(--t-1) var(--ease), background-color var(--t-1) var(--ease);
}
.side-search:hover { border-color: var(--ink-2); color: var(--ink); background: var(--surface-2); }
.side-search .kbd { margin-left: auto; }
.sidebar__scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 6px 12px 12px; scrollbar-width: thin; }
.side-group { padding-top: 10px; }
.side-group:first-child { padding-top: 2px; }
.side-group__title { margin: 0; padding: 0 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.side-group__items, .side-list { display: grid; gap: 1px; list-style: none; margin: 0; padding: 0; }
.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: var(--r-s);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  transition: color var(--t-1) var(--ease), background-color var(--t-1) var(--ease);
}
.side-link .icon { flex: none; color: var(--muted); transition: color var(--t-1) var(--ease); }
.side-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-count { flex: none; font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); }
.side-link:hover { color: var(--ink); background: var(--surface-2); }
.side-link:hover .icon { color: var(--ink); }
.side-link.is-active { color: var(--ink); font-weight: 600; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.side-link.is-active .icon { color: var(--ink); }
.side-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2.5px;
  border-radius: 0 2px 2px 0;
  background: var(--ink);
}
.side-cat { display: grid; gap: 2px; }
.side-cat__row { display: flex; align-items: center; gap: 4px; }
.side-cat__row .side-link { flex: 1 1 auto; min-width: 0; }
.side-cat__toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-s);
  background: none;
  color: var(--muted);
  transition: color var(--t-1) var(--ease), background-color var(--t-1) var(--ease);
}
.side-cat__toggle .icon { transition: transform var(--t-2) var(--ease); }
.side-cat__toggle:hover { color: var(--ink); background: var(--surface-2); }
.side-cat__toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.side-sublist {
  display: grid;
  gap: 1px;
  list-style: none;
  margin: 2px 0 6px 17px;
  padding: 2px 0 2px 10px;
  border-left: 1px solid var(--line);
}
.side-sublink {
  display: block;
  padding: 5px 8px;
  border-radius: var(--r-s);
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--t-1) var(--ease), background-color var(--t-1) var(--ease);
}
.side-sublink:hover { color: var(--ink); background: var(--surface-2); }
.side-sublink.is-active { color: var(--ink); font-weight: 600; background: var(--surface-2); }
.side-sublink--pinned { color: var(--ink-2); font-weight: 500; padding-left: 10px; }
.side-sublink--all { font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); }
.sidebar__foot {
  flex: none;
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.sidebar__status { display: flex; align-items: center; gap: 8px; padding: 2px 10px 0; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.sidebar-backdrop { display: none; }

.site-head { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); border-bottom: 1px solid var(--line); }
.nav { display: flex; align-items: center; gap: var(--s-3); min-height: var(--nav-h); }
.menu-btn { display: none; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: none; color: var(--ink); font-size: 13px; font-weight: 500; }
.menu-btn:hover { background: var(--surface-2); }
.brand { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 0; font-size: 15px; font-weight: 700; letter-spacing: 0.01em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand__glyph { flex: none; display: block; }
.brand__text { display: inline; }
.brand__mark { color: var(--ink); font-weight: 700; }
.brand__mid { color: var(--muted); font-weight: 500; }
.nav__brand { display: none; }
.nav__crumb { min-width: 0; font-size: 13px; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav__actions { display: flex; flex: none; align-items: center; gap: 4px; margin-left: auto; }
.lang-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: none; color: var(--ink-2); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; transition: background-color var(--t-1) var(--ease), color var(--t-1) var(--ease); }
.lang-btn:hover { background: var(--surface-2); color: var(--ink); }
.donate-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: var(--surface-2); color: var(--ink); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: background-color var(--t-1) var(--ease), color var(--t-1) var(--ease), border-color var(--t-1) var(--ease); }
.donate-btn:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.side-link--donate { border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.side-link--donate:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--r-s); background: none; color: var(--ink-2); text-decoration: none; transition: background-color var(--t-1) var(--ease), color var(--t-1) var(--ease); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
/* Dark is the default canvas, so the button offers the sun; in light it offers the moon. */
.icon-theme-dark { display: none; }
[data-theme="light"] .icon-theme-dark { display: block; }
[data-theme="light"] .icon-theme-light { display: none; }
.search-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 10px; border: 0; border-radius: var(--r-s); background: none; color: var(--muted); font-size: 14px; transition: background-color var(--t-1) var(--ease), color var(--t-1) var(--ease); }
.search-btn:hover { background: var(--surface-2); color: var(--ink); }

@media (min-width: 1024px) {
  html[data-sidebar="collapsed"] .sidebar { flex-basis: var(--sidebar-rail-w); width: var(--sidebar-rail-w); }
  html[data-sidebar="collapsed"] .sidebar__head { justify-content: center; padding: 0; }
  html[data-sidebar="collapsed"] .sidebar__brand { display: none; }
  html[data-sidebar="collapsed"] .nav__brand { display: inline-flex; }
  html[data-sidebar="collapsed"] .sidebar__search-wrap { padding: 8px 10px 4px; }
  html[data-sidebar="collapsed"] .side-search { justify-content: center; width: 40px; height: 34px; padding: 0; margin: 0 auto; }
  html[data-sidebar="collapsed"] .side-search .kbd,
  html[data-sidebar="collapsed"] .side-group__title,
  html[data-sidebar="collapsed"] .side-count,
  html[data-sidebar="collapsed"] .side-cat__toggle,
  html[data-sidebar="collapsed"] .side-sublist,
  html[data-sidebar="collapsed"] [data-side-pinned] { display: none; }
  html[data-sidebar="collapsed"] .side-group { padding-top: 6px; margin-top: 6px; border-top: 1px solid var(--line); }
  html[data-sidebar="collapsed"] .side-group:first-child { padding-top: 0; margin-top: 0; border-top: 0; }
  html[data-sidebar="collapsed"] .sidebar__scroll { padding: 6px 10px 10px; }
  html[data-sidebar="collapsed"] .side-link { justify-content: center; width: 40px; min-height: 32px; height: 32px; padding: 0; margin: 0 auto; }
  html[data-sidebar="collapsed"] .sidebar .side-label { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  html[data-sidebar="collapsed"] .sidebar__status { justify-content: center; padding: 2px 0 0; }
}

@media (max-width: 1023px) {
  .menu-btn { display: inline-flex; }
  .nav__brand { display: inline-flex; }
  .nav__crumb { display: none; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 45;
    display: none;
    width: min(304px, 86vw);
    height: 100vh;
    height: 100dvh;
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { display: flex; }
  .sidebar__head { min-height: calc(var(--nav-h) + 8px); }
  .sidebar__head .sidebar__collapse { display: none; }
  .sidebar__head .sidebar__close { display: inline-grid; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.58); }
  html.sidebar-mobile-open { overflow: hidden; }
}

.site-foot { background: var(--bg); }
.foot { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); padding-top: var(--s-5); padding-bottom: var(--s-6); text-align: center; }
.foot__note { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.foot__note .brand__mark { font-weight: 500; }
.foot__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; font-size: 12px; }
.foot__links a { color: var(--muted); }
.foot__links a:hover { color: var(--ink); }

/* ---------- Buttons ---------- */

.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: transparent; color: var(--ink); font-size: 14px; font-weight: 500; line-height: 1; text-decoration: none; white-space: nowrap; transition: background-color var(--t-1) var(--ease), border-color var(--t-1) var(--ease), color var(--t-1) var(--ease); }
.btn:hover { border-color: var(--ink-2); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn--sm { height: 32px; padding: 0 10px; gap: 6px; font-size: 13px; }
.btn--dark, .btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--dark:hover, .btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn--danger { color: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn--ghost { border-color: transparent; background: none; }
.btn--ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.is-busy { opacity: 0.7; pointer-events: none; }
.btn.is-busy::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }

/* ---------- Form controls ---------- */

.input, .textarea, .select { width: 100%; padding: 7px 12px; background: var(--bg); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r-s); font-size: 14px; line-height: 1.5; transition: border-color var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease); }
.input, .select { height: 36px; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-focus); }
.input--num { width: 120px; }
.textarea { display: block; min-height: 96px; resize: vertical; }
.textarea--mono, .textarea--output { font-family: var(--font-mono); font-size: 13px; line-height: 1.6; tab-size: 2; }
.textarea--output { background: var(--code-bg); }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1a1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
[data-theme="light"] .select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>"); }
.range { width: 100%; margin: 0; accent-color: var(--ink); cursor: pointer; }
.range-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); }
.range__value { min-width: 3.5ch; text-align: right; font-family: var(--font-mono); font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field__label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field__hint { font-size: 12px; line-height: 1.5; color: var(--muted); }
.segmented { display: inline-flex; flex-wrap: wrap; width: fit-content; max-width: 100%; overflow: hidden; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-s); }
.segmented label { position: relative; display: inline-flex; max-width: 100%; }
.segmented input { position: absolute; inset: 0; margin: 0; opacity: 0; }
.segmented span { display: inline-flex; align-items: center; padding: 7px 14px; border-right: 1px solid var(--line); font-size: 14px; cursor: pointer; transition: background-color var(--t-1) var(--ease), color var(--t-1) var(--ease); }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--ink); color: var(--bg); }
.segmented input:focus-visible + span { outline: 3px solid var(--ring); outline-offset: -3px; }

/* ---------- Layout helpers used by tools ---------- */

.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.toolbar--end { justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s-4); }
.panel { padding: var(--s-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.panel__title { margin-bottom: var(--s-4); font-size: 16px; }
.options { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); padding: var(--s-4); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-s); }
.options__title { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
/* Technical summaries read as measurements, so they take the mono face. */
.tool-status { min-height: 1.5em; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.tool-status.is-error { color: var(--danger); }
.tool-status.is-ok { color: var(--ok); }
.storage-list { display: grid; gap: 8px; list-style: none; padding: 0; }
.storage-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-s); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: var(--s-3); }
.stat { display: grid; gap: 2px; padding: 12px 16px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-s); }
.stat__value { font-family: var(--font-mono); font-size: 22px; font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat__label { font-size: 12px; color: var(--muted); }

.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface-2); color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.notice .icon { margin-top: 2px; }
.notice--error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.notice--warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.notice--ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

.output { max-height: 30rem; margin: 0; padding: var(--s-4); overflow: auto; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--r-s); font-family: var(--font-mono); font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-s); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--bg); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table input { padding: 4px 8px; }

.busy { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-strong); border-right-color: var(--ink); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.file-list { display: grid; gap: 8px; list-style: none; padding: 0; }
.file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); padding: 8px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-s); }
.file-row.is-error { border-color: var(--danger); }
.file-row__body { display: grid; gap: 2px; min-width: 0; }
.file-row__name { font-weight: 500; overflow-wrap: anywhere; }
.file-row__meta { font-size: 12px; color: var(--muted); }
.file-row__actions { display: flex; gap: 2px; }
.file-row.is-error .file-row__meta { color: var(--danger); }
.thumb { width: 44px; height: 56px; object-fit: cover; background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; }

.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: var(--s-3); }
.thumb-card { position: relative; display: grid; gap: 6px; padding: 8px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-s); color: var(--muted); font-size: 12px; text-align: center; cursor: pointer; user-select: none; transition: border-color var(--t-1) var(--ease); }
.thumb-card:hover { border-color: var(--ink-2); }
.thumb-card.is-selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--accent); }
.thumb-card canvas, .thumb-card img { width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: contain; background: #fff; border-radius: 3px; }
.thumb-card input { position: absolute; top: 8px; left: 8px; width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.thumb-card--drag { cursor: grab; }

.canvas-stage { position: relative; display: grid; place-items: center; padding: var(--s-4); overflow: hidden; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-s); touch-action: none; }
.canvas-stage canvas { width: auto; height: auto; max-width: 100%; max-height: 70vh; background-color: #fafafa; background-image: linear-gradient(45deg, #e5e5e5 25%, transparent 25%, transparent 75%, #e5e5e5 75%), linear-gradient(45deg, #e5e5e5 25%, transparent 25%, transparent 75%, #e5e5e5 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.crop-box { position: absolute; border: 1.5px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55); cursor: move; touch-action: none; }
.crop-box::before, .crop-box::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.crop-box::before { background: linear-gradient(to right, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.55) calc(33.33% - 0.5px), rgba(255, 255, 255, 0.55) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255, 255, 255, 0.55) calc(66.66% - 0.5px), rgba(255, 255, 255, 0.55) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)); }
.crop-box::after { background: linear-gradient(to bottom, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.55) calc(33.33% - 0.5px), rgba(255, 255, 255, 0.55) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255, 255, 255, 0.55) calc(66.66% - 0.5px), rgba(255, 255, 255, 0.55) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)); }
.crop-handle { position: absolute; width: 14px; height: 14px; background: #fff; border: 1px solid rgba(0, 0, 0, 0.3); border-radius: 2px; }
.crop-handle--n { top: -7px; left: 50%; margin-left: -7px; cursor: ns-resize; }
.crop-handle--s { bottom: -7px; left: 50%; margin-left: -7px; cursor: ns-resize; }
.crop-handle--e { right: -7px; top: 50%; margin-top: -7px; cursor: ew-resize; }
.crop-handle--w { left: -7px; top: 50%; margin-top: -7px; cursor: ew-resize; }
.crop-handle--ne { top: -7px; right: -7px; cursor: nesw-resize; }
.crop-handle--nw { top: -7px; left: -7px; cursor: nwse-resize; }
.crop-handle--se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.crop-handle--sw { bottom: -7px; left: -7px; cursor: nesw-resize; }

.grid-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.grid-table th, .grid-table td { padding: 6px 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; min-width: 80px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.grid-table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none; }
.grid-table th:first-child, .grid-table td:first-child { position: sticky; left: 0; z-index: 2; background: var(--surface); color: var(--muted); text-align: right; }
.grid-table th:first-child { z-index: 3; background: var(--surface-2); }
.grid-table td { background: var(--surface); }
.grid-table th.is-sorted { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ring); }
.grid-table td[contenteditable="true"]:focus { outline: 2px solid var(--ring); outline-offset: -2px; background: var(--bg); white-space: normal; }

/* ---------- Home: hero, quick actions, directory ---------- */

.hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: var(--s-6); padding: var(--s-6) 0; }
/* The dot field covers the upper half of the hero and fades before the drop zone's centre. */
.hero::before { content: ""; position: absolute; inset: 0 0 auto; height: 50%; background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.4px); background-size: 10px 10px; -webkit-mask-image: linear-gradient(to bottom, #000 20%, transparent); mask-image: linear-gradient(to bottom, #000 20%, transparent); pointer-events: none; }
.hero > * { position: relative; }
.hero__title { display: inline-flex; align-items: center; gap: 12px; margin-bottom: var(--s-4); font-size: clamp(1.375rem, 1.15rem + 0.8vw, 1.625rem); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.hero__lede { max-width: 34rem; margin-bottom: var(--s-5); font-size: 16px; line-height: 1.6; color: var(--ink-2); }
/* Three definitions, the way a drawing sheet states its scale. */
.hero__stats { display: flex; flex-wrap: wrap; gap: var(--s-4) var(--s-5); margin: 0 0 var(--s-5); }
.hero__stats div { display: grid; gap: 1px; }
.hero__stats dt { font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); }
.hero__stats dd { margin: 0; font-family: var(--font-mono); font-size: 18px; font-weight: 500; line-height: 1.15; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.search { display: flex; align-items: center; gap: 10px; max-width: 24rem; height: 40px; padding: 0 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-s); color: var(--muted); transition: border-color var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease); }
.search:focus-within { border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-focus); }
.search__input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; color: var(--ink); font-size: 14px; }
.search__input::placeholder, .palette__input::placeholder { color: var(--muted); opacity: 1; }

.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: var(--s-6) var(--s-5); text-align: center; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-l); transition: border-color var(--t-1) var(--ease), background-color var(--t-1) var(--ease); }
.dropzone--over { background: var(--surface-2); border-color: var(--ink); border-style: solid; }
.dropzone--over .dropzone__art-sheet { fill: var(--surface-2); }
.dropzone--compact { padding: var(--s-5); border-radius: var(--r-m); }
.dropzone__art { margin: 0 auto var(--s-3); color: var(--muted); }
.dropzone__art-sheet { fill: var(--surface); transition: fill var(--t-1) var(--ease); }
.dropzone__icon { margin: 0 auto var(--s-1); color: var(--muted); }
.dropzone__title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.dropzone__hint { max-width: 30rem; font-size: 14px; color: var(--muted); }
.dropzone__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); margin-top: var(--s-3); }
.dropzone__accept { width: 100%; margin-top: var(--s-1); font-size: 12px; color: var(--muted); }
.dropzone__results { width: 100%; margin-top: var(--s-4); text-align: left; }

.matches { display: grid; gap: var(--s-3); padding: var(--s-4); text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-m); }
.matches__title { font-size: 14px; }
.matches__title strong { overflow-wrap: anywhere; }
.matches__list { display: grid; gap: 4px; list-style: none; padding: 0; }
.matches__tool { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--r-s); text-decoration: none; }
.matches__tool:hover { background: var(--surface-2); }
.matches__name { font-weight: 600; color: var(--ink); }
.matches__desc { font-size: 13px; color: var(--muted); }

.quick { padding: var(--s-4) 0 var(--s-5); }
.quick__links { display: flex; flex-wrap: wrap; gap: 8px 20px; list-style: none; margin: 0; padding: 0; }
.most-used { padding-bottom: var(--s-5); }
.most-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.most-card { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; min-height: 44px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); color: var(--ink); text-decoration: none; cursor: pointer; transition: border-color var(--t-1) var(--ease), background-color var(--t-1) var(--ease); }
.most-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.most-card__num { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.most-card__body { display: grid; gap: 1px; min-width: 0; }
.most-card__name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.most-card__cat { font-size: 12px; color: var(--muted); }
.tool-link { font-size: 14px; }
.tool-link:hover { color: var(--ink); }

.directory { padding-bottom: var(--s-6); }
/* Twelve categories divide evenly into three, four and six columns, so no row is left with stragglers. */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: var(--s-5) 0; }
.tile { display: grid; justify-items: center; align-content: center; gap: 6px; min-height: 88px; padding: 14px 8px; border: 1px solid transparent; border-radius: var(--r-m); color: var(--ink); text-align: center; text-decoration: none; transition: border-color var(--t-1) var(--ease), background-color var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease); }
.tile:hover { border-color: var(--line-strong); background: var(--surface); box-shadow: var(--shadow-hover); }
.tile .icon { color: var(--muted); }
.tile:hover .icon { color: var(--ink); }
.tile__name { font-size: 14px; font-weight: 500; }
.tile__count { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.directory__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s-7); border-top: 1px solid var(--line); }
.cat { padding: var(--s-4) 0; }
.cat__title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-2); font-size: 14px; }
.cat__title a { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); text-decoration: none; }
.cat__title a:hover .cat__name { text-decoration: underline; text-decoration-color: var(--ring); text-underline-offset: 0.18em; }
.cat__title .icon { color: var(--muted); }
.cat__count { font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.cat__list { display: grid; gap: 4px; list-style: none; padding: 0; }
.cat__list .tool-link { color: var(--ink-2); }
.cat__list .tool-link:hover { color: var(--ink); }

/* ---------- Browse, categories and lists ---------- */

.page-head { max-width: 46rem; margin: var(--s-5) 0 var(--s-5); }
.page-head h1 { margin: var(--s-3) 0 var(--s-2); font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.5rem); }
.page-head p { font-size: 16px; color: var(--muted); }
.page-head__icon { margin-right: 10px; color: var(--muted); vertical-align: -5px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.crumbs .icon { color: var(--muted); }
.tool-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 var(--s-6); list-style: none; margin: 0; padding: 0; }
.tool-cards > li { position: relative; }
/* Tool entries are framed by the rails and hairlines, not by floating cards. */
.tool-card { display: grid; gap: 2px; height: 100%; padding: 12px 8px; border-top: 1px solid var(--line); border-radius: 0; color: var(--ink); text-decoration: none; transition: background-color var(--t-1) var(--ease); }
.tool-card:hover { background: var(--surface); }
.tool-card__name { font-weight: 600; }
.tool-card__desc { font-size: 14px; line-height: 1.5; color: var(--muted); }
.tool-cards--removable .tool-card { padding-right: 52px; }
.tool-cards--removable .icon-btn { position: absolute; top: 8px; right: 8px; }
/* A saved entry with a thumbnail: the picture of the last file opened with that tool. */
.tool-card--saved { grid-template-columns: 44px minmax(0, 1fr); align-items: start; gap: 10px; }
/* Saved lists stay a tidy grid: the description never pushes a row taller than its neighbours. */
.tool-cards--removable .tool-card__desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.tool-card__text { display: grid; gap: 2px; min-width: 0; }
.tool-card__thumb { width: 44px; height: 44px; object-fit: cover; border: 1px solid var(--line-strong); border-radius: 4px; background: #ffffff; }
.tool-card__file { font-family: var(--font-mono); font-size: 11px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.cat-section { margin-bottom: var(--s-5); }
.cat-section__title { display: flex; align-items: center; gap: 10px; margin-bottom: 0; padding-bottom: var(--s-2); border-bottom: 1px solid var(--line); font-size: 16px; }
.cat-section__title .icon { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
/* Filter rows above a list: a label column, then chips. */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-3); margin-bottom: var(--s-4); }
.filter-bar__label { min-width: 5.5rem; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); }
[data-browse-body] .filter-bar .chips { margin-bottom: 0; }
.list-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s-2); margin-bottom: var(--s-3); }
.list-bar__label { margin-right: var(--s-2); font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 999px; font-size: 12px; color: var(--ink-2); text-decoration: none; transition: border-color var(--t-1) var(--ease), color var(--t-1) var(--ease); }
.chip:hover { border-color: var(--ink-2); color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip__count { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.chip.is-active .chip__count { color: inherit; opacity: 0.75; }
.browse-bar { max-width: 32rem; margin-bottom: var(--s-4); }
[data-browse-body] .chips { margin-bottom: var(--s-5); }
[data-cat-kind] .filter-bar__label { min-width: 5.5rem; }
.featured-section { margin-bottom: var(--s-4); }
.featured-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.featured-card { display: grid; gap: 4px; align-content: start; min-height: 44px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); color: var(--ink); text-decoration: none; cursor: pointer; transition: border-color var(--t-1) var(--ease), background-color var(--t-1) var(--ease); }
.featured-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.featured-card__name { font-size: 15px; font-weight: 600; }
.featured-card__desc { font-size: 13px; line-height: 1.45; color: var(--muted); }
.empty { padding: var(--s-6); border: 1px dashed var(--line-strong); border-radius: var(--r-m); text-align: center; color: var(--muted); }

/* ---------- Tool pages ---------- */

.tool-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-5); margin: var(--s-4) 0 var(--s-5); }
.tool-head h1 { margin-bottom: var(--s-2); font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.5rem); }
.tool-head__desc { max-width: 44rem; font-size: 16px; color: var(--muted); }
.local-note { display: inline-flex; align-items: center; gap: 6px; margin-top: var(--s-3); font-size: 12px; color: var(--muted); }
.local-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.fav { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px 0 10px; background: transparent; border: 1px solid var(--line-strong); border-radius: var(--r-s); font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; cursor: pointer; transition: background-color var(--t-1) var(--ease), border-color var(--t-1) var(--ease), color var(--t-1) var(--ease); }
.fav:hover { border-color: var(--ink-2); background: var(--surface-2); }
/* A saved tool inverts, so the state is read from shape and fill, not from colour alone. */
.fav[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.fav[aria-pressed="true"] .icon { fill: currentColor; stroke: currentColor; }
.tool { margin-bottom: var(--s-6); padding: var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.tool__body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
.about, .related, .faq { margin-bottom: var(--s-6); }
.about h2, .related h2, .faq h2 { margin-bottom: var(--s-3); font-size: 16px; }
.about p { max-width: 42rem; margin: var(--s-3) 0 0; font-size: 14px; color: var(--muted); }
.about p:last-child { margin-bottom: 0; }
.faq__list { display: grid; gap: 8px; max-width: 44rem; }
.faq__item { border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); }
.faq__q { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 14px; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; list-style: none; }
.faq__q::-webkit-details-marker { display: none; }
.faq__q::after { content: '+'; font-family: var(--font-mono); font-size: 16px; color: var(--muted); }
.faq__item[open] .faq__q::after { content: '-'; }
.faq__a { padding: 0 14px 12px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.related .tool-link { font-size: 14px; }
.related .quick__links { margin-top: var(--s-3); }

/* ---------- Dialogs, overlay, toasts ---------- */

dialog { padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-m); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.palette { width: min(640px, calc(100vw - 32px)); margin: 12vh auto auto; }
.palette__bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palette__input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--ink); font-size: 16px; }
.palette__list { max-height: 60vh; margin: 0; padding: 8px; overflow: auto; list-style: none; }
.palette__list a, .palette__list button { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); width: 100%; padding: 10px 12px; border: 0; border-radius: var(--r-s); background: none; text-align: left; text-decoration: none; cursor: pointer; }
.palette__list li[aria-selected="true"] a, .palette__list li[aria-selected="true"] button { background: var(--surface-2); }
.palette__main { display: grid; gap: 2px; min-width: 0; }
.palette__name { color: var(--ink); font-size: 14px; font-weight: 500; }
.palette__desc { color: var(--muted); font-size: 12px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette__cat { flex: none; font-size: 12px; color: var(--muted); padding-top: 2px; }
.palette__empty { padding: var(--s-5); text-align: center; color: var(--muted); }
.palette__foot { padding: 8px 14px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11px; color: var(--muted); }
.shortcut-list { display: grid; gap: 0; border-top: 1px solid var(--line); }
.shortcut-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.shortcut-row .kbd { flex: none; }
.dialog { width: min(560px, calc(100vw - 32px)); }
.dialog[open] { display: grid; gap: var(--s-3); padding: var(--s-5); }
.dialog h2 { font-size: 16px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-2); }

.drop-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: var(--s-3); color: var(--ink); font-size: 20px; font-weight: 600; background: color-mix(in srgb, var(--bg) 88%, transparent); opacity: 0; pointer-events: none; transition: opacity var(--t-1) var(--ease); }
.drop-overlay.is-visible { opacity: 1; }

.toasts { position: fixed; left: 50%; bottom: 24px; z-index: 60; display: grid; justify-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast { display: inline-flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px); padding: 8px 14px; background: var(--surface); color: var(--ink); font-size: 14px; border: 1px solid var(--line-strong); border-radius: var(--r-s); box-shadow: var(--shadow); transition: opacity var(--t-2) var(--ease), transform var(--t-2) var(--ease); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
.toast--error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* ---------- Prose ---------- */

.prose section { padding: var(--s-4) 0; border-bottom: 1px solid var(--line); }
.prose section:last-child { border-bottom: 0; }
.prose h2 { margin-bottom: var(--s-2); font-size: 16px; }
.prose p { font-size: 14px; color: var(--ink-2); }

/* ---------- Tool-specific pieces ---------- */

.toolbar__spacer { flex: 1 1 auto; }
.toolbar > .select, .toolbar > .field { width: auto; }
.btn[aria-pressed="true"] { border-color: var(--ink); background: var(--accent-soft); color: var(--ink); }
button.chip { cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.output--snippet { max-height: 6rem; white-space: pre; }
.input--password { height: 52px; font-family: var(--font-mono); font-size: 18px; letter-spacing: 0.02em; }
.input--color { width: 48px; height: 40px; padding: 2px 4px; cursor: pointer; }
.input--filter { width: min(100%, 16rem); }

.keywords { display: grid; gap: 8px; }
.keyword-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; list-style: none; margin: 0; padding: 0; }
.keyword-list li { display: flex; align-items: baseline; gap: 10px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-s); font-size: 14px; }
.keyword-list__rank { width: 1.4ch; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.keyword-list__word { flex: 1; font-weight: 500; }

.unit-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto minmax(0, 1.4fr); align-items: end; gap: var(--s-3); }
.unit-swap .btn { width: 44px; height: 42px; padding: 0; }
.unit-result { font-size: 16px; }
.unit-result strong { font-family: var(--font-mono); font-size: 24px; font-weight: 500; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.unit-result__from { display: block; font-size: 14px; color: var(--muted); }

.file-row__icon { display: grid; place-items: center; width: 44px; color: var(--muted); }
.thumb--blank { display: grid; place-items: center; color: var(--muted); }
.file-list--drag li[draggable="true"] { cursor: grab; }
.drop-target { box-shadow: 0 0 0 2px var(--ink) !important; }

.grid-wrap { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-s); }
.grid-wrap .grid-table th, .grid-wrap .grid-table td { background-clip: padding-box; }
.grid-table .th-remove { visibility: hidden; margin-left: 6px; padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.grid-table th:hover .th-remove { visibility: visible; color: var(--danger); }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s-3); font-size: 14px; }
.pager__page { min-width: 7rem; text-align: center; }

.canvas-frame { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.crop-layer { position: absolute; inset: 0; }

/* ---------- Values, colors, comparisons and previews ---------- */

.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-4); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input--wide { width: 100%; }
.input--mono { font-family: var(--font-mono); font-size: 13px; }
.copy-field { display: grid; grid-template-columns: minmax(5rem, auto) minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); padding: 8px 8px 8px 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-s); }
.copy-field__label { font-size: 12px; font-weight: 600; color: var(--muted); }
.copy-field__value { font-family: var(--font-mono); font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; }

.color-input { display: flex; align-items: center; gap: var(--s-2); }
.color-input .input--color { flex: none; cursor: pointer; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.15); vertical-align: -3px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: var(--s-2); }
.swatch-card { display: grid; gap: var(--s-2); padding: 8px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-s); text-align: left; cursor: pointer; font: inherit; color: inherit; }
.swatch-card:hover { border-color: var(--ink-2); }
.swatch-card__color { height: 64px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.08); }
.swatch-card__hex { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.swatch-card__meta { font-size: 12px; color: var(--muted); }

.preview { padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-s); overflow-wrap: anywhere; }
.preview > :first-child { margin-top: 0; }
.preview > :last-child { margin-bottom: 0; }
.preview h1, .preview h2, .preview h3, .preview h4 { margin: 1.2em 0 0.5em; font-size: 1.25em; letter-spacing: -0.01em; }
.preview h1 { font-size: 1.6em; }
.preview p, .preview ul, .preview ol, .preview pre, .preview blockquote, .preview table, .preview img { margin-bottom: 1em; }
.preview ul, .preview ol { padding-left: 1.5em; }
.preview pre { padding: var(--s-3); background: var(--code-bg); border-radius: var(--r-s); font-family: var(--font-mono); font-size: 13px; overflow-x: auto; }
.preview code { font-family: var(--font-mono); font-size: 0.9em; }
.preview :not(pre) > code { padding: 1px 5px; background: var(--code-bg); border-radius: 4px; }
.preview blockquote { padding-left: var(--s-4); color: var(--muted); border-left: 2px solid var(--line-strong); }
.preview table { border-collapse: collapse; }
.preview th, .preview td { padding: 6px 10px; border: 1px solid var(--line); }
.preview img { max-width: 100%; height: auto; }
.preview hr { margin: 1.5em 0; border: 0; border-top: 1px solid var(--line); }
.preview-stage { position: relative; display: grid; place-items: center; min-height: 200px; padding: var(--s-5); background-color: #fafafa; background-image: linear-gradient(45deg, #e5e5e5 25%, transparent 25%, transparent 75%, #e5e5e5 75%), linear-gradient(45deg, #e5e5e5 25%, transparent 25%, transparent 75%, #e5e5e5 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; border: 1px solid var(--line); border-radius: var(--r-s); }
.preview-shape { width: 128px; height: 128px; border-radius: var(--r-m); background: var(--ink); }
.qr { display: grid; place-items: center; width: fit-content; max-width: 100%; padding: var(--s-4); background: #ffffff; border: 1px solid var(--line-strong); border-radius: var(--r-s); }
.qr canvas, .qr svg { max-width: 100%; height: auto; }
.thumb-card__actions { display: flex; justify-content: center; gap: 4px; }
.thumb-card__stage { display: grid; place-items: center; overflow: hidden; aspect-ratio: 3 / 4; background: #fff; border-radius: 3px; }
.contrast-sample { padding: var(--s-5); border: 1px solid var(--line-strong); border-radius: var(--r-s); display: grid; gap: var(--s-2); }
.gradient-preview { min-height: 200px; border: 1px solid var(--line-strong); border-radius: var(--r-m); }

.table-wrap { max-height: 32rem; overflow: auto; }
.diff { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; }
.diff th { position: sticky; top: 0; z-index: 1; padding: 8px 10px; background: var(--surface-2); font-family: var(--font-sans); font-weight: 600; color: var(--muted); text-align: left; }
.diff td { padding: 0 10px; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff td.is-add { background: var(--ok-soft); }
.diff td.is-remove { background: var(--danger-soft); }
.diff td.is-blank { border-bottom: 1px solid var(--line); }
.diff td.is-num { width: 1%; padding: 0 6px; color: var(--muted); text-align: right; user-select: none; }
.highlight { padding: var(--s-4); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--r-s); font-family: var(--font-mono); font-size: 13px; line-height: 1.6; }
.highlight mark { padding: 1px 0; background: var(--warn-soft); color: var(--ink); box-shadow: 0 2px 0 var(--warn); border-radius: 2px; }
.highlight mark[data-empty] { display: inline-block; width: 2px; height: 1em; vertical-align: -0.15em; padding: 0; background: var(--warn); }

.strength-meter { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.strength-meter span { height: 8px; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--line); }
.strength-meter[data-score="0"] span.is-on, .strength-meter[data-score="1"] span.is-on { background: var(--danger); border-color: var(--danger); }
.strength-meter[data-score="2"] span.is-on { background: var(--warn); border-color: var(--warn); }
.strength-meter[data-score="3"] span.is-on, .strength-meter[data-score="4"] span.is-on { background: var(--ok); border-color: var(--ok); }
.gauge { height: 8px; overflow: hidden; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--line); }
.gauge__fill { height: 100%; background: var(--ink); }
.gauge__fill.is-over { background: var(--danger); }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 6px 10px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-s); font-family: var(--font-mono); font-size: 13px; cursor: pointer; }
.tag:hover { border-color: var(--ink-2); color: var(--ink); }

/* A document meant for paper stays white in both themes. */
.sheet { padding: var(--s-6); background: #ffffff; color: #0a0a0a; border: 1px solid var(--line-strong); border-radius: var(--r-m); overflow-wrap: anywhere; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 15px; }
.sheet th, .sheet td { padding: 8px 10px; border-bottom: 1px solid #e5e5e5; text-align: left; }
.sheet th { font-weight: 600; color: #6b6b6b; }
.sheet .num { text-align: right; }
.sheet input { padding: 4px 8px; background: #ffffff; border: 1px solid var(--line-strong); border-radius: var(--r-s); font: inherit; color: inherit; }
.sheet input:focus { outline: 3px solid var(--ring); outline-offset: 0; }
@media print {
  .sidebar, .sidebar-backdrop, .site-head, .site-foot, .tool-head, .about, .related, .toasts, .hatch, .tool__body > :not(.sheet), .no-print { display: none !important; }
  .page { display: block; padding: 0; border: 0; }
  .page::before, .page::after { display: none; }
  .tool { margin: 0; padding: 0; border: 0; background: none; }
  .sheet { padding: 0; border: 0; }
  .sheet input, .sheet textarea { border: 0; padding: 0; background: none; resize: none; }
  .sheet .table-wrap { max-height: none; overflow: visible; border: 0; }
}

.waveform { display: block; width: 100%; height: 96px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-s); }
.checks { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }
.hex-dump { max-height: 26rem; overflow: auto; padding: var(--s-3); background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--r-s); font-family: var(--font-mono); font-size: 13px; line-height: 1.65; white-space: pre; overflow-x: auto; }
.timer-display, .totp-code { font-family: var(--font-mono); font-size: clamp(2rem, 1.6rem + 2.5vw, 3rem); font-weight: 500; line-height: 1.1; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.clock-work { display: inline-block; padding: 2px 8px; border-radius: var(--r-s); background: var(--ok-soft); color: var(--ok); font-size: 12px; font-weight: 600; }
.frame-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s-3); }
.frame-card { display: grid; gap: var(--s-2); padding: var(--s-2); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-s); }
.frame-card img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border-radius: 3px; }
.type-row { display: grid; gap: 4px; padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
.type-row:last-child { border-bottom: 0; }
.type-row__meta { display: flex; flex-wrap: wrap; gap: var(--s-3); font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.radius-preview { width: 180px; height: 180px; background: var(--ink); border: 2px solid var(--ring); transition: border-radius 0.12s var(--ease); }
.social-card { max-width: 500px; overflow: hidden; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-m); }
.social-card--compact { display: grid; grid-template-columns: 120px minmax(0, 1fr); }
.social-card__media { width: 100%; aspect-ratio: 1.91 / 1; background: var(--surface-2); object-fit: cover; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.social-card--compact .social-card__media { height: 100%; aspect-ratio: 1 / 1; }
.social-card__body { display: grid; gap: 4px; padding: var(--s-3) var(--s-4); }
.social-card__domain { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; overflow-wrap: anywhere; }
.social-card__title { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.social-card__desc { font-size: 14px; color: var(--ink-2); line-height: 1.45; overflow-wrap: anywhere; }

/* ---------- Studio workspaces (Photo Editor & Screenshot Studio) ---------- */

.studio { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--bg); overflow: hidden; }
.studio__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.studio__bar-title { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-right: auto; }
.studio__workspace { display: grid; grid-template-columns: 52px minmax(0, 1fr) 292px; min-height: 540px; }
.studio__rail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; background: var(--surface); border-right: 1px solid var(--line); }
.studio__rail-sep { width: 24px; height: 1px; margin: 4px 0; background: var(--line); }
.studio__tool { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid transparent; border-radius: var(--r-s); background: none; color: var(--ink-2); transition: background-color var(--t-1) var(--ease), color var(--t-1) var(--ease), border-color var(--t-1) var(--ease); }
.studio__tool:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.studio__tool.is-active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.studio__stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-width: 0; min-height: 440px; padding: 20px; overflow: auto; background-color: var(--bg); background-image: linear-gradient(45deg, var(--surface) 25%, transparent 25%, transparent 75%, var(--surface) 75%), linear-gradient(45deg, var(--surface) 25%, transparent 25%, transparent 75%, var(--surface) 75%); background-size: 20px 20px; background-position: 0 0, 10px 10px; }
.studio__viewport { position: relative; display: grid; place-items: center; flex: 1 1 auto; width: 100%; min-height: 0; overflow: auto; }
.studio__frame { position: relative; display: inline-block; line-height: 0; touch-action: none; user-select: none; box-shadow: 0 0 0 1px var(--line-strong); }
.studio__frame canvas { display: block; max-width: none; }
.studio__overlay { position: absolute; inset: 0; touch-action: none; }
.studio__crop-readout { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); padding: 2px 8px; border-radius: 4px; background: rgba(10, 10, 10, 0.84); color: #ffffff; border: 1px solid rgba(255, 255, 255, 0.18); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; pointer-events: none; }
.studio__stage--dots { background-color: var(--bg); background-image: radial-gradient(circle, var(--line-strong) 1px, transparent 1px); background-size: 20px 20px; background-position: 0 0; }
.studio__stage--dark { background: #0d0e10; }
.studio__stage--light { background: #f5f5f5; }

.studio__zoom { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px; padding: 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-m); box-shadow: var(--shadow-hover); }
.studio__zoom .btn--sm { height: 28px; padding: 0 8px; font-size: 12px; font-family: var(--font-mono); border-color: transparent; }
.studio__zoom-val { min-width: 48px; text-align: center; font-family: var(--font-mono); font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }

.studio__panel { display: flex; flex-direction: column; min-width: 0; max-height: 680px; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); scrollbar-width: thin; }
.studio__section { display: grid; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); }
.studio__section:last-child { border-bottom: 0; }
.studio__section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.studio__section-title { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.studio__panel .range-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; }
.studio__panel .range-row .range { grid-column: 1 / -1; }
.studio__panel .range-row .field__label { cursor: pointer; }
.studio__panel .segmented { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(66px, 1fr)); }
.studio__panel .segmented label { display: flex; }
.studio__panel .segmented span { width: 100%; justify-content: center; padding: 6px 8px; font-size: 12px; border-right: 0; box-shadow: inset -1px -1px 0 var(--line); }
.studio__panel .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.studio__panel .checks { gap: 8px 12px; }

.studio__swatches { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.studio__swatch { height: 28px; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-s); transition: transform var(--t-1) var(--ease), box-shadow var(--t-1) var(--ease); }
.studio__swatch:hover { transform: translateY(-1px); }
.studio__swatch.is-active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }

.studio__filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.studio__filter-card { display: grid; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); text-align: center; transition: border-color var(--t-1) var(--ease); }
.studio__filter-card:hover { border-color: var(--line-strong); }
.studio__filter-card.is-active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.studio__filter-card canvas { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 3px; background: var(--surface-2); }
.studio__filter-card span { font-size: 11px; font-weight: 500; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio__filter-card.is-active span { color: var(--ink); font-weight: 600; }

.studio__icon-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.studio__icon-row .btn { padding: 0; width: 100%; }

.studio-layers { display: grid; gap: 4px; list-style: none; padding: 0; margin: 0; }
.studio-layer { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); }
.studio-layer.is-selected { border-color: var(--ink); background: var(--surface-2); }
.studio-layer.is-hidden { opacity: 0.55; }
.studio-layer__name { flex: 1 1 auto; min-width: 0; padding: 4px; border: 0; background: none; text-align: left; font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-layer__acts { display: flex; flex: none; gap: 2px; }
.studio-layer__acts .btn--sm { width: 28px; height: 28px; padding: 0; }

.studio-preset-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.studio-presets__list { display: flex; flex-wrap: wrap; gap: 6px; }
.studio-preset-pill { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: var(--bg); overflow: hidden; }
.studio-preset-pill__apply { border: 0; background: none; padding: 5px 8px; font-size: 12px; color: var(--ink); }
.studio-preset-pill__apply:hover { background: var(--surface-2); }
.studio-preset-pill__del { border: 0; border-left: 1px solid var(--line); background: none; padding: 5px 6px; color: var(--muted); display: inline-grid; place-items: center; }
.studio-preset-pill__del:hover { color: var(--danger); background: var(--danger-soft); }

.studio-split__line { position: absolute; top: 0; bottom: 0; width: 2px; background: #ffffff; box-shadow: 0 0 0 1px rgba(10, 10, 10, 0.7); pointer-events: none; transform: translateX(-1px); }
.studio-split__handle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 28px; height: 28px; border-radius: 999px; background: #ffffff; color: #0a0a0a; border: 1px solid #0a0a0a; display: grid; place-items: center; font-family: var(--font-mono); font-size: 11px; font-weight: 700; pointer-events: none; }
.studio-split__tag { position: absolute; top: 8px; padding: 2px 7px; border-radius: 4px; background: rgba(10, 10, 10, 0.78); color: #ffffff; font-family: var(--font-mono); font-size: 10px; pointer-events: none; }

.studio-history { display: grid; gap: 4px; max-height: 220px; overflow-y: auto; }
.studio-history__btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); font-size: 12px; text-align: left; color: var(--ink-2); }
.studio-history__btn:hover { border-color: var(--line-strong); color: var(--ink); }
.studio-history__btn.is-current { border-color: var(--ink); background: var(--surface-2); color: var(--ink); font-weight: 600; }
.studio-history__idx { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

.studio-queue { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.studio-queue__item { position: relative; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; background: var(--bg); padding: 0; aspect-ratio: 1 / 1; }
.studio-queue__item.is-active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.studio-queue__item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.studio-step-list { display: grid; gap: 8px; }
.studio-step-card { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg); }
.studio-step-card__head { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; font-weight: 600; }
.studio-step-card__head .row { flex-wrap: nowrap; gap: 3px; flex: none; }

.palette__cmds { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.palette__cmds-label { font-size: 11px; font-family: var(--font-mono); color: var(--muted); margin-right: 4px; }
.palette__cmd-chip { padding: 3px 8px; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: var(--bg); color: var(--ink-2); font-family: var(--font-mono); font-size: 11px; }
.palette__cmd-chip:hover { color: var(--ink); background: var(--surface-2); }

.studio__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px; background: var(--surface); border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.studio__foot-status { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.studio__drop-hints { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }

.studio-export-dialog { width: min(480px, calc(100vw - 32px)); }
.studio-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.studio-dim-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.studio-dim-row .input--num { width: 100%; }
.studio-dialog__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); }

/* ---------- Narrow screens ---------- */

@container shell (min-width: 560px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@container shell (min-width: 820px) {
  .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@container shell (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: var(--s-5); padding: var(--s-5) 0; }
  .unit-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .unit-form > :last-child { grid-column: 1 / -1; }
  .studio__workspace { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .studio__rail { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .studio__rail-sep { width: 1px; height: 24px; margin: 0 2px; }
  .studio__stage { min-height: 280px; padding: 14px; }
  .studio__panel { border-left: 0; border-top: 1px solid var(--line); max-height: none; }
}
@container shell (max-width: 680px) {
  .search-btn span, .search-btn .kbd { display: none; }
  .donate-btn { display: none; }
  .directory__grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .nav { gap: var(--s-2); }
  .quick { padding-top: var(--s-3); }
  .tool { padding: var(--s-3); }
  .tool-head { flex-direction: column; }
  .range-row { grid-template-columns: minmax(0, 1fr) auto; }
  .range-row .field__label { grid-column: 1 / -1; }
  .copy-field { grid-template-columns: minmax(0, 1fr) auto; }
  .copy-field__label { grid-column: 1 / -1; }
  .segmented span { padding: 7px 12px; font-size: 13px; }
  /* On a phone the two filter rows would eat the screen, so each row scrolls sideways instead of wrapping. */
  .filter-bar { display: block; margin-bottom: var(--s-3); }
  .filter-bar__label { display: block; margin-bottom: 6px; }
  [data-browse-body] .filter-bar .chips, [data-cat-kind] .chips { flex-wrap: nowrap; overflow-x: auto; margin: -6px; padding: 6px; scrollbar-width: thin; overscroll-behavior-x: contain; }
  [data-browse-body] .filter-bar .chip, [data-cat-kind] .chip { flex: 0 0 auto; }
  .list-bar { gap: 6px; }
  .list-bar__label { min-width: 100%; }
}
@media (max-width: 479px) {
  .nav { gap: 6px; }
  .nav__actions { gap: 2px; }
  .menu-btn { width: 44px; padding: 0; justify-content: center; }
  .menu-btn span { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .nav__brand { gap: 6px; font-size: 13.5px; min-width: 0; }
  .nav__brand .brand__glyph { width: 18px; height: 18px; }
}
@media (pointer: coarse), (max-width: 640px) {
  /* Touch targets stay at least 44px even though the visual frame is 36px. */
  .icon-btn, .lang-btn, .search-btn, .menu-btn, .side-cat__toggle, .studio__tool, .studio__swatch, .studio-layer__acts .btn--sm, .studio-preset-pill__del { min-width: 44px; min-height: 44px; }
  .studio__zoom .btn--sm, .studio-layer__name, .studio-preset-pill__apply, .studio-history__btn, .palette__cmd-chip { min-height: 44px; }
  .side-link, .side-search, .side-sublink, .btn, .btn--sm, .chip, .fav, .check { min-height: 44px; align-items: center; }
  .side-sublink { display: flex; }
  .segmented span { min-height: 44px; align-items: center; }
  .input, .select { height: 44px; }
  /* 16px fields stop iOS Safari from zooming the page on focus. */
  .input, .textarea, .select { font-size: 16px; }
  /* List links and small controls get the same target height as buttons. The negative margin keeps the text aligned. */
  .brand, .search { min-height: 44px; }
  .search { height: 46px; }
  .crumbs a { min-width: 44px; justify-content: flex-start; }
  .tool-link, .section-bar__link, .crumbs a, .foot__links a, .tag, .cat__title a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 4px; margin-inline: -4px; }
  .matches__tool, .palette__list a, .palette__list button, .most-card, .featured-card, .faq__q { min-height: 44px; }
  .range { height: 44px; }
  .grid-table .th-remove { min-width: 44px; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Windows high-contrast and forced-colours modes draw their own boundaries. */
@media (forced-colors: active) {
  .hatch, .page::after { background: none; }
  .btn, .input, .textarea, .select, .chip, .fav, .lang-btn, .menu-btn, .side-search, .tile, .thumb-card, .swatch-card, .tag { border: 1px solid ButtonText; }
  :focus-visible { outline-color: Highlight; }
}
