/* Bastardhall research ledger
   Palette taken from the Arudora portrait wall: dusk damask, copper nameplates,
   walnut shelves, ectoplasm green for what the players can see, old blood for loss. */

:root {
  --wall: #272b42;
  --wall-2: #30354f;
  --wall-3: #3a4060;
  --line: #4a5070;
  --ink: #ede5d3;
  --ink-2: #b9b3c4;
  --ink-3: #8a86a0;
  --copper: #c88a56;
  --copper-hi: #e7b585;
  --copper-lo: #7d4f2c;
  --walnut: #5a3925;
  --walnut-hi: #7a4f33;
  --ecto: #a6cf7f;
  --ecto-dim: #5d7a49;
  --blood: #c0444a;
  --paper: #f3eee3;
  --paper-ink: #2b2620;

  --serif: 'Alegreya', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Alegreya Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --black: 'UnifrakturMaguntia', 'Old English Text MT', var(--serif);

  --r-sm: 3px;
  --r-md: 6px;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--wall);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--copper-hi);
  outline-offset: 2px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* ---------- controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-height: 2.25rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--wall-3);
  cursor: pointer;
  font-weight: 500;
  line-height: 1.2;
}
.btn:hover {
  border-color: var(--copper);
}
.btn.primary {
  background: var(--copper);
  border-color: var(--copper);
  color: #24170c;
  font-weight: 700;
}
.btn.primary:hover {
  background: var(--copper-hi);
}
.btn.ghost {
  background: transparent;
}
.btn.danger {
  border-color: var(--blood);
  color: #f2c9cb;
  background: transparent;
}
.btn.small {
  min-height: 1.9rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.875rem;
}
.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.icon-btn {
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.icon-btn:hover {
  border-color: var(--line);
  color: var(--ink);
}

input:not([type='checkbox']),
select,
textarea {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #1f2236;
  min-height: 2.25rem;
}
input:disabled {
  opacity: 0.55;
}
textarea {
  resize: vertical;
  line-height: 1.45;
}
input.num {
  width: 5.5rem;
}
label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--ink-2);
}
label.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-size: 0.95rem;
}
label.check input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--copper);
}
label.inline {
  display: inline-grid;
  min-width: 16rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--ink-3);
  white-space: nowrap;
}
.chip.known {
  color: var(--ecto);
  border-color: var(--ecto-dim);
}
.chip.act {
  cursor: pointer;
  background: transparent;
  color: var(--ecto);
  border-color: var(--ecto-dim);
  font-size: 0.85rem;
}
.chip.act:hover {
  background: rgba(166, 207, 127, 0.12);
}

.switch {
  position: relative;
  flex: none;
  width: 2.4rem;
  height: 1.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #1f2236;
  cursor: pointer;
  padding: 0;
}
.switch span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.35rem - 6px);
  height: calc(1.35rem - 6px);
  border-radius: 50%;
  background: var(--ink-3);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch[aria-checked='true'] {
  background: var(--ecto-dim);
  border-color: var(--ecto);
}
.switch[aria-checked='true'] span {
  transform: translateX(1.05rem);
  background: var(--ecto);
}
.switch:disabled {
  cursor: default;
  opacity: 0.7;
}

.hint {
  font-size: 0.875rem;
  color: var(--ink-3);
  margin: 0.4rem 0;
}
.hint.warn {
  color: #e8c48f;
}
.error {
  color: #f0a7aa;
  min-height: 1.5em;
}
.empty {
  color: var(--ink-2);
  padding: 2rem 0;
}

/* ---------- login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(26rem, 100%);
}
.login-card .wordmark {
  font-size: 3.4rem;
  margin: 0;
}
.login-card h1 {
  font: 500 1.15rem/1.3 var(--sans);
  color: var(--ink-2);
  margin: 0 0 1.5rem;
}
.login-card form {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

/* ---------- topbar ---------- */

.wordmark {
  font-family: var(--black);
  color: var(--copper-hi);
  font-size: 2rem;
  line-height: 1;
  letter-spacing: 0.01em;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: calc(0.7rem + env(safe-area-inset-top, 0px)) clamp(1rem, 3vw, 2rem) 0.7rem;
  background: #20243a;
  border-bottom: 4px solid var(--walnut);
  box-shadow: 0 1px 0 var(--walnut-hi) inset;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.brand-sub {
  color: var(--ink-3);
  font-size: 0.9rem;
}
.pages {
  display: flex;
  gap: 0.15rem;
  font-size: 0.9rem;
}
.pages a {
  color: var(--ink-3);
  text-decoration: none;
  padding: 0.15rem 0.45rem;
  border-radius: var(--r-sm);
}
.pages a:hover {
  color: var(--ink);
}
.pages a[aria-current='page'] {
  color: var(--copper-hi);
}
.tabs {
  display: flex;
  gap: 0.15rem;
  flex-wrap: wrap;
}
.tabs button {
  border: 0;
  background: transparent;
  padding: 0.45rem 0.75rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 500;
}
.tabs button:hover {
  color: var(--ink);
}
.tabs button[aria-selected='true'] {
  color: var(--ink);
  background: var(--wall-3);
  box-shadow: inset 0 -2px 0 var(--copper);
}
.session {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--ink-2);
  font-size: 0.9rem;
}
.session output {
  color: var(--ink);
  font-weight: 700;
}
.save-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-3);
  min-width: 8rem;
  text-align: right;
}
.save-status[data-state='busy'] {
  color: #e8c48f;
}
.save-status[data-state='bad'] {
  color: #f0a7aa;
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.75rem clamp(1rem, 3vw, 2rem);
  background: #4a2226;
  border-bottom: 1px solid var(--blood);
}
.banner p {
  margin: 0;
  flex: 1 1 22rem;
}

main {
  padding: 1.25rem clamp(1rem, 3vw, 2rem) 4rem;
  max-width: 88rem;
  margin: 0 auto;
}
main:focus {
  outline: none;
}

.top-end {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.top-end .save-status {
  min-width: 0;
}
#publish-btn {
  white-space: nowrap;
}
.tabs button.has-dot::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 0.4rem;
  border-radius: 50%;
  background: var(--copper-hi);
  vertical-align: middle;
}

/* ---------- topics ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.search {
  flex: 0 1 18rem;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  color: var(--ink-2);
}
.seg button + button {
  border-left: 1px solid var(--line);
}
.seg button[aria-pressed='true'] {
  background: var(--wall-3);
  color: var(--ink);
}
.toolbar-end {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
}

.overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem 2rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
}
.overview p {
  margin: 0;
}
.overview-count {
  font-size: 1.05rem;
  color: var(--ink-2);
}
.overview-count strong {
  color: var(--ink);
  font-size: 1.35rem;
}
.pending > p,
.bonuses > p {
  color: var(--ink-2);
  font-size: 0.9rem;
}
.bonuses ul {
  margin: 0.3rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.92rem;
}

.topics {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Each topic sits on a walnut shelf, like the portraits it names. */
.topic {
  border-bottom: 5px solid var(--walnut);
  box-shadow: 0 1px 0 var(--walnut-hi);
  padding: 0.85rem 0 0.9rem;
}
.topic-head {
  display: grid;
  grid-template-columns: 6.25rem minmax(14rem, 19rem) 1fr 11rem;
  align-items: center;
  gap: 1rem;
}

.vis {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  justify-self: start;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 0.85rem;
}
.vis svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}
.vis[aria-pressed='true'] {
  color: var(--ecto);
  border-color: var(--ecto-dim);
  background: rgba(166, 207, 127, 0.08);
}

/* The copper nameplate: the one ornamental element on the page. */
.plate {
  display: grid;
  gap: 0.05rem;
  text-align: center;
  padding: 0.45rem 1rem 0.5rem;
  border: 1px solid var(--copper-lo);
  border-radius: 2px;
  background: linear-gradient(180deg, var(--copper-hi) 0%, var(--copper) 45%, #a8703f 100%);
  box-shadow: inset 0 1px 0 rgba(255, 236, 210, 0.55), inset 0 -2px 0 rgba(70, 38, 14, 0.35), 0 2px 0 #1a1c2c;
  cursor: pointer;
  color: #3a210d;
  position: relative;
}
.plate::before,
.plate::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: #6e4321;
  box-shadow: inset 0 1px 1px rgba(255, 220, 180, 0.6);
}
.plate::before {
  left: 7px;
}
.plate::after {
  right: 7px;
}
.plate-name {
  font: 700 1.08rem/1.15 var(--serif);
  text-shadow: 0 1px 0 rgba(255, 228, 196, 0.6);
}
.plate-meta {
  font-size: 0.78rem;
  color: #5b3417;
}
.plate:hover {
  filter: brightness(1.06);
}
.is-hidden .plate {
  filter: grayscale(0.75) brightness(0.62);
}
.is-hidden .plate:hover {
  filter: grayscale(0.5) brightness(0.75);
}
.is-open .plate {
  box-shadow: inset 0 1px 0 rgba(255, 236, 210, 0.55), inset 0 -2px 0 rgba(70, 38, 14, 0.35), 0 0 0 2px var(--wall), 0 0 0 3px var(--copper-lo);
}

.track {
  min-width: 6rem;
  padding: 0 6px;
}
.rail {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: #1b1e30;
  box-shadow: inset 0 0 0 1px var(--line);
}
.fill {
  height: 100%;
  border-radius: 3px;
  background: var(--ink-2);
}
.is-known .fill {
  background: var(--ink);
}
.notch {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  transform: rotate(45deg);
  background: var(--wall);
  border: 1px solid var(--ink-3);
}
.notch.on {
  background: var(--copper);
  border-color: var(--copper-hi);
}

.rp-readout {
  margin: 0;
  display: grid;
  justify-items: end;
  line-height: 1.2;
  color: var(--ink-2);
}
.rp-num strong {
  color: var(--ink);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}
.rp-sub {
  font-size: 0.8rem;
  color: var(--ink-3);
}

.topic-body {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(19rem, 1fr);
  gap: 2rem;
  margin-top: 1.1rem;
  padding: 0 0 0.5rem 7.25rem;
}
@media (prefers-reduced-motion: no-preference) {
  .topic-body {
    animation: open 0.18s ease-out;
  }
  @keyframes open {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
  }
}
.topic-body h3 {
  font: 700 0.95rem/1.3 var(--sans);
  color: var(--ink-2);
  margin: 1.25rem 0 0.5rem;
}
.topic-body h3:first-child {
  margin-top: 0;
}

.reveals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}
.reveal {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.75rem;
  opacity: 0.55;
}
.reveal.is-reached {
  opacity: 1;
}
.thr {
  display: grid;
  place-items: center;
  height: 2rem;
  border: 1px solid var(--ink-3);
  border-radius: 2px;
  font: 700 0.9rem/1 var(--sans);
  color: var(--ink-2);
}
.is-reached .thr {
  border-color: var(--copper);
  background: var(--copper);
  color: #2b1909;
}
.reveal-text p {
  margin: 0;
  font: 400 1.02rem/1.6 var(--serif);
  max-width: 68ch;
}
.reveal-text p + p {
  margin-top: 0.35rem;
}
.reveal-text .benefit {
  font: 500 0.92rem/1.45 var(--sans);
  color: var(--ecto);
}
.reveal-text .gm-note {
  font: italic 400 0.92rem/1.45 var(--serif);
  color: #e8c48f;
}
.reveal-text .combo-cond {
  font: 500 0.85rem/1.4 var(--sans);
  color: var(--ink-3);
}

.logform {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.logform .wide {
  grid-column: 1 / -1;
}
.outcomes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.7rem;
}
.outcome {
  justify-content: space-between;
}
.outcome b {
  font-variant-numeric: tabular-nums;
}
.o-cs b {
  color: var(--copper-hi);
}
.o-cf {
  border-color: #6b3036;
}
.o-cf b {
  color: #f0a7aa;
}
.adjust {
  display: flex;
  align-items: end;
  gap: 0.5rem;
  margin-top: 0.7rem;
}
.adjust input {
  width: 6rem;
}

.srcs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}
.src {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.3rem 0;
}
.src-text {
  display: grid;
  line-height: 1.25;
}
.src-name {
  font-weight: 500;
  color: var(--ink-2);
}
.src.is-on .src-name,
tr.is-on .src-name {
  color: var(--ink);
}
.src-where {
  font-size: 0.8rem;
  color: var(--ink-3);
}
.pool {
  font-size: 0.85rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pool.is-full {
  color: #e8c48f;
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.88rem;
  color: var(--ink-2);
}
.history li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid #343a57;
}
.history b {
  color: var(--ink);
}
.history i {
  color: var(--ink-3);
}

/* ---------- pages ---------- */

.page-intro {
  max-width: 62rem;
  margin-bottom: 1rem;
}
.page-intro h2,
.export-controls h2,
.settings h2 {
  font: 700 1.5rem/1.2 var(--serif);
  margin: 0 0 0.4rem;
}
.page-intro p {
  color: var(--ink-2);
  max-width: 70ch;
  margin: 0 0 0.8rem;
}

.table-wrap {
  overflow-x: auto;
  border-top: 4px solid var(--walnut);
}
table {
  border-collapse: collapse;
  width: 100%;
}
.src-table th,
.src-table td,
.log-table th,
.log-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid #343a57;
}
thead th {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
}
.src-table th[scope='row'] {
  font-weight: 400;
  min-width: 14rem;
}
.src-table th[scope='row'] > span {
  display: block;
}
.src-table th[scope='row'] .gm-note {
  font-size: 0.8rem;
  color: #e8c48f;
  font-style: italic;
  margin-top: 0.15rem;
}
.src-table td:nth-child(3) {
  min-width: 12rem;
}
.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  min-width: 14rem;
}
.log-table td.num {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.export {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}
.export-controls {
  display: grid;
  gap: 0.8rem;
  position: sticky;
  top: 6rem;
}
.export-controls > p {
  margin: 0;
  color: var(--ink-2);
}
.export-actions {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.3rem;
}
.export-actions .btn {
  justify-content: center;
  text-decoration: none;
  color: inherit;
}
.export-actions .btn.primary {
  color: #24170c;
}
.export-controls h3 {
  font: 700 1rem/1.3 var(--sans);
  color: var(--ink-2);
  margin: 0.8rem 0 0;
}
.hint-inline {
  color: var(--ink-3);
  font-size: 0.8rem;
}
.pub-status {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--line);
  background: var(--wall-2);
  font-size: 0.9rem;
}
.pub-status.ok {
  border-left-color: var(--ecto);
}
.pub-status.behind {
  border-left-color: var(--copper);
}
.gdoc summary {
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 500;
}
.gdoc .export-actions {
  margin-top: 0.6rem;
}
.export-controls > .btn.danger {
  justify-self: start;
}
.preview {
  min-width: 0;
}
.preview-label {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-3);
}
.preview iframe {
  display: block;
  width: 100%;
  height: calc(100vh - 9rem);
  min-height: 32rem;
  border: 1px solid var(--line);
  border-top: 4px solid var(--walnut);
  background: var(--wall);
}

/* Preview in the doc's own colors so the GM sees what the players will. */
.paper {
  background: var(--paper);
  color: var(--paper-ink);
  padding: clamp(1.25rem, 4vw, 3rem);
  border-radius: 2px;
  box-shadow: 0 0 0 1px #1a1c2c, 0 18px 40px -20px rgba(0, 0, 0, 0.7);
  font: 400 1rem/1.55 var(--serif);
  max-width: 52rem;
}
.paper h1 {
  font: 700 2rem/1.15 var(--serif);
  margin: 0 0 0.3rem;
}
.paper h2 {
  font: 700 1.35rem/1.2 var(--serif);
  margin: 1.8rem 0 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #cfc5b2;
}
.paper h3 {
  font: 700 1.1rem/1.25 var(--serif);
  margin: 1.4rem 0 0.3rem;
}
.paper p {
  margin: 0.35rem 0;
  max-width: 70ch;
}
.paper ul {
  margin: 0.3rem 0 0.6rem;
  padding-left: 1.3rem;
  max-width: 70ch;
}
.paper li {
  margin: 0.2rem 0;
}
.paper table {
  margin: 0.5rem 0 1rem;
  font: 400 0.9rem/1.4 var(--sans);
}
.paper th,
.paper td {
  border-color: #b8ad98 !important;
}
.paper thead th {
  color: var(--paper-ink);
  font-weight: 700;
  font-size: 0.9rem;
}
.paper em {
  color: #6a6052;
}

.settings {
  display: grid;
  gap: 2.25rem;
  max-width: 44rem;
}
.settings section > p {
  color: var(--ink-2);
  margin: 0 0 0.75rem;
}
.rp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.file-btn {
  display: inline-flex;
  color: var(--ink);
  font-size: 1rem;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  pointer-events: none;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: grid;
  gap: 0.5rem;
  width: min(26rem, calc(100vw - 2rem));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: #171a2b;
  border: 1px solid var(--line);
  border-left: 4px solid var(--copper);
  border-radius: var(--r-sm);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
}
.toast.warn {
  border-left-color: #e8c48f;
}
.toast p {
  margin: 0;
  flex: 1;
  font-size: 0.92rem;
}
@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: rise 0.2s ease-out;
  }
  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
  }
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }
  .tabs {
    grid-column: 1 / -1;
    order: 3;
  }
  .save-status {
    grid-column: 2;
  }
  .topic-body {
    padding-left: 0;
  }
}

@media (max-width: 1100px) {
  .topbar.has-publish {
    grid-template-columns: 1fr auto auto;
  }
  .topbar.has-publish .brand {
    grid-area: 1 / 1;
  }
  .topbar.has-publish .session {
    grid-area: 1 / 2;
  }
  .topbar.has-publish .top-end {
    grid-area: 1 / 3;
  }
  .topbar.has-publish .tabs {
    grid-area: 2 / 1 / 3 / -1;
  }
}
@media (max-width: 760px) {
  .topbar.has-publish {
    grid-template-columns: 1fr auto;
  }
  .topbar.has-publish .brand {
    grid-area: 1 / 1 / 2 / -1;
  }
  .topbar.has-publish .session {
    grid-area: 2 / 1;
  }
  .topbar.has-publish .top-end {
    grid-area: 2 / 2;
  }
  .topbar.has-publish .tabs {
    grid-area: 3 / 1 / 4 / -1;
  }
}

@media (max-width: 860px) {
  .topic-head {
    grid-template-columns: auto 1fr;
    gap: 0.6rem 0.75rem;
  }
  .plate {
    grid-column: 1 / -1;
    order: -1;
  }
  .rp-readout {
    grid-column: 1 / -1;
    justify-items: start;
    grid-auto-flow: column;
    justify-content: start;
    align-items: baseline;
    gap: 0.5rem;
  }
  .topic-body,
  .export {
    grid-template-columns: 1fr;
  }
  .export-controls {
    position: static;
  }
  .toolbar-end {
    margin-left: 0;
  }
}

@media (max-width: 520px) {
  .brand-sub {
    display: none;
  }
  .wordmark {
    font-size: 1.6rem;
  }
  .topbar {
    gap: 0.4rem 1rem;
  }
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -1rem;
    padding: 0 1rem;
    scrollbar-width: none;
  }
  .tabs button {
    white-space: nowrap;
  }
  .logform,
  .outcomes {
    grid-template-columns: 1fr;
  }
  .save-status {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- gates and source status ---------- */

.seg.mini button {
  padding: 0.08rem 0.5rem;
  font-size: 0.8rem;
}
.seg.status button[aria-pressed='true'][data-v='open'] {
  background: var(--ecto-dim);
  color: var(--ink);
}
.seg.status button[aria-pressed='true'][data-v='closed'] {
  background: #4a3a2a;
  color: #e8c48f;
}
.seg button:disabled {
  cursor: default;
  opacity: 0.7;
}
.src-checks {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-2);
}
.src-gate {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--ink-2);
}
.src-gate b {
  color: var(--copper-hi);
  font-weight: 700;
}
.src.is-closed .src-name,
tr.is-closed .src-name {
  color: var(--ink-3);
}
.badge-closed {
  display: inline-block;
  padding: 0 0.4rem;
  border: 1px solid #6a5a3c;
  border-radius: 999px;
  font-size: 0.7rem;
  color: #e8c48f;
  vertical-align: 1px;
}
.chip.closed {
  color: var(--ink-3);
  text-decoration: line-through;
}
.chips-label {
  font-size: 0.75rem;
  color: var(--ink-3);
  margin-right: 0.15rem;
  align-self: center;
}
.now-dreaming {
  padding: 0.6rem 0.8rem;
  background: var(--wall-2);
  border-left: 3px solid var(--copper);
  color: var(--ink) !important;
}

.gates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(26rem, 1fr));
  gap: 1.25rem 2rem;
  align-items: start;
}
.gate-group h3 {
  font: 700 1.1rem/1.2 var(--serif);
  margin: 0 0 0.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 4px solid var(--walnut);
}
.gate-group .ch {
  display: block;
  font: 500 0.75rem/1.2 var(--sans);
  color: var(--ink-3);
}
.gate-group ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.gate {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #343a57;
}
.gate.is-region .gate-label {
  font-weight: 700;
  color: var(--copper-hi);
}
.gate-check {
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.1rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #1f2236;
  color: #1d2a12;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.gate-check[aria-pressed='true'] {
  background: var(--ecto);
  border-color: var(--ecto);
}
.gate-check:disabled {
  cursor: default;
}
.gate-label {
  margin: 0;
  font-weight: 500;
}
.gate.is-done .gate-label {
  color: var(--ink-2);
}
.gate-note {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-3);
}
.gate .chips {
  margin-top: 0.3rem;
}

.payoffs {
  margin-top: 2rem;
  padding-top: 0.75rem;
  border-top: 5px solid var(--walnut);
}
.payoffs h2 {
  font: 700 1.3rem/1.2 var(--serif);
  margin: 0 0 0.3rem;
}
.payoffs > p {
  color: var(--ink-2);
  margin: 0 0 0.75rem;
}
.payoffs ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
  gap: 0.75rem 1.5rem;
}
.payoffs li {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.6rem;
  opacity: 0.7;
}
.payoffs li.is-reached {
  opacity: 1;
}
.payoffs li p {
  margin: 0;
}
.payoffs li.is-reached .thr {
  border-color: var(--copper);
  background: var(--copper);
  color: #2b1909;
}
.badge-reached {
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--ecto);
  color: #1d2a12;
  font-size: 0.72rem;
  font-weight: 700;
}
@media (max-width: 520px) {
  .gates {
    grid-template-columns: 1fr;
  }
}

/* ---------- campaign tracker ---------- */

.camp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(26rem, 1fr));
  gap: 1.5rem 2rem;
  align-items: start;
}
.camp-card {
  padding: 0.9rem 1rem 1rem;
  background: var(--wall-2);
  border-top: 5px solid var(--walnut);
}
.camp-card h3 {
  font: 700 1.15rem/1.25 var(--serif);
  margin: 0 0 0.6rem;
}
.camp-card > p {
  margin: 0 0 0.6rem;
}
.camp-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.big-stat {
  font-size: 1rem;
  color: var(--ink-2);
}
.big-stat strong {
  font-size: 1.35rem;
  color: var(--ink);
}
.table-wrap.plain {
  border-top: 0;
}
.phantom-table th[scope='row'] {
  min-width: 12rem;
}
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}
.stepper output {
  min-width: 2.2rem;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stepper .of {
  font-weight: 400;
  color: var(--ink-3);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.counter {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.75rem;
  align-items: center;
  margin: 0.6rem 0 0.3rem;
}
.counter-label {
  font-weight: 500;
}
.counter .bar {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 3px;
  background: #1b1e30;
  overflow: hidden;
}
.counter .bar span {
  display: block;
  height: 100%;
  background: var(--copper);
}
.pc-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}
.pc-table th,
.pc-table td {
  text-align: left;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid #343a57;
}
.pc-table thead th {
  font-size: 0.8rem;
}
.camp-ul {
  margin: 0 0 0.6rem;
  padding-left: 1.1rem;
}
.camp-ul li + li {
  margin-top: 0.25rem;
}
@media (max-width: 520px) {
  .camp-grid {
    grid-template-columns: 1fr;
  }
}
.camp-card,
.gate-group {
  min-width: 0;
}
@media (max-width: 520px) {
  .camp-card {
    padding: 0.8rem 0.7rem;
  }
  .phantom-table th[scope='row'] {
    min-width: 9rem;
  }
}

/* Seven tabs plus tools need the second row sooner on the ledger. */
@media (max-width: 1360px) {
  .topbar.has-publish {
    grid-template-columns: 1fr auto auto;
  }
  .topbar.has-publish .brand {
    grid-area: 1 / 1;
  }
  .topbar.has-publish .session {
    grid-area: 1 / 2;
  }
  .topbar.has-publish .top-end {
    grid-area: 1 / 3;
  }
  .topbar.has-publish .tabs {
    grid-area: 2 / 1 / 3 / -1;
  }
}
@media (max-width: 760px) {
  .topbar.has-publish {
    grid-template-columns: 1fr auto;
  }
  .topbar.has-publish .brand {
    grid-area: 1 / 1 / 2 / -1;
  }
  .topbar.has-publish .session {
    grid-area: 2 / 1;
  }
  .topbar.has-publish .top-end {
    grid-area: 2 / 2;
  }
  .topbar.has-publish .tabs {
    grid-area: 3 / 1 / 4 / -1;
  }
}

/* Page links never break mid-name; on phones they scroll sideways if they must. */
.pages a {
  white-space: nowrap;
}
@media (max-width: 520px) {
  .brand {
    min-width: 0;
  }
  .pages {
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
}

/* ---------- family tree art (player page and ledger) ---------- */

.ft {
  position: relative;
  width: 100%;
  container-type: inline-size;
  border: 6px solid var(--walnut);
  border-radius: var(--r-md);
  box-shadow: 0 0 0 1px var(--walnut-hi), 0 18px 40px -18px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  background: #3b3550;
}
.ft-base {
  display: block;
  width: 100%;
  height: 100%;
}
.ft-pic,
.ft-hit {
  position: absolute;
  display: block;
  object-fit: fill;
}
.ft-pic {
  animation: ft-unveil 0.8s ease-out both;
}
@keyframes ft-unveil {
  from {
    opacity: 0;
    filter: brightness(0.3);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ft-pic {
    animation: none;
  }
}
.ft-hit {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.ft-hit img {
  display: block;
  width: 100%;
  height: 100%;
}
.ft-hit.peek img {
  opacity: 0.4;
}
.ft-hit.peek {
  outline: 2px dashed rgba(231, 181, 133, 0.7);
  outline-offset: -2px;
}
.ft-hit:hover,
.ft-hit:focus-visible {
  outline: 3px solid var(--copper-hi);
  outline-offset: -3px;
}
.ft-name {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0 3%;
  text-align: center;
  font: 700 1.55cqw/1 var(--serif);
  color: #2c1a0d;
  text-shadow: 0 1px 0 rgba(255, 230, 200, 0.45);
  transform-origin: center;
  overflow: hidden;
}
.ft-name span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
button.ft-name {
  border: 0;
  background: none;
  cursor: pointer;
}
button.ft-name.faint {
  color: rgba(44, 26, 13, 0.4);
  font-style: italic;
}
button.ft-name:hover,
button.ft-name:focus-visible {
  outline: 2px solid var(--copper-hi);
}

/* ledger: Family tree tab */
.fam-show {
  margin-top: 0.75rem;
}
.fam-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 34rem) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}
.fam-art .hint {
  margin-top: 0.5rem;
}
.fam-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.fam-summary p {
  margin: 0;
}
.fam-table {
  width: 100%;
  border-collapse: collapse;
}
.fam-table th,
.fam-table td {
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid #343a57;
  text-align: left;
  vertical-align: middle;
}
.fam-table thead th {
  font-size: 0.82rem;
  color: var(--ink-3);
  font-weight: 500;
}
.fam-table thead .note {
  font-weight: 400;
}
.fam-table tbody th {
  display: grid;
  gap: 0.15rem;
  font-weight: 400;
}
.fam-label {
  min-height: 2rem;
  padding: 0.2rem 0.45rem;
  font-weight: 500;
}
@media (max-width: 960px) {
  .fam-layout {
    grid-template-columns: 1fr;
  }
}

/* ---------- campaign: quests and the townsfolk switch ---------- */

.quest-line {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--ink-2);
}
.quest-line label,
.item-bolster {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}
.quest-line select,
.item-bolster select,
.item-ctl .item-note {
  width: auto;
  min-height: 1.9rem;
  padding: 0.15rem 0.4rem;
  background: var(--wall);
  font-size: 0.85rem;
}
.switch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.6rem;
  margin-top: 0.8rem;
}
.switch-row .btn {
  margin-left: auto;
  text-decoration: none;
  color: inherit;
}
.tally {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink-2);
  font-size: 0.9rem;
}
.tally strong {
  color: var(--ink);
}
.counter .bar,
.item-tile .bar {
  display: flex;
}
.counter .bar span.carried,
.item-tile .bar span.carried {
  background: repeating-linear-gradient(135deg, var(--copper-lo) 0 4px, transparent 4px 7px);
}

/* ---------- items tab ---------- */

.item-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.item-tile {
  display: grid;
  gap: 0.3rem;
  text-align: left;
  padding: 0.7rem 0.8rem 0.75rem;
  background: var(--wall-2);
  border: 1px solid transparent;
  border-top: 4px solid var(--walnut);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  cursor: pointer;
}
.item-tile:hover {
  border-color: var(--line);
  border-top-color: var(--walnut-hi);
}
.item-tile[aria-pressed='true'] {
  border-color: var(--copper-lo);
  border-top-color: var(--copper);
}
.item-tile-label {
  font: 700 1.05rem/1.2 var(--serif);
}
.item-tile-nums {
  font-size: 0.85rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.item-tile-nums strong {
  color: var(--ink);
}
.item-tile .bar {
  height: 5px;
  border-radius: 3px;
  background: #1b1e30;
  overflow: hidden;
}
.item-tile .bar span:first-child {
  background: var(--ecto-dim);
}
.items-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
}
.item-region {
  margin-top: 1.4rem;
}
.item-region h3 {
  font: 700 1.15rem/1.25 var(--serif);
  margin: 0 0 0.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 4px solid var(--walnut);
}
.item-region.is-locked h3 {
  color: var(--ink-2);
}
.lock-tag {
  font: 500 0.75rem/1 var(--sans);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-3);
  vertical-align: middle;
}
.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.item-row {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr) minmax(16rem, 22rem);
  gap: 0.4rem 1rem;
  padding: 0.6rem 0.6rem 0.6rem 0.75rem;
  border-bottom: 1px solid #343a57;
  border-left: 3px solid transparent;
}
.item-row.is-found {
  border-left-color: var(--copper);
  background: rgba(200, 138, 86, 0.06);
}
.item-row.is-done {
  border-left-color: var(--ecto-dim);
}
.item-row.is-done .item-what {
  opacity: 0.7;
}
.item-area {
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: start;
  gap: 0 0.45rem;
}
.area-code {
  grid-row: span 2;
  min-width: 2.6rem;
  padding: 0.1rem 0.3rem;
  border-radius: var(--r-sm);
  background: var(--copper-lo);
  color: #f6dcc2;
  font-weight: 700;
  text-align: center;
  align-self: start;
  font-variant-numeric: tabular-nums;
}
.area-name {
  font-weight: 500;
  line-height: 1.25;
}
.area-page {
  font-size: 0.78rem;
  color: var(--ink-3);
}
.item-what {
  display: grid;
  align-content: start;
  gap: 0.1rem;
}
.item-name {
  font-weight: 700;
}
.kind-soulheart .item-name {
  color: #f0a7aa;
}
.item-kind {
  font-weight: 400;
  color: var(--ink-3);
  margin-right: 0.2rem;
}
.item-soul,
.item-plaque {
  font-size: 0.82rem;
  color: var(--ink-2);
}
.item-soul {
  font-style: italic;
}
.item-what .gm-note {
  font-size: 0.85rem;
  color: #e8c48f;
}
.item-ctl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: start;
  gap: 0.35rem 0.5rem;
}
.item-seg button[aria-pressed='true'][data-v='found'] {
  background: var(--copper-lo);
  color: #fff3e6;
}
.item-seg button[aria-pressed='true'][data-v='done'] {
  background: var(--ecto-dim);
  color: var(--ink);
}
.item-stamps {
  font-size: 0.78rem;
  color: var(--ink-3);
}
.item-bolster {
  color: var(--ink-2);
}
.item-bolster select {
  max-width: 15rem;
}
.item-ctl .item-note {
  flex: 1 1 100%;
  width: 100%;
}
.item-note:placeholder-shown {
  border-style: dashed;
}
.item-used {
  font-size: 0.85rem;
  color: var(--ecto);
}
@media (max-width: 900px) {
  .item-row {
    grid-template-columns: 9.5rem minmax(0, 1fr);
  }
  .item-ctl {
    grid-column: 1 / -1;
  }
}
@media (max-width: 520px) {
  .item-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .item-area {
    grid-template-columns: auto auto 1fr;
    align-items: baseline;
  }
  .area-code {
    grid-row: auto;
  }
  .items-toolbar .seg {
    flex-wrap: wrap;
  }
}

/* ---------- people tab ---------- */

.pp-toolbar .pp-search {
  flex: 1 1 16rem;
  max-width: 24rem;
}
.pp-toolbar select {
  width: auto;
}
.pp-region {
  margin-top: 1.4rem;
}
.pp-region > h3 {
  font: 700 1.15rem/1.25 var(--serif);
  margin: 0 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 4px solid var(--walnut);
}
.pp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr));
  gap: 0.8rem;
}
.pp-card {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.9rem;
  padding: 0.75rem;
  background: var(--wall-2);
  border-left: 3px solid transparent;
  min-width: 0;
}
.pp-card.is-shown {
  border-left-color: var(--ecto);
}
.pp-art {
  display: grid;
  gap: 0.3rem;
  align-content: start;
}
.pp-art .btn {
  justify-content: center;
  text-decoration: none;
  color: inherit;
}
.pp-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  background: radial-gradient(circle at 50% 35%, #3d4566, #1b1e30 80%);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.pp-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.pp-noart {
  font-size: 0.8rem;
  color: var(--ink-3);
}
.pp-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
}
.pp-head h3 {
  margin: 0;
  font: 700 1.1rem/1.2 var(--serif);
}
.pp-where {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-2);
}
.pp-where .area-code {
  display: inline-block;
  min-width: 0;
  padding: 0 0.3rem;
  font-size: 0.78rem;
}
.pp-show {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--ink-2);
  white-space: nowrap;
}
.pp-body .gm-note {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: #e8c48f;
  font-style: italic;
}
.pp-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 9rem;
  gap: 0.45rem 0.6rem;
  margin-top: 0.55rem;
}
.pp-fields .wide {
  grid-column: 1 / -1;
}
.pp-fields textarea {
  min-height: 3.2rem;
}
.pp-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.pp-foot label.check {
  font-size: 0.85rem;
}
.pp-new {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.6rem 0.9rem;
  margin-top: 1rem;
  padding: 0.85rem;
  background: var(--wall-2);
  border-top: 4px solid var(--copper-lo);
}
.pp-new .wide {
  grid-column: 1 / -1;
}
.pp-new-actions {
  display: flex;
  gap: 0.5rem;
  align-items: end;
}
@media (max-width: 520px) {
  .pp-card {
    grid-template-columns: 5.5rem minmax(0, 1fr);
    gap: 0.6rem;
    padding: 0.6rem;
  }
  .pp-head {
    flex-direction: column;
  }
  .pp-fields {
    grid-template-columns: 1fr;
  }
}
.pp-art .file-btn {
  font-size: 0.875rem;
  cursor: pointer;
}

/* ---------- hero points tab ---------- */

.hp-toolbar {
  margin-bottom: 1rem;
}
.hp-toolbar .hp-why {
  flex: 1 1 18rem;
  max-width: 28rem;
}
.hp-toolbar select {
  width: auto;
}
.hp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr));
  gap: 1rem;
  align-items: start;
}
.hp-card {
  padding: 0.85rem 1rem 1rem;
  background: var(--wall-2);
  border-top: 5px solid var(--walnut);
  min-width: 0;
}
.hp-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0 1rem;
}
.hp-head h3 {
  margin: 0;
  font: 700 1.2rem/1.25 var(--serif);
}
.hp-now {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  grid-row: span 2;
}
.hp-now strong {
  font-size: 1.6rem;
  line-height: 1;
}
.hp-now .of {
  color: var(--ink-3);
}
.hp-given {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-3);
}
.hp-pips {
  display: inline-flex;
  gap: 0.3rem;
  margin-left: 0.2rem;
}
.hp-pips span {
  width: 0.85rem;
  height: 0.85rem;
  transform: rotate(45deg);
  border: 1px solid var(--ink-3);
}
.hp-pips span.on {
  background: var(--copper);
  border-color: var(--copper-hi);
}
.hp-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.7rem 0 0.5rem;
}
.hp-actions .hp-why {
  flex: 1 1 100%;
}
.hp-log td,
.hp-log th {
  padding: 0.35rem 0.45rem;
}
.hp-log td.hp-change.up {
  color: var(--ecto);
  font-weight: 700;
}
.hp-log td.hp-change.down {
  color: #f0a7aa;
  font-weight: 700;
}
.hp-log td:last-child {
  width: 2rem;
}

/* Campaign tab: which parts of the Tracking sheet players see */
.sheet-parts {
  margin-bottom: 1.25rem;
}
.sheet-switches {
  list-style: none;
  margin: 0.5rem 0 0.25rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.55rem 1.5rem;
}
.sheet-switches li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.sheet-switches label {
  display: block;
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
}

/* ---------- Chapters tab ---------- */
.chp-bulk {
  display: grid;
  gap: 0.4rem;
  justify-items: start;
  margin-bottom: 1.25rem;
}
.chp-bulk p {
  margin: 0;
}
.chp-list {
  display: grid;
  gap: 1rem;
}
.chp-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--wall-2);
  padding: 0.9rem 1rem 1rem;
  display: grid;
  gap: 0.75rem;
}
.chp-card.is-shown {
  border-color: var(--copper-lo);
  box-shadow: inset 3px 0 0 var(--copper);
}
.chp-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.75rem;
}
.chp-head h3 {
  margin: 0;
  font: 700 1.2rem var(--serif);
}
.chp-num {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.chp-line {
  font-size: 0.9rem;
}
.chp-slots {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}
.chp-slot {
  display: grid;
  gap: 0.35rem;
}
.chp-slot-label {
  font-size: 0.8rem;
  color: var(--ink-2);
}
.chp-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: radial-gradient(circle at 50% 35%, #3d4566, #1b1e30 80%);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.chp-thumb.cover {
  aspect-ratio: 3 / 2;
}
.chp-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chp-slot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.chp-cap {
  font-size: 0.85rem;
}
@media (max-width: 760px) {
  .chp-slots {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .chp-slot.is-cover {
    grid-column: 1 / -1;
  }
}
