:root {
  --bg: #ffffff;
  --surface: #f6f8fa;
  --surface2: #eaeef2;
  --accent: #0969da;
  --text: #1F2328;
  --muted: #656d76;
  --border: #d0d7de;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #10141b;
  --surface2: #161b22;
  --accent: #2f81f7;
  --text: #e6edf3;
  --muted: #848d97;
  --border: #30363d;
}

body {
  transition: background var(--transition), color var(--transition);
}

/* ── THEME TOGGLE ── */
.theme-toggle-wrap {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  animation: fadeSlideDown 0.8s 0.1s cubic-bezier(0.22,1,0.36,1) both;
}

.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.theme-toggle:hover {
  background: var(--surface2);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .sun-icon { display: none; }
html:not([data-theme="dark"]) .moon-icon { display: none; }

[data-theme="dark"] .theme-toggle svg {
  transform: rotate(360deg);
}

/* Fix for existing FAQ/Story components in dark mode */
/* Ensure ready status buttons stay green and accessible */
.btn-story-ready {
  background: #1a7f37 !important;
  color: #ffffff !important;
  border-color: rgba(0,0,0,0.1) !important;
  opacity: 1 !important;
}

[data-theme="dark"] .btn-story-ready {
  background: #238636 !important; /* Slightly brighter green for dark mode contrast */
}

/* Backgrounds for regular surface elements */
.faq-answer, .btn-story:not(.btn-story-ready), .nav-btn, .faq-question {
  background: var(--surface) !important;
}

/* Story elements MUST stay white on green buttons */
.btn-story-ready .story-name, .btn-story-ready .story-num {
  color: #ffffff !important;
  opacity: 1 !important;
}

.faq-answer-inner, .btn-story:not(.btn-story-ready), .nav-btn, .faq-question {
  color: var(--text) !important;
}

.site-title, .story-title, .story-name {
  color: var(--text) !important;
}

.story-num {
  color: var(--muted) !important;
  opacity: 0.9 !important; /* High contrast for numbers */
}

.btn-story[disabled], .btn-story:disabled {
  opacity: 0.75 !important; /* Better visibility for WIP placeholders */
}

/* Story Images */
.story-image {
  margin: 36px 0;
  text-align: center;
}

.story-image img {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.story-image figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 10px;
}
