:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #1f2328;
  --muted: #57606a;
  --border: #e2e5e9;
  --accent: #8a0e5c;
  --sidebar-bg: #f5f4f5;
  --header-bg: #fbeff7;
  --heading-accent: #8a0e5c;
  --subtext-accent: #b8619b;
  --accent-text: #ffffff;
  --accent-shadow: rgb(138 14 92 / 0.25);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --text: #e6e8eb;
    --muted: #9aa4ae;
    --border: #2c3136;
    --accent: #ff6ec0;
    --sidebar-bg: #1b191c;
    --header-bg: #2a1b26;
    --heading-accent: #ff6ec0;
    --subtext-accent: #e0a3cc;
    --accent-text: #1a0512;
    --accent-shadow: rgb(255 110 192 / 0.3);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

html {
  overflow-y: scroll;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.6;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: calc(max(0px, (100vw - 1400px) / 2) + 220px);
  height: 100%;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}

body::after {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  width: calc(max(0px, (100vw - 1400px) / 2) + 220px);
  height: 100%;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
}

.site-header {
  position: relative;
  flex: 0 0 auto;
  padding: 2rem calc(max(0px, (100vw - 1400px) / 2) + 220px + 1.5rem);
  text-align: center;
}

.site-header::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(max(0px, (100vw - 1400px) / 2) + 220px);
  right: calc(max(0px, (100vw - 1400px) / 2) + 220px);
  background: var(--header-bg);
  z-index: -1;
}

.site-header::after {
  content: "";
  position: absolute;
  left: calc(max(0px, (100vw - 1400px) / 2) + 220px);
  right: calc(max(0px, (100vw - 1400px) / 2) + 220px);
  bottom: 0;
  height: 3px;
  background: var(--heading-accent);
}

.site-header h1 {
  max-width: 1000px;
  margin: 0 auto 0.4rem;
  font-size: 2.25rem;
  color: var(--heading-accent);
}

.site-subtitle {
  max-width: 1000px;
  margin: 0 auto;
  color: var(--subtext-accent);
  font-size: 1.1rem;
}

.weak-letter {
  color: var(--heading-accent);
}

.brain-graph-link {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.brain-graph-link:hover {
  opacity: 0.8;
}

.brain-graph-icon {
  flex: 0 0 auto;
  display: block;
  transition: transform 0.3s ease;
}

.brain-graph-link:hover .brain-graph-icon {
  transform: scale(1.06);
}

.brain-graph-link:hover .brain-graph-icon.flipped {
  transform: scaleX(-1) scale(1.06);
}

.site-header .intro {
  max-width: 700px;
  margin: 1rem auto 0;
  color: var(--heading-accent);
}

.layout {
  position: relative;
  display: flex;
  align-items: stretch;
  min-height: 0;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar {
  flex: 0 0 220px;
  padding: 2rem 1.25rem;
  background: var(--sidebar-bg);
}

.sidebar-right {
  background: var(--sidebar-bg);
}

.week-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  position: fixed;
  top: 2.65rem;
  left: calc(max(0px, (100vw - 1400px) / 2) + 1.25rem);
  width: calc(220px - 2.5rem);
}

.week-list a {
  display: inline-block;
  padding: 0.4rem 1.25rem;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.2;
  text-align: center;
  transition: background-color 0.2s ease, color 0.2s ease,
    transform 0.15s ease, box-shadow 0.2s ease;
}

.week-list a:hover {
  background: var(--border);
  transform: translateX(-2px);
}

.week-list a.placeholder {
  color: var(--muted);
}

.week-list a.active {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 2px 8px var(--accent-shadow);
}

.week-list a.active:hover {
  transform: none;
}

main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8rem 2rem 3rem 2rem;
}

section,
footer {
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}

section {
  padding: 0 0 1.25rem;
}

@keyframes week-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

section[id^="week-"].fade-in {
  animation: week-fade-in 0.35s ease;
}

.week-heading {
  position: absolute;
  top: 2rem;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}

.week-heading h2 {
  margin: 0 0 0.25rem;
  font-size: 2rem;
  color: var(--heading-accent);
}

.week-heading .week-sub {
  margin: 0;
  color: var(--subtext-accent);
  font-size: 1.1rem;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

section h3 {
  margin: 1.75rem 0 0.5rem;
  color: var(--heading-accent);
  font-size: 1.25rem;
}

section h4 {
  margin: 1.25rem 0 0.5rem;
  color: var(--subtext-accent);
  font-size: 1.05rem;
}

.post-figure {
  margin: 1.5rem 0;
  text-align: center;
}

.post-figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .week-list a,
  section[id^="week-"].fade-in {
    animation: none;
    transition: none;
  }
}

@media (max-width: 640px), (max-height: 500px) and (orientation: landscape) {
  body::before,
  body::after {
    display: none;
  }

  .site-header {
    padding: 1.5rem 1.25rem;
  }

  .site-header::before,
  .site-header::after {
    left: 0;
    right: 0;
  }

  .sidebar-right {
    display: none;
  }

  .week-heading {
    position: static;
    margin-bottom: 1rem;
  }

  .layout {
    flex-direction: column;
    min-height: 0;
  }

  .sidebar {
    flex: 0 0 auto;
    width: 100%;
    padding: 1.25rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .week-list {
    position: static;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  main {
    padding: 1.5rem 1.25rem;
  }
}

@media print {
  body::before,
  body::after,
  .sidebar,
  .sidebar-right,
  .week-list,
  .site-header::after {
    display: none;
  }

  html {
    overflow-y: visible;
  }

  body {
    display: block;
    min-height: 0;
  }

  .site-header::before {
    left: 0;
    right: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .site-header {
    padding: 1rem 0.5rem;
    text-align: center;
  }

  .site-header h1,
  .site-subtitle,
  .site-header .intro {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  .layout {
    display: block;
    max-width: none;
    margin: 0;
  }

  main {
    padding: 0;
  }

  .week-heading {
    position: static;
    text-align: left;
    margin-bottom: 1rem;
  }

  section,
  footer {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  section {
    padding: 0;
  }

  footer {
    margin-top: 2rem;
  }
}
