:root {
  --cork: #855736;
  --paper: #eee2bd;
  --paper-light: #faf2d6;
  --ink: #342a1e;
  --muted: #746650;
  --line: rgba(94, 73, 44, 0.3);
  --green: #50765a;
  --green-dark: #34553d;
  --gold: #b8772f;
  --red: #9b4637;
  --shadow: 8px 11px 0 rgba(55, 31, 16, 0.17), 0 24px 52px rgba(45, 25, 12, 0.24);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--cork);
  background-image:
    radial-gradient(circle at 13px 19px, rgba(48, 29, 17, 0.22) 0 1px, transparent 1.7px),
    radial-gradient(circle at 43px 47px, rgba(247, 214, 161, 0.11) 0 1.1px, transparent 1.9px),
    repeating-linear-gradient(19deg, rgba(255, 226, 179, 0.018) 0 2px, transparent 2px 7px),
    linear-gradient(135deg, #986942, #75482d 56%, #8c5c38);
  background-size: 82px 64px, 91px 73px, auto, auto;
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
button, input, select { font: inherit; }
.hidden { display: none !important; }
.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-height: 72px;
  gap: 20px;
  padding: 0 max(18px, calc((100vw - 1220px) / 2));
  border-bottom: 1px solid rgba(234, 202, 150, 0.22);
  color: #f1e3c7;
  background: rgba(35, 27, 18, 0.97);
  box-shadow: 0 6px 22px rgba(45, 26, 14, 0.2);
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; white-space: nowrap; }
.brand > span:last-child { display: grid; }
.brand strong { font: 700 1.05rem/1.1 Georgia, serif; letter-spacing: 0.04em; }
.brand small { color: #b8a78a; font-size: 0.55rem; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(213, 170, 97, 0.52);
  border-radius: 50%;
  color: #d5aa61;
  background: rgba(211, 165, 85, 0.08);
  font: 700 1rem Georgia, serif;
  place-items: center;
}
.site-nav { display: flex; justify-content: center; gap: 2px; }
.site-nav a { padding: 8px 8px; color: #c5b494; font-size: 0.71rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.site-nav a:hover, .site-nav a.active { color: #fff1d5; background: rgba(240, 210, 157, 0.06); }
.edition-badge { padding: 6px 9px; border: 1px solid rgba(213, 170, 97, 0.3); border-radius: 2px; color: #cfb98f; font-size: 0.61rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }
.page-shell { width: min(1220px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 90px; }
.breadcrumbs { display: flex; gap: 8px; margin-bottom: 16px; color: #ead8b6; font-size: 0.75rem; font-weight: 750; }
.breadcrumbs a { text-underline-offset: 3px; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; }
h1 { margin: 0; font-size: clamp(2.5rem, 5.6vw, 5rem); line-height: 0.95; letter-spacing: -0.04em; }
.eyebrow { margin: 0 0 8px; color: #845724; font-size: 0.67rem; font-weight: 900; letter-spacing: 0.13em; text-transform: uppercase; }
.site-footer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 26px max(22px, calc((100vw - 1180px) / 2));
  color: #d6c3a2;
  background: #2a2016;
}
.site-footer p { margin: 2px 0 0; color: #a99779; font-size: 0.72rem; }
.site-footer small { color: #9e8b6d; font-size: 0.67rem; }

.index-hero, .dossier-hero {
  position: relative;
  border: 1px solid rgba(102, 79, 48, 0.24);
  border-radius: 3px 10px 4px 8px;
  background:
    linear-gradient(90deg, transparent 0 45px, rgba(152, 75, 61, 0.08) 46px, transparent 47px),
    repeating-linear-gradient(0deg, transparent 0 36px, rgba(87, 78, 59, 0.065) 37px),
    linear-gradient(145deg, #f1e4bd, #d9c695);
  box-shadow: var(--shadow);
}
.index-hero::before, .paper-panel::before, .filter-board::before, .dossier-hero::before {
  position: absolute;
  z-index: 2;
  top: -12px;
  left: 50%;
  width: 100px;
  height: 25px;
  background: linear-gradient(100deg, rgba(213, 191, 140, 0.72), rgba(240, 222, 177, 0.84), rgba(203, 178, 122, 0.7));
  box-shadow: 0 2px 4px rgba(58, 40, 22, 0.1);
  clip-path: polygon(0 12%, 9% 0, 22% 8%, 36% 1%, 52% 9%, 67% 0, 83% 8%, 100% 2%, 97% 88%, 82% 100%, 64% 91%, 48% 100%, 29% 92%, 12% 100%, 2% 87%);
  content: "";
  transform: translateX(-50%) rotate(-0.8deg);
}
.index-hero { display: grid; grid-template-columns: minmax(0, 1fr) 170px; align-items: center; gap: 30px; padding: 38px; }
.index-hero p:not(.eyebrow) { max-width: 720px; margin: 18px 0 0; color: #665944; font: italic 1rem/1.6 Georgia, serif; }
.index-hero aside {
  position: relative;
  display: grid;
  min-height: 130px;
  padding: 30px 18px 18px;
  color: #344a37;
  background: linear-gradient(145deg, #d9dfa9, #bbc98c);
  box-shadow: 4px 6px 0 rgba(69, 53, 29, 0.12);
  text-align: center;
  transform: rotate(1deg);
  place-content: center;
}
.index-hero aside .pin { position: absolute; top: 10px; left: 50%; width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #c6dcad, #66864f 65%, #3e5a34); transform: translateX(-50%); }
.index-hero aside strong { font: 700 2.2rem Georgia, serif; }
.index-hero aside small { font-size: 0.63rem; font-weight: 850; letter-spacing: 0.08em; text-transform: uppercase; }
.dex-tabs { display: flex; align-items: end; gap: 5px; margin: 0 18px; overflow-x: auto; }
.dex-tabs a { flex: 0 0 auto; padding: 10px 16px 8px; border-radius: 0 0 5px 5px; color: #ede0c1; background: #51402e; font-size: 0.66rem; font-weight: 900; text-decoration: none; text-transform: uppercase; }
.dex-tabs a:nth-child(2) { background: #70533b; }
.dex-tabs a:nth-child(3) { background: #566d61; }
.dex-tabs a:nth-child(4) { background: #80633d; }
.dex-tabs a.active { padding-bottom: 13px; color: #304d37; background: #cbd69a; }
.detail-tabs { margin-bottom: 2px; }
.dossier-tab { position: absolute; z-index: 3; top: 22px; right: -8px; padding: 8px 18px 8px 14px; color: #f4e5c4; background: #6d4d35; box-shadow: 2px 3px 0 rgba(55, 31, 16, 0.16); font-size: 0.62rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; transform: rotate(1deg); }

.filter-board {
  position: relative;
  display: grid;
  grid-template-columns: minmax(230px, 1.5fr) repeat(3, minmax(120px, 0.8fr)) auto;
  align-items: end;
  gap: 10px;
  margin: 25px 0 13px;
  padding: 23px 20px 42px;
  border: 1px solid rgba(105, 80, 47, 0.3);
  border-radius: 2px 9px 3px 7px;
  background: linear-gradient(145deg, #f4ebcd, #d8c99e);
  box-shadow: 5px 7px 0 rgba(55, 31, 16, 0.14);
}
.index-whimsy { position: absolute; right: 20px; bottom: 8px; margin: 0; color: #766243; font: italic 0.7rem Georgia, serif; transform: rotate(-0.25deg); }
.filter-board label { min-width: 0; }
.filter-board label > span { display: block; margin: 0 0 6px; color: #6c5c44; font-size: 0.62rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
input, select {
  width: 100%;
  min-height: 45px;
  padding: 9px 11px;
  border: 1px solid rgba(96, 74, 44, 0.38);
  border-radius: 3px 8px 4px 7px;
  outline: 0;
  color: var(--ink);
  background: #fbf4da;
}
input:focus, select:focus { border-color: #568062; box-shadow: 0 0 0 3px rgba(78, 121, 88, 0.14); }
.button { min-height: 45px; padding: 9px 14px; border: 1px solid; border-radius: 3px 8px 4px 7px; font-weight: 850; cursor: pointer; }
.button-secondary { border-color: rgba(71, 102, 76, 0.45); color: #3d6548; background: rgba(87, 127, 91, 0.08); }
.result-bar { display: flex; justify-content: space-between; gap: 16px; color: #f0dfbe; font-size: 0.76rem; }
.result-bar p { margin: 3px 0 10px; }
#compare-hint { color: #dac5a3; font: italic 0.76rem Georgia, serif; }
.compare-tray {
  position: sticky;
  z-index: 35;
  top: 80px;
  margin: 0 0 12px;
  padding: 13px;
  border: 1px solid rgba(80, 113, 88, 0.45);
  border-radius: 3px 9px 4px 8px;
  background: #e1e5ba;
  box-shadow: 0 9px 24px rgba(43, 28, 15, 0.25);
}
.compare-tray > div:first-child { display: flex; justify-content: space-between; margin-bottom: 8px; }
.compare-tray button { border: 0; color: #6b4b33; background: transparent; font-size: 0.7rem; font-weight: 850; cursor: pointer; }
#compare-content { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#compare-content article { display: grid; gap: 3px; padding: 9px; border-left: 3px solid var(--green); background: rgba(255, 250, 225, 0.53); }
#compare-content span { font-size: 0.72rem; }
#compare-content small { color: #65704f; font-size: 0.65rem; font-weight: 800; }

.table-wrap { overflow: auto; scrollbar-width: thin; scrollbar-color: #87633f rgba(88, 60, 36, 0.12); }
.index-table-wrap {
  max-height: min(68vh, 790px);
  border: 1px solid rgba(91, 70, 44, 0.36);
  border-radius: 3px 9px 4px 8px;
  background: #f3e9c9;
  box-shadow: var(--shadow);
}
.dex-table { width: 100%; border-collapse: collapse; }
.dex-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 12px 11px;
  color: #f2e4c6;
  background: #3b3023;
  font-size: 0.63rem;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}
.dex-table td { padding: 11px; border-bottom: 1px dashed rgba(97, 75, 46, 0.26); color: #564a39; font-size: 0.76rem; vertical-align: middle; }
.dex-table tbody tr:nth-child(even) { background: rgba(132, 102, 57, 0.045); }
.dex-table tbody tr:nth-child(5n + 2) { background: rgba(205, 222, 190, 0.15); }
.dex-table tbody tr:nth-child(5n + 3) { background: rgba(191, 215, 220, 0.14); }
.dex-table tbody tr:nth-child(5n + 4) { background: rgba(225, 199, 211, 0.13); }
.dex-table tbody tr:nth-child(5n) { background: rgba(211, 201, 224, 0.13); }
.dex-table tbody tr:hover { background: rgba(99, 135, 92, 0.11); }
.entry-link { display: grid; min-width: 180px; color: #385b43; text-decoration: none; }
.entry-link:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.entry-link strong { font: 700 0.9rem Georgia, serif; }
.entry-link small, .dex-table td small { display: block; max-width: 530px; margin-top: 3px; color: #75664f; font-size: 0.66rem; line-height: 1.4; }
.compare-cell { width: 55px; text-align: center; }
.compare-check { width: 18px; min-height: 18px; accent-color: var(--green); }
.tier { display: inline-grid; min-width: 32px; min-height: 29px; padding: 3px 6px; border-radius: 50%; font: 800 0.75rem Georgia, serif; place-items: center; }
.tier-positive { color: #315c3b; background: rgba(75, 123, 84, 0.16); }
.tier-negative { color: #8b392f; background: rgba(167, 70, 54, 0.14); }
.element-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px 4px 4px; border: 1px solid rgba(82, 74, 48, 0.2); border-radius: 999px; background: rgba(255, 249, 222, 0.58); font-size: 0.69rem; font-weight: 800; white-space: nowrap; }
.element-chip img { width: 25px; height: 25px; object-fit: contain; }
.empty-state { padding: 30px; color: #f5e6c8; text-align: center; }

.entity-hero { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: center; gap: 32px; padding: 34px; }
.entity-stamp {
  position: relative;
  display: grid;
  min-height: 190px;
  padding: 30px 18px;
  border: 2px solid rgba(65, 92, 67, 0.42);
  border-radius: 4px 13px 5px 10px;
  color: var(--green-dark);
  background: rgba(255, 250, 226, 0.5);
  text-align: center;
  place-content: center;
  transform: rotate(-1.1deg);
}
.entity-stamp::before { position: absolute; top: -12px; left: 50%; width: 84px; height: 23px; background: rgba(225, 206, 158, 0.78); clip-path: polygon(0 8%, 12% 0, 27% 10%, 43% 2%, 62% 9%, 79% 0, 100% 12%, 96% 91%, 80% 100%, 64% 91%, 45% 100%, 24% 91%, 3% 100%); content: ""; transform: translateX(-50%) rotate(2deg); }
.entity-stamp span { font: 700 4.6rem/1 Georgia, serif; }
.entity-stamp small { margin-top: 8px; font-size: 0.68rem; font-weight: 900; letter-spacing: 0.12em; text-transform: uppercase; }
.element-stamp img { width: 105px; height: 105px; object-fit: contain; margin: 0 auto; }
.item-stamp { border-color: rgba(157, 103, 45, 0.5); color: #845724; }
.hero-summary { max-width: 760px; margin: 17px 0 20px; color: #655845; font: italic 1rem/1.58 Georgia, serif; white-space: pre-line; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.hero-tags > span:not(.element-chip) { padding: 6px 9px; border: 1px solid rgba(94, 74, 46, 0.25); border-radius: 999px; color: #566248; background: rgba(255, 250, 227, 0.42); font-size: 0.68rem; font-weight: 800; }
.paper-panel {
  position: relative;
  margin-top: 23px;
  padding: 28px;
  border: 1px solid rgba(102, 79, 48, 0.24);
  border-radius: 2px 8px 3px 7px;
  background:
    radial-gradient(ellipse at 0 18%, rgba(119, 83, 45, 0.08), transparent 20%),
    radial-gradient(ellipse at 100% 74%, rgba(119, 83, 45, 0.07), transparent 18%),
    linear-gradient(145deg, #f0e6c5, #d9caa4);
  box-shadow: inset 0 1px rgba(255, 250, 230, 0.58), var(--shadow);
}
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.section-heading h2 { margin: 0; font-size: 1.55rem; }
.section-heading span { color: #756650; font: italic 0.8rem Georgia, serif; }
.profile-list { margin: 0; }
.profile-list > div { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 18px; padding: 11px 4px; border-bottom: 1px dashed var(--line); }
.profile-list > div:last-child { border-bottom: 0; }
.profile-list dt { color: #74664f; font-size: 0.66rem; font-weight: 900; letter-spacing: 0.07em; text-transform: uppercase; }
.profile-list dd { margin: 0; color: #3f503e; }
.profile-list dd a { color: #315e48; font-weight: 750; text-underline-offset: 3px; }
.field-note, .journal-callout { margin: 18px 0 0; padding: 14px 16px; border-left: 4px solid #8d7540; color: #655845; background: rgba(247, 235, 194, 0.56); font: italic 0.86rem/1.55 Georgia, serif; }
.journal-callout strong { display: block; color: #3d5d43; font-style: normal; }
.journal-callout p { margin: 5px 0 0; }
.annotation-list { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 18px; }
.annotation-list strong { margin-right: 4px; font: 700 0.85rem Georgia, serif; }
.annotation-list span { padding: 5px 8px; border: 1px dashed #9b7345; color: #755032; background: rgba(248, 228, 181, 0.47); font-size: 0.7rem; transform: rotate(-0.4deg); }
.pal-chip-grid, .related-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.pal-chip { display: flex; align-items: center; gap: 9px; min-width: 180px; padding: 8px; border: 1px solid rgba(92, 73, 46, 0.23); border-radius: 3px 8px 4px 7px; color: #3e5f46; background: rgba(255, 251, 231, 0.43); text-decoration: none; }
.pal-chip:hover { border-color: rgba(65, 104, 75, 0.55); background: rgba(255, 251, 231, 0.72); }
.pal-chip img { width: 48px; height: 48px; object-fit: contain; }
.pal-chip span { display: grid; }
.pal-chip strong { font: 700 0.82rem Georgia, serif; }
.pal-chip small { color: #786952; font-size: 0.6rem; }
.relation-table .pal-chip { padding: 0; border: 0; background: transparent; }
.relation-table .pal-chip img { width: 42px; height: 42px; }
.related-card { display: grid; align-content: start; min-height: 116px; padding: 13px; border: 1px solid rgba(92, 73, 46, 0.24); border-radius: 3px 9px 4px 8px; color: #3c5b43; background: rgba(255, 251, 231, 0.4); text-decoration: none; }
.related-card:nth-child(4n + 1), .pal-chip-grid .pal-chip:nth-child(4n + 1) { background: rgba(244, 229, 190, 0.58); }
.related-card:nth-child(4n + 2), .pal-chip-grid .pal-chip:nth-child(4n + 2) { background: rgba(218, 230, 196, 0.56); }
.related-card:nth-child(4n + 3), .pal-chip-grid .pal-chip:nth-child(4n + 3) { background: rgba(207, 225, 226, 0.56); }
.related-card:nth-child(4n), .pal-chip-grid .pal-chip:nth-child(4n) { background: rgba(232, 213, 224, 0.54); }
.related-card:hover { border-color: rgba(65, 104, 75, 0.55); transform: translateY(-1px); }
.related-card small { color: #84663e; font-size: 0.61rem; font-weight: 850; text-transform: uppercase; }
.related-card strong { margin: 5px 0; font: 700 0.95rem Georgia, serif; }
.related-card span { display: -webkit-box; overflow: hidden; color: #6e604c; font-size: 0.69rem; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.stat-note-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.stat-note-grid div { display: flex; justify-content: space-between; gap: 12px; padding: 10px; border: 1px dashed var(--line); background: rgba(255, 250, 228, 0.35); }
.stat-note-grid span { color: #74654f; font-size: 0.68rem; }
.move-callout { display: flex; align-items: center; gap: 14px; width: fit-content; min-width: 300px; padding: 12px 16px; border: 1px solid rgba(73, 111, 80, 0.35); border-radius: 3px 9px 4px 8px; color: #3b5b43; background: rgba(246, 243, 210, 0.65); text-decoration: none; }
.move-callout > span:last-child { display: grid; }
.move-callout strong { font: 700 1rem Georgia, serif; }
.move-callout small { color: #74654f; font-size: 0.68rem; }
.back-to-top { display: block; width: fit-content; margin: 20px 0 0 auto; color: #6f5e45; font-size: 0.67rem; font-weight: 850; text-decoration: none; }

@media (max-width: 980px) {
  .site-header { grid-template-columns: auto 1fr; }
  .edition-badge { display: none; }
  .site-nav { justify-content: flex-end; overflow-x: auto; }
  .filter-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .search-field { grid-column: span 2; }
  .pal-chip-grid, .related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .site-header { display: flex; min-height: auto; padding: 10px 14px; overflow-x: auto; }
  .brand small { display: none; }
  .site-nav { flex: 0 0 auto; justify-content: start; }
  .page-shell { width: min(100% - 20px, 1220px); padding-top: 24px; }
  .index-hero { grid-template-columns: 1fr; padding: 28px 22px; }
  .index-hero aside { min-height: 90px; }
  .filter-board { grid-template-columns: 1fr 1fr; padding: 21px 13px 13px; }
  .search-field { grid-column: 1 / -1; }
  .entity-hero { grid-template-columns: 1fr; padding: 28px 21px; }
  .dossier-tab { top: 14px; right: -4px; }
  .entity-stamp { min-height: 130px; }
  .entity-stamp span { font-size: 3.6rem; }
  .element-stamp img { width: 80px; height: 80px; }
  .paper-panel { padding: 23px 16px; }
  .profile-list > div { grid-template-columns: 120px minmax(0, 1fr); gap: 10px; }
  .pal-chip-grid, .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-note-grid { grid-template-columns: 1fr 1fr; }
  #compare-content { grid-template-columns: 1fr; }
  .site-footer { grid-template-columns: auto 1fr; }
  .site-footer > small { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .filter-board { grid-template-columns: 1fr; }
  .filter-board label, .filter-board button { grid-column: 1; }
  .result-bar { display: block; }
  .index-table-wrap { max-height: 72vh; }
  .dex-table th, .dex-table td { padding: 9px 8px; }
  .entry-link { min-width: 155px; }
  .pal-chip-grid, .related-grid, .stat-note-grid { grid-template-columns: 1fr; }
  .profile-list > div { grid-template-columns: 1fr; gap: 4px; }
  .move-callout { min-width: 0; width: 100%; }
}
