/* ============================================
   STUDENT TOOLS — Design system & site shell
   Tokens, base styles, layout (header / sidebar / footer), shared components
   (cards, forms, buttons, results), and the home, category and info pages.
   Tool-specific styles live in tools.css and music.css.
   Fonts (Inter, JetBrains Mono) are loaded by a <link> in each page's <head>.
   ============================================ */

/* ---- TOKENS: light (default) ---- */
:root {
  color-scheme: light;

  --bg: #FFFFFF;
  --bg-subtle: #FAFAFA;
  --surface: #FFFFFF;
  --surface-hover: #F4F4F5;
  --surface-sunken: #F7F7F8;
  --border: #E4E4E7;
  --border-strong: #D4D4D8;
  --text: #18181B;
  --text-2: #52525B;
  --text-3: #71717A;

  /* Accent ("Mono" by default; data-palette swaps it) */
  --accent: #18181B;
  --accent-text: #18181B;
  --on-accent: #FFFFFF;
  --accent-soft: color-mix(in srgb, var(--accent-text) 9%, transparent);
  --accent-ring: color-mix(in srgb, var(--accent-text) 28%, transparent);

  --success: #16A34A;
  --danger: #DC2626;
  --warning: #D97706;
  --gold: #CA8A04;

  /* Category colours (icon tiles) */
  --cat-math: #2563EB;
  --cat-studying: #059669;
  --cat-writing: #EA580C;
  --cat-music: #DB2777;
  --cat-kittle: #AA0000; /* 49ers red, for the one who knows where to look */

  --shadow-xs: 0 1px 2px rgba(16, 16, 20, 0.04);
  --shadow-sm: 0 1px 2px rgba(16, 16, 20, 0.05), 0 1px 3px rgba(16, 16, 20, 0.04);
  --shadow-md: 0 2px 4px rgba(16, 16, 20, 0.04), 0 6px 16px rgba(16, 16, 20, 0.07);
  --shadow-lg: 0 8px 24px rgba(16, 16, 20, 0.10), 0 2px 6px rgba(16, 16, 20, 0.05);
  --shadow-xl: 0 24px 64px rgba(16, 16, 20, 0.18), 0 4px 12px rgba(16, 16, 20, 0.06);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --font-body: 'Inter', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: var(--font-body);
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --header-h: 56px;
  --sidebar-w: 256px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Legacy aliases ----
     The tool styles (tools.css, music.css) and inline styles in the tool
     markup were written against these names. They map onto the tokens above. */
  --bg-primary: var(--bg);
  --bg-secondary: var(--bg-subtle);
  --bg-card: var(--surface);
  --bg-card-hover: var(--surface-hover);
  --bg-input: var(--surface-sunken);
  --border-subtle: var(--border);
  --border-accent: color-mix(in srgb, var(--accent-text) 35%, var(--border));
  --border-color: var(--border);
  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted: var(--text-3);
  --accent-cyan: var(--accent-text);
  --accent-cyan-dim: var(--accent-soft);
  --accent-purple: var(--accent-text); /* old gradients (cyan → purple) render as solid accent */
  --accent-purple-dim: var(--accent-soft);
  --accent-green: var(--success);
  --accent-red: var(--danger);
  --accent-orange: var(--warning);
  --accent-yellow: var(--gold);
  --shadow-card: var(--shadow-xs);
  --shadow-glow: var(--shadow-md);
}

/* ---- TOKENS: dark ---- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #09090B;
  --bg-subtle: #0E0E11;
  --surface: #141417;
  --surface-hover: #1C1C20;
  --surface-sunken: #0F0F12;
  --border: #26262B;
  --border-strong: #3A3A41;
  --text: #FAFAFA;
  --text-2: #A1A1AA;
  --text-3: #8A8A94;

  --accent: #FAFAFA;
  --accent-text: #FAFAFA;
  --on-accent: #18181B;
  --accent-soft: color-mix(in srgb, var(--accent-text) 12%, transparent);

  --success: #4ADE80;
  --danger: #F87171;
  --warning: #FBBF24;
  --gold: #FACC15;

  --cat-math: #60A5FA;
  --cat-studying: #34D399;
  --cat-writing: #FB923C;
  --cat-music: #F472B6;
  --cat-kittle: #F87171;

  --shadow-xs: none;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.65);
}

/* ---- ACCENT PALETTES (data-palette on <html>, set by site.js) ---- */
[data-palette="blue"]   { --accent: #2563EB; --accent-text: #1D4ED8; --on-accent: #FFFFFF; }
[data-palette="indigo"] { --accent: #4F46E5; --accent-text: #4338CA; --on-accent: #FFFFFF; }
[data-palette="violet"] { --accent: #7C3AED; --accent-text: #6D28D9; --on-accent: #FFFFFF; }
[data-palette="red"]    { --accent: #DC2626; --accent-text: #B91C1C; --on-accent: #FFFFFF; }
[data-palette="orange"] { --accent: #EA580C; --accent-text: #C2410C; --on-accent: #FFFFFF; }
[data-palette="yellow"] { --accent: #EAB308; --accent-text: #A16207; --on-accent: #18181B; }
[data-palette="green"]  { --accent: #16A34A; --accent-text: #15803D; --on-accent: #FFFFFF; }
[data-palette="blue"][data-theme="dark"]   { --accent-text: #60A5FA; }
[data-palette="indigo"][data-theme="dark"] { --accent-text: #818CF8; }
[data-palette="violet"][data-theme="dark"] { --accent-text: #A78BFA; }
[data-palette="red"][data-theme="dark"]    { --accent-text: #F87171; }
[data-palette="orange"][data-theme="dark"] { --accent-text: #FB923C; }
[data-palette="yellow"][data-theme="dark"] { --accent-text: #FACC15; }
[data-palette="green"][data-theme="dark"]  { --accent-text: #4ADE80; }

/* Suppress transitions for a frame while theme/palette switches (site.js) */
html[data-switching] *,
html[data-switching] *::before,
html[data-switching] *::after { transition: none !important; }

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}

body.no-scroll { overflow: hidden; }

a { color: inherit; }
img, svg, canvas { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: color-mix(in srgb, var(--accent-text) 22%, transparent); }

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Line icons (inner markup from ICONS in registry.js) */
.i {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-3);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

/* Category icon tile */
.cat-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--cat, var(--text-3));
  background: color-mix(in srgb, var(--cat, var(--text-3)) 11%, transparent);
}
.cat-tile .i { width: 17px; height: 17px; }
[data-cat="math"]     { --cat: var(--cat-math); }
[data-cat="studying"] { --cat: var(--cat-studying); }
[data-cat="writing"]  { --cat: var(--cat-writing); }
[data-cat="music"]    { --cat: var(--cat-music); }
[data-cat="kittle"]   { --cat: var(--cat-kittle); }
.cat-tile.lg { width: 48px; height: 48px; border-radius: var(--radius-md); }
.cat-tile.lg .i { width: 24px; height: 24px; }

/* ============================================
   LAYOUT
   ============================================ */
body.layout-sidebar {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header"
    "sidebar main"
    "sidebar footer";
}
body.layout-sidebar > .site-header { grid-area: header; }
body.layout-sidebar > .site-sidebar { grid-area: sidebar; }
body.layout-sidebar > .page-main { grid-area: main; }
body.layout-sidebar > .site-footer { grid-area: footer; }

body.layout-plain {
  display: flex;
  flex-direction: column;
}
body.layout-plain > .page-main { flex: 1; }

.page-main {
  min-width: 0;
  padding: 32px 40px 72px;
}

/* ---- HEADER ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.hdr-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  border-radius: var(--radius-sm);
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
}
.brand-mark .i { width: 16px; height: 16px; stroke-width: 2.4; }

.hdr-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 20px;
}
.hdr-nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.hdr-nav a:hover { color: var(--text); background: var(--surface-hover); }
.hdr-nav a.is-active { color: var(--text); background: var(--surface-hover); }

.hdr-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.icon-btn:hover { color: var(--text); background: var(--surface-hover); }
.icon-btn .i { width: 18px; height: 18px; }

.hdr-menu { display: none; margin-left: -8px; }

.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  width: 240px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.search-btn:hover { border-color: var(--border-strong); background: var(--surface); }
.search-btn-label { flex: 1; text-align: left; }

/* ---- SETTINGS POPOVER ---- */
.settings { position: relative; }
.settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 272px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 10;
}
.settings-panel[hidden] { display: none; }
.settings-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  margin: 2px 2px 8px;
}
.settings-label + .seg + .settings-label { margin-top: 16px; }

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 3px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.seg-btn .i { width: 14px; height: 14px; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg-btn[aria-pressed="true"] { background: var(--surface-hover); }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.swatch-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.swatch:hover { border-color: var(--border-strong); }
.swatch[aria-pressed="true"] { border-color: var(--text); }

/* ---- SIDEBAR ---- */
.site-sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 20px 12px 32px;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
}
.layout-plain .site-sidebar { display: none; }
.side-head, .side-subjects { display: none; }
.side-backdrop { display: none; }

.side-cat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
}
.side-cat:hover, .side-cat.is-active { background: var(--surface-hover); }
.side-cat-name { display: block; font-weight: 600; font-size: 14px; line-height: 1.3; }
.side-cat-count { display: block; font-size: 12px; color: var(--text-3); }

.side-label {
  padding: 16px 10px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.side-link .i { color: var(--text-3); }
.side-link:hover { color: var(--text); background: var(--surface-hover); }
.side-link.is-active {
  color: var(--text);
  font-weight: 500;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-xs);
}
.side-link.is-active .i { color: var(--accent-text); }

/* ---- FOOTER ---- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 40px 28px;
  font-size: 14px;
}
.ftr-inner {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(120px, 1fr));
  gap: 32px;
  max-width: 1120px;
}
.layout-plain .ftr-inner, .layout-plain .ftr-bottom { margin-left: auto; margin-right: auto; }
.ftr-brand p { margin-top: 12px; color: var(--text-3); max-width: 280px; }
.ftr-col { display: flex; flex-direction: column; gap: 8px; }
.ftr-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.ftr-col a { color: var(--text-2); text-decoration: none; width: fit-content; }
.ftr-col a:hover { color: var(--text); }
.ftr-bottom {
  max-width: 1120px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 13px;
}

/* ============================================
   TOOL PAGES
   ============================================ */
.tool-panel {
  max-width: 960px;
  animation: fadeIn 0.25s ease;
}
.tool-panel:not(.active) { display: none; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.tool-header { margin-bottom: 28px; }
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-3);
}
.breadcrumb a { color: var(--text-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .i { width: 14px; height: 14px; }
.tool-header h1 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.022em;
}
.tool-lede {
  margin-top: 8px;
  max-width: 680px;
  color: var(--text-2);
  font-size: 16px;
}
.tool-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  background: var(--surface);
}

/* ---- CARDS ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  color: var(--text);
}
.card-desc {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 20px;
  line-height: 1.55;
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea { background: var(--surface-sunken); border-color: var(--border); }
.form-input:hover, .form-select:hover, .form-textarea:hover { border-color: color-mix(in srgb, var(--text-3) 60%, var(--border-strong)); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-textarea { resize: vertical; min-height: 96px; }
.form-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}
.form-select option { background: var(--surface); color: var(--text); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, var(--text-3)); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
[data-theme="dark"] .btn-secondary { background: var(--surface-hover); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }

.btn-sm { min-height: 30px; padding: 4px 11px; font-size: 13px; }

.btn-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.request-timer {
  display: none;
  margin-left: 4px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* ---- RESULTS ---- */
.result-box {
  position: relative;
  min-height: 56px;
  margin-top: 20px;
  padding: 16px 18px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
  font-variant-numeric: tabular-nums;
  overflow-x: auto;
}
.result-box:empty::before {
  content: 'Results will appear here';
  color: var(--text-3);
}
.result-box .result-label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.result-box .result-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.result-box .result-step {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.result-box .result-step:last-child { border-bottom: none; }
.result-highlight { color: var(--accent-text); font-weight: 600; }
.result-success { color: var(--success); }
.result-error { color: var(--danger); }

/* ---- MODAL (dynamic, from showModal() in core.js) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 9, 11, 0.45);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}
.modal-box {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 16px; letter-spacing: -0.01em; }

/* ============================================
   SEARCH
   ============================================ */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
  background: rgba(9, 9, 11, 0.4);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.search-overlay[hidden] { display: none; }
.search-dialog {
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: popIn 0.14s ease;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.98) translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}
.search-field .i { width: 18px; height: 18px; }
.search-field input {
  flex: 1;
  height: 54px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}
.search-field input::placeholder { color: var(--text-3); }
.search-results { max-height: min(60vh, 440px); overflow-y: auto; padding: 6px; }
.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
}
.search-item.is-active { background: var(--surface-hover); }
.search-item-text { flex: 1; min-width: 0; }
.search-item-name { display: block; font-size: 14px; font-weight: 500; }
.search-item-desc { display: block; font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item-meta { font-size: 12px; color: var(--text-3); }
.search-empty { padding: 28px 16px; text-align: center; color: var(--text-3); font-size: 14px; }
.search-foot {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-3);
  font-size: 12px;
}
.search-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* ============================================
   COOKIE BANNER
   ============================================ */
.cookie-banner {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 440px;
  padding: 14px 14px 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text-2);
  font-size: 13px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity var(--transition-smooth), transform var(--transition-smooth);
}
.cookie-banner.show { opacity: 1; transform: none; pointer-events: auto; }
.cookie-banner a { color: var(--text); }

/* ============================================
   DIRECTORY (home + category pages)
   ============================================ */
.page-wrap { max-width: 1120px; }
.layout-plain .page-wrap { margin: 0 auto; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), background var(--transition-fast);
}
.tool-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
[data-theme="dark"] .tool-card:hover { background: var(--surface-hover); }
.tool-card-body { min-width: 0; }
.tool-card-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}
.tool-card-desc { display: block; margin-top: 3px; font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.ai-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.02em;
}
.ai-tag .i { width: 10px; height: 10px; }

.dir-section + .dir-section { margin-top: 36px; }
.dir-section-title {
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
}

/* ---- Category page header ---- */
.cat-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
}
.cat-header h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.022em; line-height: 1.2; }
.cat-header p { margin-top: 4px; color: var(--text-2); font-size: 16px; }

/* ---- Homepage ---- */
.hero {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 0 56px;
  text-align: center;
}
.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}
.hero-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.hero h1 {
  margin-top: 22px;
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.hero-lede {
  max-width: 560px;
  margin: 18px auto 0;
  color: var(--text-2);
  font-size: 18px;
  line-height: 1.55;
}
.hero-search {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  height: 52px;
  margin: 32px auto 0;
  padding: 0 12px 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-3);
  font-size: 15px;
  box-shadow: var(--shadow-md);
  cursor: text;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.hero-search:hover { border-color: var(--text-3); }
.hero-search .i { width: 18px; height: 18px; }
.hero-search span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-quick {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--text-3);
  font-size: 13px;
}
.hero-quick a {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  text-decoration: none;
  background: var(--surface);
}
.hero-quick a:hover { color: var(--text); border-color: var(--border-strong); }

.home-cat { padding-top: 8px; }
.home-cat + .home-cat { margin-top: 48px; }
.home-cat-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.home-cat-head h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.home-cat-head p { font-size: 14px; color: var(--text-2); }
.home-cat-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.home-cat-link:hover { color: var(--text); background: var(--surface-hover); }

/* ============================================
   INFO PAGES (guide, contact, legal, Kittle Wall)
   ============================================ */
.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 0 24px;
}
.legal-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
  color: var(--text-3);
  font-size: 14px;
  text-decoration: none;
}
.legal-back:hover { color: var(--text); }
.legal-page h1 {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.legal-page .legal-date { color: var(--text-3); font-size: 14px; margin-bottom: 32px; }
.legal-page h2 {
  margin: 36px 0 10px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}
.legal-page h3 { margin: 24px 0 8px; font-size: 16px; font-weight: 600; color: var(--text); }
.legal-page p, .legal-page li { color: var(--text-2); line-height: 1.75; }
.legal-page p { margin-bottom: 16px; }
.legal-page ul, .legal-page ol { margin: 0 0 16px 22px; }
.legal-page li { margin-bottom: 6px; }
.legal-page strong { color: var(--text); font-weight: 600; }
.legal-page a { color: var(--accent-text); text-underline-offset: 3px; }
.legal-page table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 14px; }
.legal-page th, .legal-page td { padding: 8px 10px; border: 1px solid var(--border); text-align: left; color: var(--text-2); }

.kittle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 24px;
}
.kittle-card {
  overflow: hidden;
  aspect-ratio: 4 / 5;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
}
.kittle-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kittle-empty {
  grid-column: 1 / -1;
  padding: 48px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--text-3);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1100px) {
  .hdr-nav { margin-left: 8px; }
  .search-btn { width: 200px; }
}

@media (max-width: 960px) {
  body.layout-sidebar {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "header" "main" "footer";
  }
  .hdr-menu { display: inline-flex; }

  /* The sidebar becomes a slide-in drawer on every page */
  .site-sidebar,
  .layout-plain .site-sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 400;
    width: min(300px, 86vw);
    height: auto;
    padding: 0 12px 32px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-102%);
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
  }
  body.menu-open .site-sidebar { transform: none; box-shadow: var(--shadow-xl); }
  .side-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 390;
    background: rgba(9, 9, 11, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-smooth);
  }
  body.menu-open .side-backdrop { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }

  .side-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    margin: 0 -12px 8px;
    padding: 0 12px 0 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .side-subjects {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 8px 0 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  .side-subject {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
  }
  .side-subject .cat-tile { width: 26px; height: 26px; border-radius: 6px; }
  .side-subject .cat-tile .i { width: 15px; height: 15px; }
  .side-subject.is-active { background: var(--surface-hover); border-color: var(--border-strong); }
  .side-cat { margin-top: 4px; }
  .layout-plain .side-cat { display: none; }

  .page-main { padding: 28px 24px 64px; }
  .site-footer { padding: 32px 24px 24px; }
}

@media (max-width: 760px) {
  .hdr-inner { padding: 0 16px; gap: 4px; }
  .hdr-nav { display: none; }
  .search-btn { width: 36px; padding: 0; justify-content: center; border-color: transparent; background: transparent; color: var(--text-2); }
  .search-btn .i { width: 18px; height: 18px; }
  .search-btn-label, .search-btn .kbd { display: none; }
  .hdr-actions { gap: 0; }

  .page-main { padding: 24px 16px 56px; }
  .site-footer { padding: 28px 16px 20px; }
  .ftr-inner { grid-template-columns: 1fr 1fr; gap: 24px; }
  .ftr-brand { grid-column: 1 / -1; }

  .tool-header h1, .cat-header h1 { font-size: 24px; }
  .tool-lede, .cat-header p { font-size: 15px; }
  .card { padding: 18px; border-radius: var(--radius-lg); }
  .form-row { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: 1fr; }

  .hero { padding: 28px 0 36px; }
  .hero-lede { font-size: 16px; }
  .hero-search { height: 48px; font-size: 14px; }
  .hero-search .kbd { display: none; }
  .home-cat-head { flex-wrap: wrap; }
  .home-cat-head p { display: none; }

  .cookie-banner { left: 16px; right: 16px; max-width: none; }
  .search-overlay { padding-top: 16px; }
  .search-foot { display: none; }
  .legal-page h1 { font-size: 28px; }
}

/* ---- Contact cards ---- */
.contact-grid { display: grid; gap: 12px; }
.contact-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.legal-page a.contact-card { color: var(--text); }
.contact-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.contact-card-title { display: block; font-weight: 600; }
.contact-card-desc { display: block; margin-top: 2px; color: var(--text-2); font-size: 14px; }
.contact-card-link { display: block; margin-top: 8px; color: var(--accent-text); font-size: 14px; font-weight: 500; }

/* ---- Skip link (keyboard users) ---- */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 3000;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
