/* ═══════════════════════════════════════════════════════════════════════
   Codex — Blueprint Linear Theme
   pr0t31n Toolkit Knowledge Base & Wiki
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #e8eef4;
  --bg-sidebar: #dce4ef;
  --bg-card: #f5f8fb;
  --bg-console: #0d1117;
  --bg-hover: #d2dce8;
  --bg-input: #f0f4f8;
  --fg: #0d1b2a;
  --fg-muted: #3d5a80;
  --fg-faint: #7b96b5;
  --fg-console: #e6edf3;
  --border: #c5d3e3;
  --blue: #2563eb;
  --blue-light: rgba(37,99,235,.1);
  --blue-dark: #1d4ed8;
  --teal: #0d9488;
  --teal-light: rgba(13,148,136,.1);
  --amber: #b45309;
  --amber-light: rgba(180,83,9,.1);
  --red: #be123c;
  --red-light: rgba(190,18,60,.1);
  --green: #16a34a;
  --green-light: rgba(22,163,74,.1);
  --purple: #7c3aed;
  --purple-light: rgba(124,58,237,.1);
  --slate: #5a7a9e;
  --radius: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  --risk-critical: #FF00FF;
  --risk-high: #E7716F;
  --risk-medium: #FFC000;
  --risk-low: #92D050;
  --risk-info: #BDD7EC;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1b2a;
    --bg-sidebar: #0a1525;
    --bg-card: #132236;
    --bg-console: #010409;
    --bg-hover: #1f3350;
    --bg-input: #0f1e30;
    --fg: #c9d6e3;
    --fg-muted: #8ba3c1;
    --fg-faint: #5a7a9e;
    --fg-console: #e6edf3;
    --border: rgba(74,144,217,.18);
    --blue: #4a90d9;
    --blue-light: rgba(74,144,217,.15);
    --blue-dark: #5fa0e8;
    --teal: #2dd4bf;
    --teal-light: rgba(45,212,191,.12);
    --amber: #fbbf24;
    --amber-light: rgba(251,191,36,.1);
    --red: #f87171;
    --red-light: rgba(248,113,113,.1);
    --green: #4ade80;
    --green-light: rgba(74,222,128,.1);
    --purple: #a78bfa;
    --purple-light: rgba(167,139,250,.1);
    --slate: #8ba3c1;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d1b2a;
  --bg-sidebar: #0a1525;
  --bg-card: #132236;
  --bg-console: #010409;
  --bg-hover: #1f3350;
  --bg-input: #0f1e30;
  --fg: #c9d6e3;
  --fg-muted: #8ba3c1;
  --fg-faint: #5a7a9e;
  --fg-console: #e6edf3;
  --border: rgba(74,144,217,.18);
  --blue: #4a90d9;
  --blue-light: rgba(74,144,217,.15);
  --blue-dark: #5fa0e8;
  --teal: #2dd4bf;
  --teal-light: rgba(45,212,191,.12);
  --amber: #fbbf24;
  --amber-light: rgba(251,191,36,.1);
  --red: #f87171;
  --red-light: rgba(248,113,113,.1);
  --green: #4ade80;
  --green-light: rgba(74,222,128,.1);
  --purple: #a78bfa;
  --purple-light: rgba(167,139,250,.1);
  --slate: #8ba3c1;
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.65;
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 50;
}
.sidebar-logo {
  padding: 0 20px 20px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--blue);
  text-decoration: none;
}
.sidebar-logo svg { flex-shrink: 0; }
.sidebar-search { margin: 0 16px 20px; }
.sidebar-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--fg);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}
.sidebar-search input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
.sidebar-search input::placeholder { color: var(--fg-faint); }

/* Theme toggle */
.theme-switch {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0 16px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  letter-spacing: 0.6px;
  user-select: none;
}
.theme-switch button {
  flex: 1;
  padding: 6px 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--fg-faint);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  letter-spacing: 0.6px;
  transition: all 0.15s;
}
.theme-switch button.active {
  background: var(--blue);
  color: #fff;
}

/* Nav groups */
.nav-group { margin-bottom: 6px; }
.nav-group-label {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-faint);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 20px;
  font-size: 13px;
  color: var(--fg-muted);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.12s;
}
.nav-item:hover { color: var(--fg); background: var(--bg-hover); }
.nav-item.active {
  color: var(--blue);
  background: var(--blue-light);
  font-weight: 600;
  border-right: 2px solid var(--blue);
}
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  color: var(--fg-faint);
  background: var(--bg-card);
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 500;
}
.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--fg-faint);
  text-align: center;
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg);
  cursor: pointer;
  font-size: 18px;
  align-items: center;
  justify-content: center;
}

/* ── Main ── */
.main {
  margin-left: 260px;
  flex: 1;
  padding: 36px 52px 80px;
  max-width: 960px;
  min-width: 0;
}
.breadcrumb { font-size: 12px; color: var(--fg-faint); margin-bottom: 6px; }
.breadcrumb a { color: var(--fg-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--blue); }
h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 8px; line-height: 1.2; }
h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 12px; }
.subtitle { color: var(--fg-muted); margin-bottom: 24px; font-size: 15px; }

/* Badges */
.badge { display: inline-block; padding: 3px 12px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-teal { background: var(--teal-light); color: var(--teal); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-slate { background: rgba(90,122,158,.1); color: var(--slate); }
.badge-critical { background: rgba(255,0,255,.12); color: var(--risk-critical); }
.badge-high { background: rgba(231,113,111,.12); color: var(--risk-high); }
.badge-medium { background: rgba(255,192,0,.12); color: var(--risk-medium); }
.badge-low { background: rgba(146,208,80,.12); color: var(--risk-low); }
.badge-info { background: rgba(189,215,236,.15); color: var(--risk-info); }

/* Stats row */
.stats-row { display: flex; gap: 14px; margin-bottom: 36px; flex-wrap: wrap; }
.stat-card {
  flex: 1;
  min-width: 120px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-num { font-size: 22px; font-weight: 700; }
.stat-num.blue { color: var(--blue); }
.stat-num.teal { color: var(--teal); }
.stat-num.amber { color: var(--amber); }
.stat-num.purple { color: var(--purple); }
.stat-label {
  font-size: 11px;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
  font-weight: 500;
}

/* Sections */
.section { margin-bottom: 44px; }
.section h2 {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  letter-spacing: -0.2px;
  color: var(--fg);
}
.section h3 { font-size: 15px; font-weight: 600; margin: 24px 0 10px; color: var(--fg); }
.section h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 6px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.section p, .prose p { color: var(--fg-muted); margin-bottom: 12px; line-height: 1.7; }
.prose { color: var(--fg-muted); line-height: 1.7; }
.prose strong { color: var(--fg); }
.prose code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Console blocks */
.console {
  background: var(--bg-console);
  color: var(--fg-console);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
  border: 1px solid #21262d;
  white-space: pre;
  display: block;
}
.console .prompt { color: #7ee787; }
.console .flag { color: #79c0ff; }
.console .comment { color: #8b949e; font-style: italic; }
.console .str { color: #a5d6ff; }
.console .warn { color: #d29922; }

/* Dependency command groups */
.dep-group { margin-bottom: 28px; }
.dep-group-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dep-group-title .phase-num {
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}
.dep-item { margin-bottom: 10px; }
.dep-item .dep-label { font-size: 13px; color: var(--fg-muted); margin-bottom: 4px; font-weight: 500; }
.dep-item .console { margin-bottom: 0; padding: 12px 16px; font-size: 12px; }

/* Lists */
.section ul, .section ol { color: var(--fg-muted); margin-bottom: 14px; padding-left: 22px; }
.section li { margin-bottom: 6px; line-height: 1.65; }
.section li strong { color: var(--fg); }

/* Phase list */
.phase-list { list-style: none; padding: 0; counter-reset: phase-counter; }
.phase-list li {
  counter-increment: phase-counter;
  padding: 10px 14px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
  color: var(--fg-muted);
}
.phase-list li::before {
  content: counter(phase-counter);
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.phase-list li strong { color: var(--fg); }

/* Feature cards */
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.feature-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-card);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.feature-card:hover { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
.feature-card .fc-icon { font-size: 18px; margin-bottom: 6px; }
.feature-card .fc-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--fg); }
.feature-card .fc-desc { font-size: 12px; color: var(--fg-muted); line-height: 1.55; }

/* Credits table */
.credits-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.credits-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-sidebar);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-faint);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
}
.credits-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.credits-table tr:hover td { background: var(--blue-light); }
.credits-table a { color: var(--blue); text-decoration: none; font-size: 12px; }
.credits-table a:hover { text-decoration: underline; }
.credits-table .tool-name { font-weight: 600; color: var(--fg); }

/* Finding prefix badge */
.finding-prefix {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
  background: var(--amber-light);
  color: var(--amber);
}

/* Callout */
.callout {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.6;
  border-left: 3px solid;
}
.callout-blue { background: var(--blue-light); border-left-color: var(--blue); }
.callout-amber { background: var(--amber-light); border-left-color: var(--amber); }
.callout-teal { background: var(--teal-light); border-left-color: var(--teal); }
.callout-red { background: var(--red-light); border-left-color: var(--risk-high); }

/* Authorization / Ethical use warning banners */
.warn-auth {
  border: 2px solid var(--risk-high);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px 0;
  background: var(--red-light);
}
.warn-auth .warn-title { margin: 0 0 8px 0; font-weight: 700; font-size: 15px; color: var(--risk-high); }
.warn-auth .warn-body { margin: 0; font-size: 13px; line-height: 1.6; color: var(--fg); }
.warn-data {
  border: 2px solid var(--risk-medium);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px 0;
  background: var(--amber-light);
}
.warn-data .warn-title { margin: 0 0 8px 0; font-weight: 700; font-size: 15px; color: var(--amber); }
.warn-data .warn-body { margin: 0; font-size: 13px; line-height: 1.6; color: var(--fg); }

/* Tables */
.tbl-wrap { overflow-x: auto; margin-bottom: 16px; }
.tbl-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl-wrap th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-sidebar);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-faint);
  border-bottom: 2px solid var(--border);
}
.tbl-wrap td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--fg-muted); }
.tbl-wrap tr:hover td { background: var(--blue-light); }
.tbl-wrap a { color: var(--blue); text-decoration: none; }
.tbl-wrap a:hover { text-decoration: underline; }

/* Tool cards for home/index */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 24px; }
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool-card:hover { border-color: var(--blue); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.06); }
.tool-card-head { display: flex; justify-content: space-between; align-items: center; }
.tool-card-name { font-size: 16px; font-weight: 700; }
.tool-card-desc { font-size: 12px; color: var(--fg-muted); line-height: 1.55; }
.tool-card-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.tool-card-stats { display: flex; gap: 14px; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; color: var(--fg-faint); }
.tool-card-stats strong { color: var(--fg); font-weight: 600; }

/* Category section headers */
.cat-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.cat-header h2 { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }

/* Search page */
.search-box {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--fg);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='%2394a3b8' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
  margin-bottom: 24px;
}
.search-box:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
.search-result { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); margin-bottom: 10px; }
.search-result:hover { border-color: var(--blue); }
.search-result a { color: var(--blue); text-decoration: none; font-weight: 600; font-size: 14px; }
.search-result a:hover { text-decoration: underline; }
.search-result .sr-type { font-size: 11px; color: var(--fg-faint); text-transform: uppercase; letter-spacing: 0.5px; }
.search-result .sr-snippet { font-size: 13px; color: var(--fg-muted); margin-top: 4px; }

/* Output files table */
.output-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.output-table th { text-align: left; padding: 8px 12px; background: var(--bg-sidebar); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--fg-faint); border-bottom: 2px solid var(--border); }
.output-table td { padding: 6px 12px; border-bottom: 1px solid var(--border); }
.output-table code { font-family: var(--mono); font-size: 12px; color: var(--blue); }

/* Quick links */
.quick-links { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.quick-link {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.quick-link:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }

/* Utility */
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-dim { color: var(--fg-faint); }
.text-muted { color: var(--fg-muted); }
.text-mono { font-family: var(--mono); font-size: 12px; }

/* Category filter tabs */
.cat-tabs { display: flex; gap: 6px; margin-bottom: 24px; flex-wrap: wrap; }
.cat-tab {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  transition: all 0.15s;
  text-decoration: none;
}
.cat-tab:hover { border-color: var(--blue); color: var(--fg); }
.cat-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Error page */
.error-page { text-align: center; padding: 80px 20px; }
.error-page h1 { font-size: 72px; color: var(--fg-faint); margin-bottom: 16px; }
.error-page p { color: var(--fg-muted); font-size: 16px; }
.error-page a { color: var(--blue); text-decoration: none; }
.error-page a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .main { margin-left: 0; padding: 20px 16px 60px; }
  .feature-grid { grid-template-columns: 1fr; }
  .stats-row { flex-direction: column; }
  .credits-table { font-size: 12px; }
  .tool-grid { grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
}
