/* RPG Hub — parchment by day, lamplit tavern by night */
:root {
  --bg: #f3ecdf;
  --surface: #fffaf1;
  --surface-2: #f7efe1;
  --ink: #2a2118;
  --muted: #6f6253;
  --line: #ddd0bb;
  --accent: #8b2e1f;
  --accent-ink: #fff;
  --accent-soft: #f4dfd6;
  --gold: #a87a2a;
  --gm: #4b3a7a;
  --gm-soft: #ece7f7;
  --secret: #1f5f57;
  --secret-soft: #e2f1ee;
  --danger: #a3261b;
  --link: #8b2e1f;
  --missing: #b0412e;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --radius: 10px;
  --display: "Cinzel", Georgia, serif;
  --body: "Source Serif 4", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130f; --surface: #221c16; --surface-2: #2b231b; --ink: #ece2d2; --muted: #a8998a;
    --line: #3d3329; --accent: #d0644c; --accent-ink: #1a120d; --accent-soft: #3a2219; --gold: #d3a24e;
    --gm: #b8a6f0; --gm-soft: #2a2440; --secret: #77c9bd; --secret-soft: #183330; --danger: #e0685a;
    --link: #e58c74; --missing: #e07a64; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17130f; --surface: #221c16; --surface-2: #2b231b; --ink: #ece2d2; --muted: #a8998a;
  --line: #3d3329; --accent: #d0644c; --accent-ink: #1a120d; --accent-soft: #3a2219; --gold: #d3a24e;
  --gm: #b8a6f0; --gm-soft: #2a2440; --secret: #77c9bd; --secret-soft: #183330; --danger: #e0685a;
  --link: #e58c74; --missing: #e07a64; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--body); overflow-x: hidden; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; letter-spacing: .01em; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
img { max-width: 100%; height: auto; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
pre { background: var(--surface-2); padding: .8em 1em; border-radius: 8px; overflow-x: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.user-nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: .95rem; }
.user-nav a { color: var(--ink); text-decoration: none; }
.user-nav a:hover { color: var(--accent); }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.linkish:hover { color: var(--accent); }
.inline { display: inline; }

/* campaign banner + nav */
.camp-banner { background: linear-gradient(135deg, #3b2418, #6b2a1c 55%, #8b5a2b); background-size: cover; background-position: center; color: #fff; }
.camp-banner.has-img { position: relative; }
.camp-banner-inner { max-width: 1180px; margin: 0 auto; padding: 2.2rem 16px 1.6rem;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.0) 100%); }
.camp-banner.has-img .camp-banner-inner { background: none; }
.camp-banner.has-img::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15,8,4,.25), rgba(15,8,4,.72)); }
.camp-banner.has-img .camp-banner-inner { position: relative; }
.camp-banner h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); margin: 0; }
.camp-banner h1 a { color: #fff; text-decoration: none; text-shadow: 0 2px 10px rgba(0,0,0,.4); }
.tagline { margin: .3rem 0 .6rem; font-style: italic; opacity: .92; }
.tagline-dark { margin: .2rem 0 .5rem; font-style: italic; color: var(--muted); }
.pills { display: flex; gap: .4rem; flex-wrap: wrap; }
.pill { display: inline-block; font: 600 .72rem/1 var(--body); text-transform: uppercase; letter-spacing: .06em;
  padding: .35em .6em; border-radius: 999px; background: rgba(255,255,255,.18); color: inherit; border: 1px solid rgba(255,255,255,.3); vertical-align: middle; }
main .pill, .panel .pill { background: var(--surface-2); border-color: var(--line); color: var(--muted); }
.pill.small { font-size: .62rem; }
.pill.gm, main .pill.role-gm { background: var(--gm-soft); color: var(--gm); border-color: transparent; }
main .pill.role-player { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.camp-nav { display: flex; align-items: center; gap: .2rem; flex-wrap: wrap; padding: 0 16px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.camp-nav > a { padding: .75rem .7rem; color: var(--ink); text-decoration: none; border-bottom: 2px solid transparent; font-size: .95rem; white-space: nowrap; }
.camp-nav > a:hover { color: var(--accent); }
.camp-nav > a.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.nav-search { margin-left: auto; padding: .4rem 0; }
.nav-search input { width: 200px; max-width: 100%; }
@media (max-width: 760px) {
  .camp-nav { overflow-x: auto; flex-wrap: nowrap; position: static; }
  .nav-search { display: none; }
}

/* layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.6rem 16px 4rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.4rem; align-items: start; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
@media (max-width: 900px) { .layout, .two-col { grid-template-columns: 1fr; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
section { margin-bottom: 1.6rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.panel > :last-child { margin-bottom: 0; }
.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.crumb { margin: 0 0 .3rem; font-size: .9rem; color: var(--muted); }
.crumb a { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.meta { color: var(--muted); font-size: .88rem; margin: .3rem 0 0; }
.empty { color: var(--muted); font-style: italic; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.plain li:last-child { border-bottom: 0; }
.hero { text-align: center; padding: 4rem 1rem; }
.hero h1 { font-size: 2.6rem; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card h3 { margin: 0 0 .2rem; }
.card p { margin: 0; }
.card-body { padding: .9rem 1rem 1rem; }
.thumb { height: 110px; background: linear-gradient(135deg, #3b2418, #8b5a2b) center/cover; }
.thumb.tall { height: 170px; }
.char-card { display: flex; align-items: stretch; }
.char-card .card-body { flex: 1; min-width: 0; }
.portrait { width: 92px; flex: none; background: var(--surface-2) center/cover; display: grid; place-items: center;
  font: 700 2rem var(--display); color: var(--muted); }
.portrait.big { width: 160px; height: 200px; border-radius: var(--radius); border: 1px solid var(--line); }
.char-head { display: flex; gap: 1.4rem; align-items: flex-start; margin-bottom: 1.2rem; flex-wrap: wrap; }
.char-head h1 { margin-bottom: .1rem; }
.char-head .actions { margin-top: .8rem; }
.mini-char { display: flex; gap: .7rem; align-items: center; padding: .4rem 0; color: var(--ink); text-decoration: none; line-height: 1.25; }
.mini-char:hover strong { color: var(--accent); }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--surface-2) center/cover;
  display: grid; place-items: center; font: 700 1rem var(--display); color: var(--muted); border: 1px solid var(--line); }

/* next session + log */
.next-session { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: baseline; padding: .9rem 1.2rem;
  border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent); margin-bottom: 1.2rem; }
.next-session .label { font: 600 .72rem var(--body); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.log-item { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.log-item:last-child { border-bottom: 0; }
.log-entry header h2 a { color: var(--ink); text-decoration: none; }
.log-entry header h2 a:hover { color: var(--accent); }
.log-entry header p { margin: 0 0 .6rem; }
.sess { display: block; font: 600 .75rem var(--body); text-transform: uppercase; letter-spacing: .1em; color: var(--gold); margin-bottom: .15rem; }
.excerpt { max-height: 11em; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent); mask-image: linear-gradient(180deg, #000 60%, transparent); }
.small-link { font-size: .9rem; }
.thread-row { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .6rem 0; border-bottom: 1px dashed var(--line); }
.thread-row:last-child { border-bottom: 0; }
.comment { padding: .6rem 0; border-bottom: 1px dashed var(--line); }
.panel.comment { padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.comment-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.byline { font-size: .85rem; color: var(--muted); }
.wiki-groups { columns: 2 320px; column-gap: 1.2rem; }
.wiki-groups .panel { break-inside: avoid; }
.history li { padding: .5rem 0; }

/* prose */
.prose { overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { margin-top: 1.2em; }
.prose > :first-child { margin-top: 0; }
.prose blockquote { margin: 1em 0; padding: .2em 1em; border-left: 3px solid var(--gold); color: var(--muted); font-style: italic; }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .35em .6em; text-align: left; }
.prose th { background: var(--surface-2); }
.prose img { border-radius: 8px; }
.stats { font-size: .95rem; }
.wikilink { font-weight: 600; text-decoration-style: dotted; }
.wikilink.char { color: var(--gold); }
.wikilink.missing { color: var(--missing); text-decoration-style: dashed; opacity: .85; }
.gm-secret { border: 1px dashed var(--gm); background: var(--gm-soft); border-radius: 8px; padding: .4em 1em; margin: 1em 0; position: relative; }
.gm-secret::before { content: "GM only"; position: absolute; top: -.7em; left: .8em; background: var(--gm); color: var(--surface);
  font: 700 .62rem/1 var(--body); letter-spacing: .1em; text-transform: uppercase; padding: .3em .5em; border-radius: 4px; }
.gm-box { border-color: var(--gm); background: var(--gm-soft); }
.gm-box h3 { color: var(--gm); }
.secret-box { border-color: var(--secret); background: var(--secret-soft); }
.secret-box h3 { color: var(--secret); }

/* forms */
.field { display: block; margin-bottom: 1rem; border: 0; padding: 0; min-width: 0; }
.field > span, .field > label, .field legend { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }
.hint { margin: -.1rem 0 .4rem; font-size: .85rem; color: var(--muted); }
input, select, textarea { width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 7px; padding: .55rem .7rem; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input[type=file] { padding: .4rem; background: var(--surface-2); }
textarea { resize: vertical; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; gap: .5rem; align-items: baseline; margin: .3rem 0 .8rem; font-weight: 400 !important; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.row > .field.grow { flex: 3 1 260px; }
.row.end { align-items: flex-end; }
.row.end > .btn { margin-bottom: 1rem; }
.gm-field textarea { border-color: var(--gm); background: var(--gm-soft); }
.editor-tools { display: flex; gap: .6rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .4rem; }
.md-help summary { cursor: pointer; font-size: .85rem; color: var(--muted); padding: .3rem 0; }
.md-help > div { font-size: .88rem; background: var(--surface-2); padding: .6rem .9rem; border-radius: 8px; margin-top: .3rem; }
.md-help p { margin: .3rem 0; }
.form-actions { display: flex; gap: 1rem; align-items: center; margin-top: .5rem; }
.small-input { width: 150px; padding: .3rem .5rem; font-size: .85rem; }
.banner-preview { display: block; max-height: 140px; border-radius: 8px; margin-bottom: .4rem; }
.portrait-preview { display: block; max-height: 160px; border-radius: 8px; margin-bottom: .4rem; }
.danger-zone { border-color: var(--danger); }
.invite { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; }
.invite input { flex: 1 1 260px; font-family: ui-monospace, monospace; font-size: .85rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: .3rem; font: 600 .95rem var(--body); padding: .55rem 1rem;
  border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: var(--surface); }
.btn.small { padding: .3rem .65rem; font-size: .82rem; }
.btn:disabled { opacity: .6; cursor: wait; }

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.table select { width: auto; padding: .3rem .5rem; }
.table .actions form { display: inline-flex; gap: .3rem; }

/* flashes */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid var(--line); background: var(--surface); }
.flash-success { border-color: var(--secret); background: var(--secret-soft); }
.flash-error { border-color: var(--danger); background: var(--accent-soft); }

/* maps */
.map-frame { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; margin-bottom: 1.2rem; overflow: auto; max-height: 80vh; }
.map-frame img { display: block; margin: 0 auto; max-width: none; width: 100%; }

/* dice roller */
.dice { position: fixed; right: 16px; bottom: 16px; z-index: 20; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: .5rem; }
.dice-toggle { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow); font-size: 1.5rem; cursor: pointer; }
.dice-panel { width: min(320px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem; }
.dice-panel form { display: flex; gap: .4rem; }
.dice-quick { display: flex; flex-wrap: wrap; gap: .3rem; margin: .6rem 0; }
.dice-quick button { font: .8rem ui-monospace, monospace; padding: .25rem .45rem; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; }
.dice-quick button:hover { border-color: var(--accent); }
.dice-log { list-style: none; padding: 0; margin: 0; max-height: 240px; overflow-y: auto; }
.dice-log li { padding: .35rem 0; border-top: 1px dashed var(--line); }
.dice-log li strong { font: 700 1.3rem var(--display); color: var(--accent); margin-right: .3rem; }
.dice-log .expr { font-family: ui-monospace, monospace; font-size: .85rem; }
.dice-log .detail { font-size: .78rem; color: var(--muted); font-family: ui-monospace, monospace; }
.dice-log li.err { color: var(--danger); font-size: .85rem; }

.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem 16px; }
