:root {
  --ink: #111;        /* Druckfarbe des Bogens */
  --pen: #1d3f8f;     /* "Kugelschreiber" für eingetragene Werte */
  --paper: #fff;
  --rule: #8a8a8a;
  --bg: #cdc8bf;
  --focus: #fff4c2;
  --row: 20px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.3 'Palatino Linotype', 'Book Antiqua', Palatino, 'URW Palladio L', 'TeX Gyre Pagella', Georgia, serif;
}

/* ---------- Werkzeugleiste ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 8px 16px;
  background: #1a1a1a; color: #ddd;
  font: 13px system-ui, sans-serif;
}
.toolbar a { color: #fff; }
.toolbar code, .start code { background: #333; color: #eee; padding: 2px 6px; border-radius: 3px; font-size: 12px; }
button {
  font: 13px system-ui, sans-serif; cursor: pointer;
  padding: 5px 11px; border: 1px solid #777; border-radius: 4px;
  background: #2a2a2a; color: #eee;
}
button:hover { background: #3a3a3a; }
#status { margin-left: auto; color: #9fd39f; }
#status.err, .err { color: #e06060; }

/* ---------- Seiten ---------- */
.page {
  width: min(820px, calc(100% - 32px));
  margin: 24px auto;
  padding: 26px 34px 32px;
  background: var(--paper);
  border: 12px solid var(--ink);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 5px var(--ink), 0 3px 18px rgba(0, 0, 0, .3);
}

.title { text-align: center; margin: -6px 0 18px; }
.title span {
  display: inline-block; padding: 3px 26px 1px;
  background: var(--ink); color: var(--paper);
  font-size: 30px; font-weight: bold; letter-spacing: .2em; font-variant: small-caps;
}
.title small { display: block; margin-top: 4px; font-size: 12px; letter-spacing: .35em; text-transform: uppercase; }

/* Überschriften mit schwarzen Balken links und rechts */
.bar {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 8px;
  font-size: 26px; font-weight: normal; font-variant: small-caps; letter-spacing: .03em; line-height: 1;
}
.bar::before, .bar::after { content: ''; flex: 1; height: 7px; background: var(--ink); border-radius: 2px; }
.bar.small { margin: 8px 0 6px; font-size: 12px; font-variant: normal; text-transform: uppercase; letter-spacing: .04em; }
.bar.small::before, .bar.small::after { height: 4px; }
.bar.plain { gap: 0; margin: 18px 0 10px; }
.bar.plain span, .bar.plain::after { display: none; }

h3 { margin: 2px 0 5px; font-size: 12px; font-weight: normal; text-align: center; text-transform: uppercase; letter-spacing: .03em; }
h3.gross { font-size: 15px; text-transform: none; letter-spacing: 0; }

.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 26px; }
.split { display: grid; grid-template-columns: 1.15fr 1fr; gap: 0 30px; }

/* ---------- Eingabefelder ---------- */
input.line, textarea {
  width: 100%; min-width: 0;
  padding: 0 3px;
  border: 0; border-bottom: 1px solid var(--rule); border-radius: 0;
  background: transparent; color: var(--pen);
  font: 14px/1.2 system-ui, 'Segoe UI', Roboto, Arial, sans-serif;
  outline: none;
}
input.line { height: var(--row); }
input.line:focus, textarea:focus { background: var(--focus); }

.kopf label {
  display: flex; align-items: baseline; gap: 6px;
  margin: 1px 0; font-size: 12px; text-transform: uppercase; white-space: nowrap;
}
.kopf input.line { border-bottom-color: transparent; }
.kopf input.line:hover { border-bottom-color: var(--rule); }

/* Zeile "Name ........ ●○○○○" */
.stat { display: flex; align-items: center; gap: 4px; height: var(--row); }
.stat > span { white-space: nowrap; }
.stat > i { flex: 1; min-width: 6px; align-self: flex-end; margin-bottom: 6px; border-bottom: 1.5px dotted #444; }

/* ---------- Punkte (Checkboxen) ---------- */
.dots { display: inline-flex; gap: 2px; flex: none; }
.dots input[type=checkbox] {
  appearance: none; -webkit-appearance: none;
  width: 13px; height: 13px; margin: 0; flex: none;
  border: 1.3px solid var(--ink); border-radius: 50%;
  background: var(--paper); cursor: pointer;
}
.dots input[type=checkbox]:checked { background: var(--pen); border-color: var(--pen); }
.dots[data-min="1"] > input:first-child { background: var(--ink); border-color: var(--ink); } /* vorgedruckter Punkt */
.dots input[type=checkbox]:hover { box-shadow: 0 0 0 2px #c9d6f3; }
.dots input[type=checkbox]:focus-visible, .box:focus-visible { outline: 2px solid #3b6fd6; outline-offset: 1px; }

.dots.ten { display: flex; justify-content: center; gap: 8px; margin: 6px 0; }
.dots.square input[type=checkbox] { width: 19px; height: 19px; border-radius: 0; }
.dots.square { gap: 3px; }

/* ---------- Seite 1 unten ---------- */
.unten .mitte { text-align: center; }
textarea.xp { height: 56px; border: 2px solid var(--ink); resize: vertical; padding: 3px 5px; }
.health { display: grid; grid-template-columns: 1fr 26px 16px; align-items: center; height: var(--row); cursor: pointer; }
.health b { font-weight: normal; text-align: right; padding-right: 8px; }
.box {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px; margin: 0;
  border: 1.3px solid var(--ink); background: var(--paper); cursor: pointer;
}
.box:checked {
  background:
    linear-gradient(45deg, transparent 42%, var(--pen) 42% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, var(--pen) 42% 58%, transparent 58%);
}

/* ---------- Tabellen (Kräfte, Waffen) ---------- */
.scroll { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { font-weight: normal; text-align: left; font-size: 13px; padding: 2px 4px; }
.kraefte td { padding: 0 8px 0 0; }
.kraefte td:nth-child(1) { width: 24%; }
.kraefte td:nth-child(2) { width: 20%; }
.kraefte td:nth-child(3) { width: 82px; }
.waffen th, .waffen td { border: 1px solid var(--ink); }
.waffen td { padding: 0; }
.waffen input.line { border-bottom: 0; }
.waffen td:nth-child(1) { width: 27%; }
.waffen td:nth-child(2), .waffen td:nth-child(3), .waffen td:nth-child(5) { width: 11%; }
.waffen td:nth-child(4) { width: 8%; }

/* ---------- Seite 2: Tugenden ---------- */
.tugenden { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tugend h3 { text-transform: none; font-size: 14px; margin-bottom: 0; }
.dots.vertical { display: block; }
.trow { display: grid; grid-template-columns: 18px 15px 1fr; align-items: center; gap: 5px; height: var(--row); }
.trow > span { text-align: right; }
.trow.thead { height: 14px; font-size: 10px; }
.trow.thead small:last-child { text-align: center; }

.listen h3 { text-transform: none; font-size: 15px; margin-top: 10px; }
.listen input.line { display: block; }

/* ---------- Seite 3 ---------- */
.ort { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; height: var(--row); }
.ruestung { display: grid; grid-template-columns: 1fr 34px 40px; gap: 4px; align-items: end; }
.ruestung.thead { margin-top: 10px; height: var(--row); }
.ruestung.thead small { font-size: 10px; text-align: center; }

textarea.lined {
  height: calc(12 * var(--row) + 2px);
  border: 0; resize: vertical;
  line-height: var(--row);
  background: repeating-linear-gradient(to bottom, transparent 0 calc(var(--row) - 1px), var(--rule) calc(var(--row) - 1px) var(--row));
  background-attachment: local;
}

/* ---------- Startseite ---------- */
.start { max-width: 560px; font-size: 15px; }
.start form { display: flex; gap: 8px; align-items: end; margin: 12px 0 8px; }
.start ul { padding-left: 18px; }
.start li { margin: 4px 0; }
.start a { color: var(--pen); }

/* ---------- Handy ---------- */
@media (pointer: coarse) {
  .dots input[type=checkbox] { width: 19px; height: 19px; }
  .dots.ten { gap: 4px; }
  .dots.square input[type=checkbox] { width: 22px; height: 22px; }
  .stat, .trow, .health { height: 26px; }
  .box { width: 20px; height: 20px; }
}
@media (max-width: 720px) {
  .page { width: calc(100% - 16px); margin: 10px auto; padding: 18px 14px 22px; border-width: 6px; }
  .cols3, .split { grid-template-columns: 1fr; }
  .bar { font-size: 22px; }
  table.grid { min-width: 560px; }
}

/* ---------- Drucken ---------- */
@media print {
  body { background: #fff; }
  .toolbar { display: none; }
  .page { width: auto; margin: 0; box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px #000; break-after: page; }
  input.line:focus, textarea:focus { background: none; }
}
