/* ==========================================================================
   Toolshed design system
   Tokens first, then primitives, then components. Light and dark are both
   first-class; dark follows the OS unless the user picks a theme.
   ========================================================================== */

:root {
  color-scheme: light;

  --bg: #ffffff;
  --bg-subtle: #fbfbfa;
  --bg-sunken: #f6f6f5;
  --surface: #ffffff;
  --surface-hover: #f7f7f6;
  --surface-active: #f0f0ef;

  --border: #e6e6e3;
  --border-strong: #d6d6d2;

  --text: #1c1b1a;
  --text-secondary: #5f5e5b;
  --text-tertiary: #8b8a86;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #ffffff;

  --danger: #c0392b;
  --danger-soft: #fdeceb;
  --success: #1a7f4b;
  --success-soft: #e8f6ee;
  --warning: #9a6700;
  --warning-soft: #fdf5e2;

  --star: #d98b0b;

  /* Category palette: --c-*-fg pairs with --c-*-bg at AA contrast. */
  --c-slate-fg: #4b5563;   --c-slate-bg: #f1f2f4;
  --c-violet-fg: #6d28d9;  --c-violet-bg: #f3efff;
  --c-blue-fg: #1d4ed8;    --c-blue-bg: #eaf0ff;
  --c-cyan-fg: #0e7490;    --c-cyan-bg: #e4f6fb;
  --c-teal-fg: #0f766e;    --c-teal-bg: #e2f5f2;
  --c-green-fg: #15803d;   --c-green-bg: #e7f6ec;
  --c-amber-fg: #a16207;   --c-amber-bg: #fdf3da;
  --c-orange-fg: #c2410c;  --c-orange-bg: #fdeee4;
  --c-rose-fg: #be123c;    --c-rose-bg: #fdecef;
  --c-pink-fg: #a21caf;    --c-pink-bg: #fbecfb;
  --c-indigo-fg: #4338ca;  --c-indigo-bg: #eceefd;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(15, 15, 15, 0.05);
  --shadow: 0 1px 3px rgba(15, 15, 15, 0.07), 0 4px 12px rgba(15, 15, 15, 0.05);
  --shadow-lg: 0 8px 28px rgba(15, 15, 15, 0.12);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --header-height: 56px;
  --sidebar-width: 236px;
  --max-width: 1360px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
  :root:not([data-theme="light"]) {
    --bg: #191919;
    --bg-subtle: #1f1f1f;
    --bg-sunken: #161616;
    --surface: #212121;
    --surface-hover: #2a2a2a;
    --surface-active: #323232;

    --border: #2f2f2f;
    --border-strong: #404040;

    --text: #ededec;
    --text-secondary: #a3a29e;
    --text-tertiary: #7c7b77;

    --accent: #7c74f0;
    --accent-hover: #8f88f4;
    --accent-soft: #262452;
    --accent-text: #ffffff;

    --danger: #f2837a;
    --danger-soft: #3a2220;
    --success: #5bc08c;
    --success-soft: #16301f;
    --warning: #e0b44a;
    --warning-soft: #33290f;

    --star: #e3ae4a;

    --c-slate-fg: #b6bcc6;   --c-slate-bg: #2b2d31;
    --c-violet-fg: #b8a5f7;  --c-violet-bg: #2c2545;
    --c-blue-fg: #9db8f8;    --c-blue-bg: #202b45;
    --c-cyan-fg: #86ccdf;    --c-cyan-bg: #17303a;
    --c-teal-fg: #79ccc1;    --c-teal-bg: #163030;
    --c-green-fg: #8ed3a5;   --c-green-bg: #1a3025;
    --c-amber-fg: #e2bd6b;   --c-amber-bg: #332a14;
    --c-orange-fg: #f0a97e;  --c-orange-bg: #3a2618;
    --c-rose-fg: #f09aab;    --c-rose-bg: #3a1f26;
    --c-pink-fg: #e8a1e8;    --c-pink-bg: #371f37;
    --c-indigo-fg: #a5abf5;  --c-indigo-bg: #24264a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191919;
  --bg-subtle: #1f1f1f;
  --bg-sunken: #161616;
  --surface: #212121;
  --surface-hover: #2a2a2a;
  --surface-active: #323232;
  --border: #2f2f2f;
  --border-strong: #404040;
  --text: #ededec;
  --text-secondary: #a3a29e;
  --text-tertiary: #7c7b77;
  --accent: #7c74f0;
  --accent-hover: #8f88f4;
  --accent-soft: #262452;
  --accent-text: #ffffff;
  --danger: #f2837a;
  --danger-soft: #3a2220;
  --success: #5bc08c;
  --success-soft: #16301f;
  --warning: #e0b44a;
  --warning-soft: #33290f;
  --star: #e3ae4a;
  --c-slate-fg: #b6bcc6;   --c-slate-bg: #2b2d31;
  --c-violet-fg: #b8a5f7;  --c-violet-bg: #2c2545;
  --c-blue-fg: #9db8f8;    --c-blue-bg: #202b45;
  --c-cyan-fg: #86ccdf;    --c-cyan-bg: #17303a;
  --c-teal-fg: #79ccc1;    --c-teal-bg: #163030;
  --c-green-fg: #8ed3a5;   --c-green-bg: #1a3025;
  --c-amber-fg: #e2bd6b;   --c-amber-bg: #332a14;
  --c-orange-fg: #f0a97e;  --c-orange-bg: #3a2618;
  --c-rose-fg: #f09aab;    --c-rose-bg: #3a1f26;
  --c-pink-fg: #e8a1e8;    --c-pink-bg: #371f37;
  --c-indigo-fg: #a5abf5;  --c-indigo-bg: #24264a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.5);
}

/* --------------------------------------------------------------------- Base */
*, *::before, *::after { box-sizing: border-box; }

/* The HTML `hidden` attribute must win over any author display rule.
   Without this, `.btn { display: inline-flex }` beats the user-agent
   `[hidden] { display: none }` and hidden buttons stay on screen. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.013em; }
h1 { font-size: 22px; line-height: 1.3; letter-spacing: -0.02em; }
h2 { font-size: 16px; line-height: 1.35; }
h3 { font-size: 14px; }
p { margin: 0; }

a { color: inherit; text-decoration: none; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection { background: var(--accent-soft); color: var(--text); }

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

.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ------------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms var(--ease), border-color 120ms var(--ease),
    color 120ms var(--ease), transform 80ms var(--ease);
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(0.5px); background: var(--surface-active); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }

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

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-lg { height: 38px; padding: 0 16px; font-size: 14px; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* ------------------------------------------------------------------- Inputs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

.label { font-size: 13px; font-weight: 550; color: var(--text); }
.hint { font-size: 12.5px; color: var(--text-tertiary); line-height: 1.5; }

.input, .textarea, .select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--text-tertiary); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
.input.has-error, .textarea.has-error { border-color: var(--danger); }

.field-error { font-size: 12.5px; color: var(--danger); }

.input-lg { height: 42px; font-size: 15px; }

/* ------------------------------------------------------------------- Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--radius);
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 18px;
}
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--accent-soft); color: var(--accent); }
.alert strong { font-weight: 600; }

/* ------------------------------------------------------------------ Toasts */
#toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 180ms var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------- Shell */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.015em;
  flex-shrink: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.header-search { flex: 1; max-width: 460px; position: relative; }
.header-search .input { height: 34px; padding-left: 32px; background: var(--bg-sunken); }
.header-search .search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
}
.header-search .search-clear {
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
}

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

.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: calc(100vh - var(--header-height));
}

.sidebar {
  padding: 22px 12px 40px;
  border-right: 1px solid var(--border);
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-title {
  padding: 0 10px;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 110ms var(--ease), color 110ms var(--ease);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.is-active { background: var(--surface-active); color: var(--text); font-weight: 550; }
.nav-item .nav-icon { width: 16px; display: flex; justify-content: center; color: var(--text-tertiary); }
.nav-item.is-active .nav-icon { color: var(--accent); }
.nav-count {
  margin-left: auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.main { padding: 26px 28px 64px; min-width: 0; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head .page-title-group { min-width: 0; }
.page-subtitle { margin-top: 3px; font-size: 13.5px; color: var(--text-secondary); }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

/* --------------------------------------------------------- Category cards */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
  gap: 16px;
}

.category-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease),
    transform 140ms var(--ease);
}
.category-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.category-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
}
.category-badge {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
/* A block-level column so the name and description can actually ellipsis. */
.category-card-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.category-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.category-desc {
  display: block;
  font-size: 12.5px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.category-count {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-sunken);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* Compact, name-first tool rows: the category is the visual unit, not the tool. */
.tool-list { list-style: none; margin: 0; padding: 5px; }
.tool-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background 110ms var(--ease);
}
.tool-row:hover { background: var(--surface-hover); }
.tool-row.is-inactive .tool-name { color: var(--text-tertiary); text-decoration: line-through; }

.tool-favicon {
  width: 17px; height: 17px;
  border-radius: 4px;
  object-fit: contain;
  background: var(--bg-sunken);
  flex-shrink: 0;
}
.tool-favicon-fallback {
  display: grid;
  place-items: center;
  width: 17px; height: 17px;
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--text-tertiary);
  font-size: 9.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.tool-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-row:hover .tool-name { color: var(--accent); }

.tool-row-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 110ms var(--ease);
}
.tool-row:hover .tool-row-actions,
.tool-row:focus-within .tool-row-actions { opacity: 1; }
.tool-row-actions .icon-btn { width: 24px; height: 24px; }
.star-btn.is-on { opacity: 1; color: var(--star); }
.tool-row .star-btn.is-on { opacity: 1; }

.category-empty {
  padding: 14px 15px 16px;
  font-size: 12.5px;
  color: var(--text-tertiary);
}
.category-card-foot {
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}
.category-more {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}
.category-more:hover { color: var(--accent); }

/* ------------------------------------------------------------ Flat listing */
.flat-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.flat-list .tool-row {
  border-radius: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 11px;
}
.flat-list .tool-row:last-child { border-bottom: none; }
.flat-list .tool-favicon, .flat-list .tool-favicon-fallback { width: 20px; height: 20px; }
.flat-list .tool-name { font-size: 14px; font-weight: 500; flex: 0 1 auto; }
.tool-row-meta {
  font-size: 12.5px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.tool-row-spacer { flex: 1; }

/* -------------------------------------------------------------- Detail view */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: start;
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 22px;
}
.card + .card { margin-top: 16px; }
.card-title {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 11px;
}

.detail-head { display: flex; gap: 15px; align-items: flex-start; margin-bottom: 22px; }
.detail-logo {
  width: 46px; height: 46px;
  border-radius: 11px;
  object-fit: contain;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-logo-fallback {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 11px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 18px; font-weight: 650;
  flex-shrink: 0;
}
.detail-url {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  word-break: break-all;
}
.detail-url:hover { color: var(--accent); }
.detail-description { font-size: 14.5px; line-height: 1.65; color: var(--text-secondary); }
.notes-body { white-space: pre-wrap; font-size: 14px; line-height: 1.7; color: var(--text-secondary); }

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.meta-row:last-child { border-bottom: none; }
.meta-row dt { color: var(--text-tertiary); }
.meta-row dd { margin: 0; text-align: right; color: var(--text); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-sunken);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 110ms var(--ease);
}
a.chip:hover { background: var(--surface-active); color: var(--text); }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
}
.status-active { background: var(--success-soft); color: var(--success); }
.status-inactive { background: var(--bg-sunken); color: var(--text-tertiary); }

/* ------------------------------------------------------- Checkbox pickers */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 6px;
}
.check-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  user-select: none;
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.check-card:hover { background: var(--surface-hover); }
.check-card input { margin: 0; accent-color: var(--accent); cursor: pointer; }
.check-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ------------------------------------------------------------ Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 62px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
}
.empty-icon {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
}
.empty-title { font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.empty-text { font-size: 13.5px; color: var(--text-secondary); max-width: 380px; margin-bottom: 18px; }

/* ----------------------------------------------------------- Loading state */
.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--surface-hover) 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 620ms linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.is-busy .btn-label-idle { display: none; }
.btn-label-busy { display: none; align-items: center; gap: 7px; }
.is-busy .btn-label-busy { display: inline-flex; }

.fetch-status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

/* -------------------------------------------------------------- Auth pages */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg-subtle);
}
.auth-card {
  width: 100%;
  max-width: 388px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .brand { justify-content: center; margin-bottom: 14px; font-size: 15px; }
.auth-head p { font-size: 13.5px; color: var(--text-secondary); margin-top: 4px; }
.auth-foot {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}
.auth-foot a { color: var(--accent); font-weight: 550; }
.auth-foot a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ Modals */
dialog.modal {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: calc(100% - 32px);
}
dialog.modal::backdrop { background: rgba(15, 15, 15, 0.42); backdrop-filter: blur(1.5px); }
.modal-body { padding: 22px; }
.modal-body h2 { margin-bottom: 7px; }
.modal-body p { font-size: 13.5px; color: var(--text-secondary); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* ------------------------------------------------------------------ Tables */
.category-manage-list { display: flex; flex-direction: column; gap: 8px; }
.category-manage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.category-manage-row .grow { flex: 1; min-width: 0; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
/* The spacer only pushes trailing actions apart when everything fits on one row. */
@media (max-width: 760px) {
  .form-actions .spacer { display: none; }
}
.form-actions .spacer { flex: 1; }

.swatch-row { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch {
  position: relative;
  width: 27px; height: 27px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  display: grid; place-items: center;
}
.swatch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.swatch:has(input:checked) { border-color: var(--text); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.mobile-only { display: none; }

/* -------------------------------------------------------------- Responsive */
@media (max-width: 1000px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}

@media (max-width: 860px) {
  :root { --header-height: 52px; }
  .app-body { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
    display: flex;
    gap: 18px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar-section { margin-bottom: 0; display: flex; align-items: center; gap: 5px; }
  .sidebar-title { display: none; }
  .nav-item { white-space: nowrap; padding: 5px 11px; }
  .nav-item .nav-count { display: none; }
  .main { padding: 18px 16px 56px; }
  .category-grid { grid-template-columns: 1fr; gap: 12px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .page-head { flex-wrap: wrap; }
}

@media (max-width: 620px) {
  .app-header { padding: 0 14px; gap: 10px; }
  .brand-text { display: none; }
  .header-search { max-width: none; }
  .desktop-only { display: none; }
  .mobile-only { display: inline-flex; }
  h1 { font-size: 19px; }
  .card { padding: 17px; }
  .auth-card { padding: 24px 20px; }
  /* Touch devices have no hover, so row actions are always visible. */
  .tool-row-actions { opacity: 1; }
  .page-head-actions { width: 100%; margin-left: 0; }
  .form-actions { flex-wrap: wrap; }
}

@media (hover: none) {
  .tool-row-actions { opacity: 1; }
}

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

/* ------------------------------------------------------- Third-party auth */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-tertiary);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-google {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 500;
}
.btn-google:hover { background: var(--surface-hover); }

/* ==========================================================================
   Dashboard refinement
   Sharper hierarchy inside the category card, a real sidebar on desktop and a
   drawer on mobile. Restrained on purpose: this is a tool, not a landing page.
   ========================================================================== */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 300;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 550;
}
.skip-link:focus { left: 8px; }

/* ----------------------------------------------------------- Header tweaks */
.search-hint {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-tertiary);
  font-family: var(--font);
  font-size: 11px;
  line-height: 1.5;
  pointer-events: none;
}
.header-search:focus-within .search-hint { opacity: 0; }

.nav-toggle { margin-right: -2px; }

/* --------------------------------------------------------------- Sidebar */
.sidebar-inner { position: sticky; top: calc(var(--header-height) + 22px); }

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 6px;
}
.sidebar-title-action {
  display: inline-flex;
  padding: 3px;
  border-radius: 5px;
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity 120ms var(--ease), background 120ms var(--ease);
}
.sidebar:hover .sidebar-title-action { opacity: 1; }
.sidebar-title-action:hover { background: var(--surface-hover); color: var(--text); }
.sidebar-title-action:focus-visible { opacity: 1; }

/* A left rail on the active item reads faster than a background alone. */
.nav-item { position: relative; }
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 17px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-item .nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-icon-category {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  font-size: 10px;
  line-height: 1;
}
.nav-item-muted { color: var(--text-tertiary); }

.nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 15, 15, 0.38);
  backdrop-filter: blur(1px);
  animation: fade-in 140ms var(--ease);
}
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }

/* --------------------------------------------------------- Category cards */
.category-grid {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  align-items: start;
}

.category-card {
  border-radius: var(--radius-lg);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease),
    transform 160ms var(--ease);
}
.category-card:hover { transform: translateY(-2px); }
.category-card:focus-within {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.category-card.is-empty { background: var(--bg-subtle); }
.category-card.is-empty:hover { transform: none; box-shadow: none; }

.category-card-head {
  gap: 11px;
  padding: 14px 16px 13px;
  border-bottom: 1px solid var(--border);
}
.category-card.is-empty .category-card-head { border-bottom-color: transparent; }

.category-badge {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 14px;
  transition: transform 160ms var(--ease);
}
.category-card:hover .category-badge { transform: scale(1.06); }
.category-badge-muted { background: var(--bg-sunken); color: var(--text-tertiary); }

.category-name {
  font-size: 14.5px;
  font-weight: 620;
  letter-spacing: -0.014em;
}
a.category-name:hover { color: var(--accent); }
.category-desc { font-size: 12px; margin-top: 1px; }

.category-count {
  align-self: flex-start;
  margin-top: 2px;
  min-width: 22px;
  padding: 2px 7px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.01em;
}
.category-card:hover .category-count {
  background: var(--accent-soft);
  color: var(--accent);
}

.tool-list { padding: 6px; }
.tool-row { padding: 7px 9px; gap: 10px; }
.tool-row + .tool-row { margin-top: 1px; }
.tool-name { font-size: 13.5px; font-weight: 450; }

.tool-list-overflow { padding-top: 0; }
.tool-list-overflow[hidden] { display: none; }

.category-card-foot {
  padding: 0;
  border-top: 1px solid var(--border);
  background: transparent;
}
.category-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 520;
  cursor: pointer;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.category-more:hover { background: var(--surface-hover); color: var(--accent); }
.category-more-chevron {
  display: inline-flex;
  transition: transform 180ms var(--ease);
}
.category-more[aria-expanded="true"] .category-more-chevron { transform: rotate(90deg); }

.category-empty {
  padding: 15px 16px 17px;
  font-size: 12.5px;
  color: var(--text-tertiary);
}
.category-empty a { color: var(--accent); font-weight: 500; }
.category-empty a:hover { text-decoration: underline; }

/* -------------------------------------------------------- Sidebar: mobile */
@media (max-width: 860px) {
  .app-body { position: relative; }

  /* A real off-canvas drawer rather than a cramped horizontal strip. */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: 272px;
    max-width: 82vw;
    display: block;
    padding: 18px 14px 32px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-bottom: none;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 200ms var(--ease);
  }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-inner { position: static; }
  .sidebar-section { display: block; margin-bottom: 22px; }
  .sidebar-title { display: block; }
  .nav-item { padding: 7px 10px; }
  .nav-item .nav-count { display: inline; }
  .category-grid { grid-template-columns: 1fr; gap: 14px; }
}

@media (min-width: 861px) {
  .nav-scrim { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .category-card:hover { transform: none; }
  .sidebar { transition: none; }
}

/* ===================================================== Add AI: provenance ==
   The point is that a glance tells you what came from the website and what is
   yours. Badges are quiet; they label, they do not decorate.
   ========================================================================== */

.field-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  padding: 1px 6px 1px 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: lowercase;
  vertical-align: 1px;
}

.field-revert {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  padding: 1px 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-tertiary);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}
.field-revert:hover { color: var(--accent); background: var(--surface-hover); }
.field-revert[hidden] { display: none; }

.card-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card-title-note {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-tertiary);
}

/* --------------------------------------------------------- Preview card */
.preview-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--accent-soft) 55%, var(--surface)),
    var(--surface)
  );
}

.preview-logo,
.preview-logo-fallback {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.preview-logo-fallback {
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  font-size: 17px;
  font-weight: 650;
}

.preview-body { min-width: 0; flex: 1; }
.preview-name {
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.014em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-url {
  margin-top: 1px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-desc {
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-tag {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

@media (max-width: 620px) {
  .preview-card { padding: 14px; gap: 11px; }
  .preview-tag { display: none; }
}

/* ------------------------------------------------------------ Quota meter */
.quota-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-sunken);
  overflow: hidden;
}
.quota-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 240ms var(--ease);
}
.quota-fill.is-warning { background: var(--warning); }
.quota-fill.is-full { background: var(--danger); }

.sidebar-quota {
  margin: 0 10px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
}
.sidebar-quota-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 7px;
}
.sidebar-quota-label strong { color: var(--text); font-weight: 600; }
.sidebar-quota a { color: var(--accent); font-weight: 550; }

/* ======================================================= Public directory ==
   The front door for people with no account. Slightly more expansive than the
   private shed, but still a tool rather than a marketing page.
   ========================================================================== */

.public-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0;
  max-width: var(--max-width);
  margin: 0 auto;
}
.public-main { padding: 30px 28px 72px; }

.discover-hero { max-width: 620px; margin-bottom: 34px; }
.discover-hero h1 {
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: -0.028em;
  margin-bottom: 9px;
}
.discover-hero p { font-size: 15px; color: var(--text-secondary); line-height: 1.6; }
.discover-hero-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.discover-section { margin-bottom: 38px; }
.discover-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 14px;
}

/* Recommended starting points: a denser, flatter grid than category cards,
   so it reads as a shortlist rather than competing with them. */
.starter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 10px;
}
.starter-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease),
    transform 140ms var(--ease);
}
.starter-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.starter-logo,
.starter-logo-fallback {
  width: 24px; height: 24px;
  border-radius: 7px;
  object-fit: contain;
  background: var(--bg-sunken);
  margin-bottom: 5px;
}
.starter-logo-fallback {
  display: grid; place-items: center;
  color: var(--text-tertiary);
  font-size: 11px; font-weight: 700;
}
.starter-name { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.starter-desc {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-tertiary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-pill {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-sunken);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  text-transform: lowercase;
}

/* ------------------------------------------------------------- Ad rail -- */
.ad-rail {
  padding: 30px 24px 0 0;
  border-left: 1px solid var(--border);
  padding-left: 24px;
}
.ad-rail:empty { display: none; }

.ad-card {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  display: block;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 140ms var(--ease);
}
.ad-card:hover { border-color: var(--border-strong); }
.ad-label {
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.ad-image {
  width: 100%;
  border-radius: var(--radius-sm);
  margin: 10px 0;
  display: block;
}
.ad-headline { font-size: 14px; font-weight: 620; margin-top: 8px; letter-spacing: -0.01em; }
.ad-body { font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); margin-top: 4px; }
.ad-advertiser { font-size: 11.5px; color: var(--text-tertiary); margin-top: 9px; }

@media (max-width: 1080px) {
  .public-body { grid-template-columns: minmax(0, 1fr); }
  .ad-rail { display: none; }
}
@media (max-width: 620px) {
  .public-main { padding: 22px 16px 60px; }
  .discover-hero h1 { font-size: 24px; }
  .starter-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================== AI Kits ==== */
.kit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.kit-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease),
    transform 150ms var(--ease);
}
.kit-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.kit-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.kit-name { font-size: 15px; font-weight: 640; letter-spacing: -0.015em; }
.kit-tagline {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-top: 3px;
}
.kit-meta { font-size: 11.5px; color: var(--text-tertiary); margin-top: 10px; }

.kit-tag {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-sunken);
  font-size: 11px;
  font-weight: 620;
  color: var(--text-tertiary);
}
.kit-tag-premium { background: var(--accent-soft); color: var(--accent); }
.kit-tag-owned {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--success-soft);
  color: var(--success);
}

/* ------------------------------------------------------------- Paywall --- */
.paywall-notice {
  display: flex;
  gap: 10px;
  padding: 13px 14px;
  margin-bottom: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 13.5px;
}
.paywall-notice p { margin: 0; }
.paywall-notice .hint { margin-top: 3px; }

.resource-list { list-style: none; margin: 0; padding: 0; }
.resource {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.resource:last-child { border-bottom: none; }

.resource-head { display: flex; align-items: center; gap: 8px; }
.resource-kind {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-sunken);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.resource-title { font-size: 14px; font-weight: 580; letter-spacing: -0.01em; }
.resource-lock { margin-left: auto; color: var(--text-tertiary); display: inline-flex; }
.resource-summary {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-top: 5px;
}
.resource.is-locked .resource-title { color: var(--text-secondary); }

.resource-body {
  margin: 11px 0 9px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-x: auto;
}
.resource-pending { margin-top: 9px; display: flex; align-items: center; gap: 5px; }

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

/* --------------------------------------------------------------- Admin --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat-card {
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat-value {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }

.public-nav { display: flex; gap: 4px; }
.public-nav a {
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 110ms var(--ease), color 110ms var(--ease);
}
.public-nav a:hover { background: var(--surface-hover); color: var(--text); }

/* --------------------------------------------------------- Legal pages --- */
.legal { max-width: 680px; }
.legal h1 { font-size: 28px; letter-spacing: -0.026em; }
.legal-updated { font-size: 13px; color: var(--text-tertiary); margin-top: 6px; margin-bottom: 30px; }
.legal h2 {
  font-size: 16px;
  margin-top: 30px;
  margin-bottom: 9px;
  letter-spacing: -0.014em;
}
.legal p, .legal li {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.legal p + p { margin-top: 11px; }
.legal ul { margin: 11px 0 0; padding-left: 20px; }
.legal li + li { margin-top: 6px; }
.legal strong { color: var(--text); font-weight: 600; }
.legal code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-sunken);
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.legal a { color: var(--accent); }
.legal a:hover { text-decoration: underline; }
.legal-rule { margin: 34px 0 18px; border: 0; border-top: 1px solid var(--border); }
.legal-footnote { font-size: 13px; color: var(--text-tertiary); }

.legal-table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  font-size: 13.5px;
}
.legal-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.legal-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  line-height: 1.55;
  vertical-align: top;
}
@media (max-width: 620px) {
  .legal-table, .legal-table tbody, .legal-table tr, .legal-table td { display: block; width: 100%; }
  .legal-table thead { display: none; }
  .legal-table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .legal-table td { border: 0; padding: 2px 0; }
  .legal-table td:first-child { font-weight: 600; color: var(--text); }
}

/* ------------------------------------------------------- First-run tour --- */
.tour-modal { max-width: 460px; }
.tour-progress { height: 3px; background: var(--bg-sunken); border-radius: var(--radius-lg) var(--radius-lg) 0 0; overflow: hidden; }
.tour-progress-fill {
  display: block; height: 100%; width: 20%;
  background: var(--accent);
  transition: width 260ms var(--ease);
}
.tour-body { padding: 26px 24px 22px; }
.tour-step { display: none; }
.tour-step.is-current { display: block; animation: tour-in 220ms var(--ease); }
@keyframes tour-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.tour-badge {
  display: grid; place-items: center;
  width: 42px; height: 42px;
  margin-bottom: 15px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.tour-step h2 { font-size: 18px; letter-spacing: -0.02em; margin-bottom: 9px; }
.tour-step p { font-size: 14px; line-height: 1.65; color: var(--text-secondary); }
.tour-step p + p { margin-top: 10px; }
.tour-step a { color: var(--accent); font-weight: 550; }
.tour-step a:hover { text-decoration: underline; }
.tour-actions { display: flex; align-items: center; gap: 8px; }

/* ========================================================= Landing page ==== */
.landing-header { justify-content: space-between; }
.landing { max-width: 960px; margin: 0 auto; padding: 0 24px 80px; }

.landing-hero { text-align: center; padding: 72px 0 56px; }
.landing-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  margin-bottom: 20px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 620;
}
.landing-hero h1 {
  font-size: 44px;
  line-height: 1.12;
  letter-spacing: -0.033em;
  margin-bottom: 18px;
}
.landing-sub {
  max-width: 560px;
  margin: 0 auto;
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--text-secondary);
}
.landing-actions { display: flex; gap: 10px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.landing-note { margin-top: 13px; font-size: 13px; color: var(--text-tertiary); }

.waitlist-form {
  display: flex;
  gap: 8px;
  max-width: 440px;
  margin: 28px auto 0;
  flex-wrap: wrap;
}
.waitlist-form .input { flex: 1; min-width: 210px; }

.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 26px;
  padding: 46px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.landing-feature-icon {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  margin-bottom: 13px;
  border-radius: 10px;
  background: var(--bg-sunken);
  color: var(--accent);
}
.landing-feature h2 { font-size: 15px; letter-spacing: -0.014em; margin-bottom: 7px; }
.landing-feature p { font-size: 13.5px; line-height: 1.6; color: var(--text-secondary); }

.landing-cta { text-align: center; padding: 56px 0 44px; }
.landing-cta h2 { font-size: 22px; letter-spacing: -0.022em; margin-bottom: 8px; }
.landing-cta p { font-size: 14.5px; color: var(--text-secondary); margin-bottom: 20px; }

.landing-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-tertiary);
  flex-wrap: wrap;
}
.landing-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.landing-footer a:hover { color: var(--text); }

@media (max-width: 620px) {
  .landing-hero { padding: 48px 0 40px; }
  .landing-hero h1 { font-size: 31px; }
  .landing-sub { font-size: 15px; }
  .landing-features { gap: 22px; padding: 34px 0; }
}

/* ------------------------------------------------- Suggested categories --- */
.suggestion-note {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 11px;
  font-size: 12px;
  color: var(--accent);
}
.check-card.is-suggested { border-color: var(--accent); }
.suggested-dot {
  margin-left: auto;
  display: inline-flex;
  color: var(--accent);
  opacity: .8;
}

/* ==================================================== Library layouts ====== */
.layout-switch {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}
.layout-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.layout-option:hover:not(:disabled) { color: var(--text); }
.layout-option.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.layout-option:disabled { opacity: .35; cursor: not-allowed; }

/* ------------------------------------------------------------- Cards ----- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(216px, 1fr));
  gap: 14px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease),
    transform 150ms var(--ease);
}
.tool-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.tool-card.is-inactive { opacity: .62; }
.tool-card.is-inactive .tool-card-name { text-decoration: line-through; }

.tool-card-main { display: block; padding: 15px 15px 12px; flex: 1; }
.tool-card-logo,
.tool-card-logo-fallback {
  width: 30px; height: 30px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--bg-sunken);
  margin-bottom: 10px;
}
.tool-card-logo-fallback {
  display: grid; place-items: center;
  color: var(--text-tertiary);
  font-size: 13px; font-weight: 700;
}
.tool-card-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.012em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-card:hover .tool-card-name { color: var(--accent); }
.tool-card-desc {
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-tertiary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tool-card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 15px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}
.tool-card-cats {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-card-actions { display: flex; gap: 1px; flex-shrink: 0; }
.tool-card-actions .icon-btn { width: 26px; height: 26px; }

@media (max-width: 620px) {
  .tool-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* Admin tables (classification review). */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-tertiary); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-text { max-width: 280px; color: var(--text-secondary); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--bg-sunken); font-size: 12px; }

/* ---------------------------------------------------------------- Launcher
   /launch: one search box and one list. Nothing else competes for the eye. */
.launch {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(48px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.launch-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.launch .brand-text { display: inline; }
.launch-library { font-size: 13px; color: var(--text-secondary); padding: 6px 8px; border-radius: var(--radius-sm); }
.launch-library:hover { background: var(--surface-hover); color: var(--text); }

/* Stays in view while a long list scrolls underneath it. */
.launch-search {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 10px;
  background: var(--bg);
}
.launch-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-58%);
  color: var(--text-tertiary);
  display: grid;
  pointer-events: none;
}
.launch-input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 42px;
  font: inherit;
  /* 16px or more, or iOS zooms the page when the box takes focus. */
  font-size: 18px;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.launch-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.launch-input::placeholder { color: var(--text-tertiary); }

.launch-list { list-style: none; margin: 0; padding: 0; }
.launch-header {
  margin: 16px 0 4px;
  padding: 0 12px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.launch-row { border-radius: var(--radius); }
.launch-row:hover { background: var(--surface-hover); }
/* The highlight is not a hover: the mouse resting over the list must not
   look like, or become, the row Enter opens. */
.launch-row.is-highlighted {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.launch-link {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 12px;
  min-height: 44px;
  color: var(--text);
  border-radius: var(--radius);
}
.launch-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.launch-domain {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.launch-star { color: var(--star); display: inline-grid; align-self: center; flex-shrink: 0; }
.launch-empty { padding: 28px 12px; text-align: center; color: var(--text-secondary); }
.launch-empty a { color: var(--accent); }
/* Pinned to the bottom edge so what Enter will do is visible however long the list is. */
.launch-status {
  position: sticky;
  bottom: 0;
  min-height: 1.4em;
  margin: 0;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-tertiary);
  background: var(--bg);
}
.launch-status.is-error { color: var(--warning); font-weight: 500; }
