:root {
  --ink: #e9e4d4;
  --ink-soft: #c8c1ad;
  --ink-faint: #969482;
  --night: #0c100c;
  --night-deep: #080b08;
  --forest: #111811;
  --moss: #1a2419;
  --moss-raised: #202d1f;
  --paper-dark: #161c15;
  --line: #3b4737;
  --line-soft: rgba(96, 112, 86, .38);
  --fern: #8fa66f;
  --fern-light: #b7c793;
  --sage: #718463;
  --amber: #c19a70;
  --blood: #8e5551;
  --blood-soft: #b2776f;
  --shadow: 0 22px 60px rgba(0, 0, 0, .34);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, .16);
  --radius: 16px;
  --sidebar: 286px;
  --serif: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 82% 8%, rgba(143, 166, 111, .10), transparent 30rem),
    radial-gradient(circle at 14% 88%, rgba(193, 154, 112, .055), transparent 28rem),
    linear-gradient(180deg, #0a0e0a 0%, #111711 58%, #0d120d 100%);
}

/* A faint paper-grain effect made only with CSS. No image assets are used. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .15;
  z-index: 100;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.014) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.008) 0 1px, transparent 1px 6px);
  mix-blend-mode: soft-light;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
::selection { background: rgba(183, 199, 147, .24); color: #fff; }
a { color: inherit; }

.app-shell { min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: 30px 22px 24px;
  display: flex;
  flex-direction: column;
  z-index: 20;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(rgba(10,14,10,.95), rgba(12,17,12,.98)),
    repeating-linear-gradient(90deg, rgba(183,199,147,.02) 0 1px, transparent 1px 10px);
  backdrop-filter: blur(16px);
  box-shadow: 14px 0 45px rgba(0,0,0,.14);
}
.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 6px;
  width: 1px;
  background: linear-gradient(transparent, rgba(183,199,147,.22), transparent);
  pointer-events: none;
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 34px; }
.brand h1 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 1.28rem;
  line-height: 1.1;
  letter-spacing: .01em;
  font-weight: 500;
}
.sigil {
  position: relative;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(183,199,147,.72);
  border-radius: 50% 46% 51% 48%;
  color: var(--fern-light);
  font-family: var(--serif);
  font-size: 1.28rem;
  transform: rotate(-3deg);
  box-shadow: inset 0 0 0 6px rgba(143,166,111,.035), 0 5px 18px rgba(0,0,0,.22);
}
.sigil::after {
  content: "";
  position: absolute;
  width: 25px;
  height: 39px;
  border-left: 1px solid rgba(183,199,147,.35);
  border-radius: 50%;
  transform: rotate(34deg);
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--fern);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .69rem;
  font-weight: 800;
}
.nav { display: grid; gap: 7px; }
.nav-link {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ink-faint);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease;
}
.nav-link:hover {
  color: var(--ink);
  border-color: rgba(96,112,86,.35);
  background: rgba(32,45,31,.48);
  transform: translateX(2px);
}
.nav-link.active {
  color: var(--ink);
  border-color: rgba(143,166,111,.20);
  background: linear-gradient(90deg, rgba(143,166,111,.16), rgba(32,45,31,.48));
  box-shadow: inset 2px 0 0 var(--fern);
}
.sidebar-footer { margin-top: auto; color: var(--ink-faint); font-size: .76rem; line-height: 1.6; }
.sidebar-footer p { border-top: 1px solid var(--line-soft); padding-top: 16px; }

/* ---------- Main chrome ---------- */
.main { margin-left: var(--sidebar); min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 78px;
  padding: 16px clamp(22px, 4vw, 56px);
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(72,84,65,.72);
  background: rgba(11,15,11,.84);
  backdrop-filter: blur(18px);
}
.search-wrap { position: relative; flex: 1; max-width: 720px; }
.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-52%);
  color: var(--fern);
  z-index: 1;
  font-family: var(--serif);
  font-size: 1.1rem;
}
.search-wrap input {
  width: 100%;
  padding: 12px 14px 12px 38px;
  outline: none;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(19,26,18,.92);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.search-wrap input::placeholder { color: #74796d; }
.search-wrap input:focus {
  border-color: var(--fern);
  background: #151d14;
  box-shadow: 0 0 0 3px rgba(143,166,111,.075);
}
.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  max-height: 420px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #141b13;
  box-shadow: var(--shadow);
}
.search-result {
  display: block;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 9px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.search-result:hover { background: var(--moss-raised); }
.search-result strong { display: block; font-family: var(--serif); font-weight: 500; }
.search-result span { color: var(--ink-faint); font-size: .81rem; }
.menu-button { display: none; }

/* ---------- Buttons ---------- */
.primary-button, .secondary-button, .ghost-button, .text-button, .icon-button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: transform .18s ease, filter .18s ease, color .18s ease, border-color .18s ease, background .18s ease;
}
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 15px;
  border: 1px solid #aabd83;
  border-radius: 10px;
  color: #10150f;
  background: linear-gradient(180deg, #becd9b, #a8ba83);
  font-weight: 800;
  box-shadow: inset 0 1px rgba(255,255,255,.22), 0 7px 18px rgba(0,0,0,.16);
}
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.04); }
.secondary-button {
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(16,22,15,.42);
}
.secondary-button:hover, .ghost-button:hover { border-color: var(--fern); color: var(--fern-light); background: rgba(143,166,111,.05); }
.ghost-button {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink-faint);
  background: transparent;
  text-align: center;
}
.file-label { cursor: pointer; }
.text-button { padding: 0; margin-top: 10px; color: var(--fern-light); background: transparent; font-weight: 700; }
.icon-button { color: var(--ink-faint); background: transparent; font-size: 1.6rem; }
.link-button { white-space: nowrap; }

/* ---------- Sections ---------- */
.section {
  display: none;
  max-width: 1500px;
  margin: 0 auto;
  padding: clamp(34px, 5vw, 70px) clamp(22px, 5vw, 72px) 90px;
}
.section.active { display: block; animation: fade .24s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.section-heading {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}
.section-heading::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 92px;
  height: 1px;
  background: linear-gradient(90deg, var(--fern), transparent);
}
.section-heading h2, .hero h2, .character-header h2 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -.035em;
}
.section-heading h2 { margin: 0 0 8px; font-size: clamp(2.15rem, 4vw, 3.55rem); }
.section-heading p:last-child { max-width: 760px; margin: 0; color: var(--ink-faint); line-height: 1.72; }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: 1.45fr .75fr; gap: 24px; align-items: stretch; margin-bottom: 30px; }
.hero-copy, .hero-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 21px;
  background:
    radial-gradient(circle at 90% 12%, rgba(143,166,111,.09), transparent 18rem),
    linear-gradient(135deg, rgba(31,43,30,.95), rgba(19,26,18,.96));
  box-shadow: var(--shadow);
}
.hero-copy::before {
  content: "";
  position: absolute;
  width: 230px;
  height: 340px;
  right: -102px;
  bottom: -188px;
  border: 1px solid rgba(183,199,147,.12);
  border-radius: 50%;
  transform: rotate(28deg);
}
.hero-copy { padding: clamp(30px, 5vw, 66px); }
.hero h2 { max-width: 900px; margin: 8px 0 22px; font-size: clamp(2.65rem, 6vw, 5.6rem); line-height: .98; text-wrap: balance; }
.lede { max-width: 760px; color: var(--ink-soft); font-size: 1.06rem; line-height: 1.82; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 30px; }
.hero-card { min-height: 320px; padding: 32px; display: flex; flex-direction: column; justify-content: flex-end; }
.hero-card::before {
  content: "";
  position: absolute;
  inset: 24px;
  border: 1px solid rgba(143,166,111,.18);
  border-radius: 50% 44% 48% 52%;
  transform: rotate(-8deg);
}
.hero-card::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -20px;
  top: -20px;
  border: 1px solid rgba(143,166,111,.11);
  border-radius: 50%;
}
.quote { position: relative; z-index: 1; margin: 0; font-family: var(--serif); font-size: 1.72rem; line-height: 1.38; font-style: italic; }
.quote-caption { position: relative; z-index: 1; margin: 14px 0 0; color: var(--ink-faint); font-size: .80rem; letter-spacing: .03em; }

/* ---------- Cards / panels ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 24px; }
.stat-card {
  padding: 20px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: linear-gradient(150deg, rgba(27,38,26,.84), rgba(20,27,19,.82));
  box-shadow: var(--shadow-soft);
}
.stat-card strong { display: block; color: var(--fern-light); font-family: var(--serif); font-size: 2rem; font-weight: 400; }
.stat-card span { color: var(--ink-faint); font-size: .84rem; }
.content-grid { display: grid; gap: 18px; margin-bottom: 18px; }
.content-grid.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.panel {
  position: relative;
  padding: 24px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(29,39,28,.82), rgba(20,27,19,.86));
  box-shadow: var(--shadow-soft);
}
.panel::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(183,199,147,.025);
  border-radius: calc(var(--radius) - 5px);
  pointer-events: none;
}
.panel h3 { margin: 0 0 12px; font-family: var(--serif); font-size: 1.48rem; font-weight: 400; letter-spacing: -.01em; }
.panel p { color: var(--ink-soft); line-height: 1.76; }
.panel p:last-child { margin-bottom: 0; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.status {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--ink-faint);
  font-size: .67rem;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.status.canon { color: var(--fern-light); border-color: rgba(143,166,111,.44); background: rgba(143,166,111,.035); }
.status.open { color: #d2b188; border-color: rgba(193,154,112,.38); }
.warning {
  border-color: rgba(142,85,81,.46);
  background: linear-gradient(135deg, rgba(86,43,41,.17), rgba(24,32,23,.88));
}
.warning::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22px;
  bottom: 22px;
  width: 2px;
  background: linear-gradient(var(--blood), rgba(142,85,81,.15));
}
.feature-panel h3 { font-size: 1.82rem; }
.tag-cloud, .tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud span, .tags span {
  padding: 7px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 100px;
  color: var(--ink-faint);
  background: rgba(10,14,10,.22);
  font-size: .80rem;
}

/* ---------- Character archive ---------- */
.character-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.character-tab {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--ink-faint);
  background: transparent;
  cursor: pointer;
}
.character-tab:hover { color: var(--ink); border-color: var(--sage); }
.character-tab.active { color: #11170f; background: var(--fern-light); border-color: var(--fern-light); font-weight: 800; }
.character-sheet { display: none; }
.character-sheet.active { display: block; }
.character-header { display: grid; grid-template-columns: 190px 1fr; gap: 28px; align-items: center; margin-bottom: 24px; }
.character-header h2 { margin: 0 0 10px; font-size: clamp(3rem,7vw,6rem); line-height: .95; }
.character-subtitle { margin: 0 0 18px; color: var(--ink-faint); font-size: 1.03rem; }
.art-placeholder {
  position: relative;
  aspect-ratio: 4 / 5;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  overflow: hidden;
  border: 1px dashed rgba(143,166,111,.48);
  border-radius: 14px 14px 48% 14px;
  background:
    radial-gradient(circle at 55% 35%, rgba(143,166,111,.07), transparent 42%),
    linear-gradient(145deg, rgba(143,166,111,.045), rgba(8,12,8,.1));
}
.art-placeholder::before,
.art-placeholder::after {
  content: "";
  position: absolute;
  width: 62%;
  height: 82%;
  border-left: 1px solid rgba(183,199,147,.13);
  border-radius: 50%;
}
.art-placeholder::before { left: 18%; top: 18%; transform: rotate(26deg); }
.art-placeholder::after { right: 4%; top: 2%; transform: rotate(-26deg); }
.placeholder-mark { z-index: 1; color: var(--fern); font-family: var(--serif); font-size: 3rem; }
.art-placeholder p { z-index: 1; margin: 0; color: var(--ink-faint); font-size: .76rem; }
.character-art {
  width: 100%;
  aspect-ratio: 4 / 5;
  display: block;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}
.facts { margin: 0; }
.facts div { display: grid; grid-template-columns: 150px 1fr; gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--ink-faint); }
.facts dd { margin: 0; line-height: 1.55; }

/* ---------- Magic / reference ---------- */
.concept-grid, .discipline-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.concept-grid div, .discipline-grid div {
  padding: 16px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: rgba(10,14,10,.11);
}
.concept-grid strong, .discipline-grid strong { color: var(--fern-light); font-family: var(--serif); font-weight: 500; }
.concept-grid span, .discipline-grid span { color: var(--ink-faint); line-height: 1.5; }
.pdf-frame-wrap { margin-top: 20px; min-height: 720px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #0a0e0a; box-shadow: var(--shadow-soft); }
.pdf-frame { width: 100%; height: 80vh; min-height: 720px; display: block; border: 0; }

/* ---------- Places ---------- */
.place-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.place-card { min-height: 330px; }
.cave-card {
  border-color: rgba(107,128,90,.48);
  background:
    radial-gradient(circle at 65% 15%, rgba(143,166,111,.10), transparent 12rem),
    linear-gradient(145deg, rgba(42,57,38,.96), rgba(15,22,15,.93));
}
.cave-card::before {
  content: "";
  position: absolute;
  width: 75%;
  height: 60%;
  right: -25%;
  bottom: -20%;
  border: 1px solid rgba(183,199,147,.08);
  border-radius: 50%;
}

/* ---------- Timeline ---------- */
.timeline { position: relative; max-width: 900px; margin-left: 12px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 1px; background: linear-gradient(var(--line), rgba(59,71,55,.18)); }
.timeline article { position: relative; display: grid; grid-template-columns: 32px 1fr; gap: 18px; padding: 0 0 30px; }
.timeline-dot {
  width: 17px;
  height: 17px;
  margin-top: 4px;
  z-index: 1;
  border: 3px solid var(--night);
  border-radius: 50%;
  background: var(--fern);
  box-shadow: 0 0 0 1px var(--fern), 0 0 18px rgba(143,166,111,.12);
}
.timeline article.major .timeline-dot { background: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.timeline h3 { margin: 0 0 8px; font-family: var(--serif); font-weight: 400; font-size: 1.42rem; }
.timeline p:not(.eyebrow) { margin: 0; color: var(--ink-faint); line-height: 1.67; }

/* ---------- Personal archive ---------- */
.archive-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.archive-toolbar select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--moss); }
.archive-toolbar p { color: var(--ink-faint); }
.user-entry-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.user-entry {
  padding: 20px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(29,39,28,.88), rgba(19,26,18,.89));
  box-shadow: var(--shadow-soft);
}
.user-entry-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.user-entry h3 { margin: 4px 0 8px; font-family: var(--serif); font-weight: 400; font-size: 1.38rem; }
.user-entry-meta { color: var(--fern); text-transform: uppercase; letter-spacing: .11em; font-size: .66rem; }
.user-entry p { color: var(--ink-faint); line-height: 1.67; white-space: pre-wrap; }
.entry-actions { display: flex; gap: 6px; }
.entry-actions button { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink-faint); background: transparent; cursor: pointer; }
.entry-actions button:hover { color: var(--ink); border-color: var(--sage); }
.empty-state { padding: 50px 24px; border: 1px dashed var(--line); border-radius: 16px; color: var(--ink-faint); text-align: center; }
.empty-state h3 { color: var(--ink); font-family: var(--serif); font-weight: 400; }

/* ---------- Dialog ---------- */
.entry-dialog { width: min(720px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: #141b13; box-shadow: var(--shadow); }
.entry-dialog::backdrop { background: rgba(0,0,0,.71); backdrop-filter: blur(4px); }
.entry-dialog form { padding: 24px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.dialog-heading h2 { margin: 0; font-family: var(--serif); font-weight: 400; }
.entry-dialog label { display: grid; gap: 7px; margin-top: 14px; color: var(--ink-faint); font-size: .83rem; }
.entry-dialog input, .entry-dialog select, .entry-dialog textarea { padding: 11px 12px; outline: none; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #0d120d; }
.entry-dialog textarea { resize: vertical; line-height: 1.55; }
.entry-dialog input:focus, .entry-dialog select:focus, .entry-dialog textarea:focus { border-color: var(--fern); box-shadow: 0 0 0 3px rgba(143,166,111,.06); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #202c1e; box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .22s ease; }
.toast.show { transform: none; opacity: 1; }

/* ---------- Accessibility / motion ---------- */
:focus-visible { outline: 2px solid var(--fern-light); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1050px) {
  :root { --sidebar: 250px; }
  .hero { grid-template-columns: 1fr; }
  .hero-card { min-height: 220px; }
  .place-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 760px) {
  .sidebar { width: min(300px, 88vw); transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-button { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: transparent; }
  .topbar > .primary-button { display: none; }
  .section { padding-left: 18px; padding-right: 18px; }
  .content-grid.two, .concept-grid, .discipline-grid, .user-entry-grid { grid-template-columns: 1fr; }
  .character-header { grid-template-columns: 110px 1fr; gap: 16px; }
  .character-header h2 { font-size: 3rem; }
  .art-placeholder { border-radius: 12px; }
  .facts div { grid-template-columns: 1fr; gap: 4px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .pdf-frame-wrap, .pdf-frame { min-height: 520px; }
}
@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .hero-copy { padding: 28px 22px; }
  .hero h2 { font-size: 2.75rem; }
  .character-header { grid-template-columns: 1fr; }
  .art-placeholder { width: 130px; }
}

/* ---------- Editable character system ---------- */
.status.developing { color: #d2b188; border-color: rgba(193,154,112,.42); background: rgba(193,154,112,.035); }
.status.idea { color: var(--ink-faint); border-color: rgba(150,148,130,.35); background: rgba(150,148,130,.025); }

.character-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.autosave-note, .muted-note { color: var(--ink-faint); font-size: .78rem; }
.character-kicker { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.character-kicker .eyebrow { margin: 0; }
.editable-header { align-items: start; }
.character-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.danger-button {
  padding: 11px 15px;
  border: 1px solid rgba(142,85,81,.46);
  border-radius: 10px;
  color: var(--blood-soft);
  background: rgba(86,43,41,.08);
  cursor: pointer;
}
.danger-button:hover { border-color: var(--blood-soft); background: rgba(86,43,41,.17); }
.art-stack { width: 100%; }
.art-stack .art-placeholder { width: 100%; }

/* Respect the HTML hidden state even though artwork elements define their own display modes. */
.character-art[hidden],
.art-placeholder[hidden] {
  display: none !important;
}
.core-facts-panel { margin-bottom: 18px; }
.compact-heading { align-items: center; }
.compact-heading h3 { margin-bottom: 0; }
.editable-facts .fact-row { grid-template-columns: 150px minmax(0,1fr) auto; align-items: start; }
.mini-status {
  align-self: start;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-faint);
  font-size: .58rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  white-space: nowrap;
}
.mini-status.canon { color: var(--fern-light); border-color: rgba(143,166,111,.35); }
.mini-status.developing { color: #d2b188; border-color: rgba(193,154,112,.35); }
.mini-status.idea { color: var(--ink-faint); }
.character-section-panel { margin-bottom: 18px; }
.rich-text p { margin-top: 0; }
.inline-empty { margin-top: 18px; }

.character-dialog { width: min(980px, calc(100vw - 28px)); max-height: min(92vh, 980px); overflow: auto; }
.character-dialog form { padding-bottom: 0; }
.entry-dialog small { color: var(--ink-faint); line-height: 1.45; }
.entry-dialog code { color: var(--fern-light); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.editor-block {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}
.editor-block-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.editor-block-heading h3 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.4rem; }
.compact { padding: 8px 10px; font-size: .78rem; }
.repeater { display: grid; gap: 10px; }
.repeater-row {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(8,12,8,.26);
}
.repeater-grid { display: grid; gap: 10px; align-items: end; }
.fact-grid { grid-template-columns: minmax(150px,.7fr) minmax(220px,1.7fr) minmax(120px,.55fr); }
.section-grid { grid-template-columns: minmax(220px,1fr) minmax(140px,.35fr); }
.repeater-row label { margin-top: 0; }
.repeater-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 9px; }
.icon-text-button {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink-faint);
  background: transparent;
  cursor: pointer;
}
.icon-text-button:hover { color: var(--ink); border-color: var(--sage); }
.section-row-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.checkbox-label { display: flex !important; grid-template-columns: none; align-items: center; gap: 8px !important; color: var(--ink-faint); }
.checkbox-label input { width: auto; margin: 0; accent-color: var(--fern); }
.sticky-actions {
  position: sticky;
  bottom: 0;
  margin: 24px -24px 0;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: rgba(20,27,19,.96);
  backdrop-filter: blur(12px);
  z-index: 3;
}

@media (max-width: 760px) {
  .character-toolbar { align-items: flex-start; flex-direction: column; }
  .form-grid.two, .fact-grid, .section-grid { grid-template-columns: 1fr; }
  .editable-facts .fact-row { grid-template-columns: 1fr; }
  .mini-status { margin-top: 3px; }
  .section-row-footer { align-items: flex-start; flex-direction: column; }
  .repeater-actions { width: 100%; justify-content: flex-start; }
}
