/* Paper and seal ink. Red is the author's world (and red links, the unwritten parts of it);
   blue is only ever the AI, so its inferences can never be mistaken for the author's text. */

:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --ink: #1d1b17;
  --muted: #6b655a;
  --line: #e3ddd0;
  --accent: #a8322a;
  --accent-soft: #f4e3df;
  --ai: #34588f;
  --ai-soft: #e6edf7;
  --serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", "Noto Serif SC", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15140f;
    --surface: #1e1c17;
    --ink: #ece6d9;
    --muted: #a39b8b;
    --line: #353127;
    --accent: #e0685a;
    --accent-soft: #3a211d;
    --ai: #8fb0e3;
    --ai-soft: #1c2636;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15140f;
  --surface: #1e1c17;
  --ink: #ece6d9;
  --muted: #a39b8b;
  --line: #353127;
  --accent: #e0685a;
  --accent-soft: #3a211d;
  --ai: #8fb0e3;
  --ai-soft: #1c2636;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* even on elements whose class sets a display */

html { scroll-padding-top: 64px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.75 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.3; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.wrap.wrap-wide { max-width: 1360px; }

/* --- site chrome --- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; }
.site-nav a { color: var(--muted); font-size: 14px; margin-left: 20px; }

.site-footer {
  margin-top: 96px;
  border-top: 1px solid var(--line);
  padding: 24px 0 48px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
.site-footer p { margin: 0 0 8px; }

/* --- world list --- */

.intro { padding: 56px 0 24px; }
.intro h1 { font-size: 32px; margin: 0 0 8px; }
.intro p { color: var(--muted); margin: 0; }

.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); gap: 32px 24px; }
/* A world as an exhibit, the way a museum's collection pages show an object: the map on a
   plate, a label beneath. */
.world-card { display: block; color: var(--ink); }
.world-card:hover { text-decoration: none; }
.world-card .plate {
  aspect-ratio: 16 / 10; overflow: hidden; border-radius: 3px;
  background: #e9e5dc; box-shadow: 0 1px 0 var(--line), 0 10px 28px -18px rgb(40 30 10 / 0.45);
}
.map-preview { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.7s ease; }
.world-card:hover .map-preview { transform: scale(1.035); }
.plate-empty {
  height: 100%; display: grid; place-items: center;
  background: radial-gradient(ellipse at 30% 20%, #f6efe0, #e2d7bf 70%, #d6c8aa);
}
.plate-empty span {
  font-family: var(--serif); font-size: 40px; font-weight: 700; color: #fffdf8; background: var(--accent);
  width: 72px; height: 72px; display: grid; place-items: center; border-radius: 6px; transform: rotate(-3deg);
  box-shadow: inset 0 0 0 3px rgb(255 255 255 / 0.25);
}
.exhibit-label { padding: 14px 2px 0; }
.eyebrow { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.world-card h2 { margin: 4px 0 2px; font-size: 22px; transition: color 0.2s; }
.world-card:hover h2 { color: var(--accent); }
.world-card p { margin: 0; color: var(--muted); font-size: 14px; }
.card-tagline { font-family: var(--serif); }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px !important; font-size: 13px; }

/* --- world page --- */

.hero { padding: 48px 0 8px; }
.hero h1 { font-size: 40px; margin: 12px 0 4px; letter-spacing: 0.02em; }
.hero .tagline { font-family: var(--serif); font-size: 18px; color: var(--muted); margin: 0; }

.draft-note {
  margin: 24px 0 0;
  padding: 12px 16px;
  border-left: 3px solid var(--ai);
  background: var(--ai-soft);
  font-size: 14px;
  border-radius: 0 6px 6px 0;
}

.section-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  margin-top: 32px;
}
.section-nav .wrap { display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none; }
.section-nav a { color: var(--muted); font-size: 14px; white-space: nowrap; padding: 14px 0; }
.section-nav a:hover { color: var(--ink); text-decoration: none; }
.section-nav .count { font-size: 12px; opacity: 0.7; margin-left: 2px; }

section { padding-top: 48px; }
section > h2 { font-size: 26px; margin: 0 0 4px; }
section > .lede { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

.overview p { font-family: var(--serif); font-size: 18px; line-height: 1.9; margin: 0 0 16px; }

/* tags */

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.tag-accent { color: var(--accent); border-color: var(--accent); }
.tag-ai { color: var(--ai); border-color: var(--ai); background: var(--ai-soft); }
.tag-stub { color: var(--accent); border: 1px dashed var(--accent); }

/* cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
}
.card h3 { margin: 0 0 6px; font-size: 19px; }
.card p { margin: 0 0 8px; }
.stack { display: grid; gap: 12px; }

.year { font-family: var(--serif); color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

.otl {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 14px;
  color: var(--muted);
}
.otl .label { color: var(--ink); font-weight: 600; margin-right: 6px; }

/* source quote */

details.src { display: inline-block; font-size: 12px; color: var(--muted); margin-top: 2px; }
details.src summary { cursor: pointer; list-style: none; }
details.src summary::-webkit-details-marker { display: none; }
details.src summary::before { content: "▸ "; }
details.src[open] summary::before { content: "▾ "; }
details.src q {
  display: block;
  margin-top: 4px;
  padding: 4px 8px;
  border-left: 2px solid var(--line);
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink);
}

/* timeline */

.timeline { border-top: 1px solid var(--line); }
.tl-row {
  display: grid;
  grid-template-columns: 96px 1fr 1fr;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.timeline.no-otl .tl-row { grid-template-columns: 96px 1fr; }
.tl-head { font-size: 13px; color: var(--muted); padding: 10px 0; }
.tl-head .ai-col { color: var(--ai); }
.tl-row .title { font-weight: 700; }
.tl-row .summary { margin: 2px 0 6px; }
.tl-row .otl-cell { font-size: 14px; color: var(--muted); }
.tl-row .otl-cell.from-ai { color: var(--ai); }
.tl-row .region { margin-left: 6px; vertical-align: 2px; }

@media (max-width: 680px) {
  .tl-row, .timeline.no-otl .tl-row { grid-template-columns: 1fr; gap: 4px; }
  .tl-head { display: none; }
  .tl-row .otl-cell:not(:empty)::before { content: attr(data-label) "　"; font-weight: 600; }
}

/* entities */

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters input {
  flex: 1 1 200px;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.chip {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.entity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); gap: 12px; }
.entity .aliases { font-size: 13px; color: var(--muted); margin: -2px 0 6px; }
.entity .head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.entity.stub, .book.stub { border-style: dashed; border-color: var(--accent); }
.entity.flash, .book.flash, .card.flash { outline: 2px solid var(--accent); outline-offset: 2px; }

.otl-chip { display: inline-flex; gap: 6px; align-items: baseline; font-size: 13px; color: var(--ai); margin: 2px 0 8px; }
.otl-chip .why { color: var(--muted); }

.links { font-size: 13px; color: var(--muted); }
.elink { margin-right: 8px; }
.elink.stub { border-bottom: 1px dashed var(--accent); }

/* books */

.book-list { display: grid; gap: 10px; }
.book { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: start; }
.book h3 { font-size: 18px; margin: 0; }
.book .by { color: var(--muted); font-size: 14px; }
.claim {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px dashed var(--accent);
  background: transparent;
  color: var(--accent);
  opacity: 0.6;
  cursor: not-allowed;
}

/* mechanisms */

.mech { counter-increment: mech; }
.mechanisms { counter-reset: mech; }
.mech h3::before { content: counter(mech) " · "; color: var(--accent); }
.mech .statement { font-family: var(--serif); font-size: 17px; }
.mech ul { margin: 6px 0 4px; padding-left: 20px; color: var(--muted); font-size: 14px; }

/* threads and questions */

.group-title { font-size: 15px; color: var(--muted); margin: 24px 0 10px; font-weight: 600; }
.card.from-ai { border-color: var(--ai); background: var(--ai-soft); }
.question .why { font-size: 14px; color: var(--muted); }
.import-notes { white-space: pre-wrap; font-size: 14px; color: var(--muted); }

.loading, .error { padding: 64px 0; color: var(--muted); }
.error { color: var(--accent); }
.empty { color: var(--muted); font-size: 14px; }

/* rules page */

.prose { max-width: 720px; }
.prose h1 { font-size: 32px; margin: 48px 0 8px; }
.prose h2 { font-size: 22px; margin: 40px 0 8px; }
.prose li { margin-bottom: 6px; }
.prose .status { color: var(--muted); font-size: 14px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.pair .card { font-size: 15px; }
.pair .ok { border-color: #5a8a5a; }
.pair .no { border-color: var(--accent); }
@media (max-width: 680px) { .pair { grid-template-columns: 1fr; } }

/* --- map ---------------------------------------------------------------
   The eight categorical slots and their dark steps are the documented, validated default
   palette (dataviz skill, references/palette.md), unchanged. Colour only separates
   neighbours; see map.js. */

:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --map-sea: #eef1f2;
  --map-land: #e4e0d6;
  --map-edge: #fcfcfb;
  --map-grid: #ece9e1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --map-sea: #171a1c;
    --map-land: #2c2a24;
    --map-edge: #15140f;
  }
}
:root[data-theme="dark"] {
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --map-sea: #171a1c;
  --map-land: #2c2a24;
  --map-edge: #15140f;
  --map-grid: #25231e;
}

.map-note { margin: 0 0 16px; }
.map-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.map-controls input[type="range"] { flex: 1; accent-color: var(--accent); min-width: 0; }
.map-year { font-size: 20px; min-width: 88px; text-align: right; }
.map-years { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.map-years .chip { padding: 4px 10px; font-size: 12px; }

.map-frame {
  position: relative;
  background: var(--map-sea);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
#map-svg { display: block; width: 100%; aspect-ratio: 958 / 420; cursor: grab; touch-action: none; }
#map-svg:active { cursor: grabbing; }
.map-region { fill: var(--map-land); stroke: var(--map-edge); stroke-width: 0.25; vector-effect: non-scaling-stroke; }
.map-region.held { stroke-width: 0.4; }
.map-region.cf-medium { opacity: 0.8; }
.map-region.cf-low { opacity: 0.5; }
.map-region.st-vassal { fill-opacity: 0.45; }
.map-region.st-claimed { stroke: var(--hold); stroke-width: 1.2; stroke-dasharray: 3 2; }
.map-region:hover { stroke: var(--ink); stroke-width: 1; }
#map-labels text {
  fill: var(--ink);
  font-family: var(--sans);
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 0.25em;
  stroke-linejoin: round;
  pointer-events: none;
}
.map-zoom { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }
.map-zoom .chip { padding: 4px 10px; font-size: 13px; }
.map-tip {
  position: absolute;
  max-width: 240px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);
  pointer-events: none;
}
.map-tip .region-name { font-weight: 700; margin-bottom: 4px; }
.map-tip .region-name span, .map-tip .why { color: var(--muted); font-weight: 400; }
.map-kf-note { margin: 14px 0 8px; font-size: 15px; }
.map-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 8px 20px; }
.legend-row { display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: start; font-size: 14px; }
.legend-row svg { margin-top: 5px; }
.legend-row rect { stroke: var(--line); }
.legend-row rect.st-claimed { stroke: var(--hold); stroke-dasharray: 3 2; stroke-width: 1.5; }
.legend-row rect.cf-low { opacity: 0.5; }
.legend-row rect.cf-medium { opacity: 0.8; }
.legend-row .tag { margin-left: 4px; }
.muted { color: var(--muted); }

/* --- article ---------------------------------------------------------- */

.article { padding-top: 32px; }
.article::after { content: ""; display: block; clear: both; }
.crumbs { font-size: 14px; color: var(--muted); }
.article h1 { font-size: 36px; margin: 8px 0 4px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.article-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.article h2 { font-size: 22px; margin: 32px 0 10px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.article p { margin: 0 0 14px; line-height: 1.9; }
.article p.lead { font-size: 17px; }
.article p.inferred { color: var(--ai); }
.article a.stub, .links-here a.stub { color: var(--accent); border-bottom: 1px dashed var(--accent); }
.ai-text { color: var(--ai); }

.infobox {
  float: right;
  width: 300px;
  margin: 0 0 20px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  overflow: hidden;
}
.infobox-title { font-family: var(--serif); font-weight: 700; font-size: 17px; text-align: center; padding: 10px; background: var(--accent-soft); }
.infobox table { width: 100%; border-collapse: collapse; }
.infobox th, .infobox td { text-align: left; vertical-align: top; padding: 7px 10px; border-top: 1px solid var(--line); line-height: 1.6; }
.infobox th { width: 34%; color: var(--muted); font-weight: 600; }
.infobox .empty { padding: 10px; margin: 0; }

.toc { display: inline-block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 20px 10px 14px; margin: 4px 0 8px; font-size: 14px; }
.toc-title { font-weight: 700; margin-bottom: 4px; }
.toc ol { margin: 0; padding-left: 20px; }

sup.cite { font-size: 11px; margin-left: 1px; }
.footnotes { font-size: 14px; color: var(--muted); padding-left: 24px; }
.footnotes q { color: var(--ink); font-family: var(--serif); }
.footnotes li:target { background: var(--accent-soft); }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 4px 0; }
.links-here { overflow-wrap: anywhere; }
.links-here a { display: inline-block; max-width: 100%; margin-right: 12px; }
.redlink-note { border: 1px dashed var(--accent); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; }

.title-link { color: inherit; }
.title-link:hover { color: var(--accent); }
.has-article { font-size: 13px; margin: -2px 0 6px; }

@media (max-width: 680px) {
  .infobox { float: none; width: auto; margin: 0 0 20px; }
  .map-zoom { position: static; padding: 8px; justify-content: flex-end; background: var(--surface); border-top: 1px solid var(--line); }
  .map-legend { grid-template-columns: 1fr; }
}

/* --- tabs, buttons, notices ------------------------------------------- */

.section-nav a[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.badge {
  display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 4px;
  border-radius: 999px; background: var(--accent); color: var(--surface);
  font-size: 11px; line-height: 16px; text-align: center; vertical-align: 1px;
}
.tag-edit { color: var(--surface); background: var(--ink); border-color: var(--ink); }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.button {
  display: inline-block; font: inherit; font-size: 14px; line-height: 1.2;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--surface); cursor: pointer; white-space: nowrap;
}
.button:hover { text-decoration: none; filter: brightness(1.08); }
.button:disabled { opacity: 0.5; cursor: wait; }
.button-quiet { background: transparent; color: var(--accent); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  max-width: min(90vw, 520px); padding: 10px 16px; border-radius: 8px;
  background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.2);
}
.toast-error { background: var(--accent); color: var(--surface); }
.claim-link { font-size: 13px; white-space: nowrap; }
.flash { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

/* --- wiki -------------------------------------------------------------- */

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 12px; }
.cat-card h3 a { color: var(--ink); }
.cat-card .count, h2 .count { font-size: 13px; color: var(--muted); font-family: var(--sans); font-weight: 400; }
.cat-desc { font-size: 13px; color: var(--muted); }
.cat-children { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cat-children .chip { padding: 4px 10px; font-size: 13px; }
.cat-entry { font-size: 13px; margin-right: 4px; }
.cat-entry.stub, .wiki-name.stub { color: var(--accent); border-bottom: 1px dashed var(--accent); }
.wiki-list { list-style: none; margin: 0 0 16px; padding: 0; border-top: 1px solid var(--line); }
.wiki-row {
  display: grid; grid-template-columns: minmax(96px, auto) auto 1fr auto; gap: 4px 12px;
  align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line);
}
.wiki-name { font-family: var(--serif); font-weight: 700; }
.wiki-kind { font-size: 12px; color: var(--muted); }
.wiki-summary { font-size: 14px; color: var(--muted); min-width: 0; }
@media (max-width: 680px) {
  .wiki-row { grid-template-columns: auto 1fr; }
  .wiki-summary { grid-column: 1 / -1; }
}
.article-cats { font-size: 14px; color: var(--muted); margin: -8px 0 20px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.article-cats select, .work-tools select, .editor select, .map-editor select {
  font: inherit; font-size: 13px; padding: 4px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface); color: var(--ink);
}

/* --- timeline eras --------------------------------------------------- */

.era-nav { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 12px; font-size: 14px; }
.era { margin-top: 28px; }
.era-title { font-size: 20px; margin: 0 0 4px; }
.era-years { font-family: var(--sans); font-weight: 400; font-size: 13px; color: var(--muted); margin-left: 6px; }
.era-summary { color: var(--muted); font-size: 14px; margin: 0 0 8px; }

/* --- map editor -------------------------------------------------------- */

.map-editor { font-size: 14px; display: grid; gap: 12px; align-content: start; }
.map-editor .muted { margin: 0; font-size: 13px; }
.editor-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; }
.editor-row label { display: flex; flex-direction: column; gap: 4px; }
.editor-row label.check { flex-direction: row; align-items: center; }
.editor-checks { margin-top: 10px; }
.map-editor input:not([type]) , .map-editor input[type="text"] {
  font: inherit; font-size: 13px; padding: 4px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface); color: var(--ink);
}
#map-svg.editing { cursor: crosshair; }
.map-region.cf-author { opacity: 1; }
.legend-row rect.cf-author { opacity: 1; }

/* --- works ------------------------------------------------------------- */

.work-card { display: block; color: var(--ink); }
.work-card:hover { border-color: var(--accent); text-decoration: none; }
.work-card h3 { margin: 6px 0 4px; }
.work-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.work-status.st-canon { color: var(--surface); background: var(--accent); border-color: var(--accent); }
.work-status.st-accepted { color: var(--accent); border-color: var(--accent); }
.work-page { padding-top: 32px; max-width: 760px; }
.work-page h1 { font-size: 34px; margin: 8px 0; }
.work-tools { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: 16px 0 28px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 14px; }
.work-tools label { display: flex; gap: 6px; align-items: center; }
.work-body { font-family: var(--serif); font-size: 18px; line-height: 2; }
.work-body p { margin: 0 0 1.1em; text-indent: 2em; }
.work-body h2, .work-body h3 { text-indent: 0; margin: 1.6em 0 0.6em; }
.work-body blockquote { margin: 0 0 1.1em; padding: 4px 16px; border-left: 3px solid var(--line); color: var(--muted); }
.proposal .proposal-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.proposal.decided { opacity: 0.6; }
.editor { display: grid; gap: 14px; margin-top: 16px; }
.editor > label { display: grid; gap: 6px; font-size: 14px; }
.editor input, .editor textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); width: 100%;
}
.editor textarea { font-family: var(--serif); font-size: 17px; line-height: 1.9; resize: vertical; }
.editor-foot { display: flex; justify-content: space-between; align-items: center; }
.about-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -6px; }
.about-chips .chip { cursor: default; }
.about-chips button { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0 0 0 4px; }

.lang-picker { font: inherit; font-size: 12px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); }

/* --- writing by hand (edit.js) ------------------------------------------ */

.edit-link {
  font: inherit; font-size: 13px; color: var(--accent); background: none; border: 0;
  padding: 0; cursor: pointer; white-space: nowrap;
}
.edit-link:hover { text-decoration: underline; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card-head h3 { margin-bottom: 6px; }
.tl-row .edit-link { margin-left: 6px; font-weight: 400; }
.article-sub .edit-link { margin-right: 10px; }
.section-head h2 + .edit-link { margin-top: 30px; }
.tag-noai { color: #3d7a4f; border-color: #3d7a4f; }
.world-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.world-tools .chip { font-size: 13px; padding: 4px 12px; }
.world-tools a.chip:hover { text-decoration: none; }
.start-here { border-style: dashed; border-color: var(--accent); margin-bottom: 8px; }
.start-here p { margin: 0 0 10px; }
.shelf { margin-bottom: 56px; }
.shelf-title {
  font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink); border-top: 2px solid var(--ink); padding-top: 10px; margin: 0 0 22px;
}
.rooms { padding-top: 48px; }

/* finding worlds: search, the tag list, tags on a world */
.finder { display: flex; gap: 8px; margin: 0 0 16px; max-width: 560px; }
.finder input { flex: 1; min-width: 0; font: inherit; font-size: 15px; padding: 9px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 0 0 36px; }
.topic { font-size: 13px; color: var(--muted); padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); white-space: nowrap; }
.topic:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.topic.on { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.topic .count { margin-left: 6px; font-size: 11px; opacity: 0.7; }
.search-head { margin: -12px 0 28px; color: var(--muted); }
.world-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.world-card .card-tags { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: 12px; }
.shelf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.shelf-head .shelf-title { flex: 1; }
.shelf-filter { font: inherit; font-size: 13px; padding: 5px 12px; margin-bottom: 22px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface); color: var(--ink); width: min(240px, 45%); }
.tag-suggest { margin-top: 10px; }
.tag-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-suggestions p { width: 100%; margin: 0; }
.intro .button { margin-top: 16px; }

.edit-dialog {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 20px 22px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink);
  box-shadow: 0 12px 48px rgb(0 0 0 / 0.25);
}
.edit-dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.edit-dialog h2 { margin: 0; font-size: 22px; }
.edit-dialog .editor { margin-top: 0; }
.edit-dialog textarea { font-size: 16px; line-height: 1.7; }
.editor label.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.editor label.check input { width: auto; margin-top: 4px; }
.editor .muted { font-size: 13px; }
.editor select { font-size: 14px; padding: 8px 10px; border-radius: 8px; }
.editor-row label.grow { flex: 1; min-width: min(240px, 100%); }
.editor-actions { display: flex; gap: 8px; }
.editor h2 { margin: 16px 0 0; font-size: 22px; }
.refs label { display: grid; gap: 6px; font-size: 14px; }
.refs .about-chips { margin-top: 8px; }
.section-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0; display: grid; gap: 10px; }
.section-block label { display: grid; gap: 6px; font-size: 14px; }
.section-tools { display: flex; gap: 6px; }
.section-tools .chip { padding: 4px 10px; }
.section-tools .chip:disabled { opacity: 0.4; cursor: default; }
.map-years-tools { align-items: center; margin-bottom: 10px; }
.map-years-tools .chip { font-size: 13px; padding: 4px 10px; }

/* A reader who hides AI content sees only what the author wrote. The map keeps its regions
   but drops the AI's colours back to plain land. */
.hide-ai .ai-content { display: none !important; }
.hide-ai .map-region.held:not(.cf-author) { fill: var(--map-land) !important; stroke: var(--map-edge) !important; opacity: 1; }
.hide-ai .otl-cell.ai-content { display: block !important; visibility: hidden; }
/* Labels read as one line (name, then any hint), with the input on its own line below. */
.editor > label, .refs label, .section-block label { display: block; }
.editor > label > :is(input, textarea, select), .refs label > input, .section-block label > :is(input, textarea) {
  display: block; width: 100%; margin-top: 6px;
}
.editor > label.check { display: flex; }
.map-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

/* --- accounts (account.js) ----------------------------------------------- */

.site-nav #site-user a { color: var(--ink); }
.byline { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.byline a { color: var(--muted); }
.world-card .byline { font-size: 13px; }
.hidden-note { border-left-color: var(--accent); background: var(--accent-soft); }
.report-link { color: var(--muted); font-size: 12px; }
.auth-page { max-width: 440px; padding-top: 48px; }
.auth-split { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 56px; align-items: start; max-width: 1120px; padding-top: 48px; }
.auth-split .auth-page { padding-top: 0; max-width: none; }
.auth-art { margin: 0; position: sticky; top: 24px; }
.auth-art img { display: block; width: 100%; max-height: 76vh; object-fit: cover; border-radius: 3px; box-shadow: 0 18px 44px -20px rgb(30 20 5 / 0.55); }
.auth-art figcaption { margin-top: 12px; color: var(--muted); }
@media (max-width: 820px) {
  .auth-split { grid-template-columns: 1fr; gap: 20px; padding-top: 24px; }
  .auth-art { position: static; order: -1; }
  .auth-art img { max-height: 180px; }
}
.auth-page h1 { font-size: 30px; margin: 0 0 8px; }
.oauth-row { display: grid; gap: 8px; margin: 18px 0; }
.oauth-button { text-align: center; }
.account-page { max-width: 760px; padding-top: 40px; }
.account-page h1 { font-size: 32px; margin: 0 0 8px; }
.account-section { padding-top: 32px; }
.account-section h2 { font-size: 20px; margin: 0 0 10px; }
.balance { margin: 0 0 6px; }
.balance-number { font-family: var(--serif); font-size: 34px; font-weight: 700; margin-right: 4px; }
.offer-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.offer-row .button { white-space: normal; text-align: left; }
.ledger { margin-top: 12px; font-size: 14px; }
.ledger table, .admin-users { border-collapse: collapse; width: 100%; font-size: 14px; }
.ledger td, .admin-users td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.ledger .plus { color: #3d7a4f; }
.ledger .minus { color: var(--accent); }
.provider-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.provider-row > span:first-child { min-width: 80px; font-weight: 600; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr)); gap: 10px; margin-top: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat-number { font-family: var(--serif); font-size: 24px; font-weight: 700; }
.stat .muted { font-size: 13px; }
.admin-users td:nth-child(2) { overflow-wrap: anywhere; }
.security-log { font-size: 13px; width: 100%; display: block; overflow-x: auto; }
.security-log td { padding: 3px 8px 3px 0; white-space: nowrap; }
.security-log .log-bad td:nth-child(2) { color: var(--accent); }
/* two-step sign-in */
.steps { padding-left: 20px; line-height: 1.8; }
.steps .qr { display: block; width: 200px; height: 200px; margin: 8px 0; border-radius: 8px; image-rendering: pixelated; }
.secret { display: inline-block; font-size: 15px; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--line); user-select: all; overflow-wrap: anywhere; }
.recovery-codes { font-size: 15px; line-height: 1.7; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; columns: 2; max-width: 360px; }
/* a field for sign-up bots only (app.py, register) */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.danger-zone { margin-top: 40px; padding: 16px 18px; border: 1px dashed var(--accent); border-radius: 10px; }
.danger-zone h2 { font-size: 18px; margin: 0 0 6px; }

/* --- importing and translating (edit.js) -------------------------------- */

.start-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 10px; margin: 16px 0 8px; }
.choice {
  display: grid; gap: 4px; text-align: left; font: inherit; cursor: pointer; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.choice span { font-size: 13px; color: var(--muted); }
.choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.estimate { font-size: 14px; margin: 0; }
.job-card { margin-top: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.job-card p { margin: 0 0 8px; }
.job-card.done { border-color: #3d7a4f; }
.job-step { font-size: 14px; color: var(--muted); }
.job-step.error { color: var(--accent); }
.job-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.job-table td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.job-table .job-failed td:nth-child(3) { color: var(--accent); }

/* --- provinces and map modes (map.js) ------------------------------------ */

.map-modes { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.map-modes .chip { font-size: 13px; padding: 5px 12px; }
.map-modes .chip .muted { font-size: 11px; }
.chip-add { border-style: dashed; color: var(--accent); }
.map-mode-note:empty { display: none; }
.map-mode-note { margin: -4px 0 12px; font-size: 14px; }
/* Inside one holder or value, province edges take its colour, so a country reads as one shape;
   zoomed in, and while editing, every province's edge shows. */
#map-svg:not(.fine) .map-region.held:not(.st-claimed) { stroke: var(--hold); }
#map-svg:not(.fine) .map-region:not(.held) { stroke: var(--map-grid); }
#map-svg.fine .map-region { stroke: var(--map-edge); stroke-width: 0.35; }
#map-svg.editing .map-region:hover { stroke: var(--ink); stroke-width: 1.2; }
.map-region.painting { stroke: var(--ink) !important; stroke-width: 1.4 !important; }
#map-labels text.big { font-size: 1.3em; }
.legend-absent { opacity: 0.5; }
.legend-family { display: grid; gap: 8px; align-content: start; }
.legend-depth-2 { margin-left: 20px; }
.legend-depth-3 { margin-left: 40px; }
.map-levels { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 12px; font-size: 13px; }
.map-levels .chip { font-size: 12px; padding: 3px 10px; }
.state-group { font-size: 12px; font-weight: 700; color: var(--muted); margin: 8px 0 2px 6px; }
.map-editor [data-value], .map-legend [data-value] { cursor: default; }
.mode-tools { display: inline-flex; gap: 8px; align-items: center; margin-left: 12px; }
.mode-ai { font-size: 10px; font-weight: 700; color: var(--ai); border: 1px solid var(--ai); border-radius: 4px; padding: 0 3px; margin-left: 2px; }
#map-draft-progress:empty { display: none; }
#map-draft-progress { margin-bottom: 12px; }

/* painting tools */
.map-tools .tool[aria-pressed="true"], .map-tools [data-size][aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tool-size { display: inline-flex; gap: 6px; align-items: center; margin-left: 8px; }
.map-region.preview { stroke: var(--ink); stroke-width: 1.1; stroke-dasharray: 2 1.5; vector-effect: non-scaling-stroke; }
.brush-cursor { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; pointer-events: none; }
#map-svg.editing[data-tool="move"] { cursor: grab; }
#map-svg.editing[data-tool="fill"] { cursor: cell; }
#map-svg.editing[data-tool="pick"] { cursor: copy; }

/* map styles (map.js, MAP_STYLES): the variables come from the chosen style */
@font-face { font-family: "IM Fell English"; src: url(/fonts/IMFeENrm28P.ttf); font-display: swap; }
@font-face { font-family: "IM Fell English"; font-style: italic; src: url(/fonts/IMFeENit28P.ttf); font-display: swap; }
@font-face { font-family: "IM Fell English SC"; src: url(/fonts/IMFeENsc28P.ttf); font-display: swap; }
@font-face { font-family: "Amiri"; src: url(/fonts/Amiri-Regular.ttf); font-display: swap; }
#map .map-region.held { fill-opacity: var(--map-fill-opacity, 1); }
#map #map-labels text { font-family: var(--map-label-font, var(--sans)); fill: var(--map-label-ink, var(--ink));
  stroke: var(--map-label-halo, var(--surface)); font-style: var(--map-label-style, normal); }
#map[data-map-style]:not([data-map-style="modern"]) .map-frame { background: var(--map-sea); border: 3px double var(--map-edge); }
#map[data-map-style="eastasia"] .map-frame { border: 1px solid var(--map-edge); box-shadow: inset 0 0 0 6px var(--map-paper), inset 0 0 0 7px var(--map-edge); }
#map[data-map-style="islamic"] .map-frame { border: 6px solid #b8913f; box-shadow: inset 0 0 0 2px #2e210f; }
#map .paper-grain, #map .compass { pointer-events: none; mix-blend-mode: multiply; }
.map-style-pick { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }

/* a map traced from a picture: the picture shows through the provinces */
#map[data-base="image"] .map-region:not(.held) { fill: transparent; }
#map[data-base="image"] .map-region.held { fill-opacity: calc(var(--map-fill-opacity, 1) * 0.55); }
#map[data-base="image"] #map-svg:not(.fine) .map-region:not(.held) { stroke: transparent; }
.kf-picture { margin: 12px 0 0; }
.kf-picture img { max-width: 100%; max-height: 520px; border: 1px solid var(--line); border-radius: 8px; display: block; }
.kf-picture figcaption { font-size: 13px; margin-top: 4px; }

/* writing: each form laid out its own way (works.js) */
.toc details { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 12px 0 20px; }
.toc summary { cursor: pointer; font-weight: 600; }
.toc ol { margin: 8px 0 0; padding-left: 22px; columns: 2; }
.toc li[aria-current="true"] a { font-weight: 700; color: var(--ink); }
.chapter-title { margin-top: 8px; }
.chapter-nav { display: flex; justify-content: space-between; gap: 12px; margin: 32px 0 8px; }
.chapter-edit, .poem-edit { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 12px; margin: 0 0 14px; }
.chapter-edit legend, .poem-edit legend { font-weight: 600; padding: 0 6px; }
.chapter-edit textarea, .poem-edit textarea { width: 100%; }
.poem { margin: 0 0 36px; }
.poem .stanza { margin: 0 0 1.1em; line-height: 1.9; text-indent: 0; }
.poem-classical { text-align: center; font-family: var(--serif); font-size: 1.1em; }
.poem-form { font-size: 13px; margin: -6px 0 10px; }
.form-check { font-size: 13px; color: var(--accent); min-height: 1em; }
.fountain { font-family: "Courier Prime", "Courier New", var(--serif), monospace; max-width: 38em; margin: 0 auto; }
.fs-scene { text-transform: uppercase; font-weight: 700; margin: 1.6em 0 .6em; font-size: 1em; }
.fs-character { text-align: center; text-transform: uppercase; margin: 1.2em 0 0; }
.fs-paren { text-align: center; margin: 0; font-style: italic; }
.fs-dialogue { margin: 0 auto; max-width: 24em; }
.fs-transition { text-align: right; text-transform: uppercase; }
.fs-centre { text-align: center; }
textarea.mono { font-family: "Courier New", monospace; }
.in-world-doc { background: #f4ecd8; color: #2b2419; border: 1px solid #cdbd97; border-radius: 4px; padding: 28px 34px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08); font-family: var(--serif); max-width: 42em; margin: 8px auto; }
.in-world-doc .doc-kind { text-align: center; letter-spacing: .3em; font-size: 13px; color: #7a6546; margin-bottom: 14px; }
.in-world-doc .doc-head { border-bottom: 1px solid #cdbd97; padding-bottom: 10px; margin-bottom: 14px; font-size: 14px; }
.in-world-doc .doc-head .muted { color: #7a6546; min-width: 3em; display: inline-block; }
.in-world-doc .doc-seal { text-align: right; margin-top: 22px; font-weight: 700; }
.in-world-doc.doc-decree .doc-seal, .in-world-doc.doc-treaty .doc-seal { color: #a3322a; }
.doc-fields { flex-wrap: wrap; }
.footnotes { font-size: 14px; border-top: 1px solid var(--line); margin-top: 28px; padding-top: 10px; }
sup.fn a { text-decoration: none; }

.small { font-size: 13px; }

/* figures: character sheets (figures.js) */
.figure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; margin-top: 14px; }
.figure-card { display: flex; gap: 14px; align-items: flex-start; color: inherit; text-decoration: none; }
.figure-card:hover { border-color: var(--muted); }
.figure-card h3 { margin: 4px 0 2px; }
.portrait { border-radius: 10px; object-fit: cover; background: var(--line); flex: none; width: 96px; height: 120px; }
.portrait.small { width: 64px; height: 80px; border-radius: 8px; }
.portrait.large { width: 100%; max-width: 260px; height: auto; aspect-ratio: 4 / 5; }
.portrait-blank { display: grid; place-items: center; font-family: var(--serif); font-size: 32px; color: var(--muted); }
.portrait.large.portrait-blank { font-size: 72px; }
.trait-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip.trait { cursor: default; font-size: 12px; padding: 2px 10px; }
.sheet { display: grid; grid-template-columns: minmax(200px, 260px) 1fr; gap: 28px; margin-top: 16px; }
@media (max-width: 720px) { .sheet { grid-template-columns: 1fr; } .sheet-side .portrait.large { max-width: 200px; } }
.sheet-main h1 { margin: 6px 0 2px; }
.epithet { font-family: var(--serif); color: var(--muted); font-size: 18px; margin: 0 0 12px; }
.sheet-stats { display: grid; gap: 6px; margin-top: 16px; font-size: 14px; }
.sheet-stat { display: grid; grid-template-columns: minmax(4.5em, max-content) 1fr 2.2em; gap: 8px; align-items: center; }
.sheet-stat b { text-align: right; font-variant-numeric: tabular-nums; }
.stat-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.stat-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.figure-quote { font-family: var(--serif); font-size: 18px; border-left: 3px solid var(--accent); margin: 16px 0; padding: 2px 16px; }
.career { list-style: none; padding: 0; margin: 0 0 20px; border-left: 2px solid var(--line); }
.career li { position: relative; padding: 4px 0 10px 18px; }
.career li::before { content: ""; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.career .year { display: inline-block; min-width: 7em; color: var(--muted); font-variant-numeric: tabular-nums; }
.relations { list-style: none; padding: 0; display: grid; gap: 6px; }
.relations .chip { cursor: default; font-size: 12px; padding: 2px 10px; }
.portrait-row { align-items: flex-start; }
.portrait-row .portrait.large { width: 140px; }
.sheet-block { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 12px; margin: 0; display: grid; gap: 8px; }
.sheet-block legend { font-weight: 600; padding: 0 6px; }
.sheet-row { align-items: center; }
.sheet-row input { min-width: 0; flex: 1 1 140px; }
.sheet-row input.short, .sheet-row input.num { flex: 0 1 90px; }

/* languages and scripts (languages.js) */
.lang-card { color: inherit; text-decoration: none; }
.lang-card:hover { border-color: var(--muted); }
.native { font-weight: 400; color: var(--muted); margin-left: 8px; }
.lang-parts { margin: 12px 0 20px; }
.in-script { font-size: 1.15em; }
.in-script.vertical { writing-mode: vertical-rl; display: inline-block; }
.in-script.glyphs { display: inline-flex; flex-wrap: wrap; align-items: flex-end; gap: 1px; }
.in-script.glyphs.vertical { flex-direction: column; flex-wrap: nowrap; }
img.glyph { height: 1.4em; width: auto; vertical-align: middle; }
.glyph-space { display: inline-block; width: .5em; }
.glyph-break { flex-basis: 100%; height: 0; }
img.glyph.big { height: 44px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) img.glyph { filter: invert(1); } }
:root[data-theme="dark"] img.glyph { filter: invert(1); }
.letters { border-collapse: collapse; margin: 12px 0; min-width: min(420px, 100%); }
.letters th, .letters td { border-bottom: 1px solid var(--line); padding: 6px 12px; text-align: left; }
.letters .glyph-cell { font-size: 28px; }
.glyph-cell { min-width: 48px; display: inline-flex; align-items: center; justify-content: center; }
.chip.ipa { cursor: default; font-family: "Charis SIL", "Doulos SIL", "Gentium Plus", var(--serif); }
.ipa { font-family: "Charis SIL", "Doulos SIL", "Gentium Plus", var(--serif); color: var(--muted); }
.interlinear { margin: 0 0 20px; }
.il-script { font-size: 22px; margin-bottom: 4px; }
.il-script.long { font-size: 17px; line-height: 1.7; }
.il-reading { color: var(--muted); font-family: "Charis SIL", "Doulos SIL", "Gentium Plus", var(--serif); }
.il-words { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.il-word { display: inline-flex; flex-direction: column; }
.il-gloss { font-size: 12px; color: var(--muted); font-variant: small-caps; letter-spacing: .02em; }
.il-translation { margin-top: 4px; font-family: var(--serif); }
.scribe-out { min-height: 3em; margin: 12px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 26px; line-height: 1.6; overflow-wrap: anywhere; }
#scribe-in { width: 100%; }
.dict-tools input[type="search"] { flex: 1 1 220px; }
.dict-entry { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; gap: 2px; }
.dict-entry .headword { font-size: 18px; }
.dict-entry .edit-link { margin-left: 8px; }
.grammar-row textarea, .text-row textarea { width: 100%; }
.work-body table { border-collapse: collapse; margin: 0 0 1.1em; font-family: var(--sans); font-size: 15px; line-height: 1.5; }
.work-body th, .work-body td { border: 1px solid var(--line); padding: 4px 10px; text-align: left; }
.work-body th { background: var(--surface); }
.scribe-out .in-script, .il-script .in-script { white-space: pre-wrap; }

/* --- the gallery (gallery.js): old maps, hung with labels ------------------ */

.gallery-hero {
  position: relative; display: flex; align-items: flex-end; overflow: hidden;
  min-height: min(76vh, 660px); background: #1d1b17; color: #f6f3ec;
}
.hero-frames { position: absolute; inset: 0; }
.hero-art {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transform: scale(1.06); transition: opacity 1.8s ease, transform 14s ease-out;
}
.hero-art.shown { opacity: 1; transform: scale(1); }
.hero-shade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgb(20 17 12 / 0.1) 0%, rgb(20 17 12 / 0.3) 40%, rgb(20 17 12 / 0.86) 100%);
}
.hero-inner { position: relative; width: 100%; padding-top: 140px; padding-bottom: 84px; }
.gallery-hero .eyebrow { color: #efe6d2; margin: 0 0 12px; }
.gallery-hero h1 {
  font-size: clamp(34px, 5.2vw, 62px); line-height: 1.1; margin: 0 0 16px; max-width: 13em;
  color: #fffdf8; text-shadow: 0 2px 22px rgb(0 0 0 / 0.4);
}
.hero-lede { max-width: 34em; font-size: 17px; color: #ebe3d2; margin: 0 0 24px; }
.art-label { margin: 0; display: grid; gap: 1px; font-size: 12px; line-height: 1.5; }
.art-title { font-family: var(--serif); font-style: italic; font-size: 13px; }
.art-source { font-size: 11px; }
.hero-label { position: absolute; right: 20px; bottom: 18px; max-width: 340px; text-align: right; color: #e6dcc7; }
.hero-label a { color: #e6dcc7; text-decoration: underline; text-decoration-color: rgb(255 255 255 / 0.35); }
.hero-dots { position: absolute; left: 20px; bottom: 22px; display: flex; gap: 8px; }
.hero-dot { width: 9px; height: 9px; padding: 0; border-radius: 50%; border: 1px solid #fffdf8; background: transparent; cursor: pointer; opacity: 0.8; }
.hero-dot[aria-pressed="true"] { background: #fffdf8; opacity: 1; }
@media (max-width: 640px) {
  .hero-label { left: 16px; right: 16px; max-width: none; text-align: left; bottom: 40px; }
  .hero-dots { bottom: 16px; left: 16px; }
  .hero-inner { padding-bottom: 110px; }
}
@media (prefers-reduced-motion: reduce) { .hero-art { transition: opacity 0.3s; transform: none !important; } }

/* A painted scroll, unrolling slowly across the foot of the page. */
.art-band { margin: 40px 0 0; }
.band-window { overflow: hidden; height: clamp(120px, 18vw, 220px); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.band-track { display: flex; height: 100%; width: max-content; animation: unroll 240s linear infinite; }
.band-track img { height: 100%; width: auto; display: block; }
@keyframes unroll { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .band-track { animation: none; } }
.art-band figcaption { color: var(--muted); padding-top: 10px; }

/* --- the map page: a style picker, and the author's tools beside the map -- */

.map-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 20px; margin: 28px 0 12px; }
.map-head h2 { margin: 0; }
.map-actions { align-items: center; }
.map-check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.style-button { display: inline-flex; align-items: center; gap: 8px; }
.style-button[aria-expanded="true"] { background: var(--accent-soft); }
.style-chip { width: 26px; height: 12px; border-radius: 3px; display: inline-block; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12); }
.style-gallery { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 14px; margin: 0 0 14px; }
.style-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.style-card {
  display: grid; gap: 6px; padding: 6px 6px 8px; font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.style-card:hover { border-color: var(--muted); }
.style-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.style-thumb { display: block; width: 100%; aspect-ratio: 8 / 5; object-fit: cover; border-radius: 6px; }
.style-card-name { font-size: 13px; font-weight: 600; padding: 0 2px; }
.style-dots { display: flex; gap: 3px; padding: 0 2px; }
.style-dots i { width: 12px; height: 7px; border-radius: 2px; display: block; }
.style-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; }

.map-body.editing { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.map-stage { min-width: 0; }
.map-body.editing .map-editor { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; }
.panel h3 { margin: 0; font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel-head .chip { font-size: 12px; padding: 3px 10px; }
.tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool {
  display: grid; justify-items: center; gap: 1px; padding: 7px 4px 5px; font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink);
}
.tool kbd { font-family: var(--sans); font-size: 10px; color: var(--muted); }
.tool[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tool[aria-pressed="true"] kbd { color: inherit; opacity: 0.7; }
.map-editor .tool-size { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.tool-size .chip { font-size: 12px; padding: 3px 10px; }
.tool-size [data-size][aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.panel-field { display: grid; gap: 4px; font-size: 13px; }
.panel-field select, .panel-field input {
  width: 100%; font: inherit; font-size: 14px; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink);
}
.panel .check { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.tool-help summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.tool-help p { font-size: 13px; color: var(--muted); margin: 6px 0 0; line-height: 1.6; }
.state-find {
  width: 100%; font: inherit; font-size: 14px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink);
}
.state-list { display: grid; gap: 1px; max-height: 340px; overflow: auto; margin: 0 -6px; padding: 0 6px; }
.state-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 2px 6px; border-radius: 8px; }
.state-row:hover { background: var(--bg); }
.state-row.on { background: var(--accent-soft); }
.swatch { position: relative; display: block; width: 22px; height: 22px; border-radius: 6px; overflow: hidden; cursor: pointer; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.16); }
.swatch input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.swatch.unused { background: repeating-linear-gradient(45deg, var(--line) 0 3px, transparent 3px 6px) !important; }
.swatch.eraser { cursor: default; background: linear-gradient(135deg, transparent 44%, var(--accent) 44% 56%, transparent 56%), var(--surface); }
.state-pick {
  min-width: 0; padding: 4px 0; text-align: left; background: none; border: 0; font: inherit; font-size: 14px;
  color: var(--ink); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.state-pick[aria-pressed="true"] { font-weight: 700; }
.state-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.state-auto { background: none; border: 0; padding: 0 2px; color: var(--muted); cursor: pointer; font-size: 15px; }
.brush-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.panel-row { display: flex; flex-wrap: wrap; gap: 6px; }
.panel-row .chip { font-size: 13px; padding: 4px 10px; }
.editor > label.colour-field > input[type="color"] { width: 72px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
@media (max-width: 1060px) {
  .map-body.editing { grid-template-columns: 1fr; }
  .map-body.editing .map-editor { position: static; max-height: none; order: -1; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .state-list { max-height: 200px; }
}

/* --- the AI assistant (assist.js) ------------------------------------------ */

.assist { border: 1px solid var(--ai); background: var(--ai-soft); border-radius: 12px; padding: 0; margin: 20px 0; }
.assist > summary { cursor: pointer; list-style: none; padding: 10px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-weight: 600; }
.assist > summary::-webkit-details-marker { display: none; }
.assist[open] > summary { border-bottom: 1px solid rgb(52 88 143 / 0.2); }
.assist-mark { display: inline-grid; place-items: center; min-width: 26px; height: 20px; padding: 0 5px; border-radius: 5px; background: var(--ai); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.assist-form, .assist-form-inline, .assist-result { padding: 12px 14px; }
.assist-result:empty { display: none; }
.assist textarea { width: 100%; font: inherit; font-size: 15px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.assist-examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.assist-examples .chip { font-size: 12px; padding: 3px 10px; background: var(--surface); }
.assist-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.assist-reply { display: flex; gap: 10px; align-items: flex-start; }
.assist-reply p { margin: 0; }
.assist-ops { display: grid; gap: 8px; margin-top: 12px; }
.assist-op { display: grid; grid-template-columns: 20px 1fr; gap: 8px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.assist-op input { margin-top: 4px; }
.assist-op details summary { cursor: pointer; color: var(--muted); }
.assist-detail { font-size: 14px; color: var(--ink); background: var(--bg); border-radius: 6px; padding: 8px 10px; margin-top: 6px; max-height: 280px; overflow: auto; }
.assist-detail p { margin: 0 0 6px; }
.write-text { max-height: 360px; font-family: var(--serif); font-size: 16px; line-height: 1.9; }
.map-editor .assist { margin: 0; }

/* translations: the list in world settings, and the hand editor (translations.js) */
.tr-langs { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 12px; }
.tr-langs td { padding: 8px 10px 8px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.tr-lang-actions { white-space: nowrap; text-align: right; }
.tr-lang-actions .chip { font-size: 12px; padding: 3px 10px; }
.tr-add { align-items: flex-end; flex-wrap: wrap; }
.work-page.tr-page { max-width: 1120px; }
.tr-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 12px 0 4px; }
.tr-tabs { display: flex; gap: 6px; margin: 16px 0 12px; }
.tr-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 8px; }
.tr-filters .chip { font-size: 12px; padding: 4px 10px; }
.tr-filters .count { margin-left: 4px; opacity: 0.7; }
.tr-filters select, .tr-filters input { font: inherit; font-size: 13px; padding: 5px 10px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface); color: var(--ink); }
.tr-filters input { flex: 1; min-width: 160px; }
.tr-row { border-top: 1px solid var(--line); padding: 12px 0; }
.tr-where { font-size: 12px; color: var(--muted); margin-bottom: 6px; overflow-wrap: anywhere; }
.tr-where .tag { margin-left: 6px; font-size: 11px; padding: 3px 7px; }
.tr-mine .tr-state { color: #3d7a4f; border-color: #3d7a4f; }
.tr-missing .tr-state { color: var(--accent); border-color: var(--accent); }
.tr-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tr-source { font-family: var(--serif); font-size: 15px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.tr-text { width: 100%; box-sizing: border-box; font-family: var(--serif); font-size: 15px; line-height: 1.7; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); resize: vertical; min-height: 44px; }
.tr-missing .tr-text { border-style: dashed; border-color: var(--accent); }
.tr-tools { display: flex; gap: 12px; margin-top: 4px; font-size: 12px; }
.tr-earlier { margin-top: 6px; font-size: 13px; padding: 6px 10px; border-radius: 8px; background: var(--ai-soft); }
.tr-earlier-text { font-family: var(--serif); }
.tr-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 16px 0; }
.tr-savebar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 10px 0; background: var(--bg); border-top: 1px solid var(--line); z-index: 5; }
.tr-savebar span { margin-right: auto; color: var(--accent); font-size: 14px; }
.tr-names { width: 100%; border-collapse: collapse; font-size: 14px; }
.tr-names th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 8px 4px 0; }
.tr-names td { padding: 6px 8px 6px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.tr-names input { width: 100%; box-sizing: border-box; font: inherit; padding: 5px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface); color: var(--ink); }
@media (max-width: 680px) {
  .tr-pair { grid-template-columns: 1fr; }
  .tr-names thead { display: none; }
  .tr-names td { display: block; border-top: 0; padding: 2px 0; }
  .tr-names tr { display: block; border-top: 1px solid var(--line); padding: 8px 0; }
  .tr-langs td { display: block; border-top: 0; padding: 2px 0; text-align: left; }
  .tr-langs tr { display: block; border-top: 1px solid var(--line); padding: 8px 0; }
}

/* --- discussion and activity (talk.js) ------------------------------------ */

.talk-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 0 48px; align-items: start; }
@media (max-width: 860px) { .talk-grid { grid-template-columns: minmax(0, 1fr); } }
.comments h2 .count { margin-left: 8px; }
.comment-form { display: grid; gap: 8px; margin: 4px 0 20px; }
.comment-form textarea {
  font: inherit; font-size: 15px; line-height: 1.7; padding: 10px 12px; width: 100%; resize: vertical;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.comment-form textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.comment-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
.comment-signin { margin: 4px 0 20px; padding: 12px 16px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 14px; }
.comment-list { display: grid; gap: 0; }
.comment { padding: 14px 0; border-top: 1px solid var(--line); }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 14px; }
.comment-head > a { font-weight: 600; color: var(--ink); }
.comment-head .tag { font-size: 11px; padding: 0 6px; }
.comment-tools { margin-left: auto; display: flex; gap: 10px; }
.comment-body { margin-top: 4px; font-size: 15px; }
.comment-body p { margin: 0 0 8px; overflow-wrap: anywhere; }
.comment-body p:last-child { margin-bottom: 0; }

.activity { list-style: none; margin: 0; padding: 0; }
.act { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0 9px 18px;
  border-top: 1px solid var(--line); font-size: 14px; position: relative; }
.act::before { content: ""; position: absolute; left: 2px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.act-work::before, .act-figure::before { background: var(--accent); }
.act-comment::before { background: var(--ink); }
.act > span { min-width: 0; overflow-wrap: anywhere; }
.act > span > a:first-child, .act > span > span:first-child { font-weight: 600; color: var(--ink); }
.act time { flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
.recent .activity { max-width: 720px; }
.chip-danger { color: var(--accent); border-color: var(--accent); }
.reported-comment { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--line); background: var(--surface); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
