/* ============================================================
   Design tokens — AbleMosaic (neo-Bauhaus modular)
   Brand palette: deep teal anchor, coral for primary actions,
   ochre for energy/markers, sage for balance/validation.
   :root is the dark (deep petrol) theme; [data-theme="light"] is the
   warm-cream theme, which layout.js picks by default.
   ============================================================ */
:root {
  /* Brand constants (same in both themes) */
  --brand-teal: #006666;
  --brand-petrol: #134E4A;
  --brand-coral: #E85D4A;
  --brand-ochre: #F4A236;
  --brand-sage: #74A87E;
  --brand-cream: #F6F1E7;

  --bg: #0E2624;
  --bg-elevated: #133331;
  --bg-elevated-2: #1A3F3C;
  --border: #24504C;
  --border-strong: #2F625D;
  --text: #F4EEE2;
  --text-muted: #B5C4BF;
  --text-faint: #9DB0AB; /* ≥4.5:1 on --bg, --bg-elevated and --bg-elevated-2 (WCAG AA) */
  --accent: #F07A66;
  --accent-text: #13302E;
  --danger: #FF8A7A;
  --success: #8BC497;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  /* Directional "tactile" tile shadow (offset, no blur) */
  --tile-shadow: rgba(0, 0, 0, 0.32);
  --max-width: 1080px;
  --text-scale: 1;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  /* Geometric display face for headings: system fonts only (no web-font
     request, in keeping with the privacy promise). */
  --font-display: "Futura PT", Futura, "Avenir Next", "Century Gothic",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="light"] {
  --bg: #F6F1E7;
  --bg-elevated: #FFFDF8;
  --bg-elevated-2: #EFE7D8;
  --border: #E2D8C6;
  --border-strong: #CBBFA9;
  --text: #13302E;
  --text-muted: #4E5F5C;
  --text-faint: #5A6562; /* ≥4.5:1 on --bg, --bg-elevated and --bg-elevated-2 (WCAG AA) */
  --accent: #C8432F;
  --accent-text: #ffffff;
  --danger: #B3261E;
  --success: #2F6B3D; /* ≥4.5:1 even on its own 12% tint (.privacy-note) */
  --shadow: 0 8px 24px rgba(19, 78, 74, 0.10);
  --tile-shadow: rgba(19, 78, 74, 0.14);
}

/* ============================================================
   Reset
   ============================================================ */
* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  /* Base bumped well past the 16px browser default for easy reading.
     Nearly every font-size below is in rem, so this — combined with
     --text-scale from the A-/A+ control in the header — scales the
     whole site's type together. */
  font-size: calc(20px * var(--text-scale));
}
html[data-theme="light"] {
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.15s ease, color 0.15s ease;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, p {
  margin: 0;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Renders the page content ~15% smaller everywhere (like a permanent
   85% browser zoom), which is what actually frees up the margin the
   skyscraper ads need to clear the content without overlapping it.
   Scoped to the header/main/footer only — NOT to body — so the
   skyscraper/corner ads (appended straight to body) stay full-size
   and stay positioned relative to the real viewport. */
.site-header,
main,
.site-footer {
  zoom: 0.85;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  z-index: 50;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  max-width: 1400px;
  min-height: 68px;
  padding-top: 10px;
  padding-bottom: 10px;
  gap: 16px;
}

.logo {
  font-weight: 700;
  font-size: 1.11rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.logo-mark {
  width: 40px;
  height: 40px;
  display: block;
  flex-shrink: 0;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  row-gap: 4px;
  flex: 1;
}

.main-nav a {
  font-size: 0.89rem;
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--text);
  background: var(--bg-elevated);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Accessible text-size control: A- / A+, always visible in the header
   (not tucked in a menu) so it's easy to find without hunting. */
.text-scale-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elevated);
}

.text-scale-group button {
  width: 40px;
  height: 42px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.text-scale-group button:first-child {
  font-size: 13px;
  border-right: 1px solid var(--border);
}

.text-scale-group button:last-child {
  font-size: 19px;
}

.text-scale-group button:hover:not(:disabled) {
  background: var(--bg-elevated-2);
}

.text-scale-group button:disabled {
  opacity: 0.35;
  cursor: default;
}

.lang-picker {
  position: relative;
  flex-shrink: 0;
}

.lang-picker-btn {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.83rem;
  font-weight: 600;
  padding: 0 6px;
  cursor: pointer;
}

.lang-picker-btn:hover {
  color: var(--text);
}

.lang-picker-caret {
  font-size: 0.65rem;
  color: var(--text-faint);
  margin-left: -2px;
}

.lang-picker .fi {
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 2px;
}

.lang-picker-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 150px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 60;
}

.lang-picker-menu.open {
  display: block;
}

.lang-picker-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  outline: none;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.lang-picker-option:hover {
  background: var(--bg-elevated-2);
}

.lang-picker-option.active {
  color: var(--accent);
  font-weight: 600;
}

.login-link {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 9px 4px;
  white-space: nowrap;
}

.login-link:hover {
  color: var(--text);
}

.pro-link {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  padding: 9px 16px;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.pro-link:hover {
  background: var(--bg-elevated);
}

.pro-link.is-pro {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.theme-toggle {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  font-size: 18px;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--border-strong);
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.nav-toggle:hover {
  border-color: var(--border-strong);
}

/* Desktop: the drawer wrapper is transparent to layout, so .main-nav and
   .header-actions sit directly in the header flex row exactly as before. */
.nav-drawer {
  display: contents;
}

.nav-scrim {
  display: none;
}

body.nav-locked {
  overflow: hidden;
}

/* ---- Mobile navigation: slide-in drawer + scrim ---- */
@media (max-width: 760px) {
  /* The 0.85 content zoom only exists to clear the desktop skyscraper ads
     (shown >=1440px). On phones it just shrinks everything and throws off
     fixed-position math, so drop it back to 1 here. */
  .site-header,
  main,
  .site-footer {
    zoom: 1;
  }

  /* backdrop-filter makes the header a containing block for its
     position:fixed descendants — which would clip the drawer to the
     header's height. Drop the blur here and lean on a solid bg instead. */
  .site-header {
    background: var(--bg);
    backdrop-filter: none;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .site-header.nav-open {
    z-index: 65;
  }

  .site-header.nav-open .nav-toggle {
    position: relative;
    z-index: 61;
  }

  .nav-drawer {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 84vw);
    padding: 76px 20px 28px;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.24s ease, visibility 0.24s ease;
    z-index: 60;
  }

  .site-header.nav-open .nav-drawer {
    transform: translateX(0);
    visibility: visible;
  }

  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
    z-index: 55;
  }

  .site-header.nav-open .nav-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .main-nav {
    flex: none;
    flex-direction: column;
    gap: 2px;
  }

  /* The header pre-rendered in each page's HTML has the nav directly in the
     header row (layout.js later moves it into the off-canvas drawer). Hide
     it here so the static header is as short as the real one — otherwise
     the stacked links made it ~414px tall and the page jumped up when
     layout.js swapped it (CLS 0.38 in Lighthouse). */
  .site-header > .container > .main-nav {
    display: none;
  }

  .main-nav a {
    padding: 12px 14px;
    font-size: 0.95rem;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-top: 14px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }

  .pro-link,
  .login-link {
    text-align: center;
    padding: 12px 16px;
  }

  .text-scale-group {
    width: 100%;
  }

  .text-scale-group button {
    flex: 1;
    height: 44px;
  }

  .theme-toggle {
    width: 100%;
  }

  .lang-picker {
    width: 100%;
  }

  .lang-picker-btn {
    width: 100%;
    height: 44px;
    justify-content: flex-start;
    padding: 0 12px;
  }

  .lang-picker-menu {
    position: static;
    min-width: 0;
    box-shadow: none;
    margin-top: 4px;
  }
}

@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .nav-drawer,
  .nav-scrim {
    transition: none;
  }
}

/* Visually hidden, not display:none — the wordmark stays the logo link's
   accessible name for screen readers on narrow screens. */
@media (max-width: 420px) {
  .logo span.wordmark {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 96px;
  padding: 40px 0;
  color: var(--text-faint);
  font-size: 0.83rem;
}

.site-footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 1400px;
  text-align: center;
  gap: 10px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-links a:hover {
  color: var(--text-muted);
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding-top: 88px;
  padding-bottom: 56px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(34px, 5.5vw, 56px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.12;
  max-width: 800px;
  margin: 0 auto;
}

.hero p {
  margin: 20px auto 0;
  max-width: 580px;
  color: var(--text-muted);
  font-size: 1.11rem;
}

.hero .badges {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 100px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.search-bar {
  max-width: 520px;
  margin: 36px auto 0;
  position: relative;
}

.search-bar input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 18px;
  font-size: 1rem;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--border-strong);
}

/* ============================================================
   Category / tool grid
   ============================================================ */
.category {
  margin: 56px 0;
}

.category-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 18px;
}

.category-head h2 {
  font-size: 1.39rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.category-head span {
  color: var(--text-faint);
  font-size: 0.83rem;
}

/* Screen-reader-only text (e.g. the hub pages' "All … tools" heading that
   keeps the heading order h1 → h2 → h3 without repeating the h1 visually). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* "See all →" link from a homepage section to its category hub page. */
.category-head .category-more {
  margin-left: auto;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  padding: 6px 0;
}

.category-head .category-more:hover {
  text-decoration: underline;
}

/* Category hub pages: "Which tool do I need?" task → tool list. */
.hub-which {
  list-style: none;
  padding: 0;
  margin: 12px 0 8px;
  display: grid;
  gap: 8px;
}

.hub-which li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.hub-which li span {
  color: var(--text-muted);
}

.hub-which li a {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  padding: 4px 0;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.tool-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tool-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

/* Colored badge icons — one per tool, inspired by the flat colored-tile
   icon system common on tool directories like iLovePDF: a solid brand
   color per tool with a simple white line-glyph on top. */
.tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  flex-shrink: 0;
}

.tool-icon svg {
  width: 24px;
  height: 24px;
}

.tool-icon--lg {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  margin-bottom: 16px;
}

.tool-icon--lg svg {
  width: 34px;
  height: 34px;
}

.tool-card h3 {
  font-size: 1rem;
  font-weight: 600;
}

.tool-card p {
  font-size: 0.83rem;
  color: var(--text-muted);
}

/* Recently used: compact pill-style cards instead of the full icon+desc
   tile, since it's just a quick jump-back list, not a browsing surface. */
.tool-grid--chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tool-card--chip {
  flex-direction: row;
  padding: 10px 16px;
  border-radius: 100px;
}

.tool-card--chip h3 {
  font-size: 0.85rem;
  font-weight: 500;
}

/* ============================================================
   Tool page
   ============================================================ */
.breadcrumb {
  font-size: 0.83rem;
  color: var(--text-faint);
  padding: 24px 0 0;
}

/* Taller hit area for thumbs on mobile (was 22px) without moving the text. */
.breadcrumb a {
  display: inline-block;
  padding: 6px 0;
  margin: -6px 0;
}

.breadcrumb a:hover {
  color: var(--text-muted);
}

.tool-header {
  padding: 32px 0 28px;
  text-align: center;
}

.tool-header h1 {
  font-size: clamp(28px, 4.5vw, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tool-header p {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
  padding: 7px 14px;
  border-radius: 100px;
  margin-top: 16px;
}

.tool-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  max-width: 720px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}

.tool-panel.wide {
  max-width: 900px;
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 48px 22px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--bg-elevated-2);
}

.dropzone .icon {
  font-size: 1.89rem;
  margin-bottom: 10px;
}

.dropzone strong {
  font-size: 1rem;
}

.dropzone p {
  color: var(--text-faint);
  font-size: 0.83rem;
  margin-top: 6px;
}

.dropzone input[type="file"] {
  display: none;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.83rem;
}

.file-row .thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}

.file-row .meta {
  flex: 1;
  min-width: 0;
}

.file-row .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row .size {
  color: var(--text-faint);
  font-size: 0.78rem;
}

.file-row .remove {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1.06rem;
  padding: 4px 6px;
}

.file-row .remove:hover {
  color: var(--danger);
}

.file-row .move-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.89rem;
  padding: 4px 6px;
}

.file-row .move-btn:hover:not(:disabled) {
  color: var(--text);
}

.file-row .move-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.file-row .actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.controls {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
}

.field label {
  font-size: 0.83rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field input[type="datetime-local"],
.field input[type="password"],
.field input[type="search"],
.field input[type="url"],
.field select,
.field textarea {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.94rem;
  outline: none;
  width: 100%;
  color: var(--text);
}

/* Native date/time picker indicator stays visible on the dark surface */
.field input[type="date"]::-webkit-calendar-picker-indicator,
.field input[type="time"]::-webkit-calendar-picker-indicator,
.field input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
  cursor: pointer;
}

[data-theme="light"] .field input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="light"] .field input[type="time"]::-webkit-calendar-picker-indicator,
[data-theme="light"] .field input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: none;
}

.field textarea {
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--border-strong);
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 22px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.checkbox-row input {
  accent-color: var(--accent);
  width: 19px;
  height: 19px;
}

.more-options {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
}

.more-options summary {
  cursor: pointer;
  padding: 12px 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}

.more-options summary::-webkit-details-marker {
  display: none;
}

.more-options summary::before {
  content: "▸ ";
}

.more-options[open] summary::before {
  content: "▾ ";
}

.more-options[open] {
  padding-bottom: 14px;
}

.more-options .field-row {
  margin-top: 12px;
}

/* Section heading inside a long .controls form (EXIF / PDF metadata editors) */
.meta-group-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin: 6px 0 -8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  padding: 15px 22px;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s ease, transform 0.05s ease;
  width: 100%;
}

.btn:active {
  transform: scale(0.99);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.88;
}

.btn-secondary {
  background: var(--bg-elevated-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-row .btn {
  width: auto;
  flex: 1;
}

.result {
  margin-top: 20px;
  display: none;
}

.result.visible {
  display: block;
}

.result-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.stat {
  flex: 1;
  min-width: 130px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.stat .label {
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat .value {
  font-size: 1.11rem;
  font-weight: 700;
  margin-top: 4px;
}

.stat .value.saved {
  color: var(--success);
}

.result-preview {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.result-preview img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  max-height: 220px;
  margin: 0 auto;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: var(--accent-text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.btn .spinner {
  display: none;
}

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

.btn.loading .btn-label {
  opacity: 0.7;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-wrap {
  margin-top: 14px;
  display: none;
}

.progress-track {
  height: 8px;
  border-radius: 100px;
  background: var(--bg-elevated-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
}

.progress-text {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 6px;
  text-align: center;
}

.batch-summary {
  font-size: 0.89rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  text-align: center;
}

.error-msg {
  color: var(--danger);
  font-size: 0.83rem;
  margin-top: 10px;
  display: none;
}

.error-msg.visible {
  display: block;
}

.status-msg {
  color: var(--text-muted);
  font-size: 0.83rem;
  margin-top: 10px;
  display: none;
}

.status-msg.visible {
  display: block;
}

/* ============================================================
   Content sections — long-form guide content on tool pages
   ============================================================ */
.info-section {
  max-width: 720px;
  margin: 56px auto 0;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-faint);
  font-size: 0.78rem;
  margin-bottom: 22px;
}

.article-meta .dot-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-faint);
  display: inline-block;
}

/* Links inside article text must look like links (WCAG 1.4.1): the global
   reset makes every <a> inherit the text color with no underline. TOC,
   chips, cards and the hub task list keep their own styling — :where()
   keeps this at (0,1,1) so those later, more specific rules win. */
.info-section :where(p, li, td, .tip-box) a:where(:not(.btn)) {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.info-section :where(p, li, td, .tip-box) a:where(:not(.btn)):hover {
  text-decoration-thickness: 2px;
}

.info-section .toc a,
.info-section .hub-which a {
  text-decoration: none;
}

.toc {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 32px;
}

.toc-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.toc ol {
  margin: 0;
  padding-left: 1.1em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toc a {
  font-size: 0.89rem;
  color: var(--text-muted);
}

.toc a:hover {
  color: var(--text);
  text-decoration: underline;
}

.info-section .article-title {
  font-size: clamp(26px, 4.2vw, 38px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 14px;
}

.info-section code {
  background: var(--surface-2, rgba(127, 127, 127, 0.15));
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

.info-section .lede {
  font-size: 1.11rem;
  color: var(--text);
  margin-bottom: 28px;
  line-height: 1.55;
}

.info-section h2 {
  font-size: 1.28rem;
  font-weight: 700;
  margin-top: 38px;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
  scroll-margin-top: 84px;
}

.info-section h2:first-of-type {
  margin-top: 0;
}

.info-section h3 {
  font-size: 1.06rem;
  font-weight: 600;
  margin-top: 22px;
  margin-bottom: 8px;
}

.info-section p {
  color: var(--text-muted);
  font-size: 0.94rem;
  margin-bottom: 14px;
}

.info-section ul,
.info-section ol {
  color: var(--text-muted);
  font-size: 0.94rem;
  margin: 0 0 14px;
  padding-left: 1.3em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-section strong {
  color: var(--text);
}

.info-section .faq-item {
  margin-bottom: 18px;
}

.info-section .faq-item h3 {
  font-size: 0.96rem;
  margin-top: 0;
  margin-bottom: 4px;
  color: var(--text);
}

.info-section .faq-item p {
  margin-bottom: 0;
}

.tip-box {
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 20px 0;
  font-size: 0.89rem;
  color: var(--text-muted);
}

.tip-box strong {
  color: var(--text);
}

.related-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* "Related tools" sits at the top of .info-section, above the guide
   content — this divider gives it a clear boundary from the article. */
.info-section > .related-tools {
  padding-bottom: 28px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.related-tools a {
  font-size: 0.83rem;
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 100px;
  color: var(--text-muted);
}

.related-tools a:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ============================================================
   Ad slots — containers for manually controlled AdSense units
   (no Auto Ads). layout.js reads data-ad-placement, sets
   data-ad-type ("rectangle" | "horizontal") and injects the
   responsive <ins class="adsbygoogle"> only once that type's unit ID
   is configured. Until then the slot is collapsed: no label, no box.
   Width follows the content column up to a per-type maximum, so
   nothing overflows on mobile; no height is reserved.
   Preview empty slots locally with ?adpreview=1 (localhost only).
   ============================================================ */
.ad-slot {
  display: none;
  width: 100%;
  margin: 40px auto;
  text-align: center;
}

.ad-slot:has(ins.adsbygoogle) {
  display: block;
}

.ad-slot[data-ad-type="rectangle"] {
  max-width: 336px;
}

.ad-slot[data-ad-type="horizontal"] {
  max-width: 970px;
}

.ad-slot .ad-label {
  display: block;
  font-size: 0.61rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.ad-slot ins.adsbygoogle {
  display: block;
  margin: 0 auto;
}

.ad-slot ins.ad-mock {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 280px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-faint);
  font-size: 0.78rem;
}

.ad-slot[data-ad-type="horizontal"] ins.ad-mock {
  height: 100px;
}

@media (min-width: 768px) {
  .ad-slot[data-ad-type="horizontal"] ins.ad-mock {
    height: 250px;
  }
}

.ad-preview .ad-slot:not(:has(ins.adsbygoogle)) {
  display: block;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  min-height: 90px;
}

.ad-preview .ad-slot:not(:has(ins.adsbygoogle))::after {
  content: attr(data-ad-placement) " (" attr(data-ad-type) ")";
  display: block;
  padding: 8px;
  font-size: 0.78rem;
  color: var(--text-faint);
}

/* ============================================================
   PDF page picker (split PDF preview / select / reorder)
   ============================================================ */
.muted-note {
  color: var(--text-faint);
  font-size: 0.78rem;
  margin-top: 10px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.83rem;
  cursor: pointer;
  padding: 2px 0;
}

.text-btn:hover {
  color: var(--text);
  text-decoration: underline;
}

.page-picker-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.page-picker-toolbar .actions {
  display: flex;
  gap: 14px;
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  max-height: 460px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated-2);
}

.page-tile {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}

.page-tile img {
  width: 100%;
  display: block;
  pointer-events: none;
}

.page-tile.selected {
  border-color: var(--accent);
}

.page-tile.excluded {
  opacity: 0.35;
}

.page-tile .badge {
  position: absolute;
  top: 5px;
  left: 5px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-tile .page-num {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

.page-tile .tile-move {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.page-tile:hover .tile-move,
.page-tile:focus-within .tile-move {
  opacity: 1;
}

.page-tile .tile-move button {
  width: 22px;
  height: 22px;
  font-size: 11px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.page-tile .tile-move button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ============================================================
   Calculator specific
   ============================================================ */
.ingredient-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ingredient-row .field {
  flex: 1;
}

.ingredient-row .remove {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-faint);
  border-radius: var(--radius-sm);
  width: 42px;
  height: 42px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.89rem;
}

.ingredient-row .remove:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.add-row-btn {
  align-self: flex-start;
  background: none;
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.83rem;
  cursor: pointer;
}

.add-row-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.89rem;
}

.result-table th,
.result-table td {
  text-align: left;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

.result-table th {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.big-result {
  text-align: center;
  padding: 20px 0 8px;
}

.big-result .value {
  font-size: 2.33rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.big-result .label {
  color: var(--text-faint);
  font-size: 0.83rem;
  margin-top: 4px;
}

.toggle-group {
  display: flex;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.toggle-group button {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 12px;
  font-size: 0.83rem;
  color: var(--text-muted);
  border-radius: 5px;
  cursor: pointer;
}

.toggle-group button.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

/* ============================================================
   Tab bar — like .toggle-group but wraps for 3+ options
   ============================================================ */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.tab-bar button {
  flex: 1 1 auto;
  min-width: 84px;
  background: none;
  border: none;
  padding: 9px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-bar button.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

.field input[type="color"] {
  padding: 4px;
  height: 46px;
  cursor: pointer;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 100%;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-field input[type="color"] {
  width: 46px;
  flex-shrink: 0;
}

.color-field input[type="text"] {
  flex: 1;
  min-width: 0;
  text-transform: uppercase;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}

.style-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 6px 10px;
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.style-swatch:hover {
  border-color: var(--border-strong);
}

.style-swatch.active {
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.style-swatch-preview {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: 6px;
  overflow: hidden;
}

.style-swatch-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================================================
   QR code generator preview
   ============================================================ */
.qr-preview-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.qr-preview canvas,
.qr-preview svg {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}

.qr-empty {
  color: var(--text-faint);
  font-size: 0.83rem;
  text-align: center;
  line-height: 1.5;
}

.qr-stats {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.78rem;
  margin: 10px 0 0;
}

.contrast-warning {
  display: none;
  text-align: center;
  color: var(--danger);
  font-size: 0.78rem;
  margin: 6px 0 0;
}

.contrast-warning.visible {
  display: block;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.logo-preview-wrap {
  display: none;
  align-items: center;
  gap: 10px;
}

.logo-preview-wrap img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
}

.btn-small {
  width: auto;
  padding: 10px 16px;
  font-size: 0.83rem;
}

/* ============================================================
   Password generator
   ============================================================ */
.password-output {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.password-output-text {
  flex: 1;
  min-width: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  word-break: break-all;
  user-select: all;
}

.password-output-text.empty {
  color: var(--text-faint);
  font-size: 0.94rem;
  font-weight: 400;
  letter-spacing: normal;
}

.password-strength {
  margin-top: 12px;
}

.strength-track {
  height: 6px;
  border-radius: 100px;
  background: var(--bg-elevated-2);
  overflow: hidden;
  display: flex;
  gap: 3px;
}

.strength-track span {
  flex: 1;
  height: 100%;
  border-radius: 100px;
  background: var(--border);
}

.strength-track span.filled.weak {
  background: var(--danger);
}

.strength-track span.filled.fair {
  background: #ffb648;
}

.strength-track span.filled.good {
  background: var(--accent);
}

.strength-track span.filled.strong {
  background: var(--success);
}

.strength-label {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 6px;
  text-align: center;
}

/* ============================================================
   Random number / name picker
   ============================================================ */
.pool-note {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 8px;
}

.picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.picker-chip {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.94rem;
}

.wheel-area {
  margin-top: 20px;
  text-align: center;
}

.wheel-wrap {
  position: relative;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  margin: 0 auto;
}

.wheel-rotor {
  width: 100%;
  height: 100%;
}

#wheel-canvas {
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
}

.wheel-pointer {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 20px solid var(--accent);
  z-index: 2;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.winner-banner {
  margin-top: 16px;
  font-size: 1.2rem;
  font-weight: 700;
  min-height: 1.5em;
}

.picker-history {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.picker-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.picker-history-head h3 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.picker-history ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.picker-history li {
  font-size: 0.83rem;
  color: var(--text-muted);
  background: var(--bg-elevated-2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

/* ============================================================
   BMI calculator gauge
   ============================================================ */
.bmi-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  font-weight: 700;
  /* Category color pulled halfway toward the theme text color, so all four
     categories (incl. yellow on light) stay >= 4.5:1 on their own tint. */
  color: color-mix(in srgb, var(--cat-color, var(--accent)) 50%, var(--text));
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat-color, var(--accent)) 32%, transparent);
  padding: 8px 18px;
  border-radius: 100px;
  margin-top: 8px;
}

.bmi-gauge {
  margin-top: 26px;
}

.bmi-gauge-track {
  position: relative;
}

.bmi-gauge-bar {
  display: flex;
  height: 14px;
  border-radius: 100px;
  overflow: hidden;
}

.bmi-gauge-bar .zone {
  height: 100%;
}

.bmi-gauge-marker {
  position: absolute;
  top: -12px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 12px solid var(--text);
  transform: translateX(-50%);
  transition: left 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.bmi-gauge-ticks {
  position: relative;
  height: 16px;
  margin-top: 6px;
}

.bmi-gauge-ticks span {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.68rem;
  color: var(--text-faint);
}

/* ============================================================
   Week number calendar
   ============================================================ */
.wknum-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.wknum-nav-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Shrinks instead of pushing the next-month button off-screen when a
   long translated "Today" + month name meet a 390px phone. */
.wknum-nav .month-label {
  font-weight: 700;
  font-size: 1.02rem;
  flex: 1;
  min-width: 0;
  text-align: center;
}

.wknum-nav #next-month-btn {
  flex-shrink: 0;
}

.wknum-grid {
  display: grid;
  grid-template-columns: 30px repeat(7, minmax(0, 1fr));
  gap: 3px;
  max-width: 380px;
  margin: 0 auto;
}

.wknum-grid .head {
  text-align: center;
  font-size: 0.6rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 0 5px;
}

.wknum-week-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-faint);
  background: var(--bg-elevated-2);
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid transparent;
}

.wknum-week-cell:hover {
  border-color: var(--border-strong);
}

.wknum-week-cell.active {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--text);
  border-color: var(--accent);
}

.wknum-day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: 0.72rem;
  cursor: pointer;
  background: var(--bg-elevated-2);
  border: 1px solid transparent;
}

.wknum-day-cell:hover {
  border-color: var(--border-strong);
}

/* Days from the neighbouring months: --text-faint alone (no extra
   opacity) so these clickable cells keep 4.5:1 contrast. */
.wknum-day-cell.outside {
  color: var(--text-faint);
}

.wknum-day-cell.today {
  box-shadow: inset 0 0 0 2px var(--accent);
  font-weight: 700;
}

.wknum-day-cell.in-selected-week {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.wknum-day-cell.selected {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}

.wknum-summary {
  text-align: center;
  padding: 20px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 20px;
}

.wknum-summary .week-big {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.wknum-summary .range {
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 0.94rem;
}

.wknum-jump-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.wknum-jump-row .field {
  flex: 1;
  min-width: 100px;
}

.wknum-jump-row .btn {
  width: auto;
  flex-shrink: 0;
}

/* ============================================================
   Age calculator
   ============================================================ */
.age-summary {
  text-align: center;
  padding: 20px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 16px;
}

.age-summary .age-big {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.age-summary .age-facts {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.94rem;
}

/* ============================================================
   Image cropper — interactive drag/resize crop selection
   ============================================================ */
.crop-stage-wrap {
  display: flex;
  justify-content: center;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.crop-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  touch-action: none;
  overflow: hidden;
  border-radius: 4px;
}

.crop-stage img {
  display: block;
  max-width: 100%;
  max-height: 65vh;
  user-select: none;
  -webkit-user-drag: none;
}

.crop-box {
  position: absolute;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  border: 1.5px dashed #fff;
  cursor: move;
  touch-action: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.45) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.45) 1px, transparent 1px);
  background-size: 33.334% 33.334%;
  background-position: -1.5px -1.5px;
}

.crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 50%;
  touch-action: none;
}

.crop-handle.n {
  top: 0;
  left: 50%;
  cursor: ns-resize;
}
.crop-handle.s {
  top: 100%;
  left: 50%;
  cursor: ns-resize;
}
.crop-handle.e {
  top: 50%;
  left: 100%;
  cursor: ew-resize;
}
.crop-handle.w {
  top: 50%;
  left: 0;
  cursor: ew-resize;
}
.crop-handle.ne {
  top: 0;
  left: 100%;
  cursor: nesw-resize;
}
.crop-handle.nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}
.crop-handle.se {
  top: 100%;
  left: 100%;
  cursor: nwse-resize;
}
.crop-handle.sw {
  top: 100%;
  left: 0;
  cursor: nesw-resize;
}

.crop-dims {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.78rem;
  margin: 10px 0 0;
}

.btn-highlight {
  animation: btn-pulse 1.8s ease-in-out infinite;
}

@keyframes btn-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
  }
  50% {
    box-shadow: 0 0 0 9px color-mix(in srgb, var(--accent) 0%, transparent);
  }
}

@media (max-width: 600px) {
  .tool-panel {
    padding: 20px;
  }
  .field-row {
    flex-direction: column;
  }
}

/* ============================================================
   In-tool Pro feature markers — badge on a Pro-only control, a
   dimmed "locked" state for its field, and the upsell note.
   ============================================================ */
.pro-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  vertical-align: middle;
  margin-left: 4px;
}

/* Dim only the controls: the label + PRO badge stay full-contrast so the
   locked feature is still readable (axe color-contrast). */
.pro-feature-box.locked > :not(label) {
  opacity: 0.6;
}

.pro-note {
  font-size: 0.83rem;
  color: var(--text-faint);
  margin: -4px 0 0;
}

.pro-note a {
  color: var(--accent);
  font-weight: 600;
}

/* ============================================================
   Pro pricing page (/pro/, /pro/success/, /pro/restore/)
   ============================================================ */
.pro-hero {
  text-align: center;
  padding: 40px 0 8px;
}

.pro-hero h1 {
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.pro-hero p {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 760px;
  margin: 36px auto 0;
}

@media (max-width: 640px) {
  .pricing-grid {
    grid-template-columns: 1fr;
  }
}

.price-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.price-card.featured {
  border-color: var(--accent);
  position: relative;
}

.price-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.price-card .price {
  font-size: 2rem;
  font-weight: 800;
  margin: 10px 0 4px;
}

.price-card .price span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-faint);
}

.price-card .price-sub {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-bottom: 18px;
}

.price-card ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
  font-size: 0.89rem;
  color: var(--text-muted);
}

.price-card ul li strong {
  color: var(--text);
}

.price-card-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.price-card .price-sub.pro-active-note {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 12px;
}

/* ============================================================
   Favicon Generator
   ============================================================ */
.favgen-preview {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.favgen-preview .field label {
  align-items: center;
}

.favgen-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.favgen-preview-bar .btn-small {
  text-transform: none;
  letter-spacing: 0;
}

/* Popped-out: floats above the page and follows the scroll */
.favgen-preview.is-pinned {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  gap: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.favgen-preview.is-pinned .favgen-preview-bar {
  position: sticky;
  top: -18px;
  margin: -18px -18px 0;
  padding: 12px 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

/* Holds the layout space while the preview is floating */
.favgen-preview-placeholder {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 0.8rem;
  padding: 24px;
}

@media (max-width: 560px) {
  .favgen-preview.is-pinned {
    left: 16px;
    width: auto;
  }
}

.favgen-frame-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.favgen-frame {
  width: 256px;
  max-width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: repeating-conic-gradient(var(--border) 0% 25%, transparent 0% 50%) 50% / 18px 18px;
}

.favgen-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.favgen-frame canvas:active {
  cursor: grabbing;
}

.favgen-sizes {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.favgen-size {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.favgen-size canvas {
  image-rendering: -webkit-optimize-contrast;
  background: repeating-conic-gradient(var(--border) 0% 25%, transparent 0% 50%) 50% / 14px 14px;
  border-radius: 3px;
}

.favgen-size span {
  font-size: 0.7rem;
  color: var(--text-faint);
}

/* Mock browser tab */
.favgen-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: 9px 9px 0 0;
  padding: 9px 14px;
  max-width: 240px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.favgen-tab canvas {
  flex-shrink: 0;
}

.favgen-tab span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mock phone home screen icon */
.favgen-ios {
  display: flex;
  align-items: center;
  gap: 14px;
}

.favgen-ios-tile {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  background: #ddd;
}

.favgen-ios-tile canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.favgen-ios small {
  font-size: 0.78rem;
  color: var(--text-faint);
}

.favgen-snippet {
  width: 100%;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-muted);
  resize: vertical;
  white-space: pre;
}

.favgen-swatch-transparent {
  background-image: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%);
  background-size: 12px 12px;
}

/* Inline code / code blocks inside long-form guide content */
.info-section code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.info-section pre {
  overflow-x: auto;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 14px 0;
}

.info-section pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ============================================================
   Dev tools — shared bits
   ============================================================ */

/* Small "Copied!" pill, bottom-center, used by the copy buttons */
.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 100px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 80;
}

.copy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mono-output {
  width: 100%;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  resize: vertical;
  white-space: pre;
  overflow-x: auto;
}

/* Color converter */
.big-swatch {
  width: 100%;
  height: 110px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.palette-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  text-align: left;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.palette-cell:hover {
  border-color: var(--border-strong);
}

.palette-chip {
  height: 44px;
  border-radius: 6px;
  background: var(--sw);
  border: 1px solid var(--border);
  margin-bottom: 6px;
}

.palette-hex {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
}

.palette-sub {
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* Timestamp / UUID / hash — a value with a copy button beside it */
.value-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.value-row input {
  flex: 1;
  min-width: 0;
}

/* Cron explainer */
.cron-sentence {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-top: 4px;
}

.cron-field-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  margin-top: 16px;
}

.cron-field-table th,
.cron-field-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.cron-field-table th {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cron-field-table td:first-child {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--accent);
}

.next-runs {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.next-runs li {
  font-size: 0.86rem;
  color: var(--text-muted);
  background: var(--bg-elevated-2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Find & replace + hash highlighting */
mark.fr-hit {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
  border-radius: 2px;
}

.hash-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.hash-row .hash-algo {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.hash-row .hash-value {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--text);
}

.hash-row.match .hash-value {
  color: var(--success);
}

.verify-banner {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  display: none;
}

.verify-banner.visible {
  display: block;
}

.verify-banner.ok {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 34%, transparent);
  color: var(--success);
}

.verify-banner.bad {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 34%, transparent);
  color: var(--danger);
}

/* Sign a PDF */
.signpdf-stage-wrap {
  display: flex;
  justify-content: center;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow: auto;
}

.signpdf-stage {
  position: relative;
  line-height: 0;
  touch-action: none;
}

.signpdf-stage canvas {
  display: block;
  max-width: 100%;
  border-radius: 4px;
}

.signpdf-placed {
  position: absolute;
  border: 1px dashed var(--accent);
  cursor: move;
  touch-action: none;
}

.signpdf-placed img {
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-user-drag: none;
}

.signpdf-placed .sp-resize {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 50%;
  cursor: nwse-resize;
}

.signpdf-placed .sp-del {
  position: absolute;
  top: -11px;
  right: -11px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.signpad-controls {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.signpad-controls .field {
  max-width: 150px;
}

.signpad-controls .signpad-thickness {
  max-width: 210px;
  flex: 1 1 160px;
}

#stroke-width-val {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.signpdf-pagepick {
  max-width: 260px;
  margin-top: 20px;
}

.signpad {
  width: 100%;
  aspect-ratio: 3 / 1;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  touch-action: none;
  cursor: crosshair;
}

.signpdf-pagebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ============================================================
   Countdown generator
   ============================================================ */

.field-hint {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 6px;
}

.countdown-display {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  text-align: center;
}

.cd-seg {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 6px 12px;
}

.cd-num {
  display: block;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: clamp(1.7rem, 8vw, 2.8rem);
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.cd-label {
  display: block;
  margin-top: 8px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.countdown-headline {
  margin-top: 16px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
}

.countdown-display.is-past .cd-num {
  color: var(--text-muted);
}

/* ============================================================
   Coin flip / dice roller / decision spinner
   ============================================================ */

.randomizer-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  gap: 16px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  overflow: hidden;
  perspective: 900px;
}

.randomizer-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  min-height: 1.2em;
}

/* 3D coin */
.coin-wrap {
  position: relative;
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
  will-change: transform;
}

.coin-wrap::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 92px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  filter: blur(6px);
  z-index: -1;
}

.coin {
  position: relative;
  width: 116px;
  height: 116px;
  transform-style: preserve-3d;
  will-change: transform;
}

.coin__face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a4304;
  backface-visibility: hidden;
  background: radial-gradient(circle at 34% 30%, #ffeeb0, #f2c34e 46%, #cc9a33 76%, #9a7420);
  box-shadow:
    inset 0 0 0 4px rgba(255, 255, 255, 0.4),
    inset 0 0 0 9px rgba(150, 108, 24, 0.55),
    0 12px 24px rgba(0, 0, 0, 0.4);
}

.coin__face--heads { transform: rotateX(0deg); }
.coin__face--tails { transform: rotateX(180deg); }

/* Dice */
.dice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  perspective: 600px;
}

.die {
  position: relative;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  will-change: transform;
}

.die--solo {
  width: 88px;
  height: 88px;
  font-size: 2.1rem;
}

/* d6 — classic pip face with a moulded, slightly 3D look */
.die--pips {
  background: linear-gradient(150deg, #fbfbfb, #d6d6d6);
  border-radius: 13px;
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.9),
    inset 0 -4px 6px rgba(0, 0, 0, 0.22),
    0 7px 14px rgba(0, 0, 0, 0.34);
}

.die--pips i {
  align-self: center;
  justify-self: center;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #5a5a5a, #111);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.6);
}

.die--solo.die--pips i {
  width: 17px;
  height: 17px;
}

/* d4/d8/d10/d12/d20/d100 — coloured polygon tokens */
.die--poly {
  color: #fff;
  filter: drop-shadow(0 6px 9px rgba(0, 0, 0, 0.4));
}

.die--poly span {
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.die--poly::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(150deg, var(--die-c1, #6c7bd6), var(--die-c2, #3f4ea0));
}

.die--d4::before { clip-path: polygon(50% 3%, 97% 93%, 3% 93%); }
.die--d8::before { clip-path: polygon(50% 1%, 99% 50%, 50% 99%, 1% 50%); }
.die--d10::before { clip-path: polygon(50% 1%, 92% 33%, 76% 97%, 24% 97%, 8% 33%); }
.die--d12::before { clip-path: polygon(50% 0, 96% 35%, 79% 92%, 21% 92%, 4% 35%); }
.die--d20::before,
.die--d100::before { clip-path: polygon(25% 3%, 75% 3%, 99% 50%, 75% 97%, 25% 97%, 1% 50%); }

.die--d4 span { transform: translateY(4px); }
.die--d100 span { font-size: 0.8em; }

.die.tumble {
  animation: die-tumble 0.62s cubic-bezier(0.28, 0.8, 0.35, 1);
}

@keyframes die-tumble {
  0% { transform: translateY(0) rotateX(0) rotateZ(0); }
  35% { transform: translateY(-30px) rotateX(180deg) rotateZ(90deg); }
  70% { transform: translateY(0) rotateX(320deg) rotateZ(220deg); }
  85% { transform: translateY(-7px) rotateX(350deg) rotateZ(320deg); }
  100% { transform: translateY(0) rotateX(360deg) rotateZ(360deg); }
}

/* Decision spinner — vertical slot reel */
.decide-reel {
  position: relative;
  width: 100%;
  max-width: 340px;
  height: 60px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow:
    inset 0 9px 12px -9px rgba(0, 0, 0, 0.55),
    inset 0 -9px 12px -9px rgba(0, 0, 0, 0.55);
}

.decide-reel::before,
.decide-reel::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 16px;
  z-index: 2;
  pointer-events: none;
}

.decide-reel::before {
  top: 0;
  background: linear-gradient(var(--bg-elevated), transparent);
}

.decide-reel::after {
  bottom: 0;
  background: linear-gradient(transparent, var(--bg-elevated));
}

.decide-reel.landed {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.decide-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  will-change: transform;
}

.decide-cell {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.decide-cell.win {
  color: var(--accent);
}

.randomizer-history {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-faint);
  word-break: break-word;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .coin { transition: none !important; }
  .die.tumble { animation: none !important; }
}

/* ============================================================
   QR code reader
   ============================================================ */

.qr-drop-preview {
  max-height: 320px;
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 16px auto 0;
  display: block;
}

.qr-decoded {
  margin-top: 18px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}

.qr-decoded-type {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.qr-decoded-value {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  color: var(--text);
  word-break: break-all;
  white-space: pre-wrap;
}

.qr-decoded-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

/* ============================================================
   Instagram grid / carousel splitter
   ============================================================ */

.ig-preview-wrap {
  position: relative;
  margin: 16px auto 0;
  max-width: 460px;
  line-height: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  touch-action: none;
}

.ig-preview-wrap img {
  display: block;
  width: 100%;
}

.ig-grid-overlay {
  position: absolute;
  display: grid;
  cursor: move;
  outline: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.ig-grid-overlay > span {
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  padding: 3px 5px;
  line-height: 1;
  pointer-events: none;
}

.ig-reframe {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-top: 14px;
}

.ig-reframe .field {
  flex: 1 1 200px;
  max-width: 320px;
}

.ig-reframe .field-hint {
  flex-basis: 100%;
  margin-top: 0;
}

.ig-tiles {
  display: grid;
  gap: 4px;
  margin-top: 16px;
}

.ig-tiles figure {
  margin: 0;
}

.ig-tiles img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 2px;
  display: block;
  background: var(--bg-elevated-2);
}

.ig-tiles figcaption {
  font-size: 0.68rem;
  color: var(--text-faint);
  text-align: center;
  margin-top: 3px;
}

.ig-order-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 14px;
}

/* ============================================================
   Lottery number generator
   ============================================================ */

.lottery-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.lottery-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.lottery-idx {
  font-size: 0.75rem;
  color: var(--text-faint);
  width: 28px;
  flex: none;
}

.lottery-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  flex: none;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  font-weight: 700;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.lottery-ball.bonus {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.lottery-plus {
  color: var(--text-faint);
  font-size: 0.8rem;
  margin: 0 2px;
}

/* ============================================================
   Passport photo maker
   ============================================================ */
.passport-frame-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.passport-frame {
  position: relative;
  max-width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: repeating-conic-gradient(var(--border) 0% 25%, transparent 0% 50%) 50% / 18px 18px;
}

.passport-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.passport-frame canvas:active {
  cursor: grabbing;
}

.passport-guide {
  position: absolute;
  left: 27%;
  right: 27%;
  top: 12%;
  bottom: 18%;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: 50% / 40%;
  pointer-events: none;
}

.sheet-copies-label {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

/* Waveform trim selector (audio-trimmer). */
.waveform-wrap {
  position: relative;
  width: 100%;
  height: 120px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated-2);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.waveform-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.waveform-mask {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.waveform-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  margin-left: -2px;
  background: var(--accent);
  cursor: ew-resize;
}

.waveform-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

.waveform-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #ffffff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  display: none;
}

.waveform-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* A block of fields inside .controls that is shown/hidden together */
.controls-group {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Non-<label> caption above a button group (same look as .field label) */
.field-label {
  font-size: 0.83rem;
  color: var(--text-muted);
}

.toggle-group button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================
   Image Upscaler — before/after comparison slider
   ============================================================ */
.compare-view {
  max-width: 220px;
  margin: 0 auto 12px;
}

.compare-scroll {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated-2);
  margin-bottom: 14px;
  display: flex;
  justify-content: center;
}

.compare-scroll.is-zoomed {
  overflow: auto;
  max-height: 70vh;
  display: block;
}

.compare {
  --pos: 50%;
  position: relative;
  max-width: 100%;
  line-height: 0;
  user-select: none;
}

.compare img {
  display: block;
  max-width: 100%;
  max-height: 60vh;
}

.compare-scroll.is-zoomed .compare {
  max-width: none;
}

.compare-scroll.is-zoomed .compare img {
  width: 100%;
  max-width: none;
  max-height: none;
}

.compare .compare-before {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  clip-path: inset(0 calc(100% - var(--pos)) 0 0);
}

.compare::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  pointer-events: none;
}

.compare-tag {
  position: absolute;
  top: 8px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.4;
  pointer-events: none;
}

.compare-tag--before {
  left: 8px;
}

.compare-tag--after {
  right: 8px;
}

.compare-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}

.compare:has(.compare-range:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   Image to SVG — side-by-side preview on a checkerboard
   ============================================================ */
.svg-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.svg-compare figure {
  margin: 0;
  min-width: 0;
}

.svg-compare figcaption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.svg-compare-box {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: #fff;
  background-image: repeating-conic-gradient(#e6e6e6 0% 25%, #fff 0% 50%);
  background-size: 16px 16px;
}

.svg-compare-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}


/* ============================================================
   AbleMosaic brand layer — neo-Bauhaus modular
   Flat tiles, geometric shapes (square / quarter / half circle),
   offset directional shadows instead of blurred ones, and a bento
   grid on the homepage + category hubs. Colors come from the brand
   tokens at the top of the file.
   ============================================================ */
h1, h2, h3,
.logo,
.hero h1,
.tool-header h1,
.category-head h2 {
  font-family: var(--font-display);
}

.logo .wordmark {
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Header: a thin four-color mosaic rule under the bar */
.site-header {
  border-bottom: 0;
}
.site-header::after {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(90deg,
    var(--brand-teal) 0 25%, var(--brand-coral) 25% 50%,
    var(--brand-ochre) 50% 75%, var(--brand-sage) 75% 100%);
}

.main-nav a.active {
  box-shadow: inset 0 -3px 0 var(--brand-coral);
}

/* ---- Hero ---- */
.hero {
  padding-top: 64px;
  padding-bottom: 48px;
}

.hero-mosaic {
  display: inline-grid;
  grid-template-columns: repeat(6, 34px);
  grid-auto-rows: 34px;
  gap: 6px;
  margin-bottom: 26px;
}
.hero-mosaic span { display: block; }
.m-teal { background: var(--brand-teal); }
.m-petrol { background: var(--brand-petrol); }
.m-coral { background: var(--brand-coral); }
.m-ochre { background: var(--brand-ochre); }
.m-sage { background: var(--brand-sage); }
:root:not([data-theme="light"]) .m-petrol { background: #2A7A73; }
.m-sq { border-radius: 3px; }
.m-dot { border-radius: 50%; }
.m-q1 { border-radius: 0 100% 0 0; }
.m-q2 { border-radius: 100% 0 0 0; }
.m-q4 { border-radius: 0 0 100% 0; }
.m-arch { border-radius: 100% 100% 0 0 / 100% 100% 0 0; }

.hero-eyebrow {
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.hero .hero-eyebrow {
  margin: 0 auto 14px;
  font-size: 0.83rem;
  color: var(--accent);
}

.badge {
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.search-bar input {
  border: 2px solid var(--border-strong);
  box-shadow: 4px 4px 0 var(--tile-shadow);
}
.search-bar input:focus {
  border-color: var(--brand-teal);
}

/* ---- Tiles: tool cards ---- */
.tool-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow: 3px 3px 0 var(--tile-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.tool-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--tile-shadow);
}
.tool-card > * {
  position: relative;
  z-index: 1;
}
/* Corner shape: a quarter circle in one of the four brand colors,
   cycling so a grid of cards reads as a mosaic. */
.tool-card::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 46px;
  height: 46px;
  border-radius: 100% 0 0 0;
  background: var(--brand-teal);
  opacity: 0.13;
  transition: opacity 0.15s ease, width 0.2s ease, height 0.2s ease;
}
.tool-card:nth-child(4n+2)::after { background: var(--brand-coral); border-radius: 50%; right: -16px; bottom: -16px; }
.tool-card:nth-child(4n+3)::after { background: var(--brand-ochre); border-radius: 100% 100% 0 0 / 100% 100% 0 0; height: 23px; }
.tool-card:nth-child(4n+4)::after { background: var(--brand-sage); border-radius: 0; width: 23px; height: 23px; }
.tool-card:hover::after {
  opacity: 0.32;
}
.tool-card--chip::after { display: none; }

.tool-icon {
  border-radius: var(--radius-sm);
}
.tool-icon--lg {
  border-radius: var(--radius-md);
  box-shadow: 4px 4px 0 var(--tile-shadow);
}

/* ---- Bento grid (homepage sections + category hubs) ----
   The first tile of each section is a feature tile spanning 2×2;
   dense auto-flow packs the rest around it. Only from tablet up, so a
   one-column phone grid never gets an implicit extra column. */
@media (min-width: 760px) {
  .category .tool-grid:not(.tool-grid--chips) {
    grid-auto-flow: dense;
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child {
    grid-column: span 2;
    grid-row: span 2;
    padding: 30px;
    justify-content: flex-end;
    gap: 10px;
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child .tool-icon {
    width: 60px;
    height: 60px;
    margin-bottom: auto;
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child .tool-icon svg {
    width: 32px;
    height: 32px;
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child h3 {
    font-size: 1.39rem;
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child p {
    font-size: 0.94rem;
    max-width: 34ch;
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child::after {
    opacity: 1;
  }
  /* Feature tile: solid teal block with a full-strength ochre quarter */
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child {
    background: var(--brand-teal);
    border-color: var(--brand-teal);
    color: #F6F1E7;
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child p {
    color: rgba(246, 241, 231, 0.86);
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child .tool-icon {
    background: #F6F1E7 !important;
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child .tool-icon svg {
    stroke: var(--brand-teal);
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child .tool-icon svg [fill="#fff"] {
    fill: var(--brand-teal);
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child::after,
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child:hover::after {
    background: var(--brand-ochre);
    border-radius: 100% 0 0 0;
    right: 0;
    bottom: 0;
    width: 120px;
    height: 120px;
    opacity: 1;
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child::before {
    content: "";
    position: absolute;
    right: 120px;
    bottom: 0;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--brand-coral);
    transform: translateY(-60px);
  }
  .category .tool-grid:not(.tool-grid--chips) > .tool-card:first-child p {
    max-width: calc(100% - 200px);
  }
}

.category-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---- Tool page ---- */
.tool-header {
  padding: 24px 0 24px;
}

.tool-panel {
  position: relative;
  border-width: 1px;
  box-shadow: 6px 6px 0 var(--tile-shadow);
}
/* Mosaic rule across the top of every tool panel */
.tool-panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 24px;
  width: 96px;
  height: 5px;
  background: linear-gradient(90deg,
    var(--brand-teal) 0 25%, var(--brand-coral) 25% 50%,
    var(--brand-ochre) 50% 75%, var(--brand-sage) 75% 100%);
}

.dropzone {
  border-width: 2px;
}
.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--brand-teal);
}

.btn-primary {
  box-shadow: 3px 3px 0 var(--tile-shadow);
  transition: opacity 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
}
.btn-primary:hover:not(:disabled) {
  opacity: 1;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--tile-shadow);
}
.btn-primary:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--tile-shadow);
}

.privacy-note {
  border-radius: var(--radius-sm);
}

/* ---- Footer ---- */
.site-footer {
  border-top: 0;
  position: relative;
}
.site-footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 6px;
  background: linear-gradient(90deg,
    var(--brand-teal) 0 25%, var(--brand-coral) 25% 50%,
    var(--brand-ochre) 50% 75%, var(--brand-sage) 75% 100%);
}

@media (prefers-reduced-motion: reduce) {
  .tool-card,
  .tool-card::after,
  .btn-primary {
    transition: none;
  }
}
