:root {
  --content-max: 1400px;
}

/* ============================================
   SIDEBAR STYLING FOR CN CONSOLE
   ============================================ */

/* CLEAN STICKY SIDEBAR - PRODUCTION VERSION */
aside.sunday-md-aside nav.sunday-md-toc {
  position: sticky !important;
  top: 80px !important;
  width: 280px !important;
  min-height: calc(100vh - 100px) !important;
  max-height: calc(100vh - 80px) !important;
  overflow-y: auto !important;
  padding: 20px !important;
  background: var(--card) !important;
  border: 1px solid var(--line) !important;
  border-radius: 16px !important;
  z-index: 100 !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
}

/* CLEAN TOC LINK STYLING */
.sunday-md-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sunday-md-toc li {
  margin: 0;
  padding: 0;
}

.sunday-md-toc li::before {
  display: none;
}

.sunday-md-toc a {
  display: block;
  padding: 8px 16px;
  margin: 4px 0;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  transition: all 0.2s ease;
  position: relative;
}

.sunday-md-toc a:hover {
  background: color-mix(in srgb, var(--brand) 6%, transparent);
  color: var(--ink);
  transform: translateX(2px);
}

.sunday-md-toc a.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 15%, transparent), color-mix(in srgb, var(--brand) 8%, transparent));
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 20%, transparent);
  border-left: 3px solid var(--brand);
  padding-left: 13px;
}

/* HEADING LEVEL STYLING */
.sunday-md-toc .lvl-1 a {
  font-weight: 700;
  color: var(--ink);
  padding-left: 16px;
  font-size: 15px;
  margin-top: 12px;
  margin-bottom: 8px;
}

.sunday-md-toc .lvl-1 a:first-child {
  margin-top: 0;
}

.sunday-md-toc .lvl-2 a {
  padding-left: 24px;
  font-size: 13px;
  font-weight: 500;
}

.sunday-md-toc .lvl-3 a {
  padding-left: 32px;
  font-size: 12px;
  font-weight: 400;
  opacity: 0.85;
}

body {
  background: var(--bg);
}

.tabs-container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  overflow: hidden;
}

/* Defensive: ensure CN top tabs are always visible */
.tabs-container,
.tabs {
  display: flex;
  visibility: visible;
  opacity: 1;
}

.tabs-container {
  position: relative;
  z-index: 50;
  background: var(--sunday-surface, var(--surface, #0f131c));
  border-bottom: 1px solid var(--sunday-line, var(--line, #1e2636));
}

.tabs {
  flex-wrap: nowrap;
  width: 100%;
  overflow-x: auto;
  gap: 4px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  color: var(--sunday-text-muted, var(--muted, #9bb1c7));
  font-weight: 650;
}

.tab-btn:hover {
  color: var(--sunday-text, var(--ink, #e9f3ff));
  background: color-mix(in srgb, var(--sunday-card, #141820) 70%, transparent);
}

.tab-btn.active {
  color: var(--sunday-accent, var(--accent, #7ce3ff));
  border-bottom-color: var(--sunday-accent, var(--accent, #7ce3ff));
}

.content-container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 16px;
  min-height: 70vh;
}

/* Sunday Card Header/Body (for proper card structure) */
.sunday-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.sunday-card__body {
  padding-top: 0;
}

.sunday-text {
  margin: 0;
}

.sunday-text--title {
  font-size: 24px;
  font-weight: 900;
  color: var(--ink);
  margin-bottom: 6px;
}

.sunday-text--muted {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.ai-embed {
  width: 100%;
  height: calc(100vh - 180px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b0c10;
}

/* CN Overview (beginner map) */
.cn-overview-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 12px;
  align-items: start;
}

@media (max-width: 980px) {
  .cn-overview-grid {
    grid-template-columns: 1fr;
  }
}

.cn-overview-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 32px;
  width: 100%;
  box-sizing: border-box;
}

.cn-overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.cn-overview-title {
  font-weight: 900;
  font-size: 28px;
  color: var(--ink);
  margin: 0 0 8px 0;
}

.cn-overview-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.cn-toggle {
  display: flex;
  gap: 6px;
}

.cn-toggle-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
}

.cn-toggle-btn.active {
  color: var(--ink);
  border-color: rgba(124, 227, 255, 0.6);
  background: rgba(124, 227, 255, 0.08);
}

.cn-structure-diagram {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 24px 0;
}

.cn-node {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 14px;
  padding: 10px;
}

.cn-node-title { font-weight: 900; font-size: 18px; margin: 0 0 8px 0; display: flex; align-items: center; gap: 8px; }

.cn-step-num-inline {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.5);
  color: rgba(34, 197, 94, 1);
}
.cn-node-desc { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; margin: 0 0 16px 0; }

.cn-node-expanded {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.cn-node-expanded p {
  margin: 0 0 12px 0;
  line-height: 1.7;
  color: var(--ink);
  font-size: 13px;
}

.cn-node-expanded ul {
  margin: 12px 0;
  padding-left: 24px;
}

.cn-node-expanded li {
  margin-bottom: 8px;
  line-height: 1.6;
  font-size: 13px;
}

.cn-principles {
  margin-top: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.cn-principles h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 12px 0;
}

.cn-principles ul {
  margin: 0;
  padding-left: 24px;
}

.cn-principles li {
  margin-bottom: 8px;
  line-height: 1.6;
  font-size: 13px;
}

.cn-node-network {
  border-color: rgba(124, 227, 255, 0.55);
  background: rgba(124, 227, 255, 0.06);
  margin-bottom: 10px;
}

.cn-node-settings { border-left: 4px solid rgba(139, 92, 246, 0.6); }
.cn-node-framework { border-left: 4px solid rgba(124, 227, 255, 0.6); }
.cn-node-console { border-left: 4px solid rgba(34, 197, 94, 0.6); }
.cn-node-cartridge { border-left: 4px solid rgba(245, 158, 11, 0.6); }
.cn-node-app { border-left: 4px solid rgba(167, 139, 250, 0.6); }
.cn-node-page { border-left: 4px solid rgba(96, 165, 250, 0.6); }
.cn-node-component { border-left: 4px solid rgba(236, 72, 153, 0.6); }

.cn-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 32px 0;
  width: 100%;
}

.cn-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  padding: 20px;
  font-size: 13px;
}

.cn-step-num {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.5);
  color: rgba(34, 197, 94, 1);
}

.cn-step-text {
  flex: 1;
}

.cn-step-text strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px 0;
}

.cn-step-text p {
  margin: 0;
  line-height: 1.7;
  color: var(--ink);
  font-size: 14px;
}

.cn-step-text code {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  color: var(--accent);
}

.cn-pill-row { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.cn-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.cn-pill .k { color: var(--muted); }
.cn-pill .v { font-weight: 900; color: var(--ink); }

.cn-inventory {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  width: 100%;
}

.sunday-markdown {
  line-height: 1.8;
  color: var(--ink);
}

.sunday-markdown h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 16px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
}

.sunday-markdown h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 32px 0 16px 0;
}

.sunday-markdown p {
  margin: 0 0 16px 0;
  line-height: 1.8;
  font-size: 14px;
}

.sunday-markdown ul,
.sunday-markdown ol {
  margin: 16px 0;
  padding-left: 24px;
}

.sunday-markdown li {
  margin-bottom: 8px;
  line-height: 1.7;
  font-size: 14px;
}

.sunday-markdown code {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  color: var(--accent);
}

/* Contributions Carousel */
.cn-contributions-carousel {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.cn-carousel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.cn-carousel-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.cn-carousel-nav {
  display: flex;
  gap: 4px;
}

.cn-carousel-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.cn-carousel-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.cn-carousel-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  padding-bottom: 8px;
}

.cn-carousel-track::-webkit-scrollbar {
  height: 4px;
}

.cn-carousel-track::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

.cn-carousel-loading,
.cn-carousel-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.cn-carousel-card {
  flex-shrink: 0;
  width: 300px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s ease;
}

.cn-carousel-card:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cn-carousel-card__emoji {
  font-size: 32px;
  line-height: 1;
}

.cn-carousel-card__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cn-carousel-card__name {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
}

.cn-carousel-card__tagline {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.cn-carousel-card__desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
}

.cn-carousel-card__meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.cn-carousel-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--muted);
}

.cn-badge-active {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: rgba(34, 197, 94, 1);
}

.cn-carousel-card__link {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.cn-carousel-card__link:hover {
  color: var(--ink);
  gap: 8px;
}

/* CN Contributions page */
.cn-ecosystem {
  margin-bottom: 14px;
}

.cn-ecosystem__label {
  margin-bottom: 8px;
}

.cn-ecosystem__row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cn-eco-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  text-decoration: none;
  color: var(--ink);
  min-width: 220px;
}

.cn-eco-card:hover {
  background: rgba(255, 255, 255, 0.04);
}

.cn-eco-emoji {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 18px;
  flex: 0 0 auto;
}

.cn-eco-title {
  min-width: 0;
}

.cn-eco-name {
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cn-eco-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cn-eco-arrow {
  color: var(--muted);
  font-weight: 900;
  padding: 0 2px;
  user-select: none;
}

.cn-controls {
  display: grid;
  grid-template-columns: 1fr 200px 200px auto;
  gap: 10px;
  align-items: center;
}

.cn-input,
.cn-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--ink);
  outline: none;
}

.cn-input::placeholder {
  color: var(--muted);
}

.cn-meta {
  margin-top: 10px;
}

.cn-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 80, 80, 0.35);
  background: rgba(255, 80, 80, 0.08);
  color: #ffb4b4;
  white-space: pre-wrap;
}

.cn-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.cn-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 12px 12px 10px;
}

.cn-card__top {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.cn-emoji {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 18px;
}

.cn-name {
  font-weight: 800;
  line-height: 1.1;
}

.cn-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.cn-tagline {
  margin-top: 10px;
  font-weight: 700;
}

.cn-desc {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.cn-links {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

/* ============================================
   CN CONTRIBUTIONS PAGE — DARK MODE POLISH
   Scoped to the actual Contributions page container to avoid side effects.
   ============================================ */

[data-cn-page="contributions"] .cn-overview-card {
  background: var(--card);
  border-color: var(--line);
  box-shadow: var(--shadow-md);
}

[data-cn-page="contributions"] .cn-toggle-btn {
  background: var(--surface);
  color: var(--muted);
}

[data-cn-page="contributions"] .cn-toggle-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--ink);
}

[data-cn-page="contributions"] .cn-toggle-btn.active {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--ink);
}

[data-cn-page="contributions"] .cn-node {
  background: var(--surface);
  border-color: var(--line);
  padding: 16px;
}

[data-cn-page="contributions"] .cn-node-network {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

[data-cn-page="contributions"] .cn-principles {
  background: var(--bg);
  border-color: var(--line);
}

[data-cn-page="contributions"] .cn-step-text code,
[data-cn-page="contributions"] .sunday-markdown code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 6px;
  color: var(--accent);
}

[data-cn-page="contributions"] .cn-pill {
  background: var(--surface);
}

[data-cn-page="contributions"] .cn-carousel-btn {
  background: var(--bg);
  color: var(--muted);
}

[data-cn-page="contributions"] .cn-carousel-btn:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  border-color: var(--accent);
  color: var(--ink);
}

[data-cn-page="contributions"] .cn-carousel-card {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

[data-cn-page="contributions"] .cn-carousel-card:hover {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  box-shadow: var(--shadow-md);
}

[data-cn-page="contributions"] .cn-carousel-badge {
  background: var(--bg);
  color: var(--muted);
}

