:root {
  --bg-page: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.8);
  --border-subtle: rgba(148, 163, 184, 0.15);
  --border-focus: #38bdf8;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-night: #818cf8;
  --accent-dawn: #f59e0b;
  --accent-day: #38bdf8;
  --accent-surgical: #f43f5e;
  --accent-induced: #10b981;
  --accent-emergency: #fb923c;
  
  --font-serif: "Newsreader", "Fraunces", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
  background-color: var(--bg-page);
}

body {
  font-family: var(--font-sans);
  color: var(--text-main);
  background: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #0f172a 60%, #020617 100%);
  min-height: 100vh;
  line-height: 1.65;
  font-size: 1.05rem;
  padding: 0;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

header {
  margin-bottom: 3.5rem;
  text-align: center;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.lang-switch a, .home-link {
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  transition: all 0.2s ease;
}

.lang-switch a:hover, .home-link:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.kicker {
  display: inline-block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent-dawn);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

h1 {
  font-family: var(--font-serif);
  font-size: 2.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  color: #ffffff;
}

.subtitle {
  font-size: 1.25rem;
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto 1.5rem;
  line-height: 1.5;
}

.lead-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  padding: 1.75rem;
  margin-bottom: 3.5rem;
  backdrop-filter: blur(8px);
  text-align: left;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.lead-card p {
  margin-bottom: 1rem;
  color: #e2e8f0;
}

.lead-card p:last-child {
  margin-bottom: 0;
}

.stat-highlight {
  color: var(--accent-dawn);
  font-weight: 600;
}

/* Interactive Explorer */
.explorer-section {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 1.25rem;
  padding: 2rem;
  margin-bottom: 3.5rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.explorer-header {
  text-align: center;
  margin-bottom: 2rem;
}

.explorer-header h2 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.time-control-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.dial-display {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 700;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid var(--border-subtle);
  padding: 0.5rem 1.75rem;
  border-radius: 1rem;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.dial-period {
  font-size: 1rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.slider-container {
  width: 100%;
  max-width: 600px;
}

input[type="range"].time-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #312e81 0%, #1e3a8a 25%, #f59e0b 35%, #38bdf8 50%, #f59e0b 75%, #312e81 100%);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
}

input[type="range"].time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--accent-dawn);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.8);
  cursor: pointer;
  transition: transform 0.1s ease;
}

input[type="range"].time-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.time-presets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-btn:hover, .preset-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  border-color: var(--accent-day);
}

/* Visualization Canvas / SVG Container */
.chart-wrapper {
  position: relative;
  width: 100%;
  max-width: 680px;
  margin: 0 auto 2.5rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-subtle);
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Details Breakdown Card */
.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  .details-grid {
    grid-template-columns: 1fr;
  }
}

.detail-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.detail-card h3 {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.prob-bar-group {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.prob-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.prob-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.prob-name {
  color: var(--text-main);
}

.prob-value {
  font-family: var(--font-mono);
  font-weight: 600;
}

.prob-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.prob-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fill-spontaneous { background: var(--accent-night); }
.fill-elective { background: var(--accent-surgical); }
.fill-induced { background: var(--accent-induced); }
.fill-emergency { background: var(--accent-emergency); }

/* Circadian Hormone Stats */
.hormone-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hormone-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.hormone-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.hormone-name {
  color: #cbd5e1;
}

.hormone-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-dawn);
}

/* Day Toggle */
.day-toggle-group {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.toggle-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-pill.active {
  background: var(--accent-day);
  color: #0f172a;
  font-weight: 600;
  border-color: var(--accent-day);
}

/* Editorial Content Sections */
.article-body {
  margin-top: 4rem;
}

.article-section {
  margin-bottom: 3.5rem;
}

.article-section h2 {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  margin-bottom: 1rem;
  line-height: 1.25;
  color: #ffffff;
}

.article-section p {
  margin-bottom: 1.25rem;
  color: #cbd5e1;
  font-size: 1.05rem;
  line-height: 1.7;
}

.quote-box {
  border-left: 3px solid var(--accent-dawn);
  padding: 1.25rem 1.5rem;
  background: rgba(245, 158, 11, 0.06);
  border-radius: 0 0.5rem 0.5rem 0;
  margin: 1.75rem 0;
  color: #fde68a;
}

.quote-box p {
  margin-bottom: 0.5rem;
  font-style: italic;
  color: #fef08a;
  line-height: 1.6;
}

.quote-box cite {
  display: block;
  font-size: 0.85rem;
  font-style: normal;
  color: var(--text-muted);
}

.quote-box cite a {
  color: var(--accent-day);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Method Note */
.method-note {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: 0.75rem;
  padding: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 3rem;
}

.method-note h3 {
  color: var(--text-main);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.method-note p {
  margin-bottom: 0.75rem;
}

.method-note p:last-child {
  margin-bottom: 0;
}

.method-note a {
  color: var(--accent-day);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

.method-note a:hover {
  color: #ffffff;
}

.sources-list {
  margin-top: 1rem;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.sources-list li {
  color: #cbd5e1;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Static Fallback */
.no-js-notice {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--accent-dawn);
  color: #fde68a;
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.static-table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

table.data-table th, table.data-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

table.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
}

/* Footer & Back to Top */
footer {
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-dim);
}

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

footer a:hover {
  text-decoration: underline;
  color: var(--text-main);
}

#back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(30, 41, 59, 0.85);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1.25rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  z-index: 100;
}

#back-to-top:hover {
  background: var(--accent-day);
  color: #0f172a;
  transform: translateY(-2px);
}

/* Accessibility & Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 1.5rem 1rem 4rem;
  }
  h1 {
    font-size: 2.1rem;
  }
  .subtitle {
    font-size: 1.1rem;
  }
  .dial-display {
    font-size: 2.25rem;
    padding: 0.4rem 1.25rem;
  }
  .explorer-section {
    padding: 1.25rem;
  }
}
