:root {
  --bg: #090d14;
  --bg-elev: #101722;
  --bg-card: #131c2b;
  --bg-code: #0b111b;
  --border: #223047;
  --border-strong: #324766;
  --text: #eef3fa;
  --text-muted: #9eb0c9;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-ink: #0b0f17;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.14);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.16);
  --orange: #fb923c;
  --orange-soft: rgba(251, 146, 60, 0.16);
  --yellow: #facc15;
  --yellow-soft: rgba(250, 204, 21, 0.14);
  --radius: 10px;
  --radius-sm: 6px;
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', ui-monospace, SFMono-Regular, Consolas, monospace;
}

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

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 12% 0%, rgba(245, 158, 11, 0.08), transparent 36%),
              radial-gradient(circle at 88% 4%, rgba(34, 211, 238, 0.07), transparent 34%),
              var(--bg);
  color: var(--text);
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
textarea:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  padding: 10px 16px;
  z-index: 100;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  border-radius: var(--radius-sm);
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(9, 13, 20, 0.92);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 0.9rem;
}

.brand-pill {
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(52, 211, 153, 0.45);
  background: var(--green-soft);
  color: var(--green);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--text);
  background: var(--bg-card);
  text-decoration: none;
}

.nav-links a.nav-oracle {
  color: var(--accent);
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}

.nav-links a.nav-oracle:hover {
  background: rgba(245, 158, 11, 0.16);
}

/* Main */
main {
  flex: 1;
  padding: 24px 0 48px;
}

.hero {
  margin-bottom: 22px;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

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

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.hero-sub {
  margin: 0;
  color: var(--text-muted);
  max-width: 78ch;
  font-size: 1rem;
}

.trust-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.trust-pill {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.trust-pill strong {
  color: var(--green);
}

/* Studio Tabs */
.studio-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.tab-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 700;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tab-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.tab-btn[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.studio-panel[hidden] {
  display: none !important;
}

/* Cards & Controls */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 9px 14px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: #1c283d;
  border-color: var(--cyan);
  text-decoration: none;
}

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

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

.btn-secondary {
  background: var(--cyan-soft);
  color: var(--cyan);
  border-color: rgba(34, 211, 238, 0.4);
}

.btn-secondary:hover {
  background: rgba(34, 211, 238, 0.24);
  color: #ecfeff;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-code);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 11px;
  min-height: 36px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip:hover,
.chip.is-active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.12);
}

.select-input {
  background: var(--bg-code);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-height: 42px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
}

.code-input {
  width: 100%;
  min-height: 220px;
  background: var(--bg-code);
  color: #e2ecf8;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  resize: vertical;
  tab-size: 2;
}

.code-input.compact {
  min-height: 185px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.kpi-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
}

.kpi-val {
  font-size: 1.32rem;
  font-weight: 800;
  font-family: var(--font-mono);
  margin-top: 4px;
  color: var(--text);
}

.kpi-val.good { color: var(--green); }
.kpi-val.warn { color: var(--yellow); }
.kpi-val.bad { color: var(--red); }

/* Plan Tree Table */
.plan-tree-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-code);
}

.plan-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  min-width: 720px;
}

.plan-table th {
  text-align: left;
  padding: 10px 10px;
  background: #0f1724;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.plan-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(34, 48, 71, 0.65);
  vertical-align: top;
}

.plan-table tr.is-hot {
  background: rgba(248, 113, 113, 0.1);
}

.plan-table tr.is-skipped {
  opacity: 0.48;
  text-decoration: line-through;
}

.plan-op-cell {
  white-space: nowrap;
}

.op-indent {
  color: var(--border-strong);
  user-select: none;
}

.op-name {
  font-weight: 700;
  color: var(--text);
}

.op-obj {
  color: var(--cyan);
  margin-left: 6px;
}

.num-col {
  text-align: right;
  white-space: nowrap;
}

.flame-track {
  width: 96px;
  height: 8px;
  border-radius: 999px;
  background: #1a2538;
  overflow: hidden;
  margin-top: 4px;
}

.flame-meter {
  width: 96px;
  height: 10px;
  border-radius: 999px;
  accent-color: #f59e0b;
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.section-heading {
  margin: 18px 0 10px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-flush {
  margin-bottom: 0;
}

.code-block-tight {
  margin: 6px 0 4px;
}

.code-block-flush {
  margin-bottom: 0;
}

.flame-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.pred-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  white-space: normal;
  max-width: 560px;
}

.pred-pill {
  font-size: 0.74rem;
  padding: 3px 8px;
  border-radius: 4px;
  line-height: 1.4;
  word-break: break-word;
}

.pred-access {
  background: var(--green-soft);
  color: #a7f3d0;
  border-left: 3px solid var(--green);
}

.pred-filter {
  background: var(--orange-soft);
  color: #fed7aa;
  border-left: 3px solid var(--orange);
}

/* Severity Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-critical, .badge-danger {
  background: var(--red-soft);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.45);
}

.badge-high {
  background: var(--orange-soft);
  color: #fed7aa;
  border: 1px solid rgba(251, 146, 60, 0.45);
}

.badge-medium, .badge-caution {
  background: var(--yellow-soft);
  color: #fef08a;
  border: 1px solid rgba(250, 204, 21, 0.45);
}

.badge-info {
  background: var(--cyan-soft);
  color: #bae6fd;
  border: 1px solid rgba(34, 211, 238, 0.4);
}

.badge-safe, .badge-low {
  background: var(--green-soft);
  color: #a7f3d0;
  border: 1px solid rgba(52, 211, 153, 0.45);
}

/* Findings & Lock Audit Cards */
.finding-list {
  display: grid;
  gap: 12px;
}

.finding-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.finding-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.finding-title {
  font-weight: 700;
  font-size: 0.96rem;
}

.finding-detail {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.finding-fix {
  margin: 0;
  font-size: 0.88rem;
  color: #d1fae5;
  background: rgba(52, 211, 153, 0.08);
  border-left: 3px solid var(--green);
  padding: 8px 10px;
  border-radius: 4px;
}

/* Two-Column Layouts */
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.ref-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.ref-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  text-decoration: none;
}

.ref-card .badge {
  align-self: flex-start;
}

.hero-actions {
  margin-top: 16px;
}

.ref-card h3 {
  margin: 0;
  font-size: 0.98rem;
  color: var(--text);
}

.ref-card p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

/* Article / Reference Pages */
.article-body {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.article-body h2 {
  margin: 22px 0 10px;
  font-size: 1.2rem;
}

.article-body h2:first-child {
  margin-top: 0;
}

.article-body a:not(.btn):not(.chip):not(.ref-card) {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-x: auto;
  margin: 8px 0 14px;
  color: #e2ecf8;
}

.alert-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: var(--red-soft);
  color: #fee2e2;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.alert-box.ok {
  border-color: rgba(52, 211, 153, 0.45);
  background: var(--green-soft);
  color: #d1fae5;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 12px;
}

.checkbox-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
}

.status-toast {
  font-size: 0.84rem;
  font-family: var(--font-mono);
  color: var(--green);
  min-height: 22px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: #070a10;
  padding: 28px 0;
  margin-top: auto;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 20px;
  margin-bottom: 18px;
}

.footer-col h4 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 0.88rem;
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

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

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

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 820px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (pointer: coarse), (max-width: 780px) {
  .btn,
  .chip,
  .tab-btn,
  .nav-links a {
    min-height: 44px;
  }
}

@media (max-width: 560px) {
  .container {
    padding: 0 14px;
  }
  .card,
  .article-body {
    padding: 14px;
  }
  .brand-pill {
    display: none;
  }
}
