/* Layout: a single-column ledger. Header with party gold, three tabs, entries as expandable rows. */
:root {
  --bg: #f2f1f5;
  --surface: #ffffff;
  --ink: #1e1b27;
  --muted: #625d70;
  --line: #dcd9e3;
  --accent: #4e3a7a;
  --accent-ink: #ffffff;
  --gold: #8a6214;
  --danger: #a3302a;
  --chip: #ebe7f3;
  --r-uncommon: #2f7d32; --r-rare: #2860b8; --r-very-rare: #7d3fb0; --r-legendary: #b85f12;
  --font-display: "Alegreya SC", Georgia, serif;
  --font-body: "Alegreya Sans", system-ui, -apple-system, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15131b; --surface: #1e1b27; --ink: #ebe8f2; --muted: #a29cb3; --line: #34303f;
    --accent: #b49ce6; --accent-ink: #15131b; --gold: #e2b65a; --danger: #ef7d74; --chip: #2a2537;
    --r-uncommon: #7fd17f; --r-rare: #7fb0f2; --r-very-rare: #c79af0; --r-legendary: #f0a35e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15131b; --surface: #1e1b27; --ink: #ebe8f2; --muted: #a29cb3; --line: #34303f;
  --accent: #b49ce6; --accent-ink: #15131b; --gold: #e2b65a; --danger: #ef7d74; --chip: #2a2537;
  --r-uncommon: #7fd17f; --r-rare: #7fb0f2; --r-very-rare: #c79af0; --r-legendary: #f0a35e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.5; }
.wrap { max-width: 860px; margin: 0 auto; padding-block: 24px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 20px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; text-wrap: balance; }
h1 { font-size: 2rem; line-height: 1.1; }
h2 { font-size: 1.3rem; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.gp { color: var(--gold); }
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 6px; padding: 6px 12px; font-weight: 500; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }

header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.title-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stats { display: flex; gap: 20px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat b { font-family: var(--font-num); font-size: 1.25rem; font-weight: 500; }

nav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
nav button { border: 0; background: none; color: var(--muted); padding: 8px 14px; font-weight: 700; border-bottom: 2px solid transparent; margin-bottom: -1px; }
nav button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search], .toolbar select { flex: 1 1 180px; min-width: 0; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }
textarea { resize: vertical; line-height: 1.45; }

.list { display: flex; flex-direction: column; gap: 10px; }
details.session { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
details.session > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: baseline; }
details.session > summary::-webkit-details-marker { display: none; }
.sno { font-family: var(--font-num); color: var(--muted); font-size: .9rem; }
.stitle { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; min-width: 0; }
.smeta { grid-column: 2 / 4; color: var(--muted); font-size: .9rem; display: flex; gap: 12px; flex-wrap: wrap; }
.sbody { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.summary p { margin: 0 0 8px; max-width: 68ch; }
.summary p b { font-weight: 700; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--chip); border-radius: 999px; padding: 1px 10px; font-size: .85rem; }
.minis { display: flex; flex-direction: column; gap: 4px; }
.mini { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.mini span:first-child { min-width: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; min-width: 620px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--chip); }
.status { font-size: .82rem; font-weight: 700; border-radius: 4px; padding: 1px 8px; background: var(--chip); white-space: nowrap; }
.status.gone { opacity: .6; text-decoration: line-through; }
.rarity { font-size: .75rem; font-weight: 700; border-radius: 4px; padding: 0 6px; border: 1px solid currentColor; white-space: nowrap; }
.r-common { color: var(--muted); } .r-uncommon { color: var(--r-uncommon); } .r-rare { color: var(--r-rare); }
.r-very-rare { color: var(--r-very-rare); } .r-legendary { color: var(--r-legendary); } .r-artifact { color: var(--danger); }
.contrib { margin: -2px 0 10px 14px; padding: 6px 12px; background: var(--chip); border-radius: 6px; max-width: 68ch; }
.contrib p { margin: 0; }
.contrib .by { font-size: .8rem; color: var(--muted); font-style: italic; margin-top: 2px; }
.contrib .by .btn.link { font-style: normal; font-size: .8rem; }
.item-info summary { cursor: pointer; font-size: .85rem; color: var(--accent); font-weight: 700; margin-top: 2px; }
.item-info p { margin: 6px 0; font-size: .9rem; max-width: 60ch; }
.item-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 6px; text-align: left; color: var(--ink); }
.card h3 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.char-head { display: flex; gap: 12px; align-items: center; }
.portrait { width: 56px; height: 56px; flex: none; border-radius: 50%; overflow: hidden; background: var(--chip); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; color: var(--accent); border: 2px solid var(--line); }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.inv summary { cursor: pointer; font-size: .9rem; color: var(--accent); font-weight: 700; }
.inv ul { margin: 6px 0 0; padding-left: 18px; font-size: .9rem; columns: 1; }
.inv li.eq::after { content: " · equipped"; color: var(--muted); font-size: .8rem; }
.note { color: var(--muted); font-size: .9rem; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 8px; padding: 24px; text-align: center; color: var(--muted); }
.banner { border: 1px solid var(--danger); color: var(--danger); border-radius: 8px; padding: 10px 14px; }

.overlay { position: fixed; inset: 0; background: rgb(10 8 16 / .55); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; z-index: 20;
  padding: calc(24px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal { background: var(--surface); border-radius: 10px; width: 100%; max-width: 560px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .85rem; font-weight: 700; }
.field .hint { font-size: .8rem; color: var(--muted); }
.modal-actions { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.modal-actions div { display: flex; gap: 8px; }
.error { color: var(--danger); font-size: .9rem; }
.att-chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--chip); color: var(--accent); border-radius: 999px; padding: 0 9px; font-size: .82rem; font-weight: 700; margin: 2px 4px 2px 0; vertical-align: baseline; max-width: 100%; }
.att-chip svg { width: 12px; height: 12px; flex: none; }
.att-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tiles.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.tile { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 0; overflow: hidden; display: flex; flex-direction: column; text-align: left; color: var(--ink); min-width: 0; }
.thumb { aspect-ratio: 4 / 3; max-width: 100%; background: var(--chip); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-thumb { font-family: var(--font-num); font-size: 1.1rem; color: var(--accent); border: 2px solid var(--accent); border-radius: 4px; padding: 6px 10px; }
.tile-text { padding: 7px 9px; display: flex; flex-direction: column; min-width: 0; }
.tile-text b { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-text span { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal.wide { max-width: 980px; }
.viewer-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.viewer-stage { overflow: auto; max-height: 72vh; background: var(--chip); border-radius: 6px; }
.viewer-stage img { display: block; max-width: 100%; margin: 0 auto; cursor: zoom-in; }
.viewer-stage.zoomed img { max-width: none; cursor: zoom-out; }
.viewer-stage canvas { display: block; width: 100%; height: auto; margin-bottom: 8px; background: #fff; }
.viewer-stage .note { padding: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
@media (max-width: 520px) { .fields { grid-template-columns: 1fr; } h1 { font-size: 1.6rem; } }
@media (prefers-reduced-motion: no-preference) { details.session[open] .sbody { animation: fade .15s ease-out; } @keyframes fade { from { opacity: .4; } to { opacity: 1; } } }
