/* Shadowdark-Westmarches-Portal: Dunkelheit, Pergament, Fackellicht. */
:root {
  --bg: #0d0c0b;
  --bg-2: #161412;
  --panel: #1b1916;
  --line: #34302a;
  --line-2: #4a443b;
  --text: #e9e3d6;
  --muted: #9d958a;
  --torch: #e0a43a;
  --torch-dim: #a8772a;
  --blood: #c4503f;
  --ok: #8fae6b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 4px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(ellipse 900px 500px at 50% -120px, rgba(224, 164, 58, .09), transparent 70%);
  background-repeat: no-repeat;
  color: var(--text);
  font: 17px/1.6 var(--serif);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--torch); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #f3c46c; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4, h5 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: .01em; margin: 1.4em 0 .5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin-top: .2em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.12rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
code { font-family: var(--mono); font-size: .85em; background: var(--bg-2); border: 1px solid var(--line); padding: .05em .35em; border-radius: 3px; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }

/* Kopfzeile */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem max(16px, calc((100vw - 1180px) / 2 + 16px));
  border-bottom: 1px solid var(--line);
  background: rgba(13, 12, 11, .92);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: .95rem; }
.brand:hover { color: var(--torch); }
.navwrap { margin-left: auto; }
.navwrap > summary {
  list-style: none; cursor: pointer; font: 600 .8rem var(--sans); letter-spacing: .12em; text-transform: uppercase;
  border: 1px solid var(--line-2); padding: .4rem .8rem; border-radius: var(--radius); color: var(--text);
}
.navwrap > summary::-webkit-details-marker { display: none; }
.navwrap nav { display: flex; flex-direction: column; gap: .1rem; padding: .6rem 0; }
.navwrap nav a {
  font: 500 .92rem var(--sans); color: var(--muted); text-decoration: none; padding: .45rem .2rem;
}
.navwrap nav a:hover, .navwrap nav a.on { color: var(--text); }
.navwrap nav a.on { box-shadow: inset 0 -2px 0 var(--torch); }
.navsep { height: 1px; background: var(--line); margin: .3rem 0; }
.gm-badge { font: 700 .62rem var(--sans); letter-spacing: .1em; color: var(--bg); background: var(--torch); padding: .05rem .3rem; border-radius: 2px; vertical-align: 2px; }

@media (max-width: 859px) {
  .navwrap { width: 100%; margin-left: 0; order: 3; }
  .navwrap:not([open]) { width: auto; margin-left: auto; order: 0; }
  .navwrap[open] > summary { display: inline-block; float: right; margin-top: -2.4rem; }
}
@media (min-width: 860px) {
  .navwrap > summary { display: none; }
  .navwrap nav { flex-direction: row; align-items: center; gap: 1.1rem; padding: 0; }
  .navsep { width: 1px; height: 1.2rem; margin: 0 .2rem; }
}

/* Seite */
.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.6rem 16px 3rem; flex: 1; }
.narrow { max-width: 620px; }
.page.narrow { margin: 0 auto; }
.foot {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  padding: 1.2rem max(16px, calc((100vw - 1180px) / 2 + 16px));
  border-top: 1px solid var(--line); color: var(--muted); font: .8rem var(--sans); letter-spacing: .04em;
}

.hero { padding: .6rem 0 1.4rem; border-bottom: 1px solid var(--line); margin-bottom: 1.6rem; }
.hero h1 { margin: .1em 0 .2em; }
.eyebrow { font: 600 .74rem var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--torch); margin: 0 0 .5rem; }

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.pagehead h1 { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Panels & Raster */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem 1.1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; margin-bottom: .6rem; }
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.more { font: .82rem var(--sans); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .38rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
ul.plain li:last-child { border-bottom: 0; }
.tag { font: 600 .68rem var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-2); padding: .08rem .4rem; border-radius: 2px; white-space: nowrap; }
.tag.secret { color: var(--blood); border-color: var(--blood); }
.tag.lock { color: var(--torch); border-color: var(--torch-dim); }

/* Buttons & Formulare */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 .86rem var(--sans); letter-spacing: .03em;
  color: var(--text); background: var(--bg-2); border: 1px solid var(--line-2);
  padding: .55rem .95rem; border-radius: var(--radius); text-decoration: none; cursor: pointer;
  min-height: 40px;
}
.btn:hover { border-color: var(--torch-dim); color: var(--text); }
.btn.primary { background: var(--torch); border-color: var(--torch); color: #1a1208; }
.btn.primary:hover { background: #f0b850; color: #1a1208; }
.btn.danger { color: var(--blood); border-color: #6a2e25; background: transparent; }
.btn.small { padding: .3rem .65rem; min-height: 32px; font-size: .78rem; }
.btn.ghost { background: transparent; }

.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font: 600 .8rem var(--sans); letter-spacing: .04em; color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); font-weight: 500; }
input, select, textarea {
  font: 16px/1.4 var(--sans); color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: var(--radius); padding: .55rem .65rem; width: 100%;
}
textarea { font: 15px/1.55 var(--mono); min-height: 14rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--torch-dim); outline-offset: 0; border-color: var(--torch-dim); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--torch); }
input[type=file] { padding: .4rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem 1rem; display: grid; gap: .8rem; margin: 0; }
legend { font: 600 .74rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--torch); padding: 0 .4rem; }
.row { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.row.stats { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); }

.mdhelp { font: .8rem var(--sans); color: var(--muted); }
.mdhelp summary { cursor: pointer; }
.mdhelp div { padding-top: .4rem; line-height: 2; }

.flash { background: rgba(143, 174, 107, .12); border: 1px solid #4e6338; color: #cfe1b8; padding: .65rem .9rem; border-radius: var(--radius); margin-bottom: 1.2rem; font: .92rem var(--sans); }
.flash.error { background: rgba(196, 80, 63, .12); border-color: #6a2e25; color: #f0b9ad; }

.empty { text-align: center; padding: 4rem 1rem; }
.empty p { color: var(--muted); }

/* Login */
.login { max-width: 380px; margin: 6vh auto 0; text-align: center; }
.login .form { text-align: left; margin: 1.6rem 0 1rem; }
.login h1 { letter-spacing: .12em; text-transform: uppercase; font-size: 1.7rem; margin: .4rem 0 .2rem; }
.login-torch { filter: drop-shadow(0 0 18px rgba(224, 164, 58, .45)); }

/* Wiki */
.wiki-layout { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .wiki-layout { grid-template-columns: minmax(0, 1fr) 260px; } }
.prose { max-width: 72ch; }
.prose p, .prose li { color: #ddd6c7; }
.prose h2 { border-bottom: 1px solid var(--line); padding-bottom: .25em; }
.prose blockquote { margin: 1.2em 0; padding: .4em 1em; border-left: 3px solid var(--torch-dim); background: var(--bg-2); color: var(--muted); }
.prose blockquote p { margin: .4em 0; }
.prose img { border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap { overflow-x: auto; margin: 1em 0; }
table { border-collapse: collapse; width: 100%; font: .92rem/1.4 var(--sans); }
th, td { border-bottom: 1px solid var(--line); padding: .5rem .6rem; text-align: left; vertical-align: top; }
th { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-bottom-color: var(--line-2); }
a.wikilink.missing { color: var(--muted); text-decoration-style: dashed; }
.meta { font: .82rem var(--sans); color: var(--muted); }
.side h3 { font: 600 .74rem var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }
.side ul { list-style: none; padding: 0; margin: 0 0 1.6rem; font: .92rem var(--sans); }
.side li { padding: .25rem 0; }
.catlist h2 { display: flex; align-items: baseline; gap: .5rem; }
.catlist h2 .count { font: .8rem var(--sans); color: var(--muted); }
.search { display: flex; gap: .5rem; max-width: 420px; }
.diff-body { white-space: pre-wrap; font: .85rem/1.5 var(--mono); background: var(--bg-2); border: 1px solid var(--line); padding: 1rem; border-radius: var(--radius); max-height: 360px; overflow: auto; }

/* Charaktere */
.chars { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.charcard { display: flex; gap: .9rem; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; color: var(--text); text-decoration: none; }
.charcard:hover { border-color: var(--torch-dim); color: var(--text); }
.charcard .portrait { width: 64px; height: 64px; flex: none; }
.charcard h3 { margin: 0; font-size: 1.08rem; }
.charcard p { margin: .1rem 0 0; font: .82rem var(--sans); color: var(--muted); }
.charcard.dead { opacity: .62; filter: grayscale(.8); }
.portrait { border-radius: var(--radius); object-fit: cover; background: var(--bg-2); border: 1px solid var(--line); display: grid; place-items: center; font: 600 1.4rem var(--serif); color: var(--muted); overflow: hidden; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait.big { width: 150px; height: 150px; font-size: 3rem; }
.sheet-head { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.4rem; }
.sheet-head h1 { margin: 0; }
.statblock { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; margin: 1rem 0 1.4rem; }
@media (max-width: 520px) { .statblock { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; padding: .5rem .2rem; }
.stat b { display: block; font: 700 .7rem var(--sans); letter-spacing: .14em; color: var(--muted); }
.stat .score { font-size: 1.5rem; line-height: 1.2; }
.stat .mod { font: .8rem var(--sans); color: var(--torch); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem 1rem; margin: 0 0 1.4rem; font-family: var(--sans); }
.facts dt { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; font-size: 1rem; }
.status-gefallen { color: var(--blood); }
.status-ruhestand { color: var(--muted); }
.tabs { display: flex; gap: 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; font: .9rem var(--sans); overflow-x: auto; }
.tabs a { padding: .5rem .1rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tabs a.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--torch); }

/* Heimatbasis */
.resources { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; margin: 0 0 .8rem; }
.resources div { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .45rem .6rem; }
.resources dt { font: .7rem var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.resources dd { margin: 0; font-size: 1.2rem; }
.res-row { display: grid; grid-template-columns: 1fr 120px 40px; gap: .5rem; align-items: center; }
.log { list-style: none; padding: 0; margin: 0; font-family: var(--sans); font-size: .92rem; }
.log li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.log time { color: var(--muted); font-size: .8rem; display: block; }

/* Karten */
.mapgrid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.mapcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); text-decoration: none; display: block; }
.mapcard:hover { border-color: var(--torch-dim); color: var(--text); }
.mapcard img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--bg-2); }
.mapcard div { padding: .6rem .8rem; }
.mapcard h3 { margin: 0; font-size: 1rem; display: flex; gap: .4rem; justify-content: space-between; }
.mapview { background: #000; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: 80vh; }
.mapview img { display: block; max-width: none; width: 100%; cursor: zoom-in; }
.mapview.zoom img { width: auto; cursor: zoom-out; }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.thumbs img { aspect-ratio: 1; object-fit: cover; border: 1px solid var(--line); border-radius: 3px; display: block; }

/* Teaser Weltkarte */
.hexteaser { display: grid; place-items: center; padding: 3rem 1rem; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--radius); }

/* ---------- Weltkarte ---------- */
body.wide .foot { display: none; }
body.wide { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.page.wide { max-width: none; padding: 0; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.page.wide > .flash { margin: .8rem 16px 0; }
.hexmap { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.hm-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem;
  padding: .5rem 16px; border-bottom: 1px solid var(--line); background: var(--bg-2);
  font: .82rem var(--sans);
}
.hm-group { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.hm-right { margin-left: auto; }
.hm-btn {
  font: 600 .78rem var(--sans); color: var(--muted); background: transparent; border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: .32rem .6rem; min-height: 32px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
}
.hm-btn:hover { color: var(--text); border-color: var(--torch-dim); }
.hm-btn.on { color: #1a1208; background: var(--torch); border-color: var(--torch); }
.hm-btn:disabled { opacity: .4; cursor: default; }
.hm-field, .hm-check { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); white-space: nowrap; }
.hm-field select { width: auto; padding: .25rem .4rem; font-size: .8rem; }
.hm-check input { width: 15px; height: 15px; }
.hm-status { font-size: .74rem; color: var(--ok); min-width: 7em; }
.hm-status.dirty { color: var(--muted); }
.hm-status.warn { color: var(--torch); }
.hm-status.err { color: var(--blood); }
.hexmap.previewing [data-edit-only] { opacity: .35; pointer-events: none; }

.hm-body { flex: 1; display: flex; min-height: 0; position: relative; }
.hm-palette { display: none; width: 236px; flex: none; border-right: 1px solid var(--line); background: var(--bg-2); flex-direction: column; min-height: 0; }
.hexmap.palette-open .hm-palette { display: flex; }
.hexmap.previewing .hm-palette { display: none; }
.hm-palette-head { display: grid; gap: .4rem; padding: .6rem; border-bottom: 1px solid var(--line); }
.hm-palette-head select, .hm-palette-head input { font-size: .85rem; padding: .35rem .5rem; }
.hm-palette-empty { padding: 1rem; font: .9rem var(--sans); color: var(--muted); }
.hm-tiles { overflow-y: auto; padding: .5rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; align-content: start; flex: 1; min-height: 0; }
.hm-tiles > .hm-auto { grid-column: 1 / -1; min-height: 0; padding: .4rem; display: flex; gap: .5rem; align-items: center; justify-content: center; }
.hm-tiles > .hm-auto .hm-auto-sym { padding: 0; font-size: 1.3rem; }
.hm-sec { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.hm-sec > summary { cursor: pointer; list-style: none; padding: .45rem .6rem; font: 600 .82rem var(--serif); display: flex; justify-content: space-between; align-items: baseline; }
.hm-sec > summary::-webkit-details-marker { display: none; }
.hm-sec > summary::after { content: '⌄'; color: var(--muted); margin-left: .4rem; }
.hm-sec[open] > summary::after { content: '⌃'; }
.hm-sec > summary .muted { font: .7rem var(--sans); margin-left: auto; }
.hm-sec-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.hm-sec-grid .hm-tile { border: 0; border-radius: 0; background: var(--bg-2); }
.hm-sec-grid .hm-tile.on { box-shadow: inset 0 0 0 2px var(--torch); }
.hm-var { border-radius: 999px; background: #e9dcc0; color: #1a1208; padding: .05rem .35rem; }
.hm-tile { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; padding: 2px; cursor: pointer; display: grid; gap: 2px; color: var(--muted); }
.hm-tile img { width: 100%; aspect-ratio: 2 / 3; object-fit: contain; display: block; }
.hm-tile span { font: .62rem/1.15 var(--sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-tile:hover { border-color: var(--torch-dim); }
.hm-tile.on { border-color: var(--torch); box-shadow: 0 0 0 1px var(--torch); color: var(--text); }

.hm-stage { flex: 1; position: relative; min-width: 0; overflow: hidden; touch-action: none; }
.hm-stage canvas { display: block; position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.hm-zoom { position: absolute; left: 12px; bottom: 12px; display: grid; gap: 4px; }
.hm-zoom button { width: 36px; height: 36px; font: 600 1.1rem var(--sans); color: var(--text); background: rgba(22,20,18,.9); border: 1px solid var(--line-2); border-radius: var(--radius); cursor: pointer; }
.hm-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; padding: 1rem; }
.hm-empty[hidden] { display: none; }
.hm-empty p:first-child { font-size: 1.3rem; margin: 0; }

.hm-panel {
  position: absolute; top: 12px; right: 12px; width: min(340px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto;
  background: rgba(27,25,22,.97); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 1rem 1.1rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.55);
}
.hm-panel[hidden] { display: none; }
.hm-panel h2 { margin: .2rem 0 .6rem; font-size: 1.25rem; }
.hm-panel .eyebrow { margin: 0; padding-right: 2rem; }
.hm-panel .prose { font-size: .95rem; }
.hm-panel .actions { margin-top: .8rem; }
.hm-panel textarea { min-height: 5.5rem; font-size: 14px; }
.hm-panel .form { gap: .7rem; margin-top: .6rem; }
.hm-panel .row { grid-template-columns: 1fr 1fr; }
.hm-close { position: absolute; top: .5rem; right: .5rem; width: 32px; height: 32px; background: none; border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer; }
.hm-close:hover { color: var(--text); }
.hm-palette-toggle { display: none; }

@media (max-width: 859px) {
  .hm-palette-toggle { display: inline-flex; }
  .hm-right { margin-left: 0; }
  .hm-palette { position: absolute; z-index: 5; top: 0; bottom: 0; left: 0; width: min(280px, 85vw); box-shadow: 8px 0 30px rgba(0,0,0,.5); }
  .hm-panel { top: auto; bottom: 0; right: 0; left: 0; width: auto; max-height: 60%; border-radius: var(--radius) var(--radius) 0 0; }
  .hm-toolbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  .hm-toolbar > *, .hm-group { flex: none; flex-wrap: nowrap; }
}

/* Tile-Verwaltung */
.tile-table td { vertical-align: middle; }
.tile-table img { width: 48px; height: 72px; object-fit: contain; display: block; }
.tile-table input[type=text] { min-width: 9rem; padding: .35rem .5rem; font-size: .88rem; }
.upload-list { list-style: none; padding: 0; margin: .6rem 0 0; font: .85rem var(--sans); max-height: 12rem; overflow-y: auto; }
.upload-list li { padding: .15rem 0; }
.upload-list .ok { color: var(--ok); }
.upload-list .err { color: var(--blood); }
.geo-figure { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font: .85rem var(--sans); color: var(--muted); }
.coord-demo text { font: 600 10px var(--sans); fill: var(--muted); text-anchor: middle; }
.hm-hint { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); width: min(420px, calc(100% - 32px)); text-align: center; pointer-events: none;
  background: rgba(27,25,22,.92); border: 1px solid var(--line-2); border-radius: var(--radius); padding: .7rem 1rem; }
.hm-hint[hidden] { display: none; }
.hm-hint p { margin: .2rem 0; }
.hm-goto { display: inline-flex; gap: .3rem; }
.hm-goto input { width: 7.5rem; padding: .25rem .5rem; font-size: .82rem; }
.hm-edit { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.hm-edit > summary { cursor: pointer; font: 600 .82rem var(--sans); color: var(--torch); }
.hm-gmnote { border-left: 2px solid var(--blood); padding-left: .7rem; margin: .8rem 0; }
.hm-gmnote .prose { font-size: .9rem; color: var(--muted); }

/* Kartenverlauf */
.history { list-style: none; padding: 0; margin: 1.6rem 0; max-width: 860px; }
.history-item { display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start; flex-wrap: wrap;
  padding: .9rem 0; border-bottom: 1px solid var(--line); }
.history-main { flex: 1 1 380px; min-width: 0; }
.history-main p { margin: 0 0 .2rem; }
.history-who { font-family: var(--sans); font-size: .9rem; display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.history-what { font-size: 1rem; }
.history-item .actions form { display: inline; }
.history-item.is-reverted .history-what { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--muted); }
.history-item.is-revert .history-what { color: var(--torch); }

.hm-hist { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.hm-hist > summary { cursor: pointer; font: 600 .82rem var(--sans); color: var(--muted); }
.hm-hist-list { list-style: none; padding: 0; margin: .5rem 0 0; font-family: var(--sans); font-size: .85rem; }
.hm-hist-list li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.hm-hist-list p { margin: 0 0 .25rem; }
.hm-hist-list .btn { min-height: 28px; padding: .15rem .5rem; font-size: .72rem; }
.hm-hl { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: center;
  background: rgba(27,25,22,.95); border: 1px solid #3f7f8c; border-radius: var(--radius); padding: .45rem .7rem; font: .85rem var(--sans); color: #bfeaf2; max-width: calc(100% - 120px); }
.hm-hl[hidden] { display: none; }

/* Ebenen */
.hm-layers { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.hm-layers button { font: 600 .74rem var(--sans); color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: .6rem .2rem; cursor: pointer; }
.hm-layers button:hover { color: var(--text); }
.hm-layers button.on { color: var(--text); border-bottom-color: var(--torch); }
.hm-modehint { margin: 0; padding: .5rem .7rem; font: .74rem/1.4 var(--sans); color: var(--muted); border-bottom: 1px solid var(--line); min-height: 2.6em; }
.hm-tile { position: relative; }
.hm-var { position: absolute; top: 3px; right: 3px; font: 700 .6rem var(--sans); color: var(--text); background: rgba(0,0,0,.65); padding: 0 .25rem; border-radius: 2px; letter-spacing: .02em; }
.hm-auto { place-content: center; text-align: center; min-height: 100%; }
.hm-auto-sym { font-size: 1.8rem; line-height: 1; color: var(--torch); display: block; padding: .6rem 0 .3rem; }
.hm-pal-empty { grid-column: 1 / -1; }
.hm-btn:disabled { opacity: .35; }
.hm-iconbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: .4rem; align-items: center;
  background: rgba(27,25,22,.96); border: 1px solid var(--torch-dim); border-radius: var(--radius); padding: .4rem .6rem; font: .82rem var(--sans); color: var(--text); max-width: calc(100% - 120px); }
.hm-iconbar[hidden] { display: none; }
.hm-iconbar [data-iconname] { margin-right: .3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-table tr.is-hidden img { opacity: .35; }
.tile-table tr.is-hidden input[type=text] { color: var(--muted); }
.hm-layers, .hm-modehint, .hm-palette-head { flex: none; }

/* Varianten-Auswahl */
.hm-variants { flex: none; padding: .55rem .6rem .6rem; border-bottom: 1px solid var(--line); background: var(--panel); }
.hm-variants[hidden] { display: none; }
.hm-var-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .45rem; font: 600 .8rem var(--sans); }
.hm-var-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-var-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; }
.hm-varbtn { background: var(--bg-2); border: 1px solid var(--line); border-radius: 3px; padding: 2px; cursor: pointer; aspect-ratio: 1; display: grid; place-items: center; }
.hm-varbtn img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.hm-varbtn:hover { border-color: var(--torch-dim); }
.hm-varbtn.on { border-color: var(--torch); box-shadow: 0 0 0 1px var(--torch); }
.hm-iconvars { display: inline-flex; gap: .25rem; }
.hm-iconvars[hidden] { display: none; }
.hm-iconvars .hm-varbtn { width: 34px; height: 34px; }
.hm-iconbar { flex-wrap: wrap; justify-content: center; width: max-content; max-width: calc(100% - 110px); }
.hm-iconvars { order: 10; flex-basis: 100%; overflow-x: auto; padding-top: .3rem; scrollbar-width: thin; }
.hm-iconvars .hm-varbtn { flex: none; }
.hm-var-row { grid-template-columns: repeat(5, minmax(0, 1fr)); max-height: 92px; overflow-y: auto; scrollbar-width: thin; }
.hm-varbtn { min-width: 0; padding: 3px; }
.hm-tile .hm-var { border-radius: 999px; background: #e9dcc0; color: #1a1208; padding: .05rem .38rem; }

/* Dock mit Ebenen (wie bei westmarches.games) */
.hm-pal-title { flex: none; display: flex; align-items: center; justify-content: space-between; padding: .55rem .7rem; border-bottom: 1px solid var(--line); font: 600 .95rem var(--serif); position: relative; }
.hm-pal-title .hm-close { position: static; width: 28px; height: 28px; display: none; }
.hm-tilepanel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.hm-tilepanel[hidden], .hm-lp[hidden] { display: none; }
.hm-dock {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: stretch; gap: 2px; padding: 4px;
  background: rgba(22,20,18,.95); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.5);
  max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none;
}
.hm-dock::-webkit-scrollbar { display: none; }
.hm-dock button {
  flex: none; display: grid; justify-items: center; gap: 2px; min-width: 54px; padding: .35rem .3rem .3rem;
  background: none; border: 0; border-radius: 7px; color: var(--muted); cursor: pointer; font: 600 .64rem var(--sans);
}
.hm-dock button:hover { color: var(--text); background: rgba(255,255,255,.05); }
.hm-dock button.on { color: #1a1208; background: var(--torch); }
.hm-dock-sep { flex: none; width: 1px; background: var(--line-2); margin: 6px 3px; }
.hm-display {
  position: absolute; right: 12px; bottom: 80px; z-index: 4; width: 230px;
  display: grid; gap: .45rem; padding: .8rem .9rem;
  background: rgba(27,25,22,.98); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.55);
  font: .85rem var(--sans);
}
.hm-display[hidden] { display: none; }
.hm-display-title { margin: 0 0 .2rem; font: 600 .72rem var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hm-display .hm-check { color: var(--text); }
.hm-clear { border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .6rem; display: grid; gap: .4rem; }
.hm-clear-confirm { display: grid; gap: .4rem; }
.hm-clear-confirm[hidden] { display: none; }
.hm-clear-confirm p { margin: 0; color: var(--muted); }
.hm-btn.danger { color: #e58b7d; border-color: #6b3128; }
.hm-btn.danger:hover { color: #fff; background: #7d2d22; border-color: #7d2d22; }
.hm-zoom { left: auto; right: 12px; bottom: 80px; }
.hm-iconbar, .hm-hl { bottom: 80px; }
.hm-panel { max-height: calc(100% - 100px); }

/* Seitenleiste für Regionen, Text, Marker */
.hm-lp { flex: 1; min-height: 0; overflow-y: auto; padding: .7rem; display: flex; flex-direction: column; gap: .6rem; font: .85rem var(--sans); }
.hm-lp-sub { margin: 0; font: 600 .72rem var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hm-lp-note { margin: 0; line-height: 1.45; }
.hm-lp-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.hm-lp-add { justify-content: center; }
.hm-lp-danger { border-top: 1px solid var(--line); padding-top: .6rem; display: grid; gap: .4rem; }
.hm-lp-danger p { margin: 0; color: var(--muted); display: grid; gap: .4rem; }
.hm-lp-danger p[hidden] { display: none; }
.hm-reglist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; }
.hm-reglist li { display: flex; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.hm-reglist li.on { border-color: var(--torch); box-shadow: 0 0 0 1px var(--torch); }
.hm-reg { flex: 1; min-width: 0; display: flex; align-items: center; gap: .5rem; background: none; border: 0; color: var(--text); padding: .45rem .5rem; cursor: pointer; text-align: left; font: inherit; }
.hm-reg-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.hm-reg small { color: var(--muted); white-space: nowrap; font-size: .72rem; }
.hm-reg-edit { flex: none; width: 34px; background: none; border: 0; border-left: 1px solid var(--line); color: var(--muted); cursor: pointer; font-size: .95rem; }
.hm-reg-edit:hover { color: var(--torch); }
.hm-regform { display: grid; gap: .55rem; padding: .7rem; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel); }
.hm-regform label { display: grid; gap: .25rem; color: var(--muted); font-size: .78rem; }
.hm-regform input[name=name] { font-size: .9rem; padding: .4rem .5rem; }
.hm-swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.hm-swatch { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(0,0,0,.35); padding: 0; cursor: pointer; display: inline-block; }
.hm-reg .hm-swatch { width: 14px; height: 14px; cursor: inherit; border-width: 1px; }
.hm-swatch.on { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--torch); }
.hm-swatch-custom { position: relative; overflow: hidden; background: conic-gradient(#c44, #dc4, #4c6, #4ac, #84c, #c44); }
.hm-swatch-custom input { position: absolute; inset: -6px; width: 40px; height: 40px; opacity: 0; cursor: pointer; }
.hm-swatch-text { width: 24px; height: 24px; border-radius: 4px; font: 700 .95rem var(--serif); display: grid; place-items: center; }
.hm-textform { display: grid; gap: .6rem; }
.hm-textform > label:first-child { display: grid; gap: .25rem; color: var(--muted); font-size: .78rem; }
.hm-textform input[data-lt=s] { font: 600 .95rem var(--serif); padding: .45rem .55rem; }
.hm-lt-row { display: grid; grid-template-columns: 4rem minmax(0, 1fr) 2.6rem; align-items: center; gap: .4rem; color: var(--muted); font-size: .78rem; }
.hm-lt-row .hm-swatches { grid-column: 2 / -1; }
.hm-lt-row input[type=range] { width: 100%; accent-color: var(--torch); padding: 0; }
.hm-lt-row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.hm-pinlist { display: grid; gap: 3px; }
.hm-pinbtn { display: flex; align-items: center; gap: .6rem; padding: .45rem .55rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); cursor: pointer; font: 600 .85rem var(--sans); text-align: left; }
.hm-pinbtn.on { border-color: var(--torch); box-shadow: 0 0 0 1px var(--torch); }
.hm-pindot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #120f0b; font: 700 .75rem var(--sans); border: 2px solid #120f0b; }

@media (max-width: 859px) {
  .hm-pal-title .hm-close { display: inline-block; }
  .hm-dock button { min-width: 42px; padding: .4rem .25rem; }
  .hm-dock button span { display: none; }
  .hm-display { right: 8px; left: 8px; width: auto; }
  .hm-iconbar, .hm-hl { max-width: calc(100% - 16px); }
  .hm-zoom { bottom: 72px; }
}
