:root {
  color-scheme: dark;
  --bg: #080b0f;
  --surface: #151922;
  --panel: #222731;
  --line: #38404d;
  --text: #f6f8fc;
  --muted: #a3acba;
  --faint: #737d8d;
  --green: #18c58a;
  --blue: #2aa8f2;
  --pink: #ed6fa5;
  --yellow: #ffc557;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family: "Segoe UI", "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(24, 197, 138, 0.24), transparent 34rem),
    radial-gradient(circle at top right, rgba(42, 168, 242, 0.18), transparent 30rem),
    var(--bg);
  color: var(--text);
}

a {
  color: inherit;
}

.portal-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  min-height: 280px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: clamp(28px, 5vw, 56px);
  background: linear-gradient(135deg, rgba(34, 39, 49, 0.96), rgba(15, 18, 24, 0.96));
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 5.6rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.lead {
  max-width: 720px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.12rem;
  font-weight: 750;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.primary-link,
.secondary-link,
.card-action,
.program-card a,
.program-card button,
.toolbar a,
.toolbar button,
.panel-links a,
.panel-links button {
  display: inline-grid;
  place-items: center;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 20px;
  background: var(--text);
  color: #11151d;
  font-weight: 950;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  font: inherit;
}

.secondary-link,
.toolbar a,
.toolbar button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.card-action-secondary {
  background: #18c58a;
  color: #06120e;
}

.featured-card,
.program-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(34, 39, 49, 0.96);
  box-shadow: var(--shadow);
}

.featured-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 26px;
  align-items: center;
  margin-top: 22px;
  padding: 30px;
}

.frequent-card {
  background: linear-gradient(135deg, rgba(24, 197, 138, 0.16), rgba(34, 39, 49, 0.98));
  border-color: rgba(24, 197, 138, 0.3);
}

.newsletter-card {
  background: linear-gradient(135deg, rgba(42, 168, 242, 0.18), rgba(34, 39, 49, 0.98));
  border-color: rgba(42, 168, 242, 0.3);
}

.newsletter-card .feature-metrics strong {
  color: var(--blue);
}

.stock-card {
  background: linear-gradient(135deg, rgba(237, 111, 165, 0.16), rgba(34, 39, 49, 0.98));
  border-color: rgba(237, 111, 165, 0.32);
}

.stock-card .feature-metrics strong {
  color: var(--pink);
}

.house-card {
  background: linear-gradient(135deg, rgba(255, 197, 87, 0.16), rgba(34, 39, 49, 0.98));
  border-color: rgba(255, 197, 87, 0.32);
}

.house-card .feature-metrics strong {
  color: var(--yellow);
}

.featured-card h2,
.section-head h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

.featured-card p {
  max-width: 640px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 760;
  line-height: 1.65;
}

.feature-metrics {
  display: grid;
  gap: 4px;
  min-width: 230px;
  color: var(--muted);
  font-weight: 850;
  text-align: right;
}

.feature-metrics strong {
  color: var(--green);
  font-size: 1.8rem;
  line-height: 1.1;
}

.feature-metrics small {
  color: var(--faint);
}

.feature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin: 44px 0 18px;
}

.section-head span {
  display: inline-block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 900;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.toolbar a,
.toolbar button {
  min-height: 40px;
  padding: 0 14px;
}

.program-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.program-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 16px;
  min-height: 230px;
  padding: 22px;
}

.program-card.is-live {
  border-color: rgba(24, 197, 138, 0.44);
}

.program-card.is-archived {
  opacity: 0.56;
}

.program-card.is-archived .program-icon {
  filter: grayscale(0.8);
}

.program-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #303743;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 1000;
}

.program-card:nth-child(3n + 1) .program-icon {
  background: var(--green);
  color: #08120e;
}

.program-card:nth-child(3n + 2) .program-icon {
  background: var(--blue);
  color: #061018;
}

.program-card:nth-child(3n) .program-icon {
  background: var(--pink);
  color: #180811;
}

.program-type {
  margin: 0 0 6px;
  color: var(--faint);
  font-size: 0.8rem;
  font-weight: 900;
}

.program-card h3 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.25;
}

.program-card p:not(.program-type) {
  margin: 12px 0;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 720;
  line-height: 1.58;
}

code {
  display: block;
  color: #cbd5e4;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.card-tags span {
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.program-actions {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.program-card a,
.program-card button {
  width: fit-content;
  min-height: 40px;
  margin-top: 2px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.9);
}

.program-card button {
  background: rgba(24, 197, 138, 0.14);
  color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(24, 197, 138, 0.42);
}

.program-card .archive-action {
  background: rgba(255, 197, 87, 0.14);
  color: var(--yellow);
  box-shadow: inset 0 0 0 1px rgba(255, 197, 87, 0.42);
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 36px;
  background: rgba(34, 39, 49, 0.96);
}

.empty-state h3 {
  margin: 0 0 10px;
  font-size: 1.4rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-weight: 760;
}

.codex-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
}

.codex-panel.is-hidden {
  display: none;
}

.codex-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(10px);
}

.codex-panel-card {
  position: relative;
  width: min(680px, 100%);
  max-height: min(780px, calc(100vh - 44px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 30px;
  background: #222731;
  box-shadow: var(--shadow);
}

.panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #303743;
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 900;
  cursor: pointer;
}

.codex-panel-card h2 {
  margin: 0 48px 12px 0;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1.12;
}

.panel-desc {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 1.02rem;
  font-weight: 760;
  line-height: 1.65;
}

.panel-meta {
  display: grid;
  gap: 14px;
  margin: 0;
}

.panel-meta div {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.panel-meta dt {
  margin-bottom: 8px;
  color: var(--faint);
  font-size: 0.82rem;
  font-weight: 950;
}

.panel-meta dd {
  margin: 0;
  color: var(--text);
  font-weight: 800;
  line-height: 1.55;
}

.panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.panel-tags span {
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.panel-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.panel-links a,
.panel-links button {
  min-height: 42px;
  background: var(--text);
  color: #11151d;
}

.panel-links button {
  background: rgba(24, 197, 138, 0.14);
  color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(24, 197, 138, 0.42);
}

@media (max-width: 920px) {
  .hero,
  .featured-card {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .feature-metrics {
    text-align: left;
  }

  .feature-actions {
    justify-content: flex-start;
  }

  .program-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .portal-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 24px;
  }

  .program-grid {
    grid-template-columns: 1fr;
  }

  .program-card {
    min-height: 0;
  }

  .program-actions {
    grid-column: 1 / -1;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }
}
