
/* ===== reset / base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(900px 460px at 50% -120px, rgba(245, 158, 11, 0.07), transparent 60%),
    radial-gradient(700px 400px at 100% -200px, rgba(14, 165, 233, 0.05), transparent 65%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== design tokens ===== */
:root {
  /* slate palette (Tailwind-inspired) */
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --bg-soft: #f1f5f9;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --ink-muted: #64748b;
  --ink-subtle: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  /* brand */
  --brand: #0f172a;
  --brand-strong: #020617;
  --brand-ink: #ffffff;
  --accent: #f59e0b;
  --accent-soft: #fffbeb;
  --accent-strong: #b45309;
  --focus: rgba(245,158,11,0.20);

  /* fonts */
  --sys: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* depth */
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.05);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.04);
  --shadow-lg: 0 24px 60px rgba(15,23,42,0.12), 0 8px 20px rgba(15,23,42,0.08);
  --shadow-focus: 0 0 0 3px var(--focus);

  /* radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* container */
  --container: 1280px;
  --sidebar-w: 260px;
}

/* ===== container ===== */
.container { max-width: var(--container); margin: 0 auto; padding: 0 28px; }
@media (max-width: 700px) { .container { padding: 0 18px; } }

/* ===== HEADER ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(226,232,240,0.7);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
  gap: 16px;
}
.logo {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--ink);
  display: inline-flex; align-items: baseline; gap: 1px;
  flex-shrink: 0;
}
.logo:hover { text-decoration: none; color: var(--ink); }
.logo .dot {
  display: inline-block; width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin: 0 1px 4px 2px;
}

/* header right side */
.header-nav { display: flex; align-items: center; gap: 10px; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 500;
  padding: 5px 11px 5px 10px;
  background: linear-gradient(180deg, #ffffff 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.stat-pill .pulse {
  position: relative;
  width: 7px; height: 7px;
  background: #10b981;
  border-radius: 50%;
  flex-shrink: 0;
}
.stat-pill .pulse::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 50%;
  background: #10b981;
  animation: live-pulse 1.8s ease-out infinite;
  opacity: 0.6;
}
@keyframes live-pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.6); opacity: 0; }
}
@media (max-width: 760px) { .stat-pill { display: none; } }
.header-search-mini {
  flex: 1; max-width: 520px;
  position: relative;
  display: none;  /* hidden on homepage, shown on category pages via .show-mini class on body */
}
body.subpage .header-search-mini { display: block; }
body.subpage #hero-search-wrap { display: none; }

.header-search-mini input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  font: inherit; font-size: 14px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  outline: none;
  color: var(--ink);
  transition: all 0.15s;
}
.header-search-mini input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.header-search-mini::before {
  content: ""; position: absolute; left: 12px; top: 50%;
  width: 16px; height: 16px; transform: translateY(-50%);
  background: no-repeat center/contain url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="m20 20-3-3"/></svg>');
  pointer-events: none;
}

.btn {
  padding: 9px 16px;
  font: inherit; font-size: 14px; font-weight: 500;
  color: var(--ink);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: all 0.12s ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover {
  background: var(--bg-soft);
  border-color: var(--line-strong);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn-primary {
  background: var(--ink);
  color: var(--brand-ink);
  border-color: var(--ink);
}
.btn-primary:hover {
  background: var(--ink-2);
  border-color: var(--ink-2);
  color: var(--brand-ink);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

/* ===== HERO ===== */
.hero {
  position: relative;
  padding: 72px 0 56px;
  text-align: center;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute; inset: -50px 0 0;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(245,158,11,0.08), transparent 70%),
    radial-gradient(50% 40% at 90% 30%, rgba(14,165,233,0.06), transparent 70%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  z-index: -1;
}
.hero .inner { max-width: 760px; margin: 0 auto; }
.hero h1 {
  font-family: var(--display);
  font-size: clamp(34px, 6vw, 60px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
  color: var(--ink);
  margin: 0 0 20px;
}
.hero h1 .accent { color: var(--accent-strong); }
.hero p.lead {
  font-size: clamp(15px, 2vw, 19px);
  color: var(--ink-muted);
  margin: 0 auto 40px;
  max-width: 560px;
  line-height: 1.5;
}

/* ===== BIG SEARCH ===== */
.search-wrap {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
}
.search-wrap input {
  width: 100%;
  padding: 20px 24px 20px 56px;
  font: inherit; font-size: 17px;
  color: var(--ink);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  outline: none;
  box-shadow: var(--shadow-md);
  transition: all 0.15s;
}
.search-wrap input::placeholder { color: var(--ink-subtle); }
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-md), var(--shadow-focus);
}
.search-wrap::before {
  content: ""; position: absolute; left: 22px; top: 50%;
  width: 20px; height: 20px; transform: translateY(-50%);
  background: no-repeat center/contain url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2364748b" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="m20 20-3-3"/></svg>');
  pointer-events: none;
}

.suggestions {
  margin-top: 22px;
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
}
.suggestions .label {
  font-size: 13px; color: var(--ink-subtle);
  margin-right: 4px; align-self: center;
}
.suggest {
  font-size: 13px;
  padding: 6px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--ink-muted);
  transition: all 0.12s;
}
.suggest:hover {
  background: var(--ink); color: var(--brand-ink);
  border-color: var(--ink);
  text-decoration: none;
}

/* ===== RESULTS SECTION (homepage when searching) ===== */
.results-section {
  padding: 0 0 80px;
  display: none;
}
.results-section.active { display: block; }
body.searching .hero { padding: 36px 0 20px; }
body.searching .suggestions { display: none; }

/* ===== TWO-PANE (detail pages) ===== */
/* Sidebar is ALWAYS on the left — same as the homepage's .app-grid — so the
 * tree doesn't appear to "jump" when you click a result to open its page. */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 32px;
  align-items: start;
}
.content { min-width: 0; }
.sidebar {
  position: sticky; top: calc(var(--header-h) + 16px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 32px);
  overflow-y: auto;
  padding-right: 4px;
  border-right: 1px solid var(--line);
}

/* ===== sidebar tree ===== */
.sidebar h3 {
  font-size: 11px; font-weight: 600;
  color: var(--ink-muted);

  margin: 0 0 14px;
}
.tree-filter {
  width: 100%; padding: 8px 12px;
  font: inherit; font-size: 13px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm); outline: none;
  margin-bottom: 12px;
  color: var(--ink);
}
.tree-filter:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.tree { font-size: 13px; }
.tree ul { list-style: none; padding-left: 14px; margin: 0; }
.tree > ul { padding-left: 0; }
.tree li { padding: 0; }
.tree .row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: var(--r-sm);
  cursor: pointer; user-select: none;
}
.tree .row:hover { background: var(--bg-soft); }
.tree .row.active { background: var(--accent-soft); }
.tree .row.active .name { color: var(--accent-strong); font-weight: 600; }
.tree .caret {
  width: 12px; flex-shrink: 0;
  font-size: 9px; color: var(--ink-subtle);
  transition: transform 0.12s;
  text-align: center;
}
.tree .caret.open { transform: rotate(90deg); }
.tree .caret.leaf { visibility: hidden; }
.tree .name {
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.tree .name:hover { color: var(--accent-strong); text-decoration: none; }
.tree .code {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-subtle); margin-left: auto;
  flex-shrink: 0;
}

/* ===== filter chips ===== */
.filters {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 16px;
}
.filters .label {
  font-size: 12px; color: var(--ink-muted);

  margin-right: 6px;
}
.chip {
  font-size: 12px; font-weight: 500;
  padding: 5px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--ink-muted);
  user-select: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.chip:hover {
  border-color: var(--ink-subtle);
  color: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(15,23,42,0.06);
}
.chip[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  color: #fff;
  border-color: var(--ink);
  box-shadow: 0 2px 6px rgba(15,23,42,0.18);
}

.results-meta {
  font-size: 13px; color: var(--ink-muted);
  margin-bottom: 12px;
}

/* ===== result card ===== */
.results { display: flex; flex-direction: column; gap: 8px; }
.result {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex; gap: 14px; align-items: flex-start;
  color: inherit; text-decoration: none;
  transition: all 0.12s ease;
}
.result:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transform: translateY(-1px);
}
.result.focused {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.result .meta { flex: 1; min-width: 0; }
.result .crumb {
  font-size: 12px; color: var(--ink-muted);
  margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result .nm {
  font-size: 15px; color: var(--ink);
  font-weight: 500;
  word-break: break-word;
}
.result .nm mark {
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 0 2px; border-radius: 2px;
  font-weight: 600;
}
.result .cd {
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-subtle); margin-top: 4px;
}
.result .actions {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
  flex-shrink: 0;
}

/* ===== badges ===== */
.badge {
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: var(--r-full);
  letter-spacing: 0.02em; white-space: nowrap;
  display: inline-flex; align-items: center;
}
.badge.standard { background: #dbeafe; color: #1e40af; }
.badge.zero { background: #dcfce7; color: #166534; }
.badge.exempt { background: #fef3c7; color: #92400e; }
.badge.excisable { background: #fee2e2; color: #991b1b; }
.badge.out-of-scope { background: #f1f5f9; color: #475569; }
.badge.unknown { background: #f1f5f9; color: #64748b; }

/* ===== copy button ===== */
.copy {
  background: transparent;
  border: 1px solid var(--line);
  font-size: 11px; color: var(--ink-muted);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-family: inherit;
  transition: all 0.12s;
}
.copy:hover { background: var(--bg-soft); color: var(--ink); border-color: var(--line-strong); }
.copy.ok { color: #166534; border-color: #86efac; background: #f0fdf4; }

/* ===== empty / loading ===== */
.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--ink-muted);
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
}
.empty .icon {
  font-size: 28px; opacity: 0.4; margin-bottom: 12px;
  display: block;
}
.empty .small { display: block; font-size: 13px; margin-top: 8px; }

/* ===== explore (homepage default — when not searching) ===== */
.explore {
  display: none;
  padding: 16px 0 80px;
}
.explore.active { display: block; }
body.searching .explore { display: none; }
.explore .browse-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.explore h2 {
  font-size: 13px; font-weight: 600;
  color: var(--ink-muted);

  margin: 0 0 16px;
}
.segment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.segment-tile {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: inherit; text-decoration: none;
  transition: all 0.12s;
}
.segment-tile:hover {
  background: var(--bg-elev);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transform: translateY(-1px);
}
.segment-tile .name { font-weight: 500; color: var(--ink); font-size: 14px; }
.segment-tile .code {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-subtle);
}

/* ===== CATEGORY DETAIL ===== */
.crumbs {
  font-size: 13px; color: var(--ink-muted);
  margin: 24px 0 16px;
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.crumbs a { color: var(--ink-muted); }
.crumbs a:hover { color: var(--accent-strong); }
.crumbs .sep { opacity: 0.4; margin: 0 4px; }
.crumbs strong { color: var(--ink); font-weight: 500; }

.cat-hero {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.cat-hero h1 {
  font-family: var(--display);
  margin: 0 0 12px;
  font-size: 28px; line-height: 1.2;
  font-weight: 700; letter-spacing: -0.02em;
  color: var(--ink);
}
.cat-hero .lead {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.cat-hero .big-code {
  font-family: var(--mono); font-size: 15px; font-weight: 600;
  padding: 6px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
}
.cat-hero .lvl {
  font-size: 11px; color: var(--ink-muted);
}
/* The injected #leaf-tax panel sits between the hero and the children list
 * — give it the same top margin as a regular section so it doesn't crowd
 * the hero card. */
#leaf-tax:not(:empty) { margin-top: 24px; display: block; }

.section-title {
  font-size: 12px; font-weight: 600;
  color: var(--ink-muted);

  margin: 32px 0 12px;
}

.children {
  list-style: none; padding: 0; margin: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.children li {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 12px; align-items: center;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  transition: background 0.12s;
}
.children li:first-child { border-top: 0; }
.children li:hover { background: var(--bg-soft); }
.children li:target {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.children .row-main { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.children .cc {
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-subtle);
  flex-shrink: 0; width: 80px;
}
.children .nn {
  flex: 1; min-width: 0; color: var(--ink);
  word-break: break-word;
}
.children .nn a { color: inherit; }
.children .nn a:hover { color: var(--accent-strong); }
.children .bb { flex-shrink: 0; }

.back {
  margin-top: 32px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--ink-muted);
}
.back:hover { color: var(--accent-strong); }

/* ===== TOOL APP SHELL (homepage — search + tree + results, no hero) ===== */
/* Goal: tool is fully usable on first paint, no scrolling required. */

:root { --header-h: 52px; --toolbar-h: 48px; --filters-h: 40px; }

.site-header .container { height: var(--header-h); }

.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}

.tool-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 30;
  padding: 18px 0 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tool-tagline {
  font-size: 13px;
  color: var(--ink-muted);
  text-align: center;
  margin: 0 auto 12px;
  max-width: 720px;
}
.tool-tagline strong { color: var(--ink); font-weight: 600; }
.tool-bar .search-row {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
}
.tool-bar .search-row .search-input {
  width: 100%;
  height: var(--toolbar-h);
  padding: 0 14px 0 44px;
  font: inherit; font-size: 14.5px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg-elev) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  outline: none;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 0 0 0 rgba(245,158,11,0);
  transition: box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.tool-bar .search-row .search-input::placeholder { color: var(--ink-subtle); }
.tool-bar .search-row .search-input:hover {
  border-color: var(--line-strong);
  box-shadow: 0 2px 6px rgba(15,23,42,0.06);
}
.tool-bar .search-row .search-input:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow:
    0 4px 14px rgba(245,158,11,0.10),
    0 0 0 4px rgba(245,158,11,0.14);
}
.tool-bar .search-row::before {
  content: ""; position: absolute; left: 14px; top: 50%;
  width: 16px; height: 16px; transform: translateY(-50%);
  background: no-repeat center/contain url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2364748b" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="m20 20-3-3"/></svg>');
  pointer-events: none;
}
.tool-bar .filter-row {
  justify-content: center;
}

.tool-bar .filter-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-top: 10px;
  min-height: var(--filters-h);
}
.tool-bar .filter-row .label {
  font-size: 11px; color: var(--ink-subtle);

  margin-right: 4px;
}
.tool-bar .clear-filters {
  font-size: 12px; color: var(--ink-muted);
  background: none; border: none; padding: 4px 6px;
  cursor: pointer; text-decoration: underline;
  display: none;
}
.tool-bar.has-filter .clear-filters { display: inline-flex; }

/* ===== app grid (tree | results) — fills viewport ===== */
.app-grid {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 28px;
  align-items: start;
  padding: 16px 0 40px;
}

.tool-sidebar {
  position: sticky;
  top: calc(var(--header-h) + var(--toolbar-h) + var(--filters-h) + 36px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - var(--toolbar-h) - var(--filters-h) - 56px);
  overflow-y: auto;
  padding-right: 4px;
  border-right: 1px solid var(--line);
}
.tool-sidebar h3 {
  font-size: 10px; font-weight: 600;
  color: var(--ink-subtle);

  margin: 0 0 8px;
}
.tool-sidebar .tree-filter {
  width: 100%; padding: 7px 11px;
  font: inherit; font-size: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm); outline: none;
  margin-bottom: 8px;
  color: var(--ink);
}
.tool-sidebar .tree-filter:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.tool-sidebar .tree { font-size: 12.5px; }
.tool-sidebar .tree .row { padding: 3px 6px; }
.tool-sidebar .tree .code { font-size: 9.5px; }
.tree .tree-loading {
  padding: 4px 10px;
  font-style: italic; color: var(--ink-subtle); font-size: 11.5px;
  list-style: none;
}
.tool-sidebar .tree-stats {
  font-size: 11px; color: var(--ink-subtle);
  padding: 8px 0 0; border-top: 1px solid var(--line);
  margin-top: 8px;
}

.tool-results { min-width: 0; }
.tool-welcome {
  padding: 28px 24px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: var(--ink-muted);
  font-size: 14px;
  text-align: center;
}
.tool-welcome .icon { font-size: 24px; opacity: 0.4; display: block; margin-bottom: 8px; }
.tool-welcome strong { color: var(--ink); font-weight: 600; }
.tool-welcome .suggest-row {
  margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
}
.tool-welcome .suggest {
  font-size: 12px; padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--ink-muted);
  cursor: pointer;
}
.tool-welcome .suggest:hover { background: var(--ink); color: var(--brand-ink); border-color: var(--ink); text-decoration: none; }

@media (max-width: 720px) {
  /* Below 720px the sidebar can't fit alongside results — stack it but keep
   * it as the FIRST element (visually above results) so the user knows it's
   * still there. They can collapse it by setting max-height + a summary. */
  .app-grid { grid-template-columns: 1fr; gap: 16px; }
  .tool-sidebar {
    position: static; max-height: 280px; border-right: 0;
    border: 1px solid var(--line); border-radius: var(--r-md);
    padding: 12px;
  }
}

/* ===== properties table (detail page) ===== */
.properties {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  margin: 0 0 8px;
  overflow: hidden;
}
.properties dl {
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: 220px 1fr;
}
.properties dt, .properties dd {
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  margin: 0;
}
.properties dt:first-of-type, .properties dd:first-of-type { border-top: 0; }
.properties dt {
  font-size: 12px; color: var(--ink-muted);

  background: var(--bg-soft);
  display: flex; align-items: center;
}
.properties dd { color: var(--ink); font-size: 14px; }
.properties dd .yes { color: #166534; font-weight: 600; }
.properties dd .no { color: var(--ink-subtle); }
.properties dd code {
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-subtle); margin-left: 6px;
}
@media (max-width: 600px) {
  .properties dl { grid-template-columns: 1fr; }
  .properties dt { padding-bottom: 4px; border-bottom: 0; }
  .properties dd { padding-top: 4px; border-top: 0; }
  .properties dd + dt { border-top: 1px solid var(--line); }
}

/* ===== FOOTER ===== */
footer.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 48px 0 28px;
  margin-top: 64px;
  font-size: 14px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 48px;
  margin-bottom: 32px;
}
.footer-grid h4 {
  font-size: 11px; font-weight: 600;
  color: var(--ink-muted);

  margin: 0 0 14px;
}
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid a { color: var(--ink-muted); }
.footer-grid a:hover { color: var(--accent-strong); }
.footer-about .footer-logo {
  font-family: var(--display);
  font-size: 18px; font-weight: 800; letter-spacing: -0.03em;
  color: var(--ink);
  display: inline-flex; align-items: baseline;
}
.footer-about .footer-logo .dot {
  display: inline-block; width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 50%; margin: 0 1px 3px 2px;
}
.footer-about p { color: var(--ink-muted); margin: 12px 0 0; max-width: 340px; }
.footer-bottom {
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 12px;
  color: var(--ink-subtle);
  font-size: 12px;
  flex-wrap: wrap;
}

/* ===== MODAL ===== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none;
  align-items: flex-start; justify-content: center;
  padding: 60px 20px 20px;
  overflow-y: auto;
}
.modal.open { display: flex; }
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-panel {
  position: relative; z-index: 1;
  background: var(--bg-elev);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 500px;
  animation: modal-in 0.2s ease-out;
}
@keyframes modal-in {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 26px 12px;
}
.modal-header h2 {
  font-family: var(--display);
  font-size: 20px; font-weight: 700; margin: 0;
  letter-spacing: -0.01em;
}
.modal-header .close {
  background: none; border: none;
  font-size: 24px; color: var(--ink-subtle);
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: all 0.12s;
}
.modal-header .close:hover { background: var(--bg-soft); color: var(--ink); }
.modal-body { padding: 0 26px 26px; }
.modal-body p.intro { color: var(--ink-muted); margin: 0 0 22px; font-size: 14px; }

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--ink-muted);

  margin-bottom: 6px;
}
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 11px 14px;
  font: inherit; font-size: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  outline: none;
  color: var(--ink);
  resize: vertical;
  font-family: inherit;
}
.form-row textarea { min-height: 110px; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  background: #fff; border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.form-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 18px; gap: 12px; flex-wrap: wrap;
}
.form-actions .direct {
  font-size: 12px; color: var(--ink-muted);
}
.form-status {
  margin-top: 12px; padding: 10px 14px;
  border-radius: var(--r-md); font-size: 13px;
  display: none;
}
.form-status.show { display: block; }
.form-status.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.form-status.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ===== MOBILE ===== */
@media (max-width: 720px) {
  /* Detail page also collapses at 720px (same breakpoint as homepage). */
  .layout { grid-template-columns: 1fr; gap: 16px; }
  .sidebar {
    position: static; max-height: 280px;
    padding-right: 0;
    border-right: 0; border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 12px;
  }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
}
@media (max-width: 600px) {
  .hero { padding: 36px 0 28px; }
  .footer-grid { grid-template-columns: 1fr; }
  .site-header .container { gap: 8px; }
  .search-wrap input { padding: 16px 18px 16px 48px; font-size: 16px; }
  .search-wrap::before { left: 18px; }
}
