/* ==========================================================================
   ToolNest Ultimate — design system
   Mobile-first. Light/dark themes and accent colours via data attributes
   on <html>: data-theme="light|dark", data-accent="indigo|…", data-motion.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Code", "Cascadia Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 160ms;
  --header-h: 64px;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e7eaf2;
  --border: #e1e4ee;
  --border-strong: #c9cfdd;
  --text: #121521;
  --text-2: #353b4d;
  --muted: #5a6174;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / .05), 0 1px 3px rgb(16 24 40 / .06);
  --shadow: 0 6px 16px -4px rgb(16 24 40 / .10), 0 2px 4px -2px rgb(16 24 40 / .06);
  --shadow-lg: 0 28px 56px -16px rgb(16 24 40 / .28);
  --backdrop: rgb(15 18 30 / .45);

  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warn: #8a5300;
  --warn-soft: #fff4dd;
  --success: #12704a;
  --success-soft: #e3f5ec;
  --info-soft: #eaf1ff;
  --star: #e8a200;
  --mark-bg: #ffe27a;
  --mark-text: #1b1b1b;

  /* Accent defaults (indigo); overridden below */
  --accent: #4f46e5;
  --accent-2: #8b5cf6;
  --accent-ink: #ffffff;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0c0e14;
  --surface: #141720;
  --surface-2: #1b1f2a;
  --surface-3: #242938;
  --border: #272c3a;
  --border-strong: #394054;
  --text: #eceef5;
  --text-2: #c9cdd9;
  --muted: #9ea4b5;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow: 0 8px 20px -6px rgb(0 0 0 / .55);
  --shadow-lg: 0 28px 60px -12px rgb(0 0 0 / .7);
  --backdrop: rgb(0 0 0 / .6);

  --danger: #ff8a80;
  --danger-soft: #3a1714;
  --warn: #ffc76b;
  --warn-soft: #33260c;
  --success: #6ee7a8;
  --success-soft: #0f2d20;
  --info-soft: #18213a;
  --star: #ffc53d;
  --mark-bg: #8a6d00;
  --mark-text: #fff;
  color-scheme: dark;
}

/* Accent palettes — light-theme values meet 4.5:1 on white,
   dark-theme values are lighter and paired with dark text. */
[data-accent="indigo"]  { --accent: #4f46e5; --accent-2: #8b5cf6; }
[data-accent="ocean"]   { --accent: #0369a1; --accent-2: #0891b2; }
[data-accent="teal"]    { --accent: #0f766e; --accent-2: #0891b2; }
[data-accent="emerald"] { --accent: #047857; --accent-2: #0f766e; }
[data-accent="amber"]   { --accent: #b45309; --accent-2: #be123c; }
[data-accent="rose"]    { --accent: #be123c; --accent-2: #7c3aed; }
[data-accent="violet"]  { --accent: #7c3aed; --accent-2: #db2777; }

[data-theme="dark"]                         { --accent: #8f97ff; --accent-2: #c4a5ff; --accent-ink: #0c0e14; }
[data-theme="dark"][data-accent="ocean"]    { --accent: #4cc3f7; --accent-2: #5eead4; }
[data-theme="dark"][data-accent="teal"]     { --accent: #2dd4bf; --accent-2: #7dd3fc; }
[data-theme="dark"][data-accent="emerald"]  { --accent: #34d399; --accent-2: #5eead4; }
[data-theme="dark"][data-accent="amber"]    { --accent: #fbbf24; --accent-2: #fb7185; }
[data-theme="dark"][data-accent="rose"]     { --accent: #fb7185; --accent-2: #c4a5ff; }
[data-theme="dark"][data-accent="violet"]   { --accent: #b9a1ff; --accent-2: #f9a8d4; }

:root {
  --accent-soft: rgb(79 70 229 / .1);
  --accent-soft: color-mix(in srgb, var(--accent) 11%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 40%, var(--border));
  --ring: color-mix(in srgb, var(--accent) 55%, transparent);
  --brand-a: var(--accent);
  --brand-b: var(--accent-2);
}
[data-theme="dark"] { --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 56px); }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
main { flex: 1; outline: none; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.5rem); font-weight: 750; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img, svg { display: block; max-width: 100%; }
.icon { flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: .92em; }
/* Coding fonts such as Cascadia Code merge "|---|" or "=>" into ligatures; show the real characters. */
code, kbd, pre, samp, .textarea--mono, .input--mono, .diff-view, .highlight-view { font-variant-ligatures: none; font-feature-settings: "calt" 0, "liga" 0; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: .08em .35em; border-radius: 6px; }
kbd {
  display: inline-block; min-width: 1.6em; padding: .05em .45em; text-align: center;
  background: var(--surface); border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 6px; font-size: .8em; line-height: 1.5; color: var(--text-2);
}
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }

:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
:focus:not(:focus-visible) { outline: none; }

.container { width: min(100% - 32px, 1200px); margin-inline: auto; }
.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); }
html:not(.js) .js-only { display: none !important; }
html.js .no-js-only { display: none !important; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: .95rem; text-decoration: none; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgb(0 0 0 / .15), inset 0 1px 0 rgb(255 255 255 / .15); }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); }
.btn--sm { min-height: 32px; padding: 0 12px; font-size: .875rem; border-radius: 8px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; font-size: .95rem; }
.link-arrow:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-bar { display: flex; align-items: center; gap: 12px; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.logo-mark { border-radius: 9px; box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--accent) 60%, transparent); }
.brand__name { font-family: var(--font-display); font-weight: 750; font-size: 1.15rem; letter-spacing: -.02em; display: inline-flex; align-items: baseline; gap: 6px; }
.brand__tag { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.primary-nav { display: none; gap: 2px; margin-left: 12px; }
.primary-nav a { padding: 8px 12px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-weight: 550; font-size: .95rem; }
.primary-nav a:hover { background: var(--surface-2); color: var(--text); }
.primary-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.header-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.search-trigger {
  display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--muted);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search-trigger:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.search-trigger__label, .search-trigger .kbd-hint { display: none; }
.kbd-hint { font-family: var(--font-sans); font-size: .72rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; white-space: nowrap; }

.theme-icon { display: grid; }
[data-theme="dark"] .theme-icon--moon, [data-theme="light"] .theme-icon--sun { display: none; }

.cat-strip { border-top: 1px solid var(--border); }
.cat-strip__inner {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px 0; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
  mask-image: linear-gradient(90deg, #000 92%, transparent);
}
.cat-strip__inner::-webkit-scrollbar { display: none; }
.cat-strip a, .mobile-menu__cats a {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-pill);
  color: var(--text-2); text-decoration: none; font-size: .875rem; font-weight: 550; white-space: nowrap;
  border: 1px solid transparent;
}
.cat-strip a:hover, .mobile-menu__cats a:hover { background: var(--surface-2); color: var(--text); }
.cat-strip a[aria-current="page"], .mobile-menu__cats a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

.mobile-menu { border-top: 1px solid var(--border); background: var(--surface); padding: 12px 0 18px; max-height: calc(100vh - var(--header-h)); overflow-y: auto; }
.mobile-menu__links { display: grid; gap: 2px; margin-bottom: 12px; }
.mobile-menu__links a { padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; }
.mobile-menu__links a:hover, .mobile-menu__links a[aria-current="page"] { background: var(--surface-2); }
.mobile-menu__heading { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 0 0 6px 12px; }
.mobile-menu__cats { display: flex; flex-wrap: wrap; gap: 6px; }
.mobile-menu__cats a { background: var(--surface-2); }

@media (max-width: 419px) {
  .header-bar { gap: 6px; }
  .header-actions { gap: 0; }
  .brand__tag { display: none; }
}
/* Keyboard shortcut hints are noise on touch-only devices. */
@media (hover: none) and (pointer: coarse) {
  .kbd-hint { display: none !important; }
}
@media (min-width: 640px) {
  .search-trigger { width: 220px; }
  .search-trigger__label { display: inline; flex: 1; text-align: left; }
  .search-trigger .kbd-hint { display: inline; }
}
@media (min-width: 900px) {
  .primary-nav { display: flex; }
  .menu-toggle { display: none; }
  .mobile-menu { display: none !important; }
  .search-trigger { width: 260px; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 40px 0 28px;
  background:
    radial-gradient(60% 80% at 15% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    radial-gradient(50% 70% at 90% 10%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 70%);
}
.hero__inner { text-align: center; max-width: 820px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; margin-bottom: 16px;
  border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--border);
  font-size: .82rem; font-weight: 600; color: var(--text-2); box-shadow: var(--shadow-sm);
}
.eyebrow .icon { color: var(--accent); }
.hero h1 { font-size: clamp(2rem, 1.3rem + 3.6vw, 3.4rem); font-weight: 800; letter-spacing: -.035em; margin-bottom: 12px; }
.grad-text {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { font-size: 1.1rem; color: var(--text-2); max-width: 62ch; }
.hero .lead { margin: 0 auto 24px; }
.hero-search {
  position: relative; display: flex; align-items: center; gap: 10px; max-width: 640px; margin: 0 auto;
  height: 56px; padding: 0 14px 0 16px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 16px; box-shadow: var(--shadow); color: var(--muted);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.hero-search:focus-within { border-color: var(--accent); box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft); }
.hero-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; font-size: 1.05rem; color: var(--text); }
.hero-search input::placeholder { color: var(--muted); }
.hero-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; list-style: none; padding: 0; margin: 20px 0 0; color: var(--muted); font-size: .92rem; }
.hero-facts strong { color: var(--text); font-weight: 700; }

/* ---------- Sections & cards ---------- */
.home { padding-bottom: 24px; }
.home-section { margin: 32px 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin-bottom: 14px; }
.section-head h2 { display: inline-flex; align-items: center; gap: 10px; margin: 0; font-size: 1.2rem; }
.section-head h2 .icon { color: var(--accent); }
.section-head h2 a { color: inherit; text-decoration: none; }
.section-head h2 a:hover { text-decoration: underline; }
.section-note { margin: 0; font-size: .85rem; color: var(--muted); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 14px; list-style: none; padding: 0; margin: 0; }
.tool-card { position: relative; }
.tool-card__link {
  display: flex; gap: 14px; height: 100%; padding: 16px 52px 16px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.tool-card__link:hover { transform: translateY(-2px); border-color: var(--accent-line); box-shadow: var(--shadow); }
.tool-card__icon, .cat-card__icon, .page-header__icon, .tool-header__icon {
  display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
}
.tool-card__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tool-card__title { font-weight: 650; line-height: 1.3; }
.tool-card__desc { color: var(--muted); font-size: .9rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tool-card__meta { color: var(--muted); font-size: .78rem; font-weight: 600; margin-top: 2px; }
.fav-btn {
  position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 9px; border: 0; background: transparent; color: var(--muted);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.fav-btn:hover { background: var(--surface-2); color: var(--star); }
.fav-btn[aria-pressed="true"], .fav-toggle[aria-pressed="true"] .icon { color: var(--star); }
.fav-btn[aria-pressed="true"] svg, .fav-toggle[aria-pressed="true"] svg { fill: currentColor; }
.fav-btn.is-popping svg { animation: pop .35s var(--ease); }
@keyframes pop { 40% { transform: scale(1.3); } }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 14px; list-style: none; padding: 0; margin: 0; }
.cat-card {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.cat-card:hover { transform: translateY(-2px); border-color: var(--accent-line); box-shadow: var(--shadow); }
.cat-card__icon { margin-bottom: 6px; }
.cat-card__name { font-weight: 700; }
.cat-card__desc { color: var(--muted); font-size: .88rem; line-height: 1.45; flex: 1; }
.cat-card__meta { font-size: .78rem; font-weight: 650; color: var(--accent); }
.cat-card--soon .cat-card__icon { background: var(--surface-2); color: var(--muted); }
.cat-card--soon .cat-card__meta { color: var(--muted); }

.values { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.value-card { padding: 20px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.value-card .icon { color: var(--accent); margin-bottom: 10px; }
.value-card h3 { margin-bottom: 6px; }
.value-card p { margin: 0; color: var(--text-2); font-size: .93rem; }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill); font-size: .72rem; font-weight: 700; letter-spacing: .02em; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge--muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.planned-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 8px; list-style: none; padding: 0; margin: 0; }
.planned-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-radius: 10px; border: 1px dashed var(--border-strong); color: var(--text-2); font-size: .92rem; }
details.planned { margin-top: 12px; }
details.planned summary { cursor: pointer; width: fit-content; color: var(--muted); font-weight: 600; font-size: .9rem; padding: 4px 0; }
details.planned[open] summary { margin-bottom: 10px; }

/* ---------- Pages ---------- */
.page { padding: 20px 0 40px; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; padding: 0; margin: 0 0 18px; font-size: .875rem; color: var(--muted); }
.breadcrumb li + li::before { content: "/"; margin-right: 4px; color: var(--border-strong); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.page-header { margin-bottom: 20px; }
.page-header .lead { margin-bottom: 0; }
.page-header--icon { display: flex; gap: 16px; align-items: flex-start; }
.page-header__icon { width: 56px; height: 56px; border-radius: 16px; }

.dir-section { margin: 28px 0; padding-top: 20px; border-top: 1px solid var(--border); }
.dir-none { margin: 0; }
.filter-bar { display: grid; gap: 12px; margin-bottom: 8px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.filter-status { min-height: 1.5em; font-size: .9rem; color: var(--muted); margin: 8px 0 0; }
.input-with-icon { position: relative; display: flex; align-items: center; color: var(--muted); }
.input-with-icon .icon { position: absolute; left: 12px; pointer-events: none; }
.input-with-icon input { padding-left: 40px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .875rem; font-weight: 600;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 40px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--text-2); background: var(--surface); }
.empty-state > .icon { color: var(--muted); margin-bottom: 4px; }
.empty-state h2 { font-size: 1.15rem; margin: 0; }
.empty-state p { max-width: 52ch; margin: 0 0 10px; color: var(--muted); }
.empty-state--large { padding: 56px 20px; margin-top: 12px; }
.big-code { font-family: var(--font-display); font-size: clamp(4rem, 12vw, 7rem); font-weight: 850; line-height: 1; letter-spacing: -.05em; background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Tool pages ---------- */
.tool-header { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; margin-bottom: 20px; }
.tool-header__icon { width: 56px; height: 56px; border-radius: 16px; }
.tool-header h1 { margin-bottom: 6px; }
.tool-header .lead { margin: 0; font-size: 1.02rem; }
.fav-toggle { grid-column: 1 / -1; justify-self: start; }
@media (min-width: 720px) {
  .tool-header { grid-template-columns: auto 1fr auto; }
  .fav-toggle { grid-column: auto; }
}

.tool-root { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm); min-height: 200px; }
@media (min-width: 720px) { .tool-root { padding: 22px; } }
.tool-loading { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 160px; color: var(--muted); }
html:not(.js) .tool-loading { display: none; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tool-grid { display: grid; gap: 18px; }
@media (min-width: 960px) { .tool-grid--split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.tool-stack { display: grid; gap: 16px; }
.panel { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.panel__title { font-weight: 650; font-size: .95rem; margin: 0; }
.panel__meta { font-size: .82rem; color: var(--muted); }

.field { display: grid; gap: 6px; }
.field__label { font-weight: 600; font-size: .9rem; }
.field__hint { font-size: .82rem; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { min-height: 220px; padding: 12px 14px; line-height: 1.6; resize: vertical; }
.textarea--mono, .input--mono { font-family: var(--font-mono); font-size: .9rem; }
.textarea[readonly] { background: var(--surface-2); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .85; }
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.input-row { display: grid; gap: 12px; }
@media (min-width: 640px) { .input-row { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--text-2); cursor: pointer; user-select: none; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.options { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; }

.choice-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.choice-group legend { font-weight: 600; font-size: .9rem; margin-bottom: 8px; padding: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); font-size: .9rem; font-weight: 600; color: var(--text-2);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.choice:hover span { border-color: var(--accent-line); color: var(--text); }
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice input:focus-visible + span { outline: 3px solid var(--ring); outline-offset: 2px; }

.action-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.action-bar--end { justify-content: flex-end; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.examples .btn { font-weight: 550; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; }
.stat { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.stat__value { display: block; font-family: var(--font-display); font-size: 1.55rem; font-weight: 750; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat__label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-top: 2px; }
.stat--primary { background: var(--accent-soft); border-color: var(--accent-line); }
.stat--primary .stat__value { color: var(--accent); }

.progress { height: 8px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.progress__bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .25s var(--ease); }
.progress--done .progress__bar { background: var(--success); }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); font-size: .92rem; background: var(--info-soft); color: var(--text); border: 1px solid var(--border); }
.notice p { margin: 0; }
.notice .icon { margin-top: 2px; }
.notice--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice--warn .icon { color: var(--warn); }
.notice--error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice--error .icon { color: var(--danger); }
.notice--success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.notice--success .icon { color: var(--success); }
.status-line:empty { display: none; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-weight: 650; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap .table tr:last-child td { border-bottom: 0; }
.cell-text { font-family: var(--font-mono); font-size: .85rem; overflow-wrap: anywhere; }

.highlight-view {
  min-height: 220px; max-height: 480px; overflow: auto; padding: 12px 14px; margin: 0;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2);
  font-family: var(--font-mono); font-size: .9rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere;
}
.highlight-view mark { background: var(--mark-bg); color: var(--mark-text); border-radius: 3px; padding: 0 1px; }
.highlight-view mark:empty { display: inline-block; width: 2px; height: 1.1em; vertical-align: text-bottom; background: var(--accent); }

details.disclosure { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
details.disclosure > summary { cursor: pointer; padding: 12px 14px; font-weight: 600; font-size: .95rem; list-style-position: inside; }
details.disclosure[open] > summary { border-bottom: 1px solid var(--border); }
details.disclosure > .disclosure__body { padding: 12px 14px; }

.tool-info { display: grid; gap: 14px; margin-top: 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.info-card { padding: 18px 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.info-card h2 { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin-bottom: 10px; }
.info-card h2 .icon { color: var(--accent); }
.info-card p, .info-card li { color: var(--text-2); font-size: .93rem; }
.info-card ol, .info-card ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.info-card p:last-child { margin-bottom: 0; }
.info-card .muted { color: var(--muted); font-size: .86rem; }
.related { margin-top: 32px; }

/* ---------- Diff view ---------- */
.diff-view {
  min-height: 160px; max-height: 560px; overflow: auto; margin: 0;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  font-family: var(--font-mono); font-size: .88rem; line-height: 1.55;
}
.diff-line { display: grid; grid-template-columns: 3.2em 3.2em 1.6em minmax(0, 1fr); }
.diff-line > span { padding: 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-num { color: var(--muted); text-align: right; user-select: none; background: var(--surface-2); border-right: 1px solid var(--border); }
.diff-sign { color: var(--muted); user-select: none; text-align: center; }
.diff-line--insert { background: var(--success-soft); }
.diff-line--insert .diff-sign { color: var(--success); font-weight: 700; }
.diff-line--delete { background: var(--danger-soft); }
.diff-line--delete .diff-sign { color: var(--danger); font-weight: 700; }
.diff-gap { padding: 4px 12px; color: var(--muted); background: var(--surface-2); font-family: var(--font-sans); font-size: .82rem; border-block: 1px dashed var(--border); }
.diff-inline { padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-inline ins, .diff-inline del { text-decoration: none; border-radius: 3px; padding: 0 1px; }
.diff-inline ins { background: var(--success-soft); color: var(--success); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--success) 45%, transparent); }
.diff-inline del { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; }
.diff-placeholder { padding: 28px 16px; text-align: center; color: var(--muted); font-family: var(--font-sans); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--muted); }
.legend__add { color: var(--success); font-weight: 650; }
.legend__del { color: var(--danger); font-weight: 650; }

/* ---------- Rendered Markdown / HTML preview ---------- */
.md-preview {
  min-height: 320px; max-height: 70vh; overflow: auto; padding: 14px 18px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  line-height: 1.65; overflow-wrap: anywhere;
}
.md-preview > :first-child { margin-top: 0; }
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4 { margin: 1.2em 0 .5em; }
.md-preview h1 { font-size: 1.7rem; }
.md-preview h2 { font-size: 1.35rem; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.md-preview p, .md-preview ul, .md-preview ol, .md-preview pre, .md-preview blockquote, .md-preview table { margin: 0 0 1em; }
.md-preview ul, .md-preview ol { padding-left: 1.5em; }
.md-preview li.task { list-style: none; margin-left: -1.3em; }
.md-preview li.task input { margin: 0 .4em 0 0; vertical-align: middle; accent-color: var(--accent); }
.md-preview pre { padding: 12px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); overflow: auto; }
.md-preview pre code { background: none; border: 0; padding: 0; }
.md-preview blockquote { padding: 2px 14px; border-left: 4px solid var(--accent-line); color: var(--text-2); }
.md-preview table { border-collapse: collapse; display: block; overflow-x: auto; }
.md-preview th, .md-preview td { border: 1px solid var(--border-strong); padding: 6px 10px; }
.md-preview th { background: var(--surface-2); }
.md-preview [align="center"] { text-align: center; }
.md-preview [align="right"] { text-align: right; }
.md-preview img { max-width: 100%; }
.md-preview hr { margin: 1.5em 0; }

/* ---------- Calculators & results ---------- */
.calc-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.calc-card { display: grid; gap: 12px; align-content: start; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.calc-card__title { font-size: 1rem; margin: 0; }
.calc-card__desc { margin: -6px 0 0; font-size: .86rem; color: var(--muted); }
.calc-card .input { background: var(--surface); }
.inline-sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .95rem; }
.inline-sentence .input { width: 9.5em; flex: 0 1 auto; }
.inline-sentence .select { width: auto; }
.field--suffix { position: relative; }
.field--suffix .input { padding-right: 3em; }
.input-suffix { position: absolute; right: 12px; bottom: 10px; color: var(--muted); font-size: .9rem; pointer-events: none; }
.big-result { font-family: var(--font-display); font-size: clamp(1.5rem, 1rem + 2vw, 2.1rem); font-weight: 750; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.big-result--muted { color: var(--muted); font-size: 1rem; font-weight: 500; letter-spacing: 0; }
.formula { font-size: .86rem; color: var(--muted); font-family: var(--font-mono); overflow-wrap: anywhere; }

.result-rows { display: grid; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.result-row { display: grid; grid-template-columns: minmax(7em, 34%) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); }
.result-row:last-child { border-bottom: 0; }
.result-row dt { font-size: .85rem; font-weight: 600; color: var(--muted); }
.result-row dd { margin: 0; min-width: 0; display: grid; gap: 2px; }
.result-row__value { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.result-row__value--mono { font-family: var(--font-mono); font-size: .92rem; font-variant-ligatures: none; }
.result-row__note { font-size: .8rem; color: var(--muted); }
.result-row--main { background: var(--accent-soft); }
.result-row--main .result-row__value { font-size: 1.15rem; font-weight: 700; }
.result-rows__empty { padding: 14px; color: var(--muted); font-size: .9rem; }
.icon-btn--sm { width: 32px; height: 32px; border-radius: 8px; }
@media (max-width: 479px) {
  .result-row { grid-template-columns: minmax(0, 1fr) auto; }
  .result-row dt { grid-column: 1 / -1; }
}

.dropzone { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 20px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); color: var(--muted); text-align: center; transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone__hint { font-size: .9rem; }
.dropzone__file { flex-basis: 100%; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.dropzone__file:empty { display: none; }

/* Scientific calculator */
.calc-display { display: grid; gap: 4px; padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.calc-display .input { font-family: var(--font-mono); font-size: 1.25rem; text-align: right; background: var(--surface); font-variant-ligatures: none; }
.calc-display__result { text-align: right; min-height: 2.2rem; }
.keypad { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.keypad--sci { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.key {
  min-height: 46px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.key:hover { background: var(--surface-2); }
.key:active { transform: scale(.97); }
.key--op { background: var(--surface-2); color: var(--accent); }
.key--fn { font-size: .85rem; color: var(--text-2); background: var(--surface-2); }
.key--eq { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.key--eq:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 260px; overflow: auto; }
.history button { width: 100%; text-align: right; display: grid; gap: 2px; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text); font-family: var(--font-mono); font-size: .88rem; font-variant-ligatures: none; }
.history button:hover { background: var(--surface-2); border-color: var(--border); }
.history .history__expr { color: var(--muted); overflow-wrap: anywhere; }

/* Colour */
.color-preview { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; align-items: center; }
.swatch-big { width: 96px; height: 96px; border-radius: 16px; border: 1px solid var(--border-strong); background-color: #fff; background-image: conic-gradient(#ccc 25%, #fff 0 50%, #ccc 0 75%, #fff 0); background-size: 16px 16px; position: relative; overflow: hidden; }
.swatch-big > span { position: absolute; inset: 0; }
.color-input-row { display: flex; gap: 10px; align-items: end; }
.color-input-row .field { flex: 1; }
.color-input-row input[type="color"] { width: 52px; height: 42px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); cursor: pointer; }
.contrast-sample { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.contrast-sample > div { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); display: grid; gap: 4px; }
.contrast-sample strong { font-size: 1.05rem; }
.badge--pass { background: var(--success-soft); color: var(--success); }
.badge--fail { background: var(--danger-soft); color: var(--danger); }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* JWT */
.jwt-token { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-family: var(--font-mono); font-size: .86rem; overflow-wrap: anywhere; line-height: 1.6; font-variant-ligatures: none; }
.jwt-token .jwt-h { color: #d6336c; }
.jwt-token .jwt-p { color: #7048e8; }
.jwt-token .jwt-s { color: #0c8599; }
[data-theme="dark"] .jwt-token .jwt-h { color: #ff8cc6; }
[data-theme="dark"] .jwt-token .jwt-p { color: #b197fc; }
[data-theme="dark"] .jwt-token .jwt-s { color: #66d9e8; }
.code-block { margin: 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-family: var(--font-mono); font-size: .86rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; font-variant-ligatures: none; }

/* Output lists (UUIDs, random numbers, primes) */
.mono-list { margin: 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2); font-family: var(--font-mono); font-size: .9rem; max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-variant-ligatures: none; }

/* ---------- Prose ---------- */
.prose { max-width: 74ch; }
.prose h2 { margin-top: 1.8em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .35em 0; }
.prose .table { margin: 1em 0; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 48px; border-top: 1px solid var(--border); background: var(--surface); font-size: .92rem; }
.footer-grid { display: grid; gap: 28px; padding: 36px 0 24px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.footer-brand p { color: var(--muted); margin-top: 12px; max-width: 38ch; }
.site-footer h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.site-footer nav a { color: var(--text-2); text-decoration: none; }
.site-footer nav a:hover { color: var(--accent); text-decoration: underline; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 16px 0 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }
.footer-bottom p { margin: 0; }

/* ---------- Dialogs ---------- */
dialog.dialog {
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); width: min(100% - 24px, 560px); max-height: min(100% - 24px, 760px);
}
dialog.dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
dialog.dialog[open] { animation: dialog-in .18s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dialog__head h2 { margin: 0; font-size: 1.15rem; }
.dialog__body { padding: 8px 18px 20px; }
.settings-group { padding: 16px 0; border-bottom: 1px solid var(--border); }
.settings-group:last-child { border-bottom: 0; }
.settings-group h3 { font-size: .95rem; margin-bottom: 10px; }
.settings-group p { font-size: .88rem; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span { display: block; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--text); }
.swatch input:focus-visible + span { outline: 3px solid var(--ring); outline-offset: 3px; }
.swatch--indigo span { background: #4f46e5; }
.swatch--ocean span { background: #0369a1; }
.swatch--teal span { background: #0f766e; }
.swatch--emerald span { background: #047857; }
.swatch--amber span { background: #d97706; }
.swatch--rose span { background: #be123c; }
.swatch--violet span { background: #7c3aed; }
.storage-status { display: flex; gap: 8px; align-items: flex-start; font-size: .86rem; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); margin: 0 0 12px; }

dialog.palette { width: min(100% - 24px, 640px); margin-top: 10vh; max-height: 75vh; display: none; flex-direction: column; overflow: hidden; }
dialog.palette[open] { display: flex; }
.palette__search { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette__search input { flex: 1; min-width: 0; height: 56px; border: 0; background: transparent; outline: none; font-size: 1.05rem; color: var(--text); }
.palette__list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.palette__group { padding: 8px 10px 4px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.palette__option { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; cursor: pointer; color: var(--text); }
.palette__option[aria-selected="true"] { background: var(--accent-soft); }
.palette__option[aria-selected="true"] .palette__go { opacity: 1; }
.palette__option[aria-disabled="true"] { cursor: default; color: var(--muted); }
.palette__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--accent); flex-shrink: 0; }
.palette__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.palette__name { font-weight: 600; }
.palette__desc { font-size: .84rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette__go { opacity: 0; color: var(--accent); }
.palette__empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.palette__foot { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: .78rem; color: var(--muted); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: 16px; transform: translateX(-50%); display: grid; gap: 8px; width: min(100% - 32px, 420px); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-size: .92rem; pointer-events: auto;
  animation: toast-in .2s var(--ease);
}
.toast__msg { flex: 1; }
.toast .btn { min-height: 30px; padding: 0 10px; background: transparent; color: inherit; border-color: currentColor; }
.toast--error { background: var(--danger); color: #fff; }
[data-theme="dark"] .toast--error { color: #1b0b0a; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="full"]) *, html:not([data-motion="full"]) *::before, html:not([data-motion="full"]) *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
[data-motion="reduce"] *, [data-motion="reduce"] *::before, [data-motion="reduce"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important;
}
[data-motion="reduce"] .spinner { animation: spin 1.6s linear infinite !important; }

/* ---------- Print ---------- */
@media print {
  .site-header, .site-footer, .action-bar, .fav-toggle, .fav-btn, .toasts, .tool-info, .related, .breadcrumb { display: none !important; }
  body { background: #fff; color: #000; }
  .tool-root { border: 0; box-shadow: none; padding: 0; }
}

.decoded-image { max-width: 100%; max-height: 320px; width: auto; border-radius: 8px; border: 1px solid var(--border); image-rendering: pixelated; min-width: 64px; background: var(--surface-2); }
