/* Orbis Codex pages and skins. The same file is served by the DDM
   (OrbisGui/webapp/static/codex/codex.css); a test keeps both copies equal.
   Handout skins look like in-world paper in both themes. */
.codex-page { position: relative; min-width: 0; padding: 1.25rem; border: 1px solid var(--edge, #baa177); border-radius: 4px; background: #fbf1dab3; color: var(--ink, #372818); overflow-wrap: break-word; }
.codex-title { margin: 0 0 .5rem; font-family: var(--book, "Palatino Linotype", Georgia, serif); font-size: 1.7rem; color: var(--wine, #52242c); }
.codex-body { font-size: 1.02rem; line-height: 1.6; }
.codex-body > * { margin: 0 0 .75rem; }
.codex-body > :last-child { margin-bottom: 0; }
.codex-heading { margin: 1.1rem 0 .5rem; font-family: var(--book, "Palatino Linotype", Georgia, serif); color: var(--wine, #52242c); }
h2.codex-heading { font-size: 1.4rem; }
h3.codex-heading { font-size: 1.2rem; }
h4.codex-heading { font-size: 1.05rem; color: var(--muted, #705d46); }
.codex-body blockquote { margin-left: 0; padding: .4rem 0 .4rem 1rem; border-left: 3px solid var(--gold, #b58a43); font-style: italic; }
.codex-body blockquote p { margin: 0; }
.codex-body cite { display: block; margin-top: .3rem; font-size: .9rem; font-style: normal; color: var(--muted, #705d46); }
.codex-body cite::before { content: "— "; }
.codex-body ul, .codex-body ol { padding-left: 1.4rem; }
.codex-checklist { list-style: none; padding-left: .2rem !important; }
.codex-checklist li.done { color: var(--muted, #705d46); text-decoration: line-through; }
.codex-check { font-size: 1.05rem; }
.codex-table { max-width: 100%; max-height: 75vh; overflow: auto; border: 1px solid var(--edge, #baa177); border-radius: 3px; }
.codex-table table { width: 100%; border-collapse: collapse; font-size: .92rem; line-height: 1.4; }
.codex-table caption { padding: .4rem .6rem; text-align: left; font-weight: 600; color: var(--wine, #52242c); }
.codex-table th, .codex-table td { padding: .3rem .6rem; border-top: 1px solid #baa17766; text-align: left; vertical-align: top; }
.codex-table th { position: sticky; top: 0; z-index: 1; background: #f3e4c4; white-space: nowrap; }
.codex-table tbody tr:nth-child(even) { background: #fdf6e399; }
.codex-table td.codex-table-repeat { color: transparent; }
.codex-table td.codex-table-repeat * { visibility: hidden; }
.codex-table-filter { position: sticky; left: 0; display: flex; gap: .6rem; align-items: center; padding: .4rem .6rem; }
.codex-table-filter input { flex: 1; min-width: 0; max-width: 22rem; }
.codex-table-count { color: var(--muted, #705d46); white-space: nowrap; }
.codex-table-sort { width: 100%; min-height: 0; padding: .1rem 1.2rem .1rem 0; border: 0; background: transparent; color: inherit; box-shadow: none; font: inherit; text-align: left; cursor: pointer; }
.codex-table-sort:hover { text-decoration: underline; filter: none; }
.codex-table th[aria-sort="ascending"] .codex-table-sort::after { content: ' ▲'; }
.codex-table th[aria-sort="descending"] .codex-table-sort::after { content: ' ▼'; }
.codex-table-pages { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: .5rem; padding: .35rem .6rem; background: var(--field, #fff8e4); border-top: 1px solid var(--edge, #baa177); }
.codex-table-pages[hidden] { display: none; }
.codex-editable-table { max-height: none; overflow: visible; border-color: #baa17788; border-radius: 5px; }
.codex-editable-table .codex-data-scroll { max-width: 100%; max-height: 65vh; overflow-x: auto; overflow-y: auto; }
.codex-editable-table table { width: 100%; table-layout: fixed; }
.codex-editable-table th, .codex-editable-table td { min-width: 0; padding: .28rem .5rem; border-top-color: #baa17755; overflow-wrap: anywhere; }
.codex-editable-table th { background: #f3e4c499; }
.codex-editable-table tbody tr:nth-child(even) { background: transparent; }
.codex-editable-table tbody tr:hover { background: #f3e4c444; }
.codex-editable-table td input, .codex-editable-table th input[type="text"],
.codex-editable-table th input[type="search"] { width: 100%; min-width: 0; box-sizing: border-box; }
.codex-editable-table th select { width: 100%; }
.codex-editable-table.is-editing td input, .codex-editable-table.is-editing th input[type="text"],
.codex-editable-table.is-editing th input[type="search"], .codex-editable-table.is-editing th select {
  min-height: 1.7rem; padding: .15rem .35rem; border: 1px solid transparent; border-radius: 3px; background: transparent; box-shadow: none;
}
.codex-editable-table.is-editing :is(td, th) input:hover,
.codex-editable-table.is-editing :is(td, th) input:focus,
.codex-editable-table.is-editing th select:hover,
.codex-editable-table.is-editing th select:focus { border-color: #baa17777; background: var(--field, #fff8e4); }
.codex-editable-table :is(input, select, button, summary):focus-visible { outline: 2px solid var(--gold, #b58a43); outline-offset: 2px; }
.codex-data-header { padding: .35rem .5rem; border-bottom: 1px solid #baa17755; }
.codex-data-heading, .codex-data-primary, .codex-data-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.codex-data-heading { justify-content: space-between; }
.codex-data-title { color: var(--wine, #52242c); font-weight: 600; }
.codex-data-actions { margin-top: .3rem; }
.codex-data-actions[hidden] { display: none; }
.codex-editable-table button.secondary.small, .codex-data-menu summary { min-height: 1.7rem; padding: .12rem .4rem; font-size: .82rem; }
.codex-data-tools { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; padding: .35rem .5rem; border-bottom: 1px solid #baa17744; }
.codex-data-tools input[type="search"] { flex: 1 1 9rem; min-width: 7rem; max-width: 16rem; }
.codex-data-tools select { max-width: 11rem; }
.codex-data-menu { position: relative; }
.codex-data-menu summary { display: inline-flex; align-items: center; cursor: pointer; border: 1px solid #baa17777; border-radius: 3px; list-style: none; }
.codex-data-menu summary::-webkit-details-marker { display: none; }
.codex-data-menu-items { position: absolute; z-index: 5; right: 0; top: 100%; min-width: 10rem; padding: .2rem; border: 1px solid var(--edge, #baa177); border-radius: 4px; background: var(--field, #fff8e4); box-shadow: 0 3px 10px #37281822; }
.codex-data-menu-items button { display: block; width: 100%; padding: .3rem .5rem; border: 0; background: transparent; color: var(--ink, #372818); text-align: left; cursor: pointer; }
.codex-data-menu-items button:hover { background: #baa17733; }
.codex-table-group th { background: var(--field, #fff8e4); color: var(--wine, #52242c); }
.codex-table-group button { width: 100%; justify-content: flex-start; }
.codex-table-actions { width: 3.25rem; white-space: nowrap; text-align: right !important; }
.codex-table-actions button { min-width: 1.35rem; padding: .1rem .2rem !important; }
.codex-row-drag { border: 0; background: transparent; box-shadow: none; color: var(--muted, #705d46); cursor: grab; font-size: 1.05rem; line-height: 1; vertical-align: middle; }
.codex-row-drag:hover { color: var(--wine, #52242c); background: #baa17733; }
.codex-row-drag:active { cursor: grabbing; }
.codex-row-drag:disabled { opacity: .35; cursor: default; }
.codex-editable-table tr.is-dragging { opacity: .45; }
.codex-editable-table tr.drop-before { box-shadow: inset 0 3px var(--gold, #b58a43); }
.codex-editable-table tr.drop-after { box-shadow: inset 0 -3px var(--gold, #b58a43); }
.codex-simple-table .codex-column-head { display: flex; align-items: center; gap: .25rem; min-width: 0; }
.codex-simple-table .codex-column-head input[type="text"] { flex: 1 1 0; width: 0; min-width: 0; font-weight: 600; }
.codex-simple-table .codex-column-drag, .codex-simple-table .codex-column-delete { flex: 0 0 1.45rem; width: 1.45rem; min-width: 1.45rem; height: 1.5rem; min-height: 1.5rem; padding: 0; border: 0; border-radius: 4px; background: transparent; box-shadow: none; color: var(--muted, #705d46); line-height: 1; cursor: pointer; }
.codex-simple-table .codex-column-drag { font-size: 1rem; cursor: grab; }
.codex-simple-table .codex-column-drag:active { cursor: grabbing; }
.codex-simple-table .codex-column-delete { font-size: 1rem; }
.codex-simple-table .codex-column-head button:hover { background: #baa17733; color: var(--wine, #52242c); }
.codex-simple-table .codex-column-delete:disabled { opacity: .3; cursor: default; }
.codex-simple-table th.drop-before { box-shadow: inset 3px 0 var(--gold, #b58a43); }
.codex-simple-table th.drop-after { box-shadow: inset -3px 0 var(--gold, #b58a43); }
.codex-simple-table th.is-dragging { opacity: .5; }
.codex-simple-table .codex-table-actions { width: 5.5rem; }
.codex-simple-table .codex-add-column-cell { text-align: center !important; }
.codex-simple-table .codex-add-column-cell button { white-space: nowrap; }
.codex-simple-table tfoot td { padding: .3rem .5rem; border-top: 1px dashed #baa17788; background: #f3e4c433; }
.codex-simple-table tfoot button { border: 0; background: transparent; box-shadow: none; color: var(--wine, #52242c); font-weight: 600; cursor: pointer; }
.codex-simple-table tfoot button:hover { background: #baa17733; }
.codex-editable-table .codex-table-pages { position: static; }
.codex-editable-table .codex-table-pages { min-height: 1.8rem; justify-content: flex-end; padding: .25rem .5rem; border-top-color: #baa17755; background: transparent; }
.codex-editable-table .codex-table-count { margin-right: auto; }
.codex-table-pages button { min-width: 2rem; min-height: 2rem; padding: 0 .35rem; }
.codex-data-table { position: relative; min-width: 0; }
.codex-data-table .codex-data-scroll { max-height: 65vh; overflow: auto; }
.codex-data-table table { min-width: 0; table-layout: fixed; width: auto; border-collapse: separate; border-spacing: 0; }
.codex-data-table th, .codex-data-table td { box-sizing: border-box; border-right: 1px solid #baa17733; padding: .42rem .55rem; overflow: hidden; text-overflow: ellipsis; }
.codex-data-table th { height: 2.25rem; padding-right: 1.9rem; background: var(--field, #fff8e4); color: var(--wine, #52242c); }
.codex-data-table td { height: 2.25rem; background: #fffaf133; }
.codex-data-table tbody tr:nth-child(even) td { background: #fffaf155; }
.codex-data-table tbody tr:hover td { background: #fffaf188; }
.codex-data-table .codex-column-label { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.codex-data-table .codex-column-trigger { position: absolute; top: 50%; right: .35rem; transform: translateY(-50%); min-width: 1.4rem; min-height: 1.4rem; padding: 0; border: 0; background: transparent; box-shadow: none; color: var(--muted, #705d46); }
.codex-data-table .codex-column-trigger:hover, .codex-data-table .codex-column-trigger:focus-visible { background: #baa17733; color: var(--wine, #52242c); }
.codex-data-table .codex-column-resize { position: absolute; top: 0; right: -4px; z-index: 3; width: 8px; height: 100%; cursor: col-resize; touch-action: none; }
.codex-data-table .codex-column-resize:hover, .codex-data-table .codex-column-resize:focus-visible { background: #b58a4388; }
.codex-data-table .codex-filter-indicator { margin-left: .3rem; color: var(--wine, #52242c); font-weight: 700; }
.codex-data-table .codex-table-actions, .codex-data-table .codex-add-column-cell { width: 60px; padding: .15rem .2rem; text-align: center !important; }
.codex-data-table .codex-add-column-cell { width: 60px; padding: .15rem; }
.codex-data-table .codex-table-actions { white-space: nowrap; }
.codex-data-table .codex-row-drag, .codex-data-table .codex-row-menu-trigger { min-width: 1.2rem; min-height: 1.5rem; padding: 0 !important; border: 0; background: transparent; box-shadow: none; color: var(--muted, #705d46); }
.codex-data-table .codex-row-menu-trigger { opacity: 0; }
.codex-data-table tr:hover .codex-row-menu-trigger, .codex-data-table .codex-row-menu-trigger:focus-visible { opacity: 1; }
.codex-data-table .codex-add-column { min-width: 1.7rem; min-height: 1.7rem; padding: 0; border: 0; background: transparent; box-shadow: none; font-size: 1.1rem; }
.codex-data-table .codex-add-row { display: block; width: 100%; min-height: 2.1rem; padding: .3rem .65rem; border: 0; border-top: 1px solid #baa17755; background: transparent; box-shadow: none; color: var(--muted, #705d46); text-align: left; cursor: pointer; }
.codex-data-table .codex-add-row:hover { background: #baa17722; color: var(--wine, #52242c); }
.codex-data-table .codex-add-row[hidden] { display: none; }
.codex-data-table.is-editing td[data-column] { cursor: text; }
.codex-data-table td[data-column] input, .codex-data-table th[data-column] input { display: block; width: 100%; min-width: 0; box-sizing: border-box; margin: 0; padding: .2rem .35rem; border: 1px solid var(--gold, #b58a43); border-radius: 3px; background: var(--field, #fff8e4); color: var(--ink, #372818); box-shadow: 0 0 0 2px #b58a4322; font: inherit; }
.codex-data-table .codex-data-tools { gap: .5rem; }
.codex-data-table .codex-group-label { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted, #705d46); font-size: .82rem; }
.codex-data-table .codex-group-actions[hidden] { display: none; }
.codex-data-table .codex-group-actions summary { border: 0; background: transparent; }
.codex-data-table .codex-column-menu { position: absolute; z-index: 10; display: grid; gap: .1rem; width: min(220px, calc(100vw - 16px)); padding: .3rem; border: 1px solid var(--edge, #baa177); border-radius: 5px; background: var(--field, #fff8e4); box-shadow: 0 5px 18px #37281833; }
.codex-data-table .codex-column-menu button { width: 100%; min-height: 1.9rem; padding: .25rem .45rem; border: 0; border-radius: 3px; background: transparent; color: var(--ink, #372818); box-shadow: none; text-align: left; }
.codex-data-table .codex-column-menu button:hover, .codex-data-table .codex-column-menu button:focus-visible { background: #baa17733; }
.codex-data-table .codex-filter-label { display: grid; gap: .3rem; padding: .3rem .4rem; color: var(--muted, #705d46); font-size: .8rem; }
.codex-data-table .codex-filter-label input { width: 100%; min-width: 0; box-sizing: border-box; }
.codex-data-table .codex-page-label { font-size: .8rem; color: var(--muted, #705d46); white-space: nowrap; }
.codex-data-table .codex-table-group th { padding: .25rem .55rem; background: #e8d4ad; }
.codex-data-table .codex-table-group button { border: 0; background: transparent; box-shadow: none; color: var(--wine, #52242c); font-weight: 600; text-align: left; }
/* Advanced tables sit on the page's parchment instead of bright form surfaces. */
.codex-data-table { --data-head: #e9d4aa; --data-field: #f1e2c1; --data-row: #f3e7cb; }
.codex-data-table .codex-data-header { background: #e9d4aa66; }
.codex-data-table .codex-data-tools { background: #e9d4aa44; }
.codex-data-table :is(.codex-data-tools, .codex-table-pages) :is(input, select, button.secondary),
.codex-data-table .codex-data-menu summary { border-color: var(--edge, #baa177); background: var(--data-field); color: var(--ink, #372818); }
.codex-data-table th { background: var(--data-head); }
.codex-data-table td { background: color-mix(in srgb, var(--data-row) 46%, transparent); }
.codex-data-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--data-row) 68%, transparent); }
.codex-data-table tbody tr:hover td { background: color-mix(in srgb, var(--data-head) 74%, transparent); }
.codex-data-table :is(.codex-data-menu-items, .codex-column-menu) { background: var(--data-field); }
.codex-data-table td[data-column] input, .codex-data-table th[data-column] input { background: var(--data-field); }
.codex-data-table .codex-table-group th { background: color-mix(in srgb, var(--data-head) 82%, var(--gold, #b58a43)); }
html[data-theme="dark"] .codex-data-table { --data-head: #423229; --data-field: #30241f; --data-row: #3b2e25; --wine: var(--dark-heading, #e0bf78); }
@media (pointer: coarse) { .codex-data-table .codex-row-menu-trigger { opacity: 1; } }
.codex-timeline { max-width: 100%; margin: 1rem 0; }
.codex-timeline-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.codex-timeline-tools input { flex: 2 1 12rem; min-width: 0; }
.codex-timeline-tools select { flex: 1 1 10rem; min-width: 0; }
.codex-timeline-events { position: relative; margin: 0; padding: 0 0 0 1.5rem !important; list-style: none; border-left: 3px solid var(--gold, #b58a43); }
.codex-timeline-event { position: relative; display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr); gap: .8rem; margin: 0 0 1rem; padding: .7rem .9rem; border: 1px solid var(--edge, #baa177); border-radius: .5rem; background: var(--field, #fff8e4); }
.codex-timeline-event::before { content: ''; position: absolute; left: calc(-1.5rem - 8px); top: 1rem; width: 12px; height: 12px; border: 2px solid var(--paper, #fff8e4); border-radius: 50%; background: var(--wine, #52242c); }
.codex-timeline-event time { color: var(--wine, #52242c); font-weight: 700; font-variant-numeric: tabular-nums; }
.codex-timeline-copy { min-width: 0; }
.codex-timeline-copy strong { display: block; }
.codex-timeline-copy small { color: var(--muted, #705d46); }
.codex-timeline-copy p { margin: .3rem 0 0; }
@media (max-width: 600px) { .codex-timeline-event { grid-template-columns: 1fr; gap: .2rem; } }
.codex-divider { border: 0; border-top: 1px solid var(--edge, #baa177); margin: 1.2rem 0; }
.codex-link { font-weight: 600; }
.codex-link.missing { font-weight: inherit; }
.codex-image, .codex-cover { margin: 0 0 .75rem; text-align: center; }
.codex-image img { max-width: 100%; max-height: 520px; border-radius: 3px; box-shadow: 0 1px 4px #0004; }
.codex-image figcaption { margin-top: .3rem; font-size: .9rem; color: var(--muted, #705d46); }
.codex-cover { margin: -1.25rem -1.25rem 1rem; overflow: hidden; }
.codex-cover img { display: block; width: 100%; max-height: 260px; object-fit: cover; object-position: center 25%; border-radius: 4px 4px 0 0; }
.codex-cover.is-portrait { display: flex; flex-direction: column; align-items: center; justify-content: center; background: #8e6e4812; border-bottom: 1px solid var(--edge, #baa177); padding: .5rem .75rem; }
html[data-theme="dark"] .codex-cover.is-portrait { background: #00000035; }
.codex-cover.is-portrait img { width: auto; max-width: 100%; max-height: 260px; object-fit: contain; margin: 0 auto; border-radius: 4px; box-shadow: 0 4px 18px #00000028; }
.codex-image-missing { display: inline-block; padding: 1.5rem 2rem; border: 1px dashed var(--edge, #baa177); color: var(--muted, #705d46); font-size: .9rem; }
.codex-cover.broken { margin: 0 0 .75rem; }
.codex-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .9rem; }
.codex-tag { padding: .05rem .5rem; border: 1px solid var(--edge, #baa177); border-radius: 999px; font-size: .78rem; color: var(--muted, #705d46); }

/* Skins: appearance only. */
.codex-skin-handout, .codex-skin-letter, .codex-skin-parchment, .codex-skin-decree { --wine: #52242c; --muted: #6b5638; --edge: #a88d5f; color: #2f2213; }
.codex-page.codex-skin-handout { max-width: 680px; margin-inline: auto; background: #fff8e4; border-color: #d9c69c; box-shadow: 0 6px 16px #0003; transform: rotate(-.4deg); }
.codex-page.codex-skin-handout::before { content: ""; position: absolute; top: -9px; left: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #d46a5a, #7c231c); box-shadow: 0 2px 3px #0005; }
.codex-page.codex-skin-letter { max-width: 640px; margin-inline: auto; padding: 2rem 2.2rem; background: #fbf4e3; border-color: #d8c8a4; box-shadow: 0 6px 18px #0003; font-family: var(--book, "Palatino Linotype", Georgia, serif); }
.codex-skin-letter .codex-body { font-style: italic; font-size: 1.08rem; }
.codex-page.codex-skin-parchment { max-width: 720px; margin-inline: auto; padding: 2rem 2.2rem; border: 0; border-radius: 2px; background: radial-gradient(ellipse at center, #f1dfb1 0, #e2c58b 70%, #c9a565 100%); box-shadow: inset 0 0 40px #8a5f2a66, 0 6px 18px #0003; font-family: var(--book, "Palatino Linotype", Georgia, serif); }
.codex-page.codex-skin-decree { max-width: 720px; margin-inline: auto; padding: 2.2rem; border: 3px double #7a5a2a; background: #f6ead0; box-shadow: 0 6px 18px #0003; text-align: center; font-family: var(--book, "Palatino Linotype", Georgia, serif); }
.codex-skin-decree .codex-title { font-size: 2rem; letter-spacing: .04em; text-transform: uppercase; }
.codex-skin-decree .codex-body { text-align: justify; }
.codex-skin-decree .codex-body::after { content: "✠"; display: block; width: 54px; height: 54px; margin: 1.2rem auto 0; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #b4413a, #6d1a16); color: #f3cfa0; font-size: 1.6rem; line-height: 54px; text-align: center; box-shadow: 0 2px 4px #0005; }
.codex-skin-letter .codex-cover, .codex-skin-parchment .codex-cover, .codex-skin-decree .codex-cover { margin: 0 0 1rem; }
.codex-skin-letter .codex-tags, .codex-skin-parchment .codex-tags, .codex-skin-decree .codex-tags { justify-content: center; }
@media (max-width: 599px) {
  .codex-page.codex-skin-letter, .codex-page.codex-skin-parchment, .codex-page.codex-skin-decree { padding: 1.25rem; }
  .codex-page.codex-skin-handout { transform: none; }
}

html[data-theme="dark"] .codex-page:not(.codex-skin-handout, .codex-skin-letter, .codex-skin-parchment, .codex-skin-decree) { background: var(--panel, #2a201dd9); }

/* Phase 2: quest state, affiliations, gathered lists, newspaper. */
.codex-facts { display: flex; flex-direction: column; gap: .3rem; margin: -.3rem 0 .9rem; }
.codex-fact { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0; font-size: .92rem; }
.codex-fact-label { color: var(--muted, #705d46); }
.codex-fact-label::after { content: ":"; }
.codex-quest-status { padding: .05rem .55rem; border-radius: 999px; border: 1px solid currentColor; font-size: .78rem; font-weight: 700; }
.codex-quest-status.status-available { color: #8a5a14; }
.codex-quest-status.status-active { color: #2f5f7a; }
.codex-quest-status.status-completed { color: #4f6b2f; }
.codex-quest-status.status-failed, .codex-quest-status.status-abandoned { color: #9a2f2f; }
html[data-theme="dark"] .codex-quest-status.status-available { color: #e0a948; }
html[data-theme="dark"] .codex-quest-status.status-active { color: #8fc3e0; }
html[data-theme="dark"] .codex-quest-status.status-completed { color: #9cbf6a; }
html[data-theme="dark"] .codex-quest-status.status-failed, html[data-theme="dark"] .codex-quest-status.status-abandoned { color: #ec8b7f; }
.codex-gathered { margin-top: 1.2rem; padding-top: .4rem; border-top: 1px solid var(--edge, #baa177); }
.codex-gathered ul { margin: 0; padding-left: 1.2rem; }
.codex-gathered li { margin-bottom: .25rem; }
/* The notice board: pinned slips of paper. */
.codex-board ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: .6rem; }
.codex-board li { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; padding: .7rem .8rem; background: #fff8e4; color: #2f2213;
  border: 1px solid #d9c69c; box-shadow: 0 2px 5px #0003; transform: rotate(-.6deg); }
.codex-board li:nth-child(even) { transform: rotate(.7deg); }
.codex-board li .codex-link { color: #52242c; font-family: var(--book, "Palatino Linotype", Georgia, serif); }
.codex-board li .codex-quest-status.status-available { color: #8a5a14; }
.codex-board li .codex-quest-status.status-active { color: #2f5f7a; }
.codex-board li .codex-quest-status.status-completed { color: #4f6b2f; }

/* Newspaper: newsprint, masthead, two columns on wide screens. */
.codex-page.codex-skin-newspaper { --wine: #1f1a14; --muted: #5a5246; --edge: #8c8070; color: #1f1a14; background: #f1ead9; border-color: #b8ab92;
  box-shadow: 0 6px 18px #0003; font-family: Georgia, "Times New Roman", serif; }
.codex-masthead { margin: -.3rem 0 .8rem; padding-bottom: .4rem; border-bottom: 3px double #1f1a14; text-align: center; }
.codex-publication { margin: 0; font: 700 2.3rem/1.05 "Old English Text MT", Georgia, serif; letter-spacing: .02em; }
.codex-issue { margin: .3rem 0 0; padding-top: .25rem; border-top: 1px solid #1f1a14; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; }
.codex-skin-newspaper .codex-title { font: 700 1.9rem/1.15 Georgia, serif; text-align: center; }
.codex-skin-newspaper .codex-heading { font-family: Georgia, serif; border-bottom: 1px solid #8c8070; }
@media (min-width: 760px) {
  .codex-skin-newspaper .codex-body { columns: 2; column-gap: 2rem; column-rule: 1px solid #b8ab92; }
  .codex-skin-newspaper .codex-body > * { break-inside: avoid-column; }
  .codex-skin-newspaper .codex-body > .codex-columns { column-span: all; }
  .codex-skin-newspaper .codex-heading { break-after: avoid-column; }
  .codex-skin-newspaper .codex-body > :first-child { column-span: all; font-size: 1.12rem; }
}
/* Campaign journal, also served by the DDM. */
.codex-journal-view { display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.codex-journal-view > h2, .codex-journal-view > p { margin: 0; }
.codex-journal-filters, .codex-journal-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.codex-journal-filters input { flex: 1 1 12rem; min-width: 0; }
.codex-journal-list { display: grid; gap: .8rem; }
.codex-journal-card, .codex-journal-form { padding: 1rem; border: 1px solid var(--codex-edge, #b89b6c); border-radius: 4px; overflow-wrap: anywhere; }
.codex-journal-card h3 { margin: .3rem 0; }
.codex-journal-card > small { display: block; opacity: .8; }
.codex-journal-card > button, .codex-journal-card > a { margin-top: .6rem; }
.codex-journal-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.codex-journal-label, .codex-journal-date { font-style: italic; }
.codex-journal-form { display: grid; gap: .7rem; margin-bottom: .8rem; }
.codex-journal-form label { display: grid; gap: .25rem; }
.codex-journal-form input, .codex-journal-form textarea, .codex-journal-form select { width: 100%; min-width: 0; box-sizing: border-box; }
.codex-journal-form [hidden] { display: none; }
.codex-journal-form [role=alert]:not(:empty) { border-left: 3px solid #b8793a; padding-left: .7rem; }
.codex-journal-link { display: block; padding: .5rem 0; }
/* Small faction overview; the complete member list remains below it. */
.codex-faction-graph { margin: 1rem 0; }
.codex-faction-graph summary { cursor: pointer; font-weight: 600; }
.codex-faction-scroll { overflow-x: auto; }
.codex-faction-orbit { position: relative; width: 440px; height: 440px; margin: 0 auto; }
.codex-faction-center, .codex-faction-node { position: absolute; transform: translate(-50%, -50%); width: 104px; padding: .45rem; box-sizing: border-box; text-align: center; overflow-wrap: anywhere; border: 1px solid currentColor; border-radius: .5rem; background: var(--codex-paper, Canvas); color: var(--codex-ink, CanvasText); z-index: 1; max-height: 90px; overflow: auto; }
.codex-faction-center { left: 50%; top: 50%; }
.codex-faction-ray { position: absolute; left: 50%; top: 50%; width: 36%; height: 1px; background: currentColor; opacity: .35; transform-origin: left center; }
.codex-diplomacy { margin: 1rem 0; }
.codex-diplomacy summary { cursor: pointer; font-weight: 600; }
.codex-diplomacy table { width: 100%; border-collapse: collapse; }
.codex-diplomacy th, .codex-diplomacy td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--edge, #baa177); overflow-wrap: anywhere; }
.codex-rumours ul { list-style: none; padding: 0; display: grid; gap: .7rem; }
.codex-rumours li { border-left: 3px solid var(--gold, #b58a43); padding: .25rem .8rem; white-space: pre-wrap; }
.codex-rumours li p { margin: 0 0 .3rem; }
.codex-rumours li small { color: var(--muted, #705d46); }
/* Campaign mind maps (C25), shared by player site and DDM. */
.codex-boards { display: grid; gap: .7rem; min-width: 0; }
.codex-boards > h2, .codex-boards > p { margin: 0; }
.codex-board-create, .codex-board-head, .codex-board-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.codex-board-create input, .codex-board-head input { flex: 1 1 12rem; min-width: 0; }
.codex-board-list { display: flex; gap: .5rem; flex-wrap: wrap; }
.codex-board-choice { text-align: left; display: grid; gap: .15rem; }
.codex-board-choice.active { outline: 2px solid var(--gold, #b58a43); }
.codex-board-choice small { font-weight: normal; }
.codex-board-editor { display: grid; gap: .7rem; min-width: 0; }
.codex-board-tools select, .codex-board-tools input { min-width: 0; max-width: 100%; }
.codex-board-scroll { overflow: auto; max-height: min(75vh, 760px); border: 1px solid var(--edge, #baa177); background: var(--field, #f8eed9); }
.codex-board-canvas { width: 2000px; height: 1600px; position: relative; background-image: radial-gradient(currentColor 1px, transparent 1px); background-size: 24px 24px; background-color: var(--paper, #f8eed9); color: var(--muted, #705d46); }
.codex-board-lines { position: absolute; inset: 0; width: 2000px; height: 1600px; pointer-events: none; overflow: visible; }
.codex-board-lines line { stroke: var(--wine, #52242c); stroke-width: 2; }
.codex-board-lines text { fill: var(--ink, #372818); font-size: 16px; font-weight: 600; paint-order: stroke; stroke: var(--paper, #f8eed9); stroke-width: 5px; }
.codex-board-node { position: absolute; box-sizing: border-box; width: 190px; min-height: 84px; padding: .35rem; border: 1px solid var(--edge, #baa177); border-radius: .4rem; background: var(--field, #fff8e4); color: var(--ink, #372818); box-shadow: 0 2px 7px #0003; overflow-wrap: anywhere; }
.codex-board-node.is-page { border-left: 4px solid var(--gold, #b58a43); }
.codex-board-node-head { display: flex; justify-content: space-between; margin-bottom: .25rem; }
.codex-board-handle { touch-action: none; cursor: grab; }
.codex-board-node textarea { width: 100%; min-height: 4rem; box-sizing: border-box; resize: vertical; }
.codex-board-edge-list ul { padding-left: 1.4rem; }
.codex-board-edge-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .3rem 0; }

/* Shared Codex Mind Map surface. Controls use the existing Codex palette. */
.mind-map-embed { display:flex; flex-direction:column; min-height:220px; max-height:900px; min-width:0; border:1px solid var(--edge,#baa177); border-radius:6px; overflow:hidden; background:transparent; }
.mind-map-embed-head { display:flex; align-items:center; justify-content:space-between; gap:.5rem; padding:.35rem .65rem; border-bottom:1px solid var(--edge,#baa177); background:var(--field,#fff8e4); }
.mind-map-embed-head strong { font-family:var(--book,Georgia,serif); color:var(--wine,#52242c); }
.mind-map { position:relative; isolation:isolate; display:flex; flex-direction:column; min-width:0; min-height:350px; height:min(74vh,780px); border:1px solid var(--edge,#baa177); border-radius:5px; overflow:hidden; background:transparent; color:var(--ink,#372818); }
.mind-map.is-embedded { flex:1; min-height:0; height:auto; border:0; border-radius:0; }
.mind-map-toolbar { position:absolute; top:.7rem; left:.7rem; display:flex; flex-direction:column; align-items:center; gap:.15rem; width:2.7rem; padding:.25rem; border:1px solid var(--edge,#baa177); border-radius:8px; background:var(--field,#fff8e4); box-shadow:0 3px 12px #0002; z-index:5; }
.mind-map-toolbar .mind-map-tool { display:grid; place-items:center; width:2.2rem; height:2.2rem; min-width:0; min-height:0; padding:0; border:0; border-radius:5px; background:transparent; color:var(--wine,#52242c); box-shadow:none; font-size:1.25rem; line-height:1; }
.mind-map-toolbar .mind-map-tool:hover,.mind-map-toolbar .mind-map-tool:focus-visible { background:var(--paper,#f8eed9); outline:1px solid var(--gold,#b58a43); }
.mind-map-toolbar .mind-map-tool:active { background:var(--gold,#b58a43); color:var(--field,#fff8e4); }
.mind-map-toolbar .mind-map-tool:disabled { opacity:.35; cursor:default; outline:0; }
.mind-map:not(.is-editable) .mind-map-toolbar { top:auto; bottom:.7rem; }
.mind-map-tool-divider { display:block; width:1.45rem; border-top:1px solid var(--edge,#baa177); margin:.15rem 0; }
.mind-map-canvas-tools { position:absolute; top:.7rem; right:.7rem; display:flex; align-items:center; gap:.2rem; padding:.25rem; border:1px solid var(--edge,#baa177); border-radius:8px; background:var(--field,#fff8e4); box-shadow:0 3px 12px #0002; z-index:5; }
.mind-map-canvas-tools button { min-height:2.2rem; padding:.25rem .55rem; border:0; border-radius:5px; background:transparent; color:var(--wine,#52242c); box-shadow:none; font-size:.78rem; white-space:nowrap; }
.mind-map-canvas-tools button:hover,.mind-map-canvas-tools button:focus-visible { background:var(--paper,#f8eed9); outline:1px solid var(--gold,#b58a43); }
.mind-map-control-icon { margin-right:.3rem; font-size:1rem; }
.mind-map-popover { position:absolute; z-index:7; display:grid; gap:.15rem; padding:.35rem; border:1px solid var(--edge,#baa177); border-radius:7px; background:var(--field,#fff8e4); box-shadow:0 6px 20px #0003; }
.mind-map-popover button { width:100%; min-height:2rem; padding:.3rem .55rem; border:0; border-radius:4px; background:transparent; color:var(--wine,#52242c); box-shadow:none; font-size:.82rem; text-align:left; }
.mind-map-popover button:hover,.mind-map-popover button:focus-visible { background:var(--paper,#f8eed9); }
.mind-map-add-menu { top:.7rem; left:3.8rem; width:min(15rem,calc(100% - 4.5rem)); max-height:calc(100% - 2rem); overflow:auto; }
.mind-map-more-menu { top:3.6rem; right:.7rem; width:min(13rem,calc(100% - 1.4rem)); }
.mind-map-page-picker { display:grid; gap:.25rem; padding:.25rem; }
.mind-map-page-picker[hidden] { display:none; }
.mind-map-page-picker input { width:100%; box-sizing:border-box; }
.mind-map-page-results { max-height:12rem; overflow:auto; }
.mind-map-edge-picker { max-height:12rem; overflow:auto; border-top:1px solid var(--edge,#baa177); padding-top:.25rem; }
.mind-map-edge-picker[hidden] { display:none; }
.mind-map-menu-empty { display:block; padding:.3rem; color:var(--muted,#705d46); font-size:.78rem; }
.mind-map-viewport { position:relative; flex:1; min-height:0; overflow:hidden; cursor:grab; touch-action:none; -webkit-user-select:none; user-select:none; outline-offset:-3px; background:radial-gradient(circle at center,#9c7c4e40 .7px,transparent 1px) 0 0/24px 24px,transparent; }
.mind-map-viewport:active { cursor:grabbing; }
.mind-map-viewport:focus-visible { outline:2px solid var(--gold,#b58a43); }
.mind-map-world { position:absolute; inset:0; width:0; height:0; transform-origin:0 0; }
.mind-map-edges { position:absolute; inset:0; width:1px; height:1px; overflow:visible; pointer-events:none; }
.mind-map.is-editable .mind-map-edges { left:-10000px; top:-10000px; width:20000px; height:20000px; }
.mind-map-edge-hit { stroke:transparent; stroke-width:18; pointer-events:stroke; cursor:pointer; }
.mind-map-edge-hit:hover,.mind-map-edge-hit.selected { stroke:#b58a4350; }
.mind-map-line { stroke:var(--wine,#52242c); stroke-width:2; opacity:.7; }
.mind-map-line.is-mention { stroke-dasharray:7 5; }
.mind-map-line.is-manual { stroke:var(--gold,#b58a43); stroke-width:2.5; }
.mind-map-line.is-obsolete { stroke:#a05b45; stroke-dasharray:3 6; opacity:.5; }
.mind-map-edges text { fill:var(--ink,#372818); font:600 13px system-ui,sans-serif; paint-order:stroke; stroke:var(--paper,#f8eed9); stroke-width:5px; }
.mind-map-node { position:absolute; box-sizing:border-box; width:190px; min-height:86px; padding:.45rem .55rem; border:1px solid var(--edge,#baa177); border-left:3px solid var(--gold,#b58a43); border-radius:5px; background:var(--field,#fff8e4); box-shadow:0 2px 7px #0002; overflow-wrap:anywhere; cursor:pointer; }
.mind-map-node:hover { box-shadow:0 4px 11px #0003; }
.mind-map-node.selected { outline:2px solid var(--wine,#52242c); outline-offset:2px; }
.mind-map-node.is-note { border-left-color:#77866d; background:#f1e6ca; }
.mind-map-node.tone-sage { background:#e7e9d7; }
.mind-map-node.tone-slate { background:#e0e5e6; }
.mind-map-node.is-group { width:360px; min-height:160px; background:#b58a4314; border:1px dashed var(--gold,#b58a43); box-shadow:none; z-index:0; }
.mind-map-node.is-page,.mind-map-node.is-note { z-index:1; }
.mind-map-node small { display:block; color:var(--muted,#705d46); font-size:.72rem; }
.mind-map-node a { color:var(--wine,#52242c); font-family:var(--book,Georgia,serif); font-weight:700; }
.mind-map-node textarea,.mind-map-node input { width:100%; box-sizing:border-box; resize:vertical; font:inherit; }
.mind-map-node button { padding:0 .3rem; min-height:1.4rem; font-size:.8rem; }
.mind-map-node-actions { position:absolute; left:0; bottom:calc(100% + .35rem); z-index:6; display:flex; gap:.1rem; padding:.2rem; border:1px solid var(--edge,#baa177); border-radius:5px; background:var(--field,#fff8e4); box-shadow:0 3px 10px #0002; white-space:nowrap; pointer-events:none; }
.mind-map-node-actions button,.mind-map-node-actions a { display:grid; place-items:center; width:1.65rem; height:1.65rem; min-width:0; min-height:0; padding:0; border:0; border-radius:3px; background:transparent; color:var(--wine,#52242c); box-shadow:none; font:600 1rem/1 system-ui,sans-serif; text-decoration:none; }
.mind-map-node-actions button,.mind-map-node-actions a { pointer-events:auto; }
.mind-map-node-actions button:hover,.mind-map-node-actions a:hover { background:var(--paper,#f8eed9); }
.mind-map-edge-editor { position:absolute; z-index:6; display:grid; gap:.35rem; width:min(16rem,calc(100% - 1rem)); box-sizing:border-box; padding:.55rem; border:1px solid var(--edge,#baa177); border-radius:6px; background:var(--field,#fff8e4); box-shadow:0 5px 16px #0003; }
.mind-map-edge-editor small { color:var(--muted,#705d46); overflow-wrap:anywhere; }
.mind-map-edge-editor input { min-width:0; width:100%; box-sizing:border-box; }
.mind-map-edge-editor button { justify-self:start; font-size:.78rem; }
.mind-map-grab { cursor:grab; touch-action:none; }
.mind-map.is-editable .mind-map-node { cursor:grab; touch-action:none; -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
.mind-map.is-editable .mind-map-node textarea,.mind-map.is-editable .mind-map-node input { cursor:text; -webkit-user-select:text; user-select:text; }
.mind-map.is-editable .mind-map-node textarea:not(:focus),.mind-map.is-editable .mind-map-node input:not(:focus) { touch-action:none; }
.mind-map.is-editable .mind-map-node.is-group .mind-map-resize { position:absolute; z-index:4; display:grid; place-items:center; width:18px; height:42px; min-width:0; min-height:0; padding:0; border:1px solid var(--gold,#b58a43); border-radius:5px; background:var(--map-control,#efdfbd); color:var(--wine,#52242c); box-shadow:0 1px 4px #0003; touch-action:none; }
.mind-map-resize::after { content:'⋮'; font:700 15px/1 system-ui,sans-serif; }
.mind-map.is-editable .mind-map-node.is-group .resize-x { right:-9px; top:50%; transform:translateY(-50%); cursor:ew-resize; }
.mind-map.is-editable .mind-map-node.is-group .resize-y { bottom:-9px; left:50%; transform:translateX(-50%); width:42px; height:18px; cursor:ns-resize; }
.mind-map-resize.resize-y::after { content:'⋯'; }
.mind-map.is-editable .mind-map-node.is-group .resize-xy { right:-9px; bottom:-9px; width:22px; height:22px; cursor:nwse-resize; }
.mind-map-resize.resize-xy::after { content:'◢'; font-size:13px; }
.mind-map-resize:hover,.mind-map-resize:focus-visible { outline:2px solid var(--wine,#52242c); outline-offset:1px; }
@media (pointer:coarse) {
  .mind-map.is-editable .mind-map-node.is-group .resize-x { width:28px; height:48px; right:-14px; }
  .mind-map.is-editable .mind-map-node.is-group .resize-y { width:48px; height:28px; bottom:-14px; }
  .mind-map.is-editable .mind-map-node.is-group .resize-xy { width:32px; height:32px; right:-16px; bottom:-16px; }
}
.mind-map.is-preview .mind-map-viewport { touch-action:auto; cursor:pointer; }
.mind-map-preview-hint { position:absolute; left:50%; bottom:.6rem; z-index:2; transform:translateX(-50%); padding:.3rem .75rem; border-radius:999px; background:var(--wine,#52242c); color:var(--field,#fff8e4); font-size:.8rem; white-space:nowrap; pointer-events:none; box-shadow:0 2px 8px #0003; }
.mind-map-node.is-dragging { cursor:grabbing; z-index:3; box-shadow:0 8px 22px #0004; opacity:.92; }
.mind-map-status { display:block; min-height:1.2rem; padding:.15rem .5rem; font-size:.75rem; color:var(--muted,#705d46); background:var(--field,#fff8e4); }
.mind-map-overlay { position:fixed; inset:0; z-index:10000; display:flex; flex-direction:column; padding:1rem; background:#211b18dc; }
.mind-map-overlay > header { display:flex; justify-content:space-between; align-items:center; gap:1rem; padding:.5rem .8rem; background:var(--field,#fff8e4); color:var(--wine,#52242c); font-family:var(--book,Georgia,serif); }
.mind-map-overlay .mind-map { flex:1; height:auto; border-radius:0; background:var(--paper,#f8eed9); }
.mind-map-context { position:fixed; z-index:10001; display:grid; gap:.2rem; padding:.3rem; border:1px solid var(--edge,#baa177); border-radius:5px; background:var(--field,#fff8e4); box-shadow:0 5px 20px #0004; }
/* Mindmaps use a deeper paper tone so cards and floating controls belong to the canvas. */
.mind-map-embed,.mind-map,.mind-map-overlay,.mind-map-context { --map-paper:#e8d5b0; --map-control:#efdfbd; --map-card:#f0e1c3; }
.mind-map-embed-head,.mind-map-overlay > header,.mind-map-status { background:var(--map-paper); }
.mind-map-toolbar,.mind-map-canvas-tools,.mind-map-popover,.mind-map-node-actions,.mind-map-edge-editor,.mind-map-context { background:var(--map-control); }
.mind-map-node { background:var(--map-card); }
.mind-map-node.is-note { background:#e4dec1; }
.mind-map-node.tone-sage { background:#dce1c9; }
.mind-map-node.tone-slate { background:#d8dedb; }
.mind-map-overlay .mind-map { background:var(--map-paper); }
html[data-theme="dark"] .mind-map-embed,html[data-theme="dark"] .mind-map,html[data-theme="dark"] .mind-map-overlay,html[data-theme="dark"] .mind-map-context { --map-paper:#2b221d; --map-control:#382b23; --map-card:#403125; --wine:var(--dark-heading,#e0bf78); }
html[data-theme="dark"] .mind-map-node.is-note { background:#343a30; }
html[data-theme="dark"] .mind-map-node.tone-sage { background:#333d32; }
html[data-theme="dark"] .mind-map-node.tone-slate { background:#303a3c; }
.cx-map-dialog { width:min(440px,calc(100vw - 2rem)); padding:1.2rem; border:1px solid var(--edge,#baa177); background:var(--field,#fff8e4); color:var(--ink,#372818); box-shadow:0 12px 45px #0005; }
.cx-map-field { margin:.65rem 0; }
.cx-map-field > label { display:block; margin-bottom:.25rem; color:var(--muted,#705d46); font-size:.82rem; }
.cx-map-field-control { display:flex; align-items:center; gap:.45rem; }
.cx-map-field-control > select,.cx-map-field-control > input { flex:1; min-width:0; box-sizing:border-box; }
.cx-map-dialog .cx-map-info { flex:none; display:inline-grid; place-items:center; width:1.7rem; height:1.7rem; min-width:0; min-height:0; padding:0; border:1px solid var(--edge,#baa177); border-radius:50%; background:transparent; color:var(--wine,#52242c); font:italic 700 .9rem Georgia,serif; cursor:pointer; }
.cx-map-dialog .cx-map-info[aria-expanded="true"] { background:var(--paper,#f8eed9); }
.cx-map-help-text { margin:.4rem 0 0; padding:.4rem .6rem; border-left:2px solid var(--gold,#b58a43); background:var(--paper,#f8eed9); font-size:.82rem; line-height:1.4; }
.cx-map-dialog > [hidden] { display:none; }
.cx-map-help-text[hidden] { display:none; }
.cx-dialog-actions { display:flex; justify-content:flex-end; gap:.5rem; }
.cx-mind-map-block { position:relative; min-width:0; padding-bottom:.55rem; }
.cx-map-resize-handle { position:absolute; z-index:3; left:50%; bottom:-.1rem; transform:translateX(-50%); width:3rem; height:.8rem; min-width:0; min-height:0; padding:0; border:1px solid var(--edge,#baa177); border-radius:999px; background:var(--field,#fff8e4); color:var(--muted,#705d46); box-shadow:0 1px 3px #0002; font:700 .7rem/.5rem system-ui,sans-serif; cursor:ns-resize; touch-action:none; }
.cx-map-resize-handle:hover,.cx-map-resize-handle:focus-visible { color:var(--wine,#52242c); border-color:var(--gold,#b58a43); }
.cx-map-height-control { display:flex; align-items:center; justify-content:flex-end; gap:.6rem; min-height:2.25rem; padding:.3rem .65rem; border:1px solid var(--edge,#baa177); border-bottom:0; border-radius:6px 6px 0 0; background:var(--field,#fff8e4); color:var(--muted,#705d46); font:600 .78rem/1.2 system-ui,sans-serif; }
.cx-map-height-control label { display:flex; align-items:center; gap:.6rem; cursor:pointer; }
.cx-map-height-control input[type="range"] { appearance:none; width:clamp(6rem,18vw,10rem); min-height:0; height:1.25rem; margin:0; padding:0; border:0; background:transparent; cursor:pointer; }
.cx-map-height-control input[type="range"]::-webkit-slider-runnable-track { height:6px; border:1px solid var(--edge,#baa177); border-radius:999px; background:linear-gradient(to right,var(--secret,#8c2f3c) var(--height-progress),var(--paper,#e2c999) var(--height-progress)); }
.cx-map-height-control input[type="range"]::-moz-range-track { height:6px; border:1px solid var(--edge,#baa177); border-radius:999px; background:linear-gradient(to right,var(--secret,#8c2f3c) var(--height-progress),var(--paper,#e2c999) var(--height-progress)); }
.cx-map-height-control input[type="range"]::-webkit-slider-thumb { appearance:none; width:18px; height:18px; margin-top:-7px; border:2px solid var(--gold,#b58a43); border-radius:50%; background:radial-gradient(circle,#f5dfab 0 2px,#8c2f3c 2.5px); box-shadow:0 0 0 2px var(--field,#fff8e4),0 2px 4px #21130f66; }
.cx-map-height-control input[type="range"]::-moz-range-thumb { width:14px; height:14px; border:2px solid var(--gold,#b58a43); border-radius:50%; background:radial-gradient(circle,#f5dfab 0 2px,#8c2f3c 2.5px); box-shadow:0 0 0 2px var(--field,#fff8e4),0 2px 4px #21130f66; }
.cx-map-height-control input[type="range"]:focus-visible { outline:2px solid var(--gold,#b58a43); outline-offset:2px; }
.cx-map-height-value { min-width:3.6rem; color:var(--wine,#52242c); font-variant-numeric:tabular-nums; text-align:right; }
.cx-mind-map-block .mind-map-embed { border-top-left-radius:0; border-top-right-radius:0; }
@media (max-width:700px) {
  .mind-map { height:min(70dvh,780px); }
  .mind-map-toolbar { top:.4rem; left:.4rem; }
  .mind-map-canvas-tools { top:.4rem; right:.4rem; }
  .mind-map-canvas-tools button { min-width:2.2rem; padding:.2rem; }
  .mind-map-control-icon { margin:0; }
  .mind-map-control-label { display:none; }
  .mind-map-add-menu { top:.4rem; left:3.5rem; }
  .mind-map-more-menu { top:3.3rem; right:.4rem; }
  .mind-map-overlay { padding:0; }
  .mind-map-overlay > header { padding:.4rem .6rem; }
}
@media (pointer:coarse) {
  .mind-map-toolbar .mind-map-tool { width:2.5rem; height:2.5rem; }
  .mind-map-toolbar { width:3rem; }
  .mind-map-node button { min-width:2rem; min-height:2rem; }
  .mind-map-context button,.mind-map-popover button { min-height:2.5rem; }
}
.codex-location-map, .cx-map-editor { margin: 1.2rem 0; }
.orbis-map { margin: 1.2rem 0 1.6rem; padding: .8rem; border: 1px solid var(--edge); border-radius: 12px; background: var(--paper-light); box-shadow: 0 12px 32px #3522141c; }
.codex-wiki-page.orbis-map-page .codex-body { max-width: none; }
.orbis-map-frame { position: relative; }
.orbis-map-stage { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border: 1px solid var(--gold); border-radius: 8px; background: #ccb992; cursor: grab; touch-action: none; }
.orbis-map-stage.dragging { cursor: grabbing; }
/* The script sizes the surface to the 4:3 map inside the stage. */
.orbis-map-surface { position: absolute; left: 0; top: 0; width: 100%; height: 100%; transform-origin: center; }
.orbis-map-surface.is-moving, .orbis-map-surface.is-moving .orbis-map-pin { transition: transform .28s cubic-bezier(.2, .7, .3, 1); }
.orbis-map-surface > img, .orbis-map-regions, .orbis-map-pins { position: absolute; inset: 0; width: 100%; height: 100%; }
.orbis-map-surface > img { object-fit: fill; user-select: none; pointer-events: none; }
.orbis-map-regions { pointer-events: none; }
.orbis-map-pins { pointer-events: none; }
.orbis-map-region { fill-opacity: .25; stroke-width: 7px; stroke-opacity: .85; pointer-events: auto; cursor: pointer; }
.orbis-map-region:hover { fill-opacity: .45; }
.orbis-map-region.is-selected { fill-opacity: .5; stroke-width: 12px; stroke-opacity: 1; }
.orbis-map-stage.image-missing .orbis-map-region { fill-opacity: .7; }
.orbis-map-stage.image-missing .orbis-map-surface > img { display: none; }
/* Scoped, so app-wide button styles (e.g. the Codex workspace) do not reshape places. */
.orbis-map .orbis-map-stage .orbis-map-pin { position: absolute; display: grid; place-items: center; width: 1.2rem; height: 1.2rem; min-width: 0; min-height: 0; padding: 0; transform: translate(-50%, -50%) scale(var(--pin-scale, 1)); border: 2px solid #fff5da; border-radius: 50%; background: var(--wine-fill, var(--wine)); color: var(--gold-light, #e0bf78); box-shadow: 0 1px 8px #1c1311a6; font-size: .55rem; line-height: 1; pointer-events: auto; cursor: pointer; }
/* The book map's own category icons, on a small parchment seal. */
.orbis-map .orbis-map-stage .orbis-map-pin.has-icon { width: 1.4rem; height: 1.4rem; border: 1.5px solid var(--gold); background: #f6e8c6; box-shadow: 0 1px 5px #1c1311a6; }
/* Fingers get a larger target than the visible seal. */
@media (pointer: coarse) { .orbis-map .orbis-map-stage .orbis-map-pin::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; } }
.orbis-map-pin img { width: 78%; height: 78%; object-fit: contain; pointer-events: none; user-select: none; }
.orbis-map-pin:hover, .orbis-map-pin:focus-visible, .orbis-map-pin.is-selected { z-index: 1; scale: 1.35; outline: 2px solid var(--gold); }
.orbis-map-pin.is-selected { outline-color: var(--wine-fill, var(--wine)); }
/* Tooltip: the book map's popup, above every layer and inside the stage. */
.orbis-map-tip { position: absolute; z-index: 3; width: max-content; max-width: min(19rem, calc(100% - 12px)); max-height: calc(100% - 12px); overflow: auto; padding: .55rem .7rem .6rem; border: 1px solid var(--gold); border-radius: 8px; background: #f8ecd0f7; color: var(--ink); box-shadow: 0 8px 24px #2a1a1052, 0 1px 3px #2a1a1033; font-size: .82rem; line-height: 1.35; cursor: auto; touch-action: auto; }
.orbis-map-tip[hidden] { display: none; }
.orbis-map-tip.passive { pointer-events: none; }
/* An invisible bridge, so the pointer can travel from a place into its tooltip. */
.orbis-map-tip::before { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 16px; }
.orbis-map-tip[data-side="below"]::before { top: auto; bottom: 100%; }
.orbis-map-tip:is([data-side="right"], [data-side="left"])::before { top: 0; bottom: 0; width: 16px; height: auto; }
.orbis-map-tip[data-side="right"]::before { left: auto; right: 100%; }
.orbis-map-tip[data-side="left"]::before { left: 100%; right: auto; }
.orbis-map-tip a { color: var(--wine); font-weight: 600; }
.orbis-map .orbis-map-tip .orbis-map-tip-close { position: absolute; top: .2rem; right: .25rem; width: 1.6rem; height: 1.6rem; min-height: 0; padding: 0; border: 0; background: transparent; box-shadow: none; filter: none; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.orbis-map-tip-close:hover, .orbis-map-tip-close:focus-visible { color: var(--wine); }
/* Narrow stages: the selected place or region as a sheet along the map's lower edge. */
.orbis-map .orbis-map-tip.sheet { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none; max-height: 52%; padding: 1.15rem .95rem .85rem; border-width: 1px 0 0; background: #f8ecd0; border-radius: 14px 14px 0 0; box-shadow: 0 -6px 22px #2a1a1047; font-size: .9rem; overscroll-behavior: contain; }
.orbis-map .orbis-map-tip.sheet::before { inset: .45rem auto auto 50%; width: 2.4rem; height: 4px; margin-left: -1.2rem; border-radius: 2px; background: var(--edge); }
.orbis-map .orbis-map-tip.sheet .orbis-map-tip-close { top: .5rem; right: .45rem; width: 2.25rem; height: 2.25rem; font-size: 1.45rem; }
.orbis-map-tip.sheet .orbis-map-card-head > img { width: 2rem; height: 2rem; }
.orbis-map-tip.sheet .orbis-map-card-head strong { font-size: 1.12rem; }
.orbis-map-tip.sheet dl { grid-template-columns: max-content 1fr; gap: .25rem .9rem; }
.orbis-map-tip.sheet a { display: inline-block; padding: .1rem 0; }
.orbis-map-card-head { display: flex; align-items: center; gap: .5rem; padding-right: 1.2rem; }
.orbis-map-card-head > img { width: 1.6rem; height: 1.6rem; object-fit: contain; flex: none; }
.orbis-map-card-head > span:last-child { display: grid; }
.orbis-map-card-head strong { font: 700 1rem/1.2 var(--book); color: var(--wine); }
.orbis-map-card-head small { color: var(--muted); font-size: .72rem; letter-spacing: .02em; }
.orbis-map-swatch { width: .9rem; height: .9rem; flex: none; border: 1px solid #0000004d; border-radius: 3px; opacity: .75; }
.orbis-map-tip dl, .orbis-map-details dl { display: grid; grid-template-columns: auto 1fr; gap: .12rem .7rem; margin: .45rem 0 0; padding-top: .4rem; border-top: 1px solid var(--edge); }
.orbis-map-tip dt, .orbis-map-details dt { color: var(--muted); }
.orbis-map-tip dd, .orbis-map-details dd { margin: 0; }
.orbis-map-tip dd.wide, .orbis-map-details dd.wide { grid-column: 1 / -1; }
.orbis-map-details { min-height: 2.5rem; margin: .7rem .2rem; padding: .55rem .75rem; border-left: 3px solid var(--gold); background: #ffffff54; }
.orbis-map-details dl { grid-template-columns: max-content 1fr; max-width: 32rem; }
.orbis-map-details a { color: var(--wine); font-weight: 600; }
.orbis-map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .9rem; margin: .55rem .2rem 0; color: var(--muted); font-size: .78rem; }
.orbis-map-legend[hidden] { display: none; }
.orbis-map-legend strong { color: var(--ink); }
.orbis-map-legend span { display: inline-flex; align-items: center; gap: .3rem; }
.orbis-map-legend i { width: .8rem; height: .8rem; border: 1px solid #00000040; border-radius: 2px; opacity: .55; }
.orbis-map-icon { width: 1.05rem; height: 1.05rem; display: block; }
/* Floating controls over the map: search, kinds of places, layers and zoom top right, fullscreen bottom right.
   The overlay lets the map take every pointer except on the controls themselves. */
.orbis-map-controls { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.orbis-map-controls > * { pointer-events: auto; }
.orbis-map-control-group { position: absolute; top: .6rem; right: .6rem; display: flex; flex-direction: column; gap: .35rem; }
.orbis-map-control-gap { height: .2rem; }
.orbis-map .orbis-map-controls .orbis-map-control { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; min-width: 0; min-height: 0; padding: 0; border: 1px solid #b58a43a6; border-radius: 8px; background: #f8ecd0e0; color: var(--wine); box-shadow: 0 2px 8px #2a1a1040, 0 1px 2px #2a1a1030; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); filter: none; cursor: pointer; transition: background-color .15s, border-color .15s, transform .1s; }
.orbis-map .orbis-map-controls .orbis-map-control:hover { background: #fff6e2f2; border-color: var(--gold); filter: none; }
.orbis-map .orbis-map-controls .orbis-map-control:active { transform: scale(.94); }
.orbis-map .orbis-map-controls .orbis-map-control:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.orbis-map .orbis-map-controls .orbis-map-control[aria-expanded="true"], .orbis-map .orbis-map-controls .orbis-map-control.is-active { border-color: var(--wine); }
.orbis-map .orbis-map-controls .orbis-map-control[aria-expanded="true"] { background: var(--wine); color: #fff1d1; }
/* A small seal marks an active search, filter or layer. */
.orbis-map .orbis-map-control-group .orbis-map-control { position: relative; }
.orbis-map-control.is-active:not([aria-expanded="true"])::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border: 1.5px solid #f8ecd0; border-radius: 50%; background: var(--wine); }
.orbis-map-fullscreen { position: absolute; right: .6rem; bottom: calc(.6rem + var(--orbis-map-sheet, 0px)); }
/* The panels open beside the buttons and always inside the map. */
.orbis-map-panel { position: absolute; top: .6rem; right: 3.35rem; display: grid; gap: .1rem; min-width: 10.5rem; max-width: calc(100% - 4.5rem); max-height: calc(100% - 1.2rem); overflow: auto; padding: .4rem; border: 1px solid var(--gold); border-radius: 10px; background: #f8ecd0f5; color: var(--ink); box-shadow: 0 8px 24px #2a1a1052, 0 1px 3px #2a1a1033; font-size: .85rem; overscroll-behavior: contain; }
.orbis-map-panel[hidden] { display: none; }
.orbis-map-panel > strong { padding: .15rem .5rem .3rem; color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.orbis-map .orbis-map-panel button { display: flex; align-items: center; gap: .5rem; justify-content: flex-start; width: 100%; min-height: 2rem; padding: .3rem .55rem; border: 0; border-radius: 6px; background: transparent; box-shadow: none; filter: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.orbis-map .orbis-map-panel button::before { content: ""; flex: none; width: .5rem; height: .5rem; border: 1.5px solid var(--edge); border-radius: 50%; }
.orbis-map .orbis-map-panel button:hover, .orbis-map .orbis-map-panel button:focus-visible { background: #b58a4326; outline: none; }
.orbis-map .orbis-map-panel button[aria-checked="true"] { background: #52242c1a; color: var(--wine); font-weight: 700; }
.orbis-map .orbis-map-panel button[aria-checked="true"]::before { border-color: var(--wine); background: var(--wine); }
.orbis-map-panel button > img { flex: none; width: 1.2rem; height: 1.2rem; object-fit: contain; }
.orbis-map-search-menu { width: 16rem; }
.orbis-map-search-menu input { width: 100%; min-width: 0; box-sizing: border-box; margin: 0; }
html[data-theme="dark"] .orbis-map .orbis-map-controls .orbis-map-control { background: #2b211ee0; border-color: #b58a4380; color: var(--gold-light, #e0bf78); box-shadow: 0 2px 10px #00000080; }
html[data-theme="dark"] .orbis-map .orbis-map-controls .orbis-map-control:hover { background: #3a2c26f2; }
html[data-theme="dark"] .orbis-map .orbis-map-controls .orbis-map-control[aria-expanded="true"] { background: var(--gold); color: #2b211e; }
html[data-theme="dark"] .orbis-map-control.is-active:not([aria-expanded="true"])::after { border-color: #2b211e; background: var(--gold); }
html[data-theme="dark"] .orbis-map-panel { background: #2b211ef5; box-shadow: 0 8px 24px #000000a0; }
html[data-theme="dark"] .orbis-map .orbis-map-panel button[aria-checked="true"] { background: #b58a432e; color: var(--gold-light, #e0bf78); }
html[data-theme="dark"] .orbis-map .orbis-map-panel button[aria-checked="true"]::before { border-color: var(--gold); background: var(--gold); }
/* Fullscreen: the same map on the whole screen. */
.orbis-map.is-fullscreen { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; margin: 0; padding: .75rem; border: 0; border-radius: 0; background: var(--paper-light, var(--paper)); overflow: auto; }
.orbis-map.is-fullscreen .orbis-map-frame { flex: 1 1 auto; min-height: 12rem; display: flex; }
.orbis-map.is-fullscreen .orbis-map-stage { flex: 1 1 auto; width: 100%; height: auto; min-height: 0; aspect-ratio: auto; }
.orbis-map.is-fullscreen .orbis-map-details { flex: none; max-height: 9rem; overflow: auto; }
.orbis-map.is-fullscreen .orbis-map-results { flex: none; max-height: 4.2rem; }
.orbis-map.is-fullscreen .orbis-map-credit { display: none; }
html.orbis-map-covered { overflow: hidden; }
html[data-theme="dark"] .orbis-map-tip { background: #2b211ef7; box-shadow: 0 8px 24px #000000a0; }
html[data-theme="dark"] .orbis-map .orbis-map-tip.sheet { background: #2b211e; }
.orbis-map-results { display: flex; flex-wrap: wrap; gap: .35rem; max-height: 8rem; overflow: auto; }
.orbis-map-result { display: flex; align-items: baseline; gap: .35rem; padding: .3rem .55rem; border: 1px solid var(--edge); border-radius: 999px; background: transparent; color: var(--ink); font-size: .78rem; }
.orbis-map-result small { color: var(--muted); }
.orbis-map-credit { display: block; margin-top: .65rem; color: var(--muted); }
.orbis-map-data { margin: .6rem 0 1.5rem; }
.orbis-map-data > summary { cursor: pointer; color: var(--wine, #52242c); font-weight: 700; }
.orbis-map-data > .codex-heading { margin-top: 1rem; }
.orbis-map-data > .codex-table { margin: .5rem 0 1rem; }
@media (max-width: 640px) {
  .orbis-map { padding: .5rem; }
  .orbis-map .orbis-map-stage .orbis-map-pin { width: 1.5rem; height: 1.5rem; }
  .orbis-map .orbis-map-stage .orbis-map-pin.has-icon { width: 1.6rem; height: 1.6rem; }
  .orbis-map-tip { font-size: .8rem; }
  /* A phone map is taller than wide, like a map app; the map fills it. */
  .orbis-map-stage { aspect-ratio: auto; height: min(68vh, 34rem); height: min(68svh, 34rem); min-height: 18rem; }
  /* Fingers get slightly larger controls. */
  .orbis-map .orbis-map-controls .orbis-map-control { width: 2.5rem; height: 2.5rem; }
  .orbis-map-panel { right: 3.6rem; }
  .orbis-map .orbis-map-panel button { min-height: 2.4rem; }
  .orbis-map.is-fullscreen { padding: .4rem; }
  /* In fullscreen the sheet on the map shows the selection; the panel below would only repeat it. */
  .orbis-map.is-fullscreen .orbis-map-details { display: none; }
}
.codex-map-stage { position: relative; width: 100%; overflow: hidden; border: 1px solid var(--border, #8e887b); border-radius: .55rem; background: #241f1b; }
.codex-map-stage > img { display: block; width: 100%; height: auto; }
.codex-map-marker { position: absolute; display: grid; place-items: center; width: 2rem; height: 2rem; transform: translate(-50%, -50%); border: 2px solid #fff; border-radius: 50%; background: #8d3430; color: #fff; font-size: 1.2rem; line-height: 1; text-decoration: none; box-shadow: 0 2px 8px #0009; cursor: pointer; }
.codex-map-marker:hover, .codex-map-marker:focus-visible, .codex-map-marker.selected { background: #b85731; outline: 3px solid #f0ca69; outline-offset: 2px; }
.codex-map-key { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: .6rem 0 0; padding-left: 1.3rem; }
.cx-map-editor { padding: .7rem 1rem; border: 1px solid var(--border, #8e887b); border-radius: .55rem; }
.cx-map-editor > summary { cursor: pointer; font-weight: 700; }
.cx-map-fields { display: grid; grid-template-columns: minmax(12rem, 2fr) minmax(9rem, 1fr); gap: .7rem; margin: .7rem 0; }
.cx-map-fields input, .cx-map-fields select { width: 100%; }
.cx-map-marker-row { display: flex; flex-wrap: wrap; align-items: end; gap: .4rem; margin: .5rem 0; }
.cx-map-marker-row label { width: 5.5rem; font-size: .85rem; }
.cx-map-marker-row input { width: 100%; }
.cx-map-marker-row button.selected { outline: 2px solid #b85731; }
@media (max-width: 640px) { .cx-map-fields { grid-template-columns: 1fr; } .codex-map-marker { width: 2.3rem; height: 2.3rem; } }

/* Book chapters read like documents; their sections stay on the same page. */
.codex-wiki-page { padding: clamp(1.35rem, 3vw, 2.7rem); }
.codex-wiki-eyebrow { display: block; margin-bottom: .5rem; color: var(--gold, #ab8350); font: 700 .72rem/1.3 "Segoe UI", system-ui, sans-serif; letter-spacing: .15em; text-transform: uppercase; }
.codex-wiki-page .codex-title { font-size: clamp(2rem, 3.5vw, 2.75rem); line-height: 1.14; }
.codex-wiki-page .codex-body { max-width: 78ch; }
.codex-wiki-toc { margin: 1.4rem 0; padding: 1rem 1.2rem; border: 1px solid var(--edge, #baa177); border-radius: 10px; background: color-mix(in srgb, var(--field, #fffaf0) 75%, transparent); }
.codex-wiki-toc > strong { display: block; margin-bottom: .5rem; color: var(--wine, #52242c); font: 700 1.05rem var(--book, Georgia, serif); }
.codex-wiki-toc ol { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 225px), 1fr)); gap: .2rem 1rem; margin: 0; padding-left: 1.2rem; }
.codex-wiki-toc li { padding-left: .1rem; color: var(--gold, #ab8350); }
.codex-wiki-toc button { display: inline; min-height: 0; padding: .2rem 0; border: 0; background: transparent; box-shadow: none; color: var(--wine, #52242c); font: 500 .92rem/1.35 "Segoe UI", system-ui, sans-serif; text-align: left; white-space: normal; }
.codex-wiki-toc button:hover { text-decoration: underline; filter: none; }
.codex-wiki-section { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--edge, #baa177); scroll-margin-top: 5rem; }
.codex-wiki-heading { margin: 0 0 .8rem; font: 700 1.45rem/1.25 var(--book, Georgia, serif); color: var(--wine, #52242c); }
.codex-wiki-section .codex-heading { margin-top: 1.2rem; }
.codex-wiki-parts { margin-top: 2rem; }
.codex-wiki-part { margin-top: 1.6rem; }
.codex-wiki-part > h3 { margin: 0 0 .75rem; padding-bottom: .4rem; border-bottom: 1px solid var(--edge, #baa177); color: var(--wine, #52242c); font: 700 1.3rem/1.3 var(--book, Georgia, serif); }
.codex-wiki-chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 205px), 1fr)); gap: .65rem; }
.codex-wiki-chapter { display: flex; flex-direction: column; gap: .4rem; padding: .8rem 1rem; border: 1px solid var(--edge, #baa177); border-radius: 9px; color: var(--ink, #372818); text-decoration: none; background: var(--field, #fffaf0); }
.codex-wiki-chapter:hover { border-color: var(--gold, #ab8350); }
.codex-wiki-chapter span { color: var(--muted, #705d46); font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; }
.codex-wiki-chapter strong { font: 700 1.05rem/1.25 var(--book, Georgia, serif); color: var(--wine, #52242c); }
.codex-wiki-chapter span:last-child { align-self: flex-end; }
.codex-tree-part, .cx-tree-part { margin: .9rem 0 .3rem; padding: .35rem .55rem; border-bottom: 1px solid var(--edge, #baa177); color: var(--gold, #ab8350); font: 700 .71rem/1.3 "Segoe UI", system-ui, sans-serif; letter-spacing: .07em; text-transform: uppercase; list-style: none; }

/* Mentions: a small page (or person) icon and the name, read as part of the sentence. */
.codex-mention { padding: 0 .12em; border-radius: 4px; text-decoration: none; }
a.codex-mention:hover { background: #8e6e4824; }
.codex-mention-label { text-decoration: underline; text-decoration-color: #8e6e4880; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.codex-mention.missing .codex-mention-label { text-decoration: none; }
.codex-mention-icon { display: inline-block; width: .95em; height: .95em; margin-right: .2em; vertical-align: -.12em; background: currentColor; opacity: .72;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M3.5 1.5h6L13 5v9.5H3.5z'/%3E%3Cpath d='M9.5 1.5V5H13M6 8.5h4.5M6 11h4.5' stroke-width='1.2'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linejoin='round'%3E%3Cpath d='M3.5 1.5h6L13 5v9.5H3.5z'/%3E%3Cpath d='M9.5 1.5V5H13M6 8.5h4.5M6 11h4.5' stroke-width='1.2'/%3E%3C/svg%3E") center / contain no-repeat; }
.codex-character .codex-mention-icon { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Ccircle cx='8' cy='5' r='3'/%3E%3Cpath d='M2.5 14.5c.6-3 2.8-4.5 5.5-4.5s4.9 1.5 5.5 4.5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Ccircle cx='8' cy='5' r='3'/%3E%3Cpath d='M2.5 14.5c.6-3 2.8-4.5 5.5-4.5s4.9 1.5 5.5 4.5'/%3E%3C/svg%3E"); }
.codex-mention-line { margin: .4rem 0; }

/* Journal: quests first (list grouped by state, or a board), then notes. */
.codex-journal-title { margin: 0 0 1rem; font-family: var(--book, "Palatino Linotype", Georgia, serif); color: var(--wine, #52242c); }
.codex-quest-overview, .codex-journal-notes { margin-bottom: 1.6rem; }
.codex-quest-overview-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .7rem; }
.codex-quest-overview-head h2 { margin: 0; font-family: var(--book, "Palatino Linotype", Georgia, serif); color: var(--wine, #52242c); font-size: 1.3rem; }
.codex-view-switch { display: inline-flex; padding: 2px; border: 1px solid var(--edge, #baa177); border-radius: 999px; }
.codex-view-switch button { min-height: 24px; padding: .05rem .75rem; border: 0; border-radius: 999px; background: transparent; color: var(--muted, #705d46); font-size: .8rem; }
.codex-view-switch button[aria-pressed=true] { background: var(--wine-fill, #52242c); color: #fff1d1; }
.codex-quest-group + .codex-quest-group { margin-top: 1rem; }
.codex-quest-group > h3, .codex-quest-column > h3 { display: flex; align-items: center; gap: .4rem; margin: 0 0 .5rem; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted, #705d46); font-family: inherit; }
.codex-quest-column > h3 small { padding: 0 .4rem; border-radius: 999px; background: #8e6e4826; }
.codex-quest-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: .7rem; }
.codex-quest-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: .7rem; }
.codex-quest-column { display: flex; flex-direction: column; gap: .55rem; min-width: 0; padding: .6rem; border-radius: 10px; background: #8e6e4814; }
.codex-quest-empty { margin: 0; color: var(--muted, #705d46); text-align: center; }
.codex-quest-card { display: flex; flex-direction: column; gap: .4rem; min-width: 0; padding: .7rem .8rem; border: 1px solid var(--edge, #baa177); border-left: 3px solid var(--gold, #b58a43); border-radius: 9px; background: var(--sheet, #fbf1dad9); }
.codex-quest-card.status-active { border-left-color: #2f5f7a; }
.codex-quest-card.status-completed { border-left-color: #4f6b2f; opacity: .9; }
.codex-quest-card.status-failed, .codex-quest-card.status-abandoned { border-left-color: #9a2f2f; opacity: .85; }
.codex-quest-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.codex-quest-card h3 { margin: 0; font-family: var(--book, "Palatino Linotype", Georgia, serif); font-size: 1.05rem; overflow-wrap: anywhere; }
.codex-quest-card h3 a { color: var(--wine, #52242c); text-decoration: none; }
.codex-quest-card h3 a:hover { text-decoration: underline; }
.codex-quest-progress { display: flex; align-items: center; gap: .5rem; }
.codex-quest-progress small { flex: none; color: var(--muted, #705d46); font-size: .78rem; }
.codex-quest-bar { flex: 1; height: 6px; overflow: hidden; border-radius: 999px; background: #8e6e4830; }
.codex-quest-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--gold, #b58a43); }
.codex-quest-next { margin: 0; font-size: .88rem; }
.codex-quest-next small { display: block; color: var(--muted, #705d46); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; }
.codex-quest-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .1rem .6rem; margin: 0; font-size: .84rem; }
.codex-quest-facts dt { color: var(--muted, #705d46); }
.codex-quest-facts dd { margin: 0; overflow-wrap: anywhere; }
html[data-theme="dark"] .codex-quest-card { background: var(--raised, #33271f); }
html[data-theme="dark"] .codex-quest-column { background: #00000029; }

/* The Questtafel is a physical surface; these rules do not affect quest pages. */
.codex-questtafel { min-width: 0; padding: clamp(1rem, 2.4vw, 2rem); border: 10px ridge #684326; border-radius: 3px; background: linear-gradient(#120c0780, #120c0726 24%, #120c075c), url("assets/quest-board-wood.jpg") center top / 760px auto repeat; box-shadow: inset 0 0 0 2px #a0713e, inset 0 0 38px 10px #140b07a8, 0 14px 32px #170e0a5c; color: #f2deae; }
.codex-questtafel-head { position: relative; width: fit-content; max-width: 100%; margin: 0 auto 1.2rem; padding: .45rem 2rem .65rem; border-top: 1px solid #d0a56b6e; border-bottom: 1px solid #100b08; background: linear-gradient(90deg, transparent, #1d100bd9 18%, #1d100bd9 82%, transparent); text-align: center; text-shadow: 0 2px 3px #100906; }
.codex-questtafel-head small { color: #e9c98b; font: 700 .7rem/1.3 Georgia, serif; text-transform: uppercase; letter-spacing: .25em; }
.codex-questtafel-head h1 { margin: .15rem 0; color: #f9e6b9; font: small-caps 700 clamp(1.9rem, 3vw, 2.6rem)/1.1 var(--book, Georgia, serif); letter-spacing: .08em; }
.codex-questtafel-head p { margin: 0; color: #e5d1aa; font: italic .9rem/1.4 var(--book, Georgia, serif); }
.codex-questtafel-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .6rem 1rem; margin: 0 auto 1.5rem; }
.codex-questtafel-toolbar input { box-sizing: border-box; flex: 0 1 230px; min-width: 170px; max-width: 260px; min-height: 38px; padding: .45rem .7rem; border: 1px solid #a17b48; border-radius: 2px; background: #f6e7bf url("assets/quest-parchment.jpg") center / 100% 100%; color: #352318; box-shadow: 0 2px 4px #0c07064d; font: .9rem var(--book, Georgia, serif); }
.codex-questtafel-toolbar input::placeholder { color: #65543f; opacity: 1; }
.codex-questtafel-toolbar input:focus-visible, .codex-questtafel-filters button:focus-visible { outline: 3px solid #f8d991; outline-offset: 2px; }
.codex-questtafel-filters { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem; }
.codex-questtafel-filters button { min-height: 38px; padding: .35rem .65rem; border: 1px solid #8e663b; border-bottom-color: #3f2818; border-radius: 2px; background: linear-gradient(#9a6b3f, #58371f); color: #fff0cd; box-shadow: inset 0 1px #d7aa70, 0 2px 4px #10090670; font: 700 .8rem var(--book, Georgia, serif); text-shadow: 0 1px #271509; cursor: pointer; }
.codex-questtafel-filters button:hover { background: linear-gradient(#ab7c48, #684127); }
.codex-questtafel-filters button[aria-pressed=true] { border-color: #efce8d; background: #e1c28a url("assets/quest-parchment.jpg") center / 100% 100%; color: #39251b; box-shadow: inset 0 0 0 1px #6f4b30, 0 2px 5px #10090680; text-shadow: none; }
.codex-questtafel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 265px), 1fr)); align-items: start; gap: clamp(1rem, 2vw, 1.6rem); padding: .25rem .4rem .8rem; }
.codex-questtafel-card { position: relative; display: flex; flex-direction: column; gap: .7rem; box-sizing: border-box; min-width: 0; min-height: 275px; padding: 2.25rem 1.15rem 1.1rem; border: 1px solid #8c6539; border-radius: 2px 4px 3px 6px; background: #efd9a6 url("assets/quest-parchment.jpg") center / 100% 100%; box-shadow: 2px 3px 1px #322013, 5px 9px 15px #100906aa, inset 0 0 18px #8c5b2530; color: #342416; cursor: pointer; transform: rotate(var(--tilt, -1deg)); transition: transform .18s ease, box-shadow .18s ease; isolation: isolate; }
.codex-questtafel-card:nth-child(4n+2) { --tilt: 1.2deg; margin-top: .6rem; }
.codex-questtafel-card:nth-child(4n+3) { --tilt: -.4deg; margin-top: .2rem; }
.codex-questtafel-card:nth-child(4n+4) { --tilt: .7deg; }
.codex-questtafel-card::before { content: ""; position: absolute; z-index: 1; top: .55rem; left: 50%; width: 16px; height: 16px; transform: translateX(-50%); border: 1px solid #422919; border-radius: 50%; background: radial-gradient(circle at 32% 27%, #ead39c 0 12%, #a57842 24%, #5b3823 69%, #311c13 100%); box-shadow: 1px 2px 2px #3d241d8c, 0 0 0 2px #6d431d24; pointer-events: none; }
.codex-questtafel-card:nth-child(3n)::before { background: radial-gradient(circle at 30% 25%, #d5ab91, #8c463c 48%, #582921 100%); }
.codex-questtafel-card:hover, .codex-questtafel-card:focus-within { z-index: 2; transform: translateY(-6px) rotate(0deg); box-shadow: 3px 5px 2px #322013, 9px 18px 23px #100906bb, inset 0 0 18px #8c5b2530; }
.codex-questtafel-card:focus-visible { outline: 3px solid #ffdf90; outline-offset: 4px; }
.codex-questtafel-card .codex-quest-card-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: .4rem; }
.codex-questtafel-card .codex-quest-status { display: inline-block; padding: .2rem .45rem; border: 2px double currentColor; border-radius: 1px; background: transparent; color: #61442e; font: 800 .7rem/1.1 Georgia, serif; letter-spacing: .07em; text-transform: uppercase; transform: rotate(-5deg); }
.codex-questtafel-card .codex-quest-status.status-available { color: #61442e; }
.codex-questtafel-card .codex-quest-status.status-active { color: #38516a; }
.codex-questtafel-card .codex-quest-status.status-completed { color: #49623b; }
.codex-questtafel-card .codex-quest-status.status-failed, .codex-questtafel-card .codex-quest-status.status-abandoned { color: #854337; }
.codex-questtafel-card .codex-tag { padding: 0; border: 0; border-radius: 0; color: #65503a; font: italic .78rem var(--book, Georgia, serif); }
.codex-questtafel-card h3 { margin: .1rem 0 0; padding-bottom: .35rem; border-bottom: 1px solid #74553580; color: #412a1a; font: small-caps 700 1.35rem/1.14 var(--book, Georgia, serif); letter-spacing: .015em; overflow-wrap: anywhere; }
.codex-questtafel-description { margin: 0; color: #382819; font: 1rem/1.48 var(--book, Georgia, serif); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.codex-questtafel-reward { margin: auto 0 0; padding-top: .4rem; color: #50341e; font: .92rem/1.35 var(--book, Georgia, serif); overflow-wrap: anywhere; }
.codex-questtafel-reward > span { color: #9c6623; font-size: 1.15rem; }
.codex-questtafel-location { color: #624930; font: italic .85rem var(--book, Georgia, serif); }
.codex-questtafel-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .55rem; margin-top: .1rem; padding-top: .6rem; border-top: 1px solid #74553580; }
.codex-questtafel-actions a { margin-left: auto; color: #61351f; font: 700 .88rem var(--book, Georgia, serif); text-decoration: underline; text-underline-offset: 2px; }
.codex-questtafel-actions a:hover { color: #882f26; }
.codex-questtafel-accept { min-height: 42px; padding: .35rem .75rem; border: 1px solid #653222; border-radius: 2px; background: linear-gradient(#a94a3a, #6f2d27); color: #fff3d8; box-shadow: inset 0 1px #d48165, 0 2px 3px #492b1b55; font: 700 .9rem var(--book, Georgia, serif); cursor: pointer; }
.codex-questtafel-accept:hover { background: linear-gradient(#bb5744, #81352b); }
.codex-questtafel-accept:disabled { opacity: .7; cursor: wait; }
.codex-questtafel-accepted { color: #49623b; font: italic 700 .88rem var(--book, Georgia, serif); }
.codex-questtafel-message { margin: 0 0 .7rem; padding: .55rem .8rem; background: #f0d7a9; color: #7b2720; font-weight: 700; }
.codex-questtafel-message:empty { display: none; }
.codex-questtafel-empty { grid-column: 1 / -1; width: fit-content; max-width: 100%; margin: 0 auto; padding: 1rem 1.4rem; background: #efd9a6 url("assets/quest-parchment.jpg") center / 100% 100%; box-shadow: 3px 6px 12px #10090699; color: #432c1b; text-align: center; }
.codex-questtafel-empty-board { padding: 2.3rem 1.5rem; }
.codex-questtafel-empty-board > span { color: #7e3f2e; font-size: 1.7rem; }
.codex-questtafel-empty-board h2 { margin: .35rem 0; color: #412a1a; font: 700 1.25rem var(--book, Georgia, serif); }
.codex-questtafel-empty-board p { margin: 0; }
@media (max-width: 720px) {
  .codex-questtafel { padding: .85rem .65rem 1.2rem; border-width: 7px; }
  .codex-questtafel-head { padding: .45rem .5rem .65rem; }
  .codex-questtafel-toolbar { align-items: stretch; }
  .codex-questtafel-toolbar input { flex: 1 1 100%; max-width: none; }
  .codex-questtafel-filters { width: 100%; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding: .1rem 0 .4rem; scrollbar-width: thin; }
  .codex-questtafel-filters button { flex: none; }
  .codex-questtafel-grid { grid-template-columns: 1fr; gap: 1rem; padding: .2rem .15rem; }
  .codex-questtafel-card, .codex-questtafel-card:nth-child(n) { min-height: 0; margin-top: 0; transform: none; }
  .codex-questtafel-card:hover, .codex-questtafel-card:focus-within { transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) { .codex-questtafel-card { transition: none; } .codex-questtafel-card:hover, .codex-questtafel-card:focus-within { transform: none; } }
.codex-own-category { margin: .7rem 0 1rem; }
/* The player's block editor, laid out like the GM editor (editor.css .cx-block): a 48px gutter with ⋮ and +,
   fields that look like the rendered text, and menus. Own pages are ordinary .codex-page pages. */
.codex-own-titlebar { display: flex; align-items: center; gap: .3rem; margin: 0 0 .8rem 48px; }
.codex-own-title { display: block; flex: 1; min-width: 0; margin: 0; padding: .2rem .3rem; border: 0; border-bottom: 1px solid transparent; background: transparent;
  color: var(--wine, #52242c); font: 700 1.7rem/1.25 var(--book, "Palatino Linotype", Georgia, serif); box-shadow: none; }
.codex-own-page-menu { flex: none; }
.codex-own-status-line { min-height: 1.1rem; padding: .3rem 0 0 48px; font-size: .78rem; }
.codex-own-author { margin: -.3rem 0 1rem; font-size: .85rem; }
.codex-shared-own small { font-size: .78rem; }
/* Who reads a block: only the two choices that differ from the default "Nur DM & ich" are marked. */
.codex-visibility-badge { display: block; padding: .15rem .4rem 0; font-size: .75rem; color: var(--muted, #705d46); }
.codex-visibility-badge.is-party { color: var(--wine, #52242c); }
.codex-player-popover-heading { padding: .25rem .65rem .1rem; font-size: .75rem; color: var(--muted, #705d46); }
.codex-own-title:hover, .codex-own-title:focus { border-bottom-color: var(--edge, #baa177); outline: 0; }
.codex-own-blocks { display: flex; flex-direction: column; }
.codex-own-block { position: relative; display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: start; }
.codex-own-gutter { display: flex; gap: 2px; padding-top: .35rem; }
.codex-own-handle { display: inline-flex; align-items: center; justify-content: center; min-height: 22px; width: 22px; padding: 0; border: 0; border-radius: 3px;
  background: transparent; box-shadow: none; color: var(--muted, #705d46); font-size: 1rem; line-height: 1; cursor: pointer; }
.codex-own-handle:hover, .codex-own-handle:focus-visible { background: #0000001a; color: var(--wine, #52242c); filter: none; }
.codex-own-handle[draggable=true] { cursor: grab; }
.codex-own-block-body { min-width: 0; padding: 1px 0; }
.codex-own-field { position: relative; min-width: 0; }
.codex-own-text { display: block; width: 100%; min-height: 2.5rem; margin: 0; padding: .3rem .4rem; resize: none; overflow: hidden; border: 1px solid transparent; border-radius: 3px;
  background: transparent; box-shadow: none; color: inherit; font: inherit; font-size: 1.02rem; line-height: 1.6; }
.codex-own-text:hover { border-color: #00000014; }
.codex-own-text:focus { border-color: var(--edge, #baa177); background: transparent; outline: 0; }
.codex-own-text::placeholder { color: var(--muted, #705d46); opacity: 0; }
.codex-own-text:focus::placeholder, .codex-own-block:hover .codex-own-text::placeholder, .codex-own-block:first-child .codex-own-text::placeholder { opacity: .6; }
.codex-own-heading-1, .codex-own-heading-2, .codex-own-heading-3 { font-family: var(--book, "Palatino Linotype", Georgia, serif); font-weight: 700; color: var(--wine, #52242c); line-height: 1.25; }
.codex-own-heading-1 { font-size: 1.45rem; margin-top: .7rem; }
.codex-own-heading-2 { font-size: 1.25rem; margin-top: .5rem; }
.codex-own-heading-3 { font-size: 1.08rem; margin-top: .3rem; color: var(--muted, #705d46); }
/* Formatted text over the raw field while it is not focused (editor.css .cx-inline-preview). */
.codex-own-inline { position: absolute; inset: 0; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; pointer-events: none; }
.codex-own-inline[hidden], .codex-own-field:focus-within > .codex-own-inline { display: none; }
.codex-own-field.has-markup:not(:focus-within) > textarea { color: transparent; }
.codex-own-list-row { display: flex; align-items: flex-start; gap: .35rem; }
.codex-own-list-row .codex-own-field { flex: 1; }
.codex-own-list-row > input[type=checkbox] { margin-top: .55rem; }
.codex-own-list-row > button { min-height: 26px; padding: 0 .45rem; border-color: transparent; background: transparent; box-shadow: none; color: var(--muted, #705d46); }
.codex-own-list-row > button:hover { border-color: var(--edge, #baa177); }
.codex-own-add-end { padding: .6rem 0 0 48px; }
.codex-own-menu, .codex-player-popover { position: absolute; z-index: 1000; display: flex; flex-direction: column; min-width: 200px; max-width: calc(100vw - 16px); max-height: 60vh; overflow: auto; padding: 4px;
  border: 1px solid var(--edge, #baa177); border-radius: 4px; background: var(--field, #fffaf0); box-shadow: 0 6px 18px #0005; }
.codex-own-menu button, .codex-player-popover button { justify-content: flex-start; width: 100%; min-height: 28px; padding: .3rem .65rem; border: 0; border-radius: 2px; background: transparent; box-shadow: none; color: var(--ink, #372818); text-align: left; }
.codex-own-menu button:hover, .codex-own-menu button:focus, .codex-player-popover button:hover, .codex-player-popover button:focus, .codex-player-popover button.active { background: var(--wine-fill, var(--wine, #52242c)); color: #fff1d1; filter: none; outline: 0; }
.codex-own-menu button:disabled, .codex-player-popover button:disabled { opacity: .45; background: transparent; color: var(--ink, #372818); }
.codex-player-popover button.danger { color: var(--secret, #8c2f3c); }
.codex-own-menu hr, .codex-player-popover hr { width: 100%; margin: 3px 0; border: 0; border-top: 1px solid var(--edge, #baa177); }
.codex-own-document.is-inline { margin: 0; padding: 0; }
.codex-own-document.is-inline .codex-own-block:first-child .codex-own-text { min-height: 2.5rem; }
.codex-own-inline-status { padding: .1rem 0 0 48px; font-size: .78rem; color: var(--muted, #705d46); }
@media (hover: none) { .codex-own-handle { min-height: 32px; width: 32px; } .codex-own-block { grid-template-columns: 66px minmax(0, 1fr); } .codex-own-add-end, .codex-own-inline-status, .codex-own-status-line { padding-left: 66px; } .codex-own-titlebar { margin-left: 66px; } }
@media (max-width: 720px) { .codex-own-document:not(.is-inline) { padding: .8rem .5rem 1rem; } }

/* Player contributions between the blocks of a GM page: a quiet edge in the player colour, author and visibility
   in a small line above, the discussion folded underneath. The + in the gutter inserts below the block. */
.codex-page.has-slots .codex-body { padding-left: 2.2rem; }
:is(.codex-body, .codex-column) > .codex-slot { position: relative; margin: -.75rem 0 0; min-height: .75rem; }
:is(.codex-body, .codex-column) > .codex-slot:first-child { margin-top: 0; }
:is(.codex-body, .codex-column) > .codex-slot.has-entries { margin-bottom: .75rem; padding-top: .75rem; }
:is(.cx-content, .cx-content .codex-column) > .codex-slot { min-height: .25rem; margin-left: 48px; }
:is(.cx-content, .cx-content .codex-column) > .codex-slot.has-entries { padding: .5rem 0; }
.codex-insert { position: absolute; z-index: 2; left: -2.2rem; top: calc(.375rem - 11px); display: inline-flex; align-items: center; justify-content: center; width: 22px; min-height: 22px; padding: 0;
  border: 0; border-radius: 3px; background: transparent; box-shadow: none; color: var(--muted, #705d46); font-size: 1rem; line-height: 1; opacity: 0; cursor: pointer; transition: opacity .12s; }
.codex-insert:hover, .codex-insert:focus-visible { background: #0000001a; color: var(--wine, #52242c); filter: none; }
:is(.codex-body, .codex-column) > :hover + .codex-slot > .codex-insert, .codex-slot:hover > .codex-insert, .codex-insert:focus-visible { opacity: 1; }
@media (hover: none) { .codex-insert { opacity: .5; width: 30px; min-height: 30px; left: -2.3rem; top: calc(.375rem - 15px); } }
.codex-contribution { --player: #4d6a87; position: relative; margin: 0 0 .5rem; padding: 0; border: 0; background: transparent; }
html[data-theme="dark"] .codex-contribution { --player: #8fb0cf; }
.codex-contribution:last-child { margin-bottom: 0; }
.codex-contribution-head { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .45rem; margin-bottom: .15rem; font-size: .8rem; color: var(--muted, #705d46); }
.codex-contribution-head strong { color: var(--player); font-weight: 600; }
.codex-contribution-head button { min-height: 22px; padding: 0 .4rem; border: 0; border-radius: 3px; background: transparent; box-shadow: none; color: var(--muted, #705d46); font-size: .8rem; }
.codex-contribution-head button:hover, .codex-contribution-head button:focus-visible { background: #0000001a; color: var(--wine, #52242c); filter: none; }
.codex-contribution-actions { margin-left: auto; display: inline-flex; gap: .1rem; opacity: 0; transition: opacity .12s; }
.codex-contribution:hover .codex-contribution-actions, .codex-contribution:focus-within .codex-contribution-actions { opacity: 1; }
@media (hover: none) { .codex-contribution-actions { opacity: 1; } }
.codex-contribution-body > * { margin: 0 0 .5rem; }
.codex-contribution-body > :last-child { margin-bottom: 0; }
.codex-contribution.is-editing { padding-left: 0; }
.codex-contribution.is-editing > .codex-own-document { width: calc(100% + 48px); margin-left: -48px; border: 0; }
@media (hover: none) { .codex-contribution.is-editing > .codex-own-document { width: calc(100% + 66px); margin-left: -66px; } }
.codex-thread-toggle { display: inline-flex; align-items: center; gap: .25rem; min-height: 22px; margin-top: .25rem; padding: 0 .35rem; border: 0; border-radius: 3px;
  background: transparent; box-shadow: none; color: var(--muted, #705d46); font-size: .8rem; }
.codex-thread-toggle:hover, .codex-thread-toggle:focus-visible { background: #0000001a; color: var(--wine, #52242c); filter: none; }
.codex-thread { display: grid; gap: .4rem; margin: .35rem 0 .2rem; padding-left: .7rem; border-left: 1px solid var(--edge, #baa177); font-size: .92rem; }
.codex-reply-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .45rem; font-size: .78rem; color: var(--muted, #705d46); }
.codex-reply-head strong { color: var(--ink, #372818); font-size: .85rem; }
.codex-reply.is-gm .codex-reply-head strong { color: var(--wine, #52242c); }
.codex-reply-head button { min-height: 20px; padding: 0 .35rem; border: 0; border-radius: 3px; background: transparent; box-shadow: none; color: var(--muted, #705d46); font-size: .78rem; }
.codex-reply-head button:hover, .codex-reply-head button:focus-visible { background: #0000001a; color: var(--wine, #52242c); filter: none; }
.codex-reply-quote { margin: .1rem 0; padding-left: .45rem; border-left: 2px solid var(--edge, #baa177); color: var(--muted, #705d46); font-size: .8rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.codex-reply p { margin: .1rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.codex-reply-form { display: grid; gap: .3rem; }
.codex-reply-form textarea { width: 100%; min-height: 2.2rem; resize: vertical; font-size: .92rem; }
.codex-reply-form > div { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.codex-reply-form small { color: var(--muted, #705d46); }
/* Collaborative Codex maps (custom-map.js): the Augusta map's frame, controls and tooltips with editing on top. */
.custom-map .orbis-map-stage { aspect-ratio: auto; height: var(--custom-map-height, 480px); background: #2b231d; }
.custom-map.is-fullscreen .orbis-map-stage { height: auto; }
.custom-map .orbis-map-stage[data-mode="marker"], .custom-map .orbis-map-stage[data-mode="region"] { cursor: crosshair; }
.custom-map .orbis-map-stage.dragging { cursor: grabbing; }
.custom-map .orbis-map-region { stroke-width: 2px; vector-effect: non-scaling-stroke; fill-opacity: .22; }
.custom-map .orbis-map-region:hover { fill-opacity: .38; }
.custom-map .orbis-map-region.is-selected { fill-opacity: .42; stroke-width: 3.5px; }
.custom-map .orbis-map-region.is-draft { stroke-dasharray: 6 4; }
.custom-map-sketch { pointer-events: none; }
.custom-map-sketch-line { fill: none; stroke-width: 2.5px; stroke-dasharray: 7 5; vector-effect: non-scaling-stroke; }
.custom-map-sketch-fill { fill-opacity: .18; stroke: none; }
.custom-map .orbis-map-stage .orbis-map-pin.is-draft { outline: 2px dashed var(--wine, #52242c); outline-offset: 2px; }
.custom-map-handles { pointer-events: none; }
.custom-map .orbis-map-stage .custom-map-handle { position: absolute; display: grid; place-items: center; width: .9rem; height: .9rem; min-width: 0; min-height: 0; padding: 0; transform: translate(-50%, -50%) scale(var(--pin-scale, 1)); border: 2px solid var(--wine, #52242c); border-radius: 50%; background: #fff6e2; box-shadow: 0 1px 4px #1c131180; color: var(--wine, #52242c); font: 700 .7rem/1 system-ui, sans-serif; pointer-events: auto; cursor: grab; filter: none; }
.custom-map .orbis-map-stage .custom-map-handle.is-first { width: 1.15rem; height: 1.15rem; background: var(--gold, #b58a43); cursor: pointer; }
.custom-map .orbis-map-stage .custom-map-handle.is-active { background: var(--wine, #52242c); }
.custom-map .orbis-map-stage .custom-map-handle.is-midpoint { width: .85rem; height: .85rem; border-width: 1px; border-style: dashed; background: #fff6e2cc; cursor: copy; }
@media (pointer: coarse) { .custom-map .orbis-map-stage .custom-map-handle::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; } }
.custom-map-seal { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; box-sizing: border-box; border: 2px solid #fff5da; border-radius: 50%; background: var(--wine-fill, var(--wine, #52242c)); color: var(--gold-light, #e0bf78); font-size: .55rem; line-height: 1; flex: none; }
.custom-map-description p { margin: .35rem 0 0; }
.custom-map-links { margin: .45rem 0 0; padding: .4rem 0 0 1.1rem; border-top: 1px solid var(--edge); }
.custom-map-links li + li { margin-top: .15rem; }
.custom-map .orbis-map-tip .custom-map-tip-edit { margin-top: .5rem; min-height: 1.9rem; padding: .2rem .7rem; border: 1px solid var(--gold); border-radius: 6px; background: transparent; box-shadow: none; filter: none; color: var(--wine); font-weight: 600; font-size: .78rem; cursor: pointer; }
.custom-map-caption { margin-top: .5rem; }
.custom-map-footer { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.35rem 1rem; margin-top:.5rem; }
.custom-map-footer .custom-map-caption { min-width:0; margin-top:0; }
.custom-map-footer .cx-map-height-control { min-height:1.5rem; margin-left:auto; padding:0; border:0; background:transparent; }
.custom-map-status { margin: .5rem .2rem 0; font-size: .85rem; color: var(--muted); }
.custom-map-status[data-kind="error"] { color: var(--danger, #9b2c2c); font-weight: 600; }
.custom-map-status[data-kind="ok"] { color: #3c6b37; }
.custom-map-status[hidden] { display: none; }
.custom-map-loading, .custom-map-empty { margin: 0; padding: 1rem; color: var(--muted); }
.custom-map-empty-state { display: grid; justify-items: center; gap: .45rem; padding: 2.4rem 1rem; border: 1px dashed var(--gold); border-radius: 8px; background: #ffffff40; text-align: center; }
.custom-map-empty-state strong { font: 700 1.15rem/1.2 var(--book, Georgia, serif); color: var(--wine); }
.custom-map-empty-state p { margin: 0; max-width: 28rem; color: var(--muted); font-style: italic; }
.custom-map-empty-state small { color: var(--muted); }
.custom-map-missing { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: #f8ecd0; }
.custom-map .orbis-map-panel .custom-map-results { display: grid; gap: .1rem; margin-top: .3rem; max-height: 16rem; overflow: auto; }
.custom-map .orbis-map-panel .custom-map-result::before { display: none; }
.custom-map .orbis-map-panel .custom-map-result > img, .custom-map .orbis-map-panel .custom-map-result > .orbis-map-swatch, .custom-map .orbis-map-panel .custom-map-result > .custom-map-seal { width: 1.2rem; height: 1.2rem; flex: none; object-fit: contain; }
.custom-map .orbis-map-panel .custom-map-result > span:last-child { display: grid; min-width: 0; }
.custom-map .orbis-map-panel .custom-map-result small { color: var(--muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-map-none { margin: .3rem .5rem; color: var(--muted); font-size: .8rem; }
.custom-map .orbis-map-panel button[role="menuitemcheckbox"]::before { border-radius: 3px; }
.custom-map .orbis-map-panel button[role="menuitemcheckbox"][aria-checked="true"] { background: #52242c1a; color: var(--wine); font-weight: 700; }
.custom-map .orbis-map-panel button[role="menuitemcheckbox"][aria-checked="true"]::before { border-color: var(--wine); background: var(--wine); }
/* Editing: a compact toolbar above the map and a small form under it, so the whole image stays reachable. */
.custom-map-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin: 0 0 .5rem; }
.custom-map-toolbar[hidden], .custom-map-tools[hidden] { display: none; }
.custom-map-tools { display: contents; }
.custom-map .custom-map-toolbar .custom-map-edit { padding: .25rem .8rem; border: 1px solid var(--gold); background: #fffaf0; color: var(--wine); }
.custom-map .custom-map-toolbar .custom-map-edit.is-active { border-color: var(--wine); background: var(--wine); color: #fff1d1; }
.custom-map-modes, .custom-map-drawing, .custom-map-image-tools { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid #b58a43a6; border-radius: 9px; background: #f8ecd0eb; box-shadow: 0 2px 8px #2a1a1040; }
.custom-map-drawing[hidden] { display: none; }
.custom-map .custom-map-toolbar button { min-height: 2rem; padding: .25rem .65rem; border: 0; border-radius: 7px; background: transparent; box-shadow: none; filter: none; color: var(--ink); font: 600 .8rem/1.2 system-ui, sans-serif; cursor: pointer; }
.custom-map .custom-map-toolbar button:hover { background: #b58a4326; }
.custom-map .custom-map-toolbar button:disabled { opacity: .45; cursor: default; background: transparent; }
.custom-map .custom-map-toolbar button.is-active, .custom-map .custom-map-toolbar button.primary:not(:disabled) { background: var(--wine); color: #fff1d1; }
.custom-map-hint { color: var(--muted); font-size: .78rem; line-height: 1.3; }
.custom-map-editor-host { margin-top: .5rem; }
.custom-map-editor-host:empty { display: none; }
.custom-map-editor-host .custom-map-editor { max-width: 34rem; }
.custom-map.is-fullscreen .custom-map-toolbar, .custom-map.is-fullscreen .custom-map-editor-host { flex: none; }
.custom-map.is-fullscreen .custom-map-editor-host { max-height: 45%; overflow: auto; overscroll-behavior: contain; }
.custom-map-editor { display: grid; gap: .55rem; padding: .7rem .8rem .8rem; border: 1px solid var(--gold); border-radius: 10px; background: #f8ecd0f7; color: var(--ink); box-shadow: 0 8px 24px #2a1a1052; font-size: .85rem; }
.custom-map-editor-title { font: 700 1rem/1.2 var(--book, Georgia, serif); color: var(--wine); }
.custom-map-editor label, .custom-map-field { display: grid; gap: .2rem; }
.custom-map-editor label > span, .custom-map-field > span { color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.custom-map-editor input, .custom-map-editor textarea { width: 100%; box-sizing: border-box; margin: 0; font: inherit; }
.custom-map-editor textarea { resize: vertical; min-height: 3.5rem; }
.custom-map-icons, .custom-map-colors { display: flex; flex-wrap: wrap; gap: .3rem; }
.custom-map .custom-map-icons button, .custom-map .custom-map-colors button { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; min-width: 0; min-height: 0; padding: 0; border: 1px solid var(--edge); border-radius: 8px; background: #fffaf0; box-shadow: none; filter: none; cursor: pointer; }
.custom-map .custom-map-icons button img { width: 1.35rem; height: 1.35rem; object-fit: contain; }
.custom-map .custom-map-colors button::after { content: ""; width: 1.2rem; height: 1.2rem; border-radius: 4px; background: var(--swatch); opacity: .85; }
.custom-map .custom-map-icons button[aria-checked="true"], .custom-map .custom-map-colors button[aria-checked="true"] { border: 2px solid var(--wine); background: #52242c14; }
.custom-map-chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.custom-map-chips:empty { display: none; }
.custom-map-chip { display: inline-flex; align-items: center; gap: .2rem; padding: .1rem .2rem .1rem .55rem; border: 1px solid var(--edge); border-radius: 999px; background: #fffaf0; font-size: .78rem; }
.custom-map .custom-map-chip button { width: 1.3rem; height: 1.3rem; min-width: 0; min-height: 0; padding: 0; border: 0; background: transparent; box-shadow: none; filter: none; color: var(--muted); cursor: pointer; }
.custom-map-help { margin: 0; color: var(--muted); font-size: .76rem; }
.custom-map .custom-map-help button { margin-top: .3rem; }
.custom-map-form-message { margin: 0; color: var(--danger, #9b2c2c); font-size: .8rem; }
.custom-map-form-message[hidden] { display: none; }
.custom-map-editor-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
.custom-map .custom-map-editor button { min-height: 2.1rem; padding: .3rem .8rem; border: 1px solid var(--gold); border-radius: 7px; background: #fffaf0; box-shadow: none; filter: none; color: var(--wine); font: 600 .8rem/1.2 system-ui, sans-serif; cursor: pointer; }
.custom-map .custom-map-editor button.primary { border-color: var(--wine); background: var(--wine); color: #fff1d1; }
.custom-map .custom-map-editor button.danger { margin-right: auto; border-color: var(--danger, #9b2c2c); background: transparent; color: var(--danger, #9b2c2c); }
.custom-map .custom-map-editor button:disabled { opacity: .5; cursor: default; }
html[data-theme="dark"] .custom-map .custom-map-toolbar .custom-map-edit:not(.is-active) { background: var(--raised, #3a2c26); color: var(--gold-light, #e0bf78); }
html[data-theme="dark"] .custom-map-modes, html[data-theme="dark"] .custom-map-drawing, html[data-theme="dark"] .custom-map-image-tools, html[data-theme="dark"] .custom-map-editor { background: #2b211ef5; color: var(--ink); }
html[data-theme="dark"] .custom-map .custom-map-icons button, html[data-theme="dark"] .custom-map .custom-map-colors button, html[data-theme="dark"] .custom-map-chip, html[data-theme="dark"] .custom-map .custom-map-editor button:not(.primary):not(.danger) { background: var(--raised, #3a2c26); }
@media (max-width: 640px) {
  .custom-map .orbis-map-stage { height: min(var(--custom-map-height, 480px), 68svh); min-height: 18rem; }
  .custom-map.is-fullscreen .orbis-map-stage { height: auto; }
  .custom-map .custom-map-toolbar button { min-height: 2.4rem; }
  .custom-map-hint { flex-basis: 100%; }
}
.cx-custom-map-block { min-width: 0; }
.cx-custom-map-block .custom-map { margin: 0; }
.codex-widget-timeline { max-width: 100%; min-width: 0; padding: 1rem; margin: 1rem 0; color: var(--ink, #372818); background: color-mix(in srgb, var(--paper, #e2c999) 88%, var(--wine-fill, #52242c)); border: 1px solid var(--edge, #baa177); border-radius: 9px; box-shadow: 0 3px 14px #28161b2b; }
.codex-timeline-header, .codex-timeline-toolbar { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.codex-timeline-header { justify-content: space-between; margin-bottom: .8rem; padding: .7rem .85rem; border: 1px solid var(--wine-fill, #52242c); border-radius: 6px; background: var(--wine-fill, #52242c); color: #f3dfad; }
.codex-timeline-header button { color: #f3dfad; border-color: #d3ac6880; background: #ffffff12; }
.codex-timeline-title { margin: 0; color: #f3dfad; font-family: var(--book, Georgia, serif); font-size: 1.25rem; overflow-wrap: anywhere; }
.codex-timeline-title[contenteditable=true] { outline: 1px dashed #d3ac68; padding: .2rem .4rem; border-radius: 4px; }
.codex-timeline-toolbar { margin-bottom: 1rem; }
.codex-timeline-toolbar input[type=search] { flex: 1 1 180px; min-width: 0; max-width: 360px; }
.codex-timeline-toolbar input, .codex-timeline-toolbar select { background: var(--field, #f8ecd0); border: 1px solid var(--edge, #baa177); color: var(--ink, #372818); }
.codex-timeline-group-filter { flex: 0 1 11rem; max-width: 100%; }
.codex-timeline-group-filter[hidden] { display: none; }
.codex-timeline-views { display: inline-flex; border: 1px solid var(--edge, #baa177); border-radius: 6px; overflow: hidden; }
.codex-timeline-views button { border: 0; border-radius: 0; background: transparent; color: var(--wine, #692c3d); padding: .4rem .7rem; }
.codex-timeline-views button.active { background: var(--wine-fill, #52242c); color: #f3dfad; }
.codex-timeline-list { position: relative; }
.codex-timeline-list:before { content: ''; position: absolute; top: .65rem; bottom: .65rem; left: 8.3rem; border-left: 2px solid var(--gold, #b58a43); }
.codex-timeline-entry { display: grid; grid-template-columns: 7.6rem 1.4rem minmax(0, 1fr); gap: .1rem; margin-bottom: .6rem; align-items: start; }
.codex-timeline-date { text-align: right; padding: .55rem .4rem 0 0; color: var(--wine, #52242c); font-size: .85rem; font-weight: 700; overflow-wrap: anywhere; }
.codex-timeline-marker { position: relative; z-index: 1; width: .65rem; height: .65rem; margin: .68rem auto 0; border-radius: 50%; background: var(--wine-fill, #52242c); border: 2px solid var(--paper, #e2c999); box-shadow: 0 0 0 1px var(--gold, #b58a43); }
.codex-timeline-card { min-width: 0; padding: .6rem .8rem; border: 1px solid var(--edge, #baa177); border-left: 3px solid var(--gold, #b58a43); border-radius: 5px; background: color-mix(in srgb, var(--paper, #e2c999) 74%, var(--field, #f8ecd0)); box-shadow: 0 2px 5px #28161b17; }
.codex-timeline-card-date { display: block; color: var(--muted, #705d46); font-size: .74rem; margin-bottom: .1rem; }
.codex-timeline-event-title { display: block; padding: 0; border: 0; background: none; color: var(--wine, #542435); font-weight: 700; text-align: left; white-space: normal; overflow-wrap: anywhere; cursor: pointer; }
.codex-timeline-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; min-width: 0; }
.codex-timeline-chip { display: inline-block; max-width: 100%; padding: .15rem .45rem; border: 1px solid var(--edge, #d8c7b8); border-radius: 999px; background: var(--paper, #f4e9d8); color: var(--wine, #643043); font-size: .78rem; overflow-wrap: anywhere; text-decoration: none; }
.codex-timeline-group { display: inline-block; max-width: 100%; margin-top: .35rem; padding: .12rem .45rem; border: 1px solid var(--gold, #b58a43); border-radius: 4px; background: color-mix(in srgb, var(--gold, #b58a43) 22%, var(--paper, #e2c999)); color: var(--wine, #52242c); font-size: .75rem; font-weight: 700; overflow-wrap: anywhere; }
.codex-timeline-detail { margin-top: .55rem; border-top: 1px solid var(--edge, #baa177); padding-top: .5rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.codex-timeline-detail p { margin: 0 0 .5rem; }
.codex-timeline-actions, .codex-timeline-form-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.codex-timeline-empty { padding: 1.5rem; text-align: center; color: var(--muted, #705d46); }
.codex-timeline-empty p { margin: .3rem 0 .8rem; }
.codex-timeline-table-scroll { max-width: 100%; overflow-x: auto; }
.codex-timeline-table { width: 100%; border-collapse: collapse; }
.codex-timeline-table th, .codex-timeline-table td { padding: .5rem; border-bottom: 1px solid var(--edge, #baa177); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.codex-timeline-table tbody tr:nth-child(4n+1) { background: color-mix(in srgb, var(--field, #f8ecd0) 45%, transparent); }
.codex-timeline-table th { color: var(--wine, #52242c); font-size: .83rem; }
.codex-timeline-form { margin-top: 1rem; padding: .85rem; border: 1px solid var(--edge, #baa177); border-radius: 7px; background: color-mix(in srgb, var(--paper, #e2c999) 58%, var(--field, #f8ecd0)); }
.codex-timeline-form h4 { margin: 0 0 .7rem; color: var(--wine, #52242c); }
.codex-timeline-field { display: block; margin-bottom: .6rem; }
.codex-timeline-field > span { display: block; margin-bottom: .2rem; font-size: .82rem; font-weight: 600; }
.codex-timeline-field input, .codex-timeline-field textarea { box-sizing: border-box; width: 100%; max-width: 100%; }
.codex-timeline-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.codex-timeline-page-results { max-height: 12rem; overflow: auto; }
.codex-timeline-page-results button { display: block; width: 100%; text-align: left; }
.codex-timeline-error { color: #9d2234; margin: .3rem 0; }
@media (max-width: 600px) {
  .codex-widget-timeline { padding: .8rem; }
  .codex-timeline-header { padding: .85rem; }
  .codex-timeline-toolbar { gap: .75rem; }
  .codex-timeline-toolbar input[type=search] { flex-basis: 100%; max-width: none; }
  .codex-timeline-list:before { left: .68rem; top: .3rem; bottom: .7rem; }
  .codex-timeline-entry { grid-template-columns: 1.4rem minmax(0, 1fr); column-gap: .55rem; row-gap: 0; margin-bottom: 1.25rem; }
  .codex-timeline-date { grid-column: 2; grid-row: 1; padding: 0 0 .4rem; text-align: left; font-size: .82rem; }
  .codex-timeline-marker { grid-column: 1; grid-row: 1 / span 2; margin: .2rem auto 0; }
  .codex-timeline-card { grid-column: 2; grid-row: 2; padding: .85rem .9rem; }
  .codex-timeline-card-date { display: none; }
  .codex-timeline-event-title { min-height: 2rem; line-height: 1.4; }
  .codex-timeline-chips { gap: .4rem; margin-top: .6rem; }
  .codex-timeline-chip { padding: .3rem .55rem; }
  .codex-timeline-detail { margin-top: .75rem; padding-top: .7rem; }
  .codex-timeline-form-grid { grid-template-columns: 1fr; gap: 0; }
  .codex-timeline-table { min-width: 560px; }
}

/* Mind Map embeds use a compact phone preview; maps keep their original sizing. */
@media (max-width: 720px) {
  .mind-map-embed { height: clamp(280px, 49svh, 364px) !important; min-height: 280px; }

  .codex-table:not(.codex-editable-table), .codex-editable-table .codex-data-scroll, .codex-timeline-table-scroll {
    max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain; touch-action: pan-x pan-y;
  }
  .codex-table table { font-size: .92rem; }
  .codex-table th, .codex-table td { border-right: 1px solid #baa17733; }
  .codex-table-filter, .codex-data-tools, .codex-data-heading, .codex-data-actions,
  .codex-editable-table .codex-table-pages { flex-wrap: wrap; min-width: 0; }
  .codex-data-tools > *, .codex-data-heading > *, .codex-data-actions > * { max-width: 100%; }
  .codex-data-menu-items { max-width: calc(100vw - 24px); max-height: min(55dvh, 20rem); overflow: auto; }
  .codex-data-table .codex-column-menu { max-height: min(55dvh, 20rem); overflow: auto; box-sizing: border-box; }
  .codex-editable-table :is(input, select) { scroll-margin-bottom: 35dvh; }
  .codex-editable-table.is-editing :is(td, th) input,
  .codex-editable-table.is-editing th select { min-height: 2.5rem; font-size: 1rem; }
  .codex-editable-table :is(button.secondary.small, .codex-data-menu summary),
  .codex-data-table :is(.codex-column-trigger, .codex-row-drag, .codex-row-menu-trigger, .codex-add-column),
  .codex-simple-table :is(.codex-column-drag, .codex-column-delete),
  .codex-table-pages button { min-width: 2.5rem; min-height: 2.5rem; }
  .codex-data-table .codex-row-menu-trigger { opacity: 1; }
}

/* Columns (block.layout, codex-render.js arrangeBlocks): blocks side by side, each column as wide as its share.
   Narrow screens stack the columns in reading order. */
.codex-columns { position: relative; display: flex; align-items: flex-start; gap: 1.5rem; min-width: 0; }
.codex-column { flex: 1 1 0; min-width: 0; }
.codex-column > * { margin: 0 0 .75rem; }
.codex-column > :last-child { margin-bottom: 0; }
.codex-column .codex-image, .codex-column .codex-image img { max-width: 100%; }
:is(.cx-content, .codex-own-blocks, .character-codex-blocks) .codex-columns { gap: 0; padding: 6px 0; }
:is(.cx-content, .codex-own-blocks, .character-codex-blocks) .codex-column > * { margin: 0; }
.codex-column-resizer { position: relative; flex: none; align-self: stretch; width: 14px; cursor: col-resize; touch-action: none; }
.codex-column-resizer::before { content: ''; position: absolute; top: 4px; bottom: 4px; left: 6px; width: 2px; border-radius: 2px; background: transparent; transition: background .12s; }
.codex-columns:hover > .codex-column-resizer::before { background: #00000014; }
.codex-column-resizer:hover::before, .cx-resizing .codex-column-resizer::before { background: var(--gold, #b58a43); }
@media (max-width: 720px) {
  .codex-columns { flex-direction: column; align-items: stretch; gap: .75rem; }
  .codex-column { flex: none; width: 100%; }
  .codex-column-resizer { display: none; }
}

/* Arranging blocks in the editors (codex-arrange.js): the selection, the frame drawn to select, where a drop lands. */
.cx-selected { border-radius: 4px; box-shadow: inset 0 0 0 100vmax #b58a4329, 0 0 0 1px #b58a438c; }
.cx-select-band { position: fixed; z-index: 1000; border: 1px solid #b58a43cc; border-radius: 2px; background: #b58a431f; pointer-events: none; }
.cx-drag-badge { position: fixed; z-index: 1001; padding: .2rem .5rem; border-radius: 4px; background: var(--wine, #52242c); color: #fff1d1; font-size: .78rem; white-space: nowrap; pointer-events: none; box-shadow: 0 3px 10px #0004; }
body.cx-arranging, body.cx-arranging * { user-select: none; -webkit-user-select: none; }
body.cx-resizing, body.cx-resizing * { cursor: col-resize !important; }
.codex-own-block.cx-dragging { opacity: .55; }
:is(.codex-own-block, .codex-columns).cx-drop-before::before, :is(.codex-own-block, .codex-columns).cx-drop-after::after { content: ''; position: absolute; z-index: 2; left: 0; right: 0; height: 3px; border-radius: 3px; background: var(--gold, #b58a43); pointer-events: none; }
:is(.codex-own-block, .codex-columns).cx-drop-before::before { top: -2px; }
:is(.codex-own-block, .codex-columns).cx-drop-after::after { bottom: -2px; }
.cx-drop-left, .cx-drop-right { border-radius: 4px; box-shadow: inset 0 0 0 100vmax #b58a4314; }
.cx-drop-left::before, .cx-drop-right::after { content: ''; position: absolute; z-index: 2; top: 0; bottom: 0; width: 3px; border-radius: 3px; background: var(--gold, #b58a43); pointer-events: none; }
.cx-drop-left::before { left: 44px; }
.cx-drop-right::after { right: -2px; }
@media (hover: none) { .cx-drop-left::before { left: 62px; } }

/* Visual refinement shared by the Codex mind map and Orbis Stage. */
.mind-map { border-radius:12px; box-shadow:0 10px 30px #0002; }
.mind-map-viewport { background:radial-gradient(circle at center,#9c7c4e35 .7px,transparent 1px) 0 0/24px 24px,var(--paper,#f8eed9); }
.mind-map-toolbar,.mind-map-canvas-tools,.mind-map-popover,.mind-map-edge-editor { border-radius:10px; box-shadow:0 8px 24px #0003; }
.mind-map-toolbar .mind-map-tool,.mind-map-canvas-tools button,.mind-map-popover button { border-radius:7px; transition:background .15s ease,transform .15s ease,color .15s ease; }
.mind-map-toolbar .mind-map-tool:hover,.mind-map-canvas-tools button:hover,.mind-map-popover button:hover { transform:translateY(-1px); }
.mind-map-node { border-radius:10px; padding:.55rem .65rem; box-shadow:0 5px 16px #0002; transition:box-shadow .17s ease,border-color .17s ease,transform .17s ease; }
.mind-map-node:hover { box-shadow:0 9px 24px #0003; border-color:var(--gold,#b58a43); }
.mind-map-node.selected { outline:2px solid var(--gold,#b58a43); outline-offset:2px; box-shadow:0 10px 27px #0004; }
.mind-map-node.is-dragging { box-shadow:0 15px 34px #0005; opacity:.96; }
.mind-map-node.is-group { border-radius:14px; }
.mind-map-line { stroke-linecap:round; stroke-linejoin:round; opacity:.8; }
.mind-map-edge-hit:hover,.mind-map-edge-hit.selected { stroke:#b58a4370; }
.mind-map-node-actions { border-radius:8px; padding:.25rem; box-shadow:0 7px 20px #0003; }
.mind-map-node-actions button,.mind-map-node-actions a { border-radius:5px; }
.mind-map-node-actions button:focus-visible,.mind-map-node-actions a:focus-visible,.mind-map-popover button:focus-visible { outline:2px solid var(--gold,#b58a43); outline-offset:1px; }
@media(pointer:coarse){.mind-map-node-actions button,.mind-map-node-actions a { width:2.2rem; height:2.2rem; }}
