/* Havenga Stamboom — aged parchment, iron-gall ink and the family's own heraldry.
   Tinctures follow the Havenga arms: Or (gold), Vert (green), Sable (black), Gules (red). */

:root {
  --parchment: #efe2c2;
  --parchment-deep: #e2cfa2;
  --parchment-edge: #b58d55;
  --ink: #2a1a0c;
  --ink-soft: #5a4128;
  --sepia: #7a5530;
  --or: #c9a13b;
  --or-bright: #e6c35c;
  --vert: #2f5e3b;
  --vert-deep: #1f4029;
  --gules: #8e2323;
  --gules-deep: #5f1414;
  --sable: #23201c;
  --shadow: 0 1px 0 rgba(255, 245, 220, .6) inset, 0 2px 3px rgba(60, 35, 10, .25), 0 10px 24px -12px rgba(60, 35, 10, .55);
  --font-body: 'IM Fell English', 'Palatino Linotype', Palatino, Georgia, serif;
  --font-caps: 'IM Fell English SC', 'Palatino Linotype', Georgia, serif;
  --font-label: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --font-black: 'UnifrakturMaguntia', 'Old English Text MT', serif;
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .22  0 0 0 0 .08  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --stains: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='900'><filter id='s'><feTurbulence type='fractalNoise' baseFrequency='.006' numOctaves='4' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .28  0 0 0 0 .1  0 0 0 -2.2 1.35'/></filter><rect width='100%' height='100%' filter='url(%23s)'/></svg>");
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--parchment);
  background-image:
    radial-gradient(ellipse at 50% 40%, rgba(255, 248, 225, .55), rgba(255, 248, 225, 0) 60%),
    var(--stains),
    var(--noise),
    radial-gradient(ellipse at center, var(--parchment) 45%, var(--parchment-deep) 80%, #c9a56d 100%);
  background-size: auto, 900px 900px, 320px 320px, cover;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* Burnt, darkened page edges */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 90px 30px rgba(92, 55, 18, .45), inset 0 0 18px 4px rgba(60, 30, 5, .55);
  z-index: 30;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }

/* ------------------------------------------------------------------ backdrop heraldry */
.backdrop { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.watermark {
  position: absolute;
  left: 50%;
  top: 54%;
  width: min(62vh, 560px);
  transform: translate(-50%, -50%);
  opacity: .075;
  filter: sepia(1) saturate(.6) contrast(1.1);
}
.beast {
  position: absolute;
  opacity: .09;
  filter: sepia(1) brightness(.5);
}
.beast-lion { left: -30px; bottom: -20px; width: 260px; transform: rotate(-6deg); }
.beast-eagle { right: -40px; bottom: 30px; height: 420px; transform: scaleX(-1) rotate(-4deg); }

/* ------------------------------------------------------------------ banner */
.banner {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: .55rem 1.4rem .65rem;
  background:
    linear-gradient(180deg, rgba(31, 64, 41, .97), rgba(22, 46, 30, .97)),
    var(--noise);
  color: #f3e6c4;
  border-bottom: 3px double var(--or);
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, .6);
}
.banner::after {
  /* gold rope under the banner */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -9px;
  height: 6px;
  background: repeating-linear-gradient(135deg, var(--or) 0 4px, #8a6a1f 4px 6px);
  opacity: .8;
}
.crest-btn {
  flex: none;
  border: 0;
  background: none;
  padding: 0;
  margin: -.2rem 0 -1.6rem;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .55));
  transition: transform .3s ease;
}
.crest-btn:hover { transform: scale(1.06) rotate(-2deg); }
.crest-btn img { height: 86px; display: block; }
.titles h1 {
  margin: 0;
  font-family: var(--font-black);
  font-weight: 400;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  letter-spacing: .02em;
  color: var(--or-bright);
  text-shadow: 0 2px 0 #1a120a, 0 0 18px rgba(230, 195, 92, .25);
  line-height: 1;
}
.subtitle {
  margin: .25rem 0 0;
  font-family: var(--font-caps);
  font-size: .95rem;
  letter-spacing: .06em;
  color: #d9c89c;
}
.search { position: relative; margin-left: auto; width: min(360px, 34vw); }
.search input {
  width: 100%;
  padding: .5rem .9rem .5rem 2.2rem;
  border: 1px solid var(--or);
  border-radius: 2px;
  background: rgba(243, 230, 196, .96) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%235a4128' stroke-width='2'><circle cx='10' cy='10' r='7'/><path d='m15 15 6 6'/></svg>") no-repeat .6rem center;
  color: var(--ink);
  box-shadow: inset 0 1px 4px rgba(60, 35, 10, .35);
}
.search input:focus { outline: 2px solid var(--or-bright); }
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: .3rem;
  list-style: none;
  max-height: 60vh;
  overflow: auto;
  background: var(--parchment) var(--noise);
  border: 1px solid var(--parchment-edge);
  box-shadow: 0 16px 30px -10px rgba(0, 0, 0, .55);
  color: var(--ink);
}
.search-results .empty { padding: .6rem; color: var(--ink-soft); font-style: italic; }
.result {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: .6rem;
  padding: .4rem .6rem;
  border: 0;
  background: none;
  text-align: left;
  border-bottom: 1px dotted rgba(122, 85, 48, .35);
}
.result:hover, .result:focus { background: rgba(201, 161, 59, .22); outline: none; }
.result-meta { color: var(--ink-soft); font-size: .85rem; white-space: nowrap; }
.nav { display: flex; gap: .4rem; }
.nav-btn {
  border: 1px solid rgba(201, 161, 59, .6);
  background: rgba(0, 0, 0, .15);
  color: #f3e6c4;
  padding: .38rem .8rem;
  font-family: var(--font-label);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.nav-btn:hover { background: rgba(201, 161, 59, .25); }

/* ------------------------------------------------------------------ stage */
.stage {
  position: relative;
  z-index: 1;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.stage.dragging { cursor: grabbing; }
.viewport { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.ink { position: absolute; inset: 0; overflow: visible; }
.ink-line {
  fill: none;
  stroke: var(--sepia);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 .5px 0 rgba(255, 245, 220, .6));
}
.ink-marriage { stroke: var(--or); stroke-width: 1.4; fill: none; }
.ink-ring circle { fill: none; stroke: #9c7a26; stroke-width: 2; }
.cards { position: absolute; inset: 0; }

/* ------------------------------------------------------------------ cards (cartouches) */
.card {
  position: absolute;
  width: 184px;
  height: 78px;
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: .45rem;
  padding: .35rem .6rem .35rem .45rem;
  text-align: left;
  border: 1px solid #a9844f;
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 250, 232, .92), rgba(240, 225, 190, .92)),
    var(--noise);
  box-shadow: var(--shadow);
  outline: 1px solid rgba(169, 132, 79, .35);
  outline-offset: -5px;
  transition: box-shadow .2s ease, transform .2s ease;
  will-change: transform;
}
.card::before, .card::after {
  /* corner flourishes */
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid var(--or);
  opacity: .8;
}
.card::before { top: 3px; left: 3px; border-right: 0; border-bottom: 0; }
.card::after { bottom: 3px; right: 3px; border-left: 0; border-top: 0; }
.card:hover { box-shadow: var(--shadow), 0 0 0 2px rgba(201, 161, 59, .55); transform: translateY(-2px); }
.card:focus-visible { outline: 2px solid var(--gules); }
.card.sex-M { border-left: 5px solid var(--vert); }
.card.sex-F { border-left: 5px solid var(--gules); }
.card.sex-U { border-left: 5px solid var(--sepia); }
.card.role-focus {
  background:
    linear-gradient(180deg, rgba(255, 246, 214, .96), rgba(236, 214, 160, .96)),
    var(--noise);
  border-color: #8a6a1f;
  box-shadow: var(--shadow), 0 0 0 3px var(--or), 0 0 0 5px rgba(31, 64, 41, .8), 0 14px 34px -10px rgba(60, 35, 10, .7);
  z-index: 2;
}
.card.role-focus::after {
  content: '✦';
  border: 0;
  width: auto;
  height: auto;
  right: 6px;
  bottom: 2px;
  color: var(--gules);
  font-size: .8rem;
}
.card.role-spouse { opacity: .95; }
.card.is-hidden { background: linear-gradient(180deg, rgba(236, 228, 208, .92), rgba(222, 210, 182, .92)), var(--noise); }
.arms { width: 44px; height: 50px; display: grid; place-items: center; }
.arms svg { width: 36px; height: 42px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.arms-edge { fill: none; stroke: #6b4a14; stroke-width: 1.4; }
.sex-M .arms-field { fill: var(--vert); }
.sex-M .arms-dexter { fill: var(--or); }
.sex-F .arms-field { fill: var(--gules); }
.sex-F .arms-dexter { fill: var(--or); }
.sex-U .arms-field { fill: #8d7654; }
.sex-U .arms-dexter { fill: #cdb68a; }
.portrait {
  width: 42px;
  height: 50px;
  object-fit: cover;
  border-radius: 50% / 45%;
  border: 2px solid var(--or);
  filter: sepia(.35);
}
.text { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.given {
  font-size: .98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nick { font-style: italic; color: var(--sepia); }
.surname {
  font-family: var(--font-label);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--vert-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sex-F .surname { color: var(--gules-deep); }
.years { font-family: var(--font-caps); font-size: .82rem; color: var(--ink-soft); margin-top: .12rem; }
.card.ghost {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 2px dashed rgba(122, 85, 48, .55);
  background: rgba(255, 248, 225, .35);
  box-shadow: none;
  outline: none;
  color: var(--sepia);
}
.card.ghost::before, .card.ghost::after { display: none; }
.ghost-plus { font-size: 1.5rem; line-height: 1; }
.ghost-label { font-family: var(--font-label); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; }
.more {
  position: absolute;
  width: 26px;
  height: 20px;
  margin-left: -13px;
  border: 1px solid var(--or);
  border-radius: 10px;
  background: var(--vert);
  color: var(--or-bright);
  font-size: .62rem;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .35);
}
.more-up { margin-top: -14px; }
.more-down { margin-top: -6px; }
.more:hover { background: var(--gules); }

/* ------------------------------------------------------------------ controls + lineage */
.controls {
  position: absolute;
  z-index: 5;
  left: 1rem;
  top: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .45rem;
  background: rgba(239, 226, 194, .88) var(--noise);
  border: 1px solid var(--parchment-edge);
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .5);
  cursor: default;
}
.controls button {
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--sepia);
  background: rgba(255, 250, 232, .8);
  font-size: 1.15rem;
}
.controls button:hover { background: var(--or-bright); }
.controls label {
  display: flex;
  flex-direction: column;
  font-family: var(--font-label);
  font-size: .55rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  max-width: 5.5rem;
}
.controls select { background: rgba(255, 250, 232, .8); border: 1px solid var(--sepia); }
.lineage {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  max-width: min(92vw, 1100px);
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .35rem .9rem;
  overflow-x: auto;
  white-space: nowrap;
  background: rgba(31, 64, 41, .92) var(--noise);
  border: 1px solid var(--or);
  border-radius: 2px;
  color: #f3e6c4;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .6);
  cursor: default;
  scrollbar-width: thin;
}
.lineage-label { font-family: var(--font-label); font-size: .65rem; letter-spacing: .12em; text-transform: uppercase; color: var(--or-bright); margin-right: .3rem; }
.lineage-sep { color: var(--or); }
.lineage-step { border: 0; background: none; color: #f3e6c4; padding: .1rem .25rem; font-style: italic; }
.lineage-step:hover { color: var(--or-bright); text-decoration: underline; }
.lineage-step.current { color: var(--or-bright); font-style: normal; font-weight: bold; }

/* ------------------------------------------------------------------ record panel (a scroll) */
.panel {
  position: fixed;
  z-index: 25;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100vw);
  transform: translateX(105%);
  transition: transform .45s cubic-bezier(.2, .7, .2, 1);
  background:
    linear-gradient(90deg, rgba(120, 80, 30, .25), rgba(255, 250, 230, 0) 4%),
    var(--stains),
    var(--noise),
    var(--parchment);
  border-left: 3px double var(--parchment-edge);
  box-shadow: -18px 0 40px -18px rgba(40, 20, 5, .7);
}
.panel.open { transform: translateX(0); }
.panel-close {
  position: absolute;
  right: .8rem;
  top: .7rem;
  z-index: 2;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--sepia);
  border-radius: 50%;
  background: var(--parchment);
}
.panel-body { height: 100%; overflow-y: auto; padding: 1.4rem 1.5rem 3rem; }
.panel-head {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 1rem;
  align-items: center;
  padding-bottom: .9rem;
  border-bottom: 2px solid var(--sepia);
  position: relative;
}
.panel-head::after {
  content: '❦';
  position: absolute;
  left: 50%;
  bottom: -.8rem;
  transform: translateX(-50%);
  background: var(--parchment);
  padding: 0 .5rem;
  color: var(--gules);
}
.panel-arms {
  width: 70px;
  height: 84px;
  background: url('/img/crest.png') center / contain no-repeat;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .4));
}
.panel-portrait { width: 72px; height: 88px; object-fit: cover; border: 3px solid var(--or); border-radius: 50% / 45%; }
.panel-head h2 { margin: 0; font-weight: 400; font-size: 1.55rem; line-height: 1.05; }
.panel-surname {
  display: block;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--vert-deep);
  margin-top: .2rem;
}
.sex-F .panel-surname { color: var(--gules-deep); }
.panel-nick { font-style: italic; color: var(--sepia); }
.panel-years { font-family: var(--font-caps); font-size: 1.05rem; margin-top: .2rem; }
.panel-code { font-size: .78rem; color: var(--ink-soft); }
.panel-actions { margin: 1.4rem 0 .4rem; display: flex; gap: .5rem; }
.vitals { margin: .8rem 0 0; }
.vital { display: grid; grid-template-columns: 7rem 1fr; gap: .6rem; padding: .28rem 0; border-bottom: 1px dotted rgba(122, 85, 48, .3); }
.vital dt { font-family: var(--font-label); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--sepia); padding-top: .15rem; }
.vital dd { margin: 0; }
.privacy-note { font-style: italic; color: var(--ink-soft); border: 1px dashed var(--parchment-edge); padding: .7rem; }
.panel-section { margin-top: 1.4rem; }
.panel-section h3 {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0 0 .5rem;
  font-family: var(--font-label);
  font-size: .8rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--vert-deep);
}
.panel-section h3::before, .panel-section h3::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--sepia), transparent);
}
.person-link {
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  color: var(--vert-deep);
  text-decoration: underline;
  text-decoration-color: rgba(47, 94, 59, .35);
  text-underline-offset: 3px;
}
.person-link.sex-F { color: var(--gules-deep); text-decoration-color: rgba(142, 35, 35, .35); }
.person-link:hover { text-decoration-color: currentColor; }
.parents .label { font-family: var(--font-caps); color: var(--sepia); }
.family { padding: .5rem 0 .7rem; border-bottom: 1px dotted rgba(122, 85, 48, .3); }
.family-head { margin-bottom: .3rem; }
.rings { color: var(--or); }
.married { font-size: .9rem; font-style: italic; }
.children, .siblings, .sources, .history { margin: .2rem 0; padding-left: 1.3rem; }
.children li, .siblings li { padding: .08rem 0; }
.note { margin: .4rem 0; line-height: 1.35; }
.note.marginalia {
  font-size: .88rem;
  font-style: italic;
  color: var(--ink-soft);
  border-left: 3px solid var(--or);
  padding-left: .6rem;
}
.sources li { margin: .25rem 0; font-size: .92rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .7rem; }
.gallery figure { margin: 0; }
.gallery figcaption { font-size: .8rem; margin-top: .25rem; }
.thumb { border: 3px solid #fffaf0; padding: 0; background: #fffaf0; box-shadow: 0 3px 8px rgba(0, 0, 0, .35); transform: rotate(-1deg); display: block; width: 100%; }
.gallery figure:nth-child(even) .thumb { transform: rotate(1.2deg); }
.thumb img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; filter: sepia(.2); }

/* ------------------------------------------------------------------ admin affordances */
.admin-bar { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: 1rem; padding: .6rem; background: rgba(47, 94, 59, .08); border: 1px dashed var(--vert); }
.admin-btn {
  border: 1px solid var(--vert);
  background: rgba(255, 250, 232, .8);
  color: var(--vert-deep);
  padding: .22rem .55rem;
  font-size: .85rem;
}
.admin-btn:hover { background: var(--vert); color: #f3e6c4; }
.admin-btn.danger { border-color: var(--gules); color: var(--gules); }
.admin-btn.danger:hover { background: var(--gules); color: #fff; }
.admin-btn.mini { padding: 0 .35rem; margin-left: .4rem; font-size: .7rem; border-color: rgba(142, 35, 35, .5); color: var(--gules); }
.admin-btn.link { border: 0; background: none; text-decoration: underline; padding: .2rem 0; margin-right: .8rem; font-size: .82rem; }
.admin-btn.link:hover { background: none; color: var(--gules); }

/* ------------------------------------------------------------------ buttons + dialogs */
.seal-btn {
  border: 1px solid var(--gules-deep);
  background: radial-gradient(circle at 35% 30%, #b73a3a, var(--gules) 55%, var(--gules-deep));
  color: #fbeed2;
  padding: .5rem 1.1rem;
  font-family: var(--font-label);
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  border-radius: 2px;
  box-shadow: 0 3px 8px -2px rgba(60, 10, 10, .6), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.seal-btn:hover { filter: brightness(1.12); }
.plain-btn { border: 1px solid var(--sepia); background: transparent; padding: .5rem 1rem; }
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(30, 18, 6, .55); backdrop-filter: blur(2px) sepia(.4); }
.parchment-dialog {
  width: min(760px, 94vw);
  max-height: 90vh;
  overflow: auto;
  padding: 1.6rem 2rem;
  border: 1px solid var(--parchment-edge);
  background: var(--stains), var(--noise), var(--parchment);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7), inset 0 0 50px rgba(120, 80, 30, .35);
  outline: 3px double var(--or);
  outline-offset: -12px;
}
.parchment-dialog h2 {
  margin: 0 0 .8rem;
  font-family: var(--font-black);
  font-weight: 400;
  font-size: 1.9rem;
  color: var(--vert-deep);
}
.small-dialog { width: min(420px, 94vw); }
.dialog-x { position: absolute; top: .9rem; right: 1rem; border: 0; background: none; font-size: 1.2rem; }
.welcome { width: min(980px, 95vw); position: relative; }
.welcome-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 1.8rem; align-items: start; }
.welcome p { line-height: 1.5; }
.welcome #welcome-body p:first-child::first-letter {
  float: left;
  font-family: var(--font-black);
  font-size: 3.6rem;
  line-height: .8;
  padding: .3rem .4rem 0 0;
  color: var(--gules);
}
.welcome-figure { margin: 0; text-align: center; }
.photo-frame {
  padding: 10px;
  border: 0;
  background: linear-gradient(135deg, #6b4a14, #c9a13b 30%, #7d5a1a 60%, #d8b75c);
  box-shadow: 0 10px 24px -6px rgba(0, 0, 0, .6);
  transform: rotate(1.5deg);
}
.photo-frame img { display: block; width: 100%; border: 3px solid #2a1a0c; }
.welcome-figure figcaption { margin-top: .9rem; font-style: italic; }
.stats { display: flex; gap: 1.2rem; flex-wrap: wrap; margin: 1rem 0; font-family: var(--font-caps); }
.stats b { font-family: var(--font-label); font-size: 1.3rem; color: var(--gules); }
.dialog-actions { margin-top: 1rem; }
.editor-form { display: flex; flex-direction: column; gap: .7rem; }
.editor-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.field { display: flex; flex-direction: column; gap: .2rem; }
.field > span { font-family: var(--font-label); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--sepia); }
.field input, .field select, .editor-form textarea, .editor-form select[size] {
  padding: .4rem .55rem;
  border: 1px solid var(--parchment-edge);
  background: rgba(255, 252, 240, .85);
  box-shadow: inset 0 1px 3px rgba(60, 35, 10, .2);
}
.field input:invalid:not(:placeholder-shown) { border-color: var(--gules); }
.check { display: flex; gap: .5rem; align-items: center; }
.editor-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .8rem; }
.error { color: var(--gules); min-height: 1.2em; }
.lightbox {
  max-width: 94vw;
  max-height: 94vh;
  padding: 1rem;
  background: #1c140c;
  color: #f3e6c4;
  border: 2px solid var(--or);
  position: relative;
}
.lightbox img { display: block; max-width: 90vw; max-height: 76vh; margin: 0 auto; }
.lightbox h3 { margin: .7rem 0 .2rem; font-weight: 400; }
.lightbox p { margin: 0; color: #d9c89c; max-width: 80ch; }
.lightbox .dialog-x { color: #f3e6c4; }
.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 4.5rem;
  transform: translate(-50%, 30px);
  opacity: 0;
  padding: .55rem 1.2rem;
  background: var(--vert);
  color: #f3e6c4;
  border: 1px solid var(--or);
  transition: all .3s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--gules); }
body:not(.is-admin) .admin-only { display: none; }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 820px) {
  .banner { flex-wrap: wrap; gap: .5rem; padding: .5rem .8rem .7rem; }
  .crest-btn img { height: 54px; }
  .crest-btn { margin: 0; }
  .subtitle { display: none; }
  .search { order: 3; width: 100%; }
  .nav { margin-left: auto; }
  .nav-btn { padding: .3rem .45rem; font-size: .62rem; }
  .controls { top: .8rem; left: .5rem; }
  .controls label { display: none; }
  .welcome-grid { grid-template-columns: 1fr; }
  .editor-form .row { grid-template-columns: 1fr; }
  .beast { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
