:root {
  --bg: #f5f0e8;
  --bg-alt: #ebe3d5;
  --bg-card: #e0d6c2;
  --fg: #2c2822;
  --fg-muted: #7a7264;
  --accent: #7a9bb8;
  --accent2: #9bb8d0;
  --border: #c4b9a6;
  --pink-soft: #d4b8c8;
  --pink-pale: #e8d4de;
  --blue-pale: #c8dae8;
  --font: 'Iowan Old Style', 'Palatino', 'Georgia', serif;
  --font-heading: 'Georgia', 'Palatino', serif;
  --font-pixel: 'Courier New', 'Courier', monospace;
  --sidebar-width: 180px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='20' cy='20' r='0.6' fill='%23c4b9a6' opacity='0.25'/%3E%3C/svg%3E");
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  min-height: 100vh;
}

a { color: var(--accent); }

a:hover { color: #5a7a9a; }

::selection { background: var(--blue-pale); color: var(--fg); }

/* ====== SIDEBAR ====== */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-alt);
  border-right: 2px solid var(--border);
  padding: 2rem 1.2rem;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

#sidebar .site-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--fg);
  display: block;
  margin-bottom: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}

#sidebar nav { display: flex; flex-direction: column; gap: 0.1rem; }

#sidebar nav a {
  display: block;
  padding: 0.3rem 0.4rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.1s;
}

#sidebar nav a:hover { border-left-color: var(--accent); color: var(--fg); }

#sidebar nav a.active {
  border-left-color: var(--accent);
  color: var(--fg);
  background: rgba(122, 155, 184, 0.1);
}

#sidebar .footer-text {
  font-size: 0.7rem;
  color: var(--fg-muted);
  margin-top: 1.5rem;
  line-height: 1.4;
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

/* ====== MAIN ====== */
#main {
  margin-left: var(--sidebar-width);
  padding: 2.5rem 3rem;
  max-width: calc(100vw - var(--sidebar-width));
}

/* ====== SPLASH ====== */
#splash {
  display: flex;
  gap: 2rem;
  align-items: center;
  margin: 0 0 2rem;
  padding: 1.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

#splash .splash-art {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--blue-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
  color: var(--accent);
  border: 1px solid var(--border);
}

#splash .splash-text { flex: 1; }
#splash .splash-text h2 { border: none; margin: 0 0 0.5rem; padding: 0; font-style: normal; font-size: 1.3rem; }
#splash .splash-text p { margin: 0; color: var(--fg-muted); font-size: 0.9rem; }

/* ====== HOME IMAGE ROW ====== */
.home-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}

.home-img-card {
  border: 2px solid var(--border);
  background: var(--bg-alt);
  padding: 0.4rem;
  text-align: center;
}

.home-img-card .img-slot {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  overflow: hidden;
}

.home-img-card .img-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-img-card .img-slot .img-placeholder {
  color: var(--fg-muted);
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  text-align: center;
  line-height: 1.3;
  padding: 0.5rem;
}

.home-img-card .img-label {
  font-size: 0.7rem;
  color: var(--fg-muted);
  margin-top: 0.3rem;
  font-family: var(--font-pixel);
}

/* ====== TYPOGRAPHY ====== */
h1 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--fg);
  margin-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--fg);
  margin: 2rem 0 0.6rem;
  font-style: italic;
}

h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 400;
  color: var(--fg);
  margin: 1.5rem 0 0.5rem;
}

p { margin-bottom: 0.8rem; }
ul, ol { margin: 0.5rem 0 1rem 1.5rem; }
li { margin-bottom: 0.2rem; }
li::marker { color: var(--accent); }

blockquote {
  border-left: 3px solid var(--pink-soft);
  padding: 0.3rem 0.8rem;
  margin: 0.8rem 0;
  color: var(--fg-muted);
  background: var(--bg-alt);
}

hr {
  border: none;
  text-align: center;
  margin: 2rem 0;
  color: var(--border);
  font-size: 0.9rem;
  letter-spacing: 0.5em;
}
hr::after { content: "\2605 \00B7 \2605 \00B7 \2605"; }

/* ====== CHAPTER GRID ====== */
.chapter-grid { display: grid; gap: 0.4rem; margin: 1rem 0; }

.chapter-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 0.5rem 0.8rem;
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.1s;
}

.chapter-card:hover { border-color: var(--accent); text-decoration: none; color: var(--fg); }

.chapter-card .ch-num {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--accent2);
  width: 1.6rem;
  text-align: right;
  flex-shrink: 0;
}

.chapter-card .ch-info { flex: 1; }
.chapter-card .ch-title { display: block; font-size: 0.9rem; }
.chapter-card .ch-meta { display: block; color: var(--fg-muted); font-size: 0.75rem; }

.chapter-card .ch-progress {
  font-size: 0.75rem;
  color: var(--accent);
  flex-shrink: 0;
  font-family: var(--font-pixel);
}

/* ====== CHAPTER BODY ====== */
.chapter-body {
  font-size: 0.95rem;
  line-height: 1.85;
  max-width: 650px;
  margin: 0 auto;
}

.chapter-body p { margin-bottom: 0.8rem; }
.chapter-body .dialogue {
  padding-left: 0.8rem;
  border-left: 2px solid var(--accent2);
  margin-bottom: 0.7rem;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0 1rem;
  margin-bottom: 1rem;
  gap: 0.5rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

/* ====== CHARACTER CARDS ====== */
.char-grid { display: grid; gap: 0.8rem; margin: 1.5rem 0; }

.char-card {
  display: flex;
  gap: 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 1rem;
}

.char-card:hover { border-color: var(--pink-soft); }

.char-avatar {
  width: 55px;
  height: 55px;
  border-radius: 50%;
  background: var(--blue-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  color: var(--accent);
  border: 1px solid var(--border);
}

.char-info { flex: 1; }
.char-info .role {
  font-size: 0.7rem;
  color: var(--pink-soft);
  text-transform: lowercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.1rem;
}
.char-info h3 { margin: 0 0 0.2rem; font-size: 1rem; }
.char-info .desc { color: var(--fg-muted); font-size: 0.85rem; margin: 0; }

.char-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.char-tag {
  font-size: 0.7rem;
  padding: 0.05rem 0.35rem;
  background: var(--bg);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  font-family: var(--font-pixel);
}

.char-links {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

/* ====== ABOUT SECTION ====== */
.about-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 1.2rem 1.5rem;
  margin: 1rem 0;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.6rem;
  margin: 1rem 0;
}

.stat {
  text-align: center;
  padding: 0.8rem 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.stat .num {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--accent);
}

.stat .label {
  font-size: 0.65rem;
  color: var(--fg-muted);
  text-transform: lowercase;
  letter-spacing: 0.05em;
  margin-top: 0.1rem;
  font-family: var(--font-pixel);
}

/* ====== STAMPS / BLINKIES ====== */
#stamps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin: 2rem 0;
  padding: 1rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

#stamps img {
  image-rendering: pixelated;
  max-height: 31px;
  width: auto;
}

#stamps .stamp-placeholder {
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  color: var(--fg-muted);
  border: 1px dashed var(--border);
  padding: 0.3rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
}

/* ====== FOOTER ====== */
footer {
  margin-top: 2rem;
  padding: 1.5rem 0 1rem;
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.75rem;
  font-family: var(--font-pixel);
  border-top: 1px solid var(--border);
}

footer a { color: var(--accent); }

/* ====== MISC ====== */
.text-center { text-align: center; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }

.updated {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-align: center;
  margin: 0.5rem 0 1.5rem;
}

/* ====== MOBILE ====== */
@media (max-width: 768px) {
  #sidebar {
    position: relative;
    top: 0;
    width: 100%;
    min-width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 2px solid var(--border);
    padding: 0.6rem 1rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    z-index: 50;
  }

  #sidebar .site-title { margin-bottom: 0; font-size: 0.9rem; border-bottom: none; padding-bottom: 0; }
  #sidebar .footer-text { display: none; }
  #sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 0; flex: 1; justify-content: flex-end; }
  #sidebar nav a { font-size: 0.75rem; padding: 0.2rem 0.3rem; border-left: none; border-bottom: 2px solid transparent; }
  #sidebar nav a:hover { border-left: none; border-bottom-color: var(--accent); }
  #sidebar nav a.active { border-left: none; border-bottom-color: var(--accent); background: none; }

  #main { margin-left: 0; padding: 1.2rem; max-width: 100%; }
  .home-images { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
}

@media (max-width: 500px) {
  #main { padding: 1rem 0.8rem; }

  h1 { font-size: 1.3rem; }
  h2 { font-size: 1rem; }

  #splash { flex-direction: column; text-align: center; padding: 1rem; }
  #splash .splash-art { width: 60px; height: 60px; font-size: 1.5rem; }

  .chapter-body { font-size: 0.9rem; }
  .chapter-body .dialogue { padding-left: 0.5rem; }

  .chapter-nav { flex-wrap: wrap; justify-content: center; }
  .chapter-nav a { font-size: 0.8rem; }

  .char-card { flex-direction: column; align-items: center; text-align: center; }
  .char-avatar { width: 45px; height: 45px; font-size: 1.1rem; }

  .home-images { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
