:root {
  /* Same warm near-black palette as the app itself (see AppTheme.swift) —
     the gold accent is meant to sit on a warm dark background, not a cold
     neutral one. */
  color-scheme: dark;
  --text: #ede6d9;
  --muted: #b8ad9a;
  --accent: #e0b84b;
  --accent-ink: #17130f;   /* dark text used ON TOP OF a solid accent-coloured background */
  --rule: #3a3226;
  --bg: #17130f;
  --field-bg: #241f18;
  --tag-bg: rgba(224, 184, 75, 0.16);
  --tag-text: #f0d590;
  --glow: rgba(224, 184, 75, 0.28);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}
a { color: var(--accent); }
strong { font-weight: 600; }

.layout {
  display: flex;
  align-items: flex-start;
  max-width: 1100px;
  margin: 0 auto;
}

/* ---------------- Sidebar nav ---------------- */
.sidenav {
  width: 230px;
  flex: 0 0 230px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.75rem 1.25rem;
  border-right: 1px solid var(--rule);
}
.nav-title { margin-bottom: 1.5rem; }
/* .sidenav .nav-title a (not just .nav-title a) — needs to out-specificity
   the later .sidenav a { display: block } rule below, which otherwise wins
   the cascade on equal specificity by source order and collapses this back
   to a block link, stacking the logo above the text instead of beside it. */
.sidenav .nav-title a {
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.nav-title img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 14px 2px var(--glow), 0 0 28px 8px rgba(224, 184, 75, 0.12);
}
.nav-title span {
  display: block;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
}
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav li { margin-bottom: 0.15rem; }
.sidenav a {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  font-size: 0.92rem;
}
.sidenav a:hover { background: var(--field-bg); }
.sidenav a.active {
  background: var(--tag-bg);
  color: var(--accent);
  font-weight: 600;
}
.back-link {
  display: block;
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.8rem;
  color: var(--muted) !important;
  text-decoration: none;
}
.sidenav-store-link {
  display: inline-block;
  margin-top: 0.9rem;
  line-height: 0;
}
.sidenav-store-link img {
  height: 32px;
  width: auto;
}

/* ---------------- Main content ---------------- */
main {
  flex: 1;
  min-width: 0;
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem 1.75rem 5rem;
}
h1 {
  font-size: 1.85rem;
  margin: 0 0 0.5rem;
}
.subtitle {
  color: var(--muted);
  font-style: italic;
  margin: 0 0 2rem;
  font-size: 1.05rem;
}
.part-intro {
  font-size: 1.02rem;
  margin-bottom: 2rem;
}
h2 {
  font-size: 1.2rem;
  color: var(--accent);
  border-top: 1px solid var(--rule);
  padding-top: 1.75rem;
  margin: 2.25rem 0 0.9rem;
}
p { margin: 0 0 1rem; }
ul { margin: 0; padding-left: 1.2rem; }
li { margin-bottom: 0.55rem; }

/* ---------------- Roles table ---------------- */
table.roles {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 0.5rem;
  font-size: 0.92rem;
}
table.roles th, table.roles td {
  border: 1px solid var(--rule);
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
table.roles th {
  background: var(--field-bg);
  font-size: 0.85rem;
}
table.roles td.role { font-weight: 600; white-space: nowrap; }
.footnote {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* ---------------- Jump links (intro page) ---------------- */
.jump-links { margin-top: 2.5rem; }
.jump-links ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1.5rem; }
.jump-links a {
  display: block;
  text-decoration: none;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
}
.jump-links a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------- Screens ---------------- */
section.screen {
  border-top: 1px solid var(--rule);
  padding-top: 1.75rem;
  margin-top: 1.75rem;
}
section.screen h3 {
  font-size: 1.08rem;
  margin: 0 0 0.6rem;
}
p.note {
  background: var(--field-bg);
  border-left: 3px solid var(--accent);
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 1rem;
  border-radius: 0 6px 6px 0;
}
.screen-body {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
figure {
  margin: 0;
  flex: 0 0 200px;
  width: 200px;
}
figure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  border: 1px solid rgba(237, 230, 217, 0.12);
  /* A soft gold ambient glow — without it, a screenshot of the app's own
     dark UI has almost no edge contrast against this page's equally-dark
     background and just disappears. */
  box-shadow: 0 0 32px 6px var(--glow), 0 0 70px 18px rgba(224, 184, 75, 0.12);
}
figure.pending .pending-box {
  width: 100%;
  aspect-ratio: 320 / 694;
  background: var(--field-bg);
  border: 1px dashed var(--muted);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 0.5rem;
}
figcaption {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.5rem;
  text-align: center;
}
.screen-text {
  flex: 1 1 320px;
  min-width: 280px;
}
.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  margin-left: 0.15rem;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 3.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
}

/* ---------------- Mobile ---------------- */
.nav-toggle {
  display: none;
}
@media (max-width: 860px) {
  .layout { display: block; }
  .sidenav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 78%;
    max-width: 280px;
    height: 100vh;
    background: var(--bg);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 20px rgba(0,0,0,0.5);
  }
  .layout.nav-open .sidenav { transform: translateX(0); }
  main { max-width: 100%; padding: 2.25rem 1.25rem 4rem; }
  .nav-toggle {
    display: block;
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 30;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 1.2rem;
    box-shadow: 0 2px 14px rgba(0,0,0,0.4);
  }
  .jump-links ul { grid-template-columns: 1fr; }
  .screen-body { flex-wrap: wrap; }
  figure { flex: 0 0 140px; width: 140px; }
}
