:root {
  --bg: #0c1217;
  --panel: #111d24;
  --ink: #e7e5dd;
  --muted: #9bafb5;
  --line: #2c4249;
  --cyan: #83d5cc;
  --brass: #c5a773;
  --pink: #cb92ae;
  --serif: Georgia,'Times New Roman',serif;
  --sans: 'Segoe UI',Arial,sans-serif;
  --space-section: clamp(1.5rem, 1rem + 2vw, 3rem);
  --heading-small: clamp(1.35rem, 1.2rem + .5vw, 1.65rem);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,input,select,textarea {
  font: inherit;
}

button,.button {
  border: 1px solid var(--cyan);
  background: var(--cyan);
  color: #0c2528;
  cursor: pointer;
  padding: 10px 18px;
  font-weight: 600;
  display: inline-block;
  border-radius: 2px;
}

button:hover,.button:hover {
  background: #b1e9de;
  text-decoration: none;
}

button.quiet,.button.quiet {
  background: transparent;
  color: var(--cyan);
  border-color: var(--line);
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 4px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -70px;
  padding: 12px;
  background: var(--cyan);
  color: var(--bg);
  z-index: 3;
}

.skip:focus {
  top: 12px;
}

.shell {
  display: grid;
  grid-template-columns: 265px minmax(0,1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 34px 25px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg,#132229,#0d171d);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.sidebar > * { flex-shrink: 0; }
.archive-navigation { margin-top: 18px; min-inline-size: 0; }
.archive-navigation > summary { cursor: pointer; color: var(--brass); }
.archive-navigation > summary span { float: right; }
.navigation-content { min-inline-size: 0; }
.sidebar nav a { padding-inline: 10px; border-inline-start: 2px solid transparent; overflow-wrap: anywhere; }
.sidebar nav a:hover { background: #ffffff05; text-decoration: none; }
.sidebar nav a[aria-current="page"] { color: var(--ink); border-inline-start-color: var(--brass); background: #c5a7730c; }
.navigation-label { margin: 0 0 10px; color: var(--brass); font-size: .65rem; letter-spacing: .16em; text-transform: uppercase; }
.account-controls { display: grid; gap: 12px; padding-block-start: 20px; margin-block-start: 16px; border-top: 1px solid var(--line); font-size: .8rem; }
.account-controls > a { overflow-wrap: anywhere; }
.account-controls form { margin: 0; }
.account-controls button { padding: 7px 14px; font-size: .8rem; }
@media (min-width: 701px) {
  .archive-navigation > summary { display: none; }
  .archive-navigation:not([open]) > .navigation-content { display: block; }
  .archive-navigation::details-content { content-visibility: visible; }
}
@media (max-width: 700px) {
  .sidebar .archive-navigation { margin-top: 16px; border-top: 1px solid var(--line); }
  .archive-navigation > summary { padding-block: 12px; font-size: .85rem; }
  .sidebar .navigation-content nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
  .sidebar .navigation-content nav a { padding: 10px 8px; font-size: .8rem; }
  .sidebar { max-height: none; }
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 1.3px;
  font-weight: 600;
}

.brand:hover {
  text-decoration: none;
}

.brand small {
  display: block;
  font-size: 8px;
  letter-spacing: 1.15px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 4px;
}

.sigil {
  display: flex;
  align-items: center;
  font: 24px var(--serif);
  border-top: 1px solid var(--brass);
  border-bottom: 1px solid var(--brass);
  padding: 7px 0;
  color: var(--brass);
  letter-spacing: -3px;
}

.sigil span {
  font-size: 18px;
  letter-spacing: 0;
  margin: 0 4px;
}

.dateline {
  font-size: 10px;
  letter-spacing: 1.5px;
  margin: 25px 0;
  color: var(--brass);
}

.search label {
  font-size: 12px;
  color: var(--muted);
}

.search div {
  display: flex;
  margin: 7px 0 25px;
}

.search input {
  width: 100%;
  min-width: 0;
  padding: 9px;
  font-size: 11px;
  border-right: 0;
}

.search button {
  padding: 5px 9px;
  background: transparent;
  color: var(--cyan);
  border-color: var(--line);
}

nav {
  display: grid;
  gap: 5px;
}

nav a {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

nav a:hover {
  color: var(--ink);
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid var(--line);
}

.dm-login {
  font-size: 12px;
  color: var(--brass);
}

.motto {
  font: italic 21px/1.5 var(--serif);
  color: var(--muted);
  margin-top: 28px;
}

.connection {
  font-size: 9px;
  color: var(--cyan);
  letter-spacing: 1.5px;
}

.workspace {
  min-width: 0;
}

.topbar {
  height: 65px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 48px;
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--muted);
  gap: 20px;
}

.topbar a {
  color: var(--brass);
}

main {
  max-width: 1200px;
  padding: 45px 48px 70px;
  margin: 0 auto;
  min-height: calc(100vh - 140px);
}

h1,h2,h3 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.2;
}

h1 {
  font-size: clamp(34px,4.5vw,58px);
  margin: 12px 0 26px;
  letter-spacing: -1.2px;
}

h2 {
  font-size: var(--heading-small);
  margin: 35px 0 20px;
}

h3 {
  font-size: 23px;
  margin: 10px 0 22px;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--brass);
}

.lead {
  font: 22px/1.5 var(--serif);
  color: #c6d4d4;
}

.hero {
  padding: 28px 0 50px;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  isolation: isolate;
  min-height: 420px;
}

.hero h1 {
  max-width: 650px;
}

.hero-art {
  position: absolute;
  z-index: -1;
  right: -1.5%;
  top: 0;
  width: 92%;
  height: 100%;
  object-fit: cover;
  object-position: 65% center;
  opacity: .86;
  mask-image: linear-gradient(to right, transparent 2%, #0002 24%, #000 61%, #000 94%, transparent);
  pointer-events: none;
}
.hero:has(.hero-art) { min-height: 520px; padding-top: 45px; }
.hero:has(.hero-art) h1,
.hero:has(.hero-art) p { text-shadow: 0 2px 16px #0c1217, 0 1px 4px #0c1217; }
@supports (mask-composite: intersect) {
  .hero-art {
    mask-image: linear-gradient(to right, transparent 2%, #0002 24%, #000 61%), url('/static/painted-edge.svg');
    mask-size: 100% 100%;
    mask-repeat: no-repeat;
    mask-composite: intersect;
  }
}
@media(max-width:700px) {
  .hero:has(.hero-art) { min-height: 590px; padding-top: 8px; }
  .hero-art { width: 135%; height: 65%; top: auto; bottom: 0; right: -12%; opacity: .62; }
}

.hero>p {
  max-width: 420px;
  color: var(--muted);
  font-size: 14px;
}

.hero p.lead {
  font: 23px/1.5 var(--serif);
  color: var(--ink);
}

.hero .button {
  margin-top: 13px;
  font-size: 12px;
  min-width: 190px;
  display: inline-flex;
  justify-content: space-between;
}

.skyline {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 43%;
  height: 85%;
  z-index: -1;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  opacity: .65;
  background: radial-gradient(ellipse at 60% 70%,#1f535b70,transparent 70%);
}

.skyline i {
  width: 15%;
  height: 65%;
  border: 1px solid #42656b;
  background: repeating-linear-gradient(0deg,transparent 0 18px,#5b95972b 19px 20px),linear-gradient(90deg,#14282e,#1b353d);
  clip-path: polygon(50% 0,65% 12%,80% 12%,80% 25%,100% 25%,100% 100%,0 100%,0 25%,20% 25%,20% 12%,35% 12%);
}

.skyline i:nth-child(2n) {
  height: 90%;
  width: 20%;
}

.skyline i:nth-child(3n) {
  height: 45%;
}

.skyline i:nth-child(4) {
  height: 100%;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin: 35px 0 22px;
}

.section-heading h2 {
  margin: 8px 0 0;
}

.section-heading>span {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 15px;
}

.article-card {
  display: block;
  border: 1px solid var(--line);
  background: linear-gradient(135deg,#17272e,#101a21);
  padding: 22px;
  color: var(--ink);
  min-width: 0;
}

.article-card:hover {
  border-color: var(--brass);
  text-decoration: none;
}

.article-card small {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--brass);
  text-transform: uppercase;
}

.article-card>span {
  font-size: 11px;
  color: var(--muted);
}

.field-note {
  border-left: 2px solid var(--brass);
  margin: 34px 0 0;
  padding: 0 22px;
  max-width: 630px;
}

.field-note>span {
  font-size: 9px;
  letter-spacing: 1.4px;
  color: var(--brass);
}

.field-note p {
  font: italic 19px/1.5 var(--serif);
  color: var(--muted);
}

.workspace > footer {
  border-top: 1px solid var(--line);
  padding: 20px 48px;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--muted);
}

.prose {
  max-width: 800px;
  overflow-wrap: anywhere;
  line-height: 1.85;
}

.prose h1 {
  font-size: 32px;
}

.prose h2 {
  font-size: 28px;
}

.prose h3 {
  font-size: 23px;
}

.prose p,.prose li {
  color: #cbd4d3;
}

.prose img {
  display: block;
  max-width: 100%;
  max-height: 520px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 24px auto 12px;
  border: 0;
  /* Alpha fades reveal the actual page background, including textured themes. */
  mask-image: radial-gradient(ellipse farthest-side, #000 84%, transparent 100%);
  mask-mode: alpha;
  mask-size: 100% 100%;
  mask-position: center;
  mask-repeat: no-repeat;
}

@supports (mask-composite: intersect) {
  .prose img {
    mask-image: url('/static/painted-edge.svg');
  }
}

/* Lore keeps the painted edge. Graphics preserve every pixel and label.
   Markdown: "Graphic" or "Graphic Detail" for a graphic beside its text. */
.prose img[data-image-kind="graphic"],
.prose img[title="Graphic"],
.prose img[title="Graphic Detail"],
.prose img[src^="/media/house-logo-"],
.prose img[alt*="logo" i],
.prose img[alt*="emblem" i],
.prose img[alt*="coat of arms" i],
.prose img[alt*="heraldry" i] {
  mask-image: none;
  clip-path: none;
  border-radius: 0;
}

/* A secondary detail can sit beside its paragraph without breaking Markdown. */
.prose p:has(> img:is([title="Detail"], [title="Graphic Detail"]), > a > img:is([title="Detail"], [title="Graphic Detail"])) {
  float: inline-end;
  width: min(42%, 300px);
  margin: 0 0 1.2rem 1.5rem;
  font-size: .82rem;
  line-height: 1.5;
}
.prose p img:is([title="Detail"], [title="Graphic Detail"]) {
  width: 100%;
  max-height: 320px;
  margin: 0 0 .6rem;
}
.prose h2, .prose h3 { clear: both; }
.prose::after { content: ""; display: table; clear: both; }
@media(max-width:700px) {
  .prose p:has(> img:is([title="Detail"], [title="Graphic Detail"]), > a > img:is([title="Detail"], [title="Graphic Detail"])) {
    float: none;
    width: 100%;
    max-width: 350px;
    margin: 1rem auto;
  }
}

.prose table {
  border-collapse: collapse;
  display: block;
  overflow: auto;
  font-size: 14px;
}

.prose td,.prose th {
  padding: 10px 14px;
  border: 1px solid var(--line);
  text-align: left;
}

.prose th {
  color: var(--brass);
}

.prose table img {
  max-width: 140px;
  max-height: 130px;
  margin: 8px auto;
}

.prose blockquote {
  margin: 20px 0;
  border-left: 2px solid var(--brass);
  padding: 1px 20px;
  font-style: italic;
}

.prose code {
  color: var(--cyan);
}

.dm-notes {
  margin-top: 35px;
  border: 1px solid #73536b;
  background: #261b2833;
  padding: 24px;
  max-width: 850px;
}

.dm-notes .eyebrow {
  color: var(--pink);
}

.sources {
  margin-top: 40px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.sources h2 {
  font: 18px var(--serif);
}

.sources p {
  margin: 4px 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  margin: 20px 0;
  font-size: 13px;
}

.stack {
  display: grid;
  gap: 20px;
  margin: 26px 0;
}

.narrow {
  max-width: 520px;
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

input,textarea,select {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-top: 6px;
  color: var(--ink);
  background: #0a151b;
  border: 1px solid var(--line);
  border-radius: 2px;
}

input[readonly] {
  color: var(--muted);
}

textarea {
  font: 14px/1.7 Consolas,monospace;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox input {
  width: auto;
  margin: 0;
}

.stack button {
  justify-self: start;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.notice {
  border: 1px solid var(--brass);
  padding: 15px;
  color: var(--brass);
}

.history {
  list-style: none;
  padding: 0;
}

.history li {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.history span {
  font-size: 12px;
  color: var(--muted);
}

.media-grid img {
  width: 100%;
  height: 160px;
  object-fit: contain;
}

.media-grid p {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.media-grid input {
  font: 11px Consolas,monospace;
}

#preview:not(:empty) {
  border-top: 1px solid var(--brass);
  padding-top: 20px;
}

@media(min-width:1500px) {
  main {
    padding-top: 60px;
  }
  .hero {
    min-height: 460px;
  }
  .sidebar {
    padding-top: 45px;
  }
}

@media(max-width:1100px) {
  .shell {
    grid-template-columns: 230px minmax(0,1fr);
  }
  .sidebar {
    padding: 25px 18px;
  }
  main {
    padding: 35px 28px 50px;
  }
  .topbar,.workspace > footer {
    padding-left: 28px;
    padding-right: 28px;
  }
  .cards {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .hero h1 {
    font-size: 45px;
  }
}

@media(max-width:700px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    padding: 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    font-size: 14px;
  }
  .dateline {
    margin: 15px 0;
  }
  .search div {
    margin-bottom: 12px;
  }
  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
  }
  .sidebar nav a {
    padding: 3px 0;
    font-size: 12px;
  }
  .sidebar-bottom {
    padding-top: 15px;
    margin-top: 0;
  }
  .sidebar-bottom nav {
    margin-bottom: 10px;
  }
  .motto,.connection {
    display: none;
  }
  .topbar {
    height: 44px;
    font-size: 8px;
    padding: 0 20px;
  }
  .topbar>a {
    display: none;
  }
  main {
    padding: 30px 20px 45px;
  }
  .hero {
    padding-top: 8px;
    min-height: 400px;
  }
  .hero h1 {
    font-size: 42px;
  }
  .skyline {
    width: 65%;
    opacity: .3;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .section-heading {
    align-items: center;
  }
  .section-heading h2 {
    font-size: 26px;
  }
  .prose {
    font-size: 16px;
  }
  .prose h2 {
    font-size: 26px;
  }
  .history li {
    display: block;
  }
  .history span {
    display: block;
    margin-top: 5px;
  }
  .workspace > footer {
    padding: 20px;
    font-size: 8px;
    gap: 20px;
  }
  .dm-notes {
    padding: 16px;
  }
}

@media(prefers-reduced-motion:reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Commercial House identities use transparent ink, not a square illustration. */
.projection-control {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: fit-content;
  margin: 1.25rem 0 .6rem auto;
  color: var(--muted);
  font-size: .8rem;
  cursor: pointer;
}
.projection-control input { width: auto; accent-color: #79e8dd; }
.house-profile > p:has(> img[src^="/media/house-logo-"]) {
  display: grid;
  place-items: center;
  min-height: 330px;
  padding: 1.7rem;
  margin: 0 0 1.6rem;
  border: 1px solid #809f99;
  border-radius: 12px;
  background: radial-gradient(ellipse at center, #ecf1e9, #c5d6d0);
  box-shadow: inset 0 0 36px #5bc9bc25;
}
.prose img[src^="/media/house-logo-"] {
  display: block;
  width: 100%;
  max-width: 300px;
  max-height: 330px;
  height: auto;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  margin: 0 auto;
  background: transparent;
}
.house-profile:has(.projection-control input:checked) > p:has(> img[src^="/media/house-logo-"]) {
  background: repeating-linear-gradient(0deg, transparent 0 4px, #6fe5dc0b 4px 5px),
    radial-gradient(ellipse at center, #133b3e, #071719);
  border-color: #64cfc590;
}
.house-profile:has(.projection-control input:checked) img[src^="/media/house-logo-"] {
  filter: brightness(0) invert(90%) sepia(30%) saturate(650%) hue-rotate(110deg)
    drop-shadow(0 0 3px #70fce7) drop-shadow(0 0 12px #3bbba877);
}
.prose table:has(img[src^="/media/house-logo-"]) { display: table; width: 100%; table-layout: fixed; }
.prose td:has(img[src^="/media/house-logo-"]) {
  background: #d9e4df;
  text-align: center;
  padding: 1rem;
  vertical-align: middle;
}
.prose td:has(img[src^="/media/house-logo-"]) a { color: #153d43; }
.prose td img[src^="/media/house-logo-"] { max-height: 190px; margin-bottom: .8rem; }
@media(max-width:700px) {
  .house-profile > p:has(> img[src^="/media/house-logo-"]) { min-height: 270px; padding: 1.2rem; }
  .prose td:has(img[src^="/media/house-logo-"]) { padding: .4rem; font-size: .75rem; }
  .prose table:has(img[src^="/media/house-logo-"]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .prose table:has(img[src^="/media/house-logo-"]) thead { display: none; }
  .prose table:has(img[src^="/media/house-logo-"]) tbody,
  .prose table:has(img[src^="/media/house-logo-"]) tr { display: contents; }
  .prose table:has(img[src^="/media/house-logo-"]) td { display: block; }
  .prose table:has(img[src^="/media/house-logo-"]) td:empty { display: none; }
}

/* Archive grids use the available desktop canvas; reading and form pages
   choose their own widths in their page-specific stylesheets. */
main:has(> .archive-page), main:has(> .hero) { width: 100%; max-width: 1720px; }
.archive-page > .cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 20px; }
.archive-page > h2 { padding-top: 12px; border-top: 1px solid var(--line); margin-top: 40px; }
.archive-page .article-card { min-height: 155px; display: flex; flex-direction: column; }
.archive-page .article-card > span:last-child { margin-top: auto; padding-top: 20px; }

.archive-library { margin-top: 48px; border-top: 1px solid var(--line); padding-top: 16px; }
.archive-library > p { max-width: 70ch; color: var(--muted); line-height: 1.7; }
.library-gateway p { line-height: 1.6; }
.reference-search { margin-top: 36px; max-width: 1000px; }
.reference-search-results { list-style: none; padding: 0; margin: 24px 0; border-top: 1px solid var(--line); }
.reference-search-results li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.reference-search-results a { font-size: 17px; }
.reference-search-results span { color: var(--muted); font-size: 12px; align-self: center; }

.report-badge { display: inline-block; border-radius: 1rem; padding: .05rem .45rem; background: var(--accent, #dfb36d); color: #171b20; font-weight: bold; }
.report-badge[hidden] { display: none; }
#article-report { width: min(32rem, calc(100vw - 2rem)); max-height: 90vh; overflow: auto; background: #192128; color: #eee5d5; border: 1px solid #998464; border-radius: .5rem; padding: 1.5rem; }
#article-report::backdrop { background: #000a; }
#article-report textarea { width: 100%; box-sizing: border-box; }
.report-card { margin: 1.5rem 0; padding: 1rem; border: 1px solid #586169; border-radius: .4rem; }
.report-message { white-space: pre-wrap; overflow-wrap: anywhere; }
