/* Soulbind: a grimoire at night. Plum ink, bone paper, brass fittings, amethyst magic. */

@font-face { font-family: 'Alegreya'; src: url(/fonts/alegreya-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Alegreya'; src: url(/fonts/alegreya-latin-500-italic.woff2) format('woff2'); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: 'Alegreya'; src: url(/fonts/alegreya-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Alegreya'; src: url(/fonts/alegreya-latin-800-normal.woff2) format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Alegreya Sans'; src: url(/fonts/alegreya-sans-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Alegreya Sans'; src: url(/fonts/alegreya-sans-latin-400-italic.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Alegreya Sans'; src: url(/fonts/alegreya-sans-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Alegreya Sans'; src: url(/fonts/alegreya-sans-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --ink: #17131f;        /* page */
  --surface: #211b2b;    /* panels */
  --raised: #2b2438;     /* inputs on panels, list items */
  --hover: #352c45;
  --line: #3d3450;
  --line-soft: #2f2840;
  --text: #ece4d6;       /* bone */
  --muted: #a99fb8;
  --amethyst: #9b6bdf;
  --amethyst-hi: #b994ee;
  --brass: #d4a24c;
  --brass-hi: #e6ba68;
  --brass-ink: #241a08;
  --ember: #e0624f;
  --moss: #86c08a;
  --serif: 'Alegreya', Georgia, 'Times New Roman', serif;
  --sans: 'Alegreya Sans', 'Segoe UI', system-ui, sans-serif;
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --shadow: 0 18px 50px rgba(5, 2, 12, .55);
  /* aliases used by older code */
  --bg: var(--ink); --bg2: var(--surface); --bg3: var(--raised);
  --accent: var(--brass); --accent2: var(--brass-hi); --danger: var(--ember);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--ink); color: var(--text);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }
a { color: var(--brass-hi); }
h1, h2, h3, h4 { margin: 0 0 .5em; font-family: var(--serif); font-weight: 700; line-height: 1.15; }
h4 { font-size: 16px; color: var(--text); margin-top: 1em; }
p { margin: 0 0 .7em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.error { color: var(--ember); min-height: 1.2em; }
.icon { flex-shrink: 0; display: block; }
::selection { background: rgba(155, 107, 223, .45); }
:focus-visible { outline: 2px solid var(--amethyst-hi); outline-offset: 2px; }

/* ---------- form controls ---------- */
input, textarea, select {
  background: var(--ink); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 8px 10px; font: inherit; min-width: 0;
  transition: border-color .15s;
}
input::placeholder, textarea::placeholder { color: #776d88; }
input:hover, textarea:hover, select:hover { border-color: #52476a; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--amethyst); box-shadow: 0 0 0 3px rgba(155, 107, 223, .25); }
input[type=color] { padding: 2px; width: 38px; height: 32px; cursor: pointer; }
input[type=checkbox] { width: auto; accent-color: var(--brass); }
input[type=range] { accent-color: var(--brass); padding: 0; border: 0; background: none; box-shadow: none; }
input[type=date], input[type=time] { color-scheme: dark; }
textarea { resize: vertical; line-height: 1.5; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--raised); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 7px 13px; font: 500 15px/1.2 var(--sans);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--hover); border-color: #574b70; }
.btn.primary {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass));
  color: var(--brass-ink); border-color: #b3842f; font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 240, 200, .35);
}
.btn.primary:hover { background: linear-gradient(180deg, #f0c878, var(--brass-hi)); }
.btn.danger { color: #ff9d8c; }
.btn.danger.primary { background: var(--ember); color: #fff; border-color: #b8473a; box-shadow: none; }
.btn.small { padding: 5px 9px; font-size: 13.5px; gap: 5px; }
.btn.big { padding: 11px 20px; font-size: 16.5px; }
.btn.wide { width: 100%; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); padding-left: 6px; }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.btn.link { background: none; border: 0; color: var(--muted); padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.btn.link:hover { color: var(--text); background: none; }
.btn.link.danger { color: #e98b7c; }
.btn.glass { background: rgba(23, 19, 31, .62); border-color: rgba(236, 228, 214, .22); backdrop-filter: blur(6px); }
.btn.glass:hover { background: rgba(23, 19, 31, .85); }
.btn.icon-only { padding: 7px 9px; }
.icon-btn {
  display: inline-grid; place-items: center;
  background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 5px; border-radius: var(--r-s); font: inherit;
}
.icon-btn:hover { color: var(--text); background: var(--hover); }

/* ---------- avatars ---------- */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; flex-shrink: 0; color: #fff; font-family: var(--serif); font-weight: 700; background: #4a3f5e; vertical-align: middle; box-shadow: 0 0 0 1.5px rgba(236, 228, 214, .14); }
.avatar-wrap { position: relative; display: inline-flex; }
.avatar-wrap .dot { position: absolute; right: -1px; bottom: -1px; border: 2px solid var(--surface); width: 12px; height: 12px; }
.avatar-stack { display: flex; align-items: center; }
.avatar-stack .stack-item { margin-left: -9px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); display: inline-flex; }
.avatar-stack .stack-item:first-child { margin-left: 0; }
.stack-more { margin-left: 6px; color: var(--muted); font-size: 13px; }
.me-row { gap: 4px; flex-wrap: nowrap; }
.me-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--raised); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 3px 13px 3px 3px; cursor: pointer; font: inherit;
}
.me-chip:hover { border-color: var(--brass); }
.me-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 40px; height: 40px; object-fit: contain; }
.wordmark { font-family: var(--serif); font-weight: 800; letter-spacing: .01em; margin: 0; }
.wordmark.small { font-size: 22px; }

/* ---------- login ---------- */
.auth-page {
  min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; align-items: center;
  gap: 32px; padding: 32px max(24px, 6vw);
  background:
    radial-gradient(60% 70% at 22% 45%, rgba(155, 107, 223, .28), transparent 70%),
    radial-gradient(40% 40% at 30% 70%, rgba(212, 162, 76, .10), transparent 70%),
    var(--ink);
}
.auth-art { display: flex; flex-direction: column; align-items: flex-start; }
.auth-dragon { width: min(300px, 50vw); filter: drop-shadow(0 20px 50px rgba(155, 107, 223, .45)); margin-bottom: 8px; }
.auth-art .wordmark { font-size: clamp(48px, 7vw, 92px); line-height: .95; color: var(--text); }
.auth-tag { font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 21px; color: var(--muted); max-width: 26ch; margin-top: 14px; }
.auth-card {
  width: 100%; max-width: 400px; justify-self: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l);
  padding: 30px 30px 22px; display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow);
}
.auth-card h2 { font-size: 26px; margin-bottom: 4px; }
.auth-card .btn.primary { margin-top: 8px; }
.auth-card .btn.link { align-self: center; margin-top: 8px; }

/* ---------- lobby ---------- */
.lobby { max-width: 1180px; margin: 0 auto; padding: 18px 24px 60px; }
.lobby-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding-bottom: 28px; }
.lobby-top > .brand { justify-self: start; }
.lobby-top > .me-row { justify-self: end; }
.top-nav { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.top-link { display: inline-flex; align-items: center; gap: 9px; padding: 7px 16px 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; }
.top-link:hover { border-color: var(--brass); }
.top-link:focus-visible { outline: 2px solid var(--amethyst); outline-offset: 2px; }
.top-link .icon { color: var(--brass-hi); flex: none; }
.top-link-text { display: flex; flex-direction: column; line-height: 1.15; }
.top-link-text b { font-family: var(--serif); font-size: 16px; }
.top-link-text small { color: var(--muted); font-size: 12px; white-space: nowrap; }
@media (max-width: 700px) { .lobby-top { grid-template-columns: 1fr auto; } .top-nav { grid-column: 1 / -1; grid-row: 2; } .lobby-top > .brand .wordmark { display: none; } }
.lobby-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.lobby-head h1 { font-size: clamp(34px, 4.4vw, 52px); margin: 0; }
.covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 26px; }

/* banner art */
.banner { position: relative; overflow: hidden; background: #261d33; }
.banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner.generated {
  background:
    radial-gradient(55% 80% at var(--x, 70%) 30%, rgba(155, 107, 223, .55), transparent 70%),
    radial-gradient(35% 50% at calc(100% - var(--x, 70%)) 85%, rgba(212, 162, 76, .25), transparent 70%),
    conic-gradient(from var(--ang, 0deg) at 50% 120%, #1c1527, #2e2140, #1a1424, #2a1f3a, #1c1527);
}
.banner.generated::before {
  content: ''; position: absolute; inset: 0; opacity: .5;
  background-image: radial-gradient(1px 1px at 12% 18%, #fff8, transparent), radial-gradient(1px 1px at 72% 12%, #fff6, transparent),
    radial-gradient(1.5px 1.5px at 40% 30%, #fff7, transparent), radial-gradient(1px 1px at 88% 40%, #fff5, transparent),
    radial-gradient(1px 1px at 25% 55%, #fff4, transparent), radial-gradient(1.5px 1.5px at 60% 8%, #fff6, transparent);
}
.banner.generated .banner-mark {
  position: absolute; width: auto; height: 120%; right: -6%; top: -14%; object-fit: contain;
  opacity: .22; filter: saturate(.8) drop-shadow(0 0 30px rgba(155, 107, 223, .6));
}

/* reordering */
.covers .cover[data-id] { position: relative; }
.cover-grip {
  position: absolute; top: 10px; right: 10px; z-index: 2; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: var(--r-s); color: var(--text);
  background: rgba(23, 19, 31, .6); border: 1px solid rgba(236, 228, 214, .18);
  cursor: grab; touch-action: none; opacity: 0; transition: opacity .15s;
}
.cover:hover .cover-grip, .cover.dragging .cover-grip { opacity: 1; }
@media (hover: none) { .cover-grip { opacity: 1; } }
.cover.dragging { outline: 2px solid var(--brass); outline-offset: 3px; opacity: .85; transform: scale(1.02); box-shadow: var(--shadow); z-index: 3; }
body.reordering, body.reordering * { cursor: grabbing !important; user-select: none; }
body.reordering .cover-art .banner { transform: none; }

/* the signature element: a campaign is a book cover */
.cover {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-l);
  overflow: hidden; box-shadow: 0 10px 30px rgba(5, 2, 12, .35);
}
.cover-art { position: relative; display: block; font: inherit; aspect-ratio: 16 / 10; padding: 0; border: 0; background: none; cursor: pointer; color: inherit; text-align: left; overflow: hidden; }
.cover-art .banner { position: absolute; inset: 0; transition: transform .5s ease; }
.cover-art:hover .banner { transform: scale(1.035); }
.cover-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(23, 19, 31, 0) 35%, rgba(23, 19, 31, .55) 62%, rgba(23, 19, 31, .96)); pointer-events: none; }
.cover-title { position: absolute; left: 20px; right: 20px; bottom: 16px; z-index: 1; }
.cover-title h2 { font-size: 32px; margin: 4px 0 0; text-wrap: balance; text-shadow: 0 2px 14px rgba(0, 0, 0, .6); }
.cover-role {
  position: absolute; top: 12px; left: 12px; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px;
  background: rgba(23, 19, 31, .7); border: 1px solid rgba(212, 162, 76, .45); backdrop-filter: blur(4px);
  color: var(--brass-hi); font-size: 14px; font-weight: 500;
}
.cover-foot { display: flex; align-items: center; gap: 12px; padding: 12px 16px 14px 20px; border-top: 1px solid var(--line-soft); }
.cover-facts { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; font-size: 14px; }
.cover-facts span { display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cover-facts .soon { color: var(--text); font-weight: 500; }
.cover-facts .soon .icon { color: var(--brass-hi); }
.cover-facts .world { color: var(--text); }
.cover-facts .world .icon { color: var(--amethyst-hi); }
.cover-facts .icon { flex: none; }
.new-cover {
  min-height: 300px; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 28px;
  background: transparent; border: 1.5px dashed var(--line); color: var(--muted); cursor: pointer; font: inherit; box-shadow: none;
}
.new-cover:hover { border-color: var(--brass); color: var(--brass-hi); }
.new-cover .new-title { font-family: var(--serif); font-weight: 700; font-size: 24px; color: var(--text); }
.new-cover .muted { max-width: 30ch; }

/* ---------- campaign page ---------- */
.campaign-page { max-width: 1180px; margin: 0 auto; padding: 14px 24px 60px; }
.cp-top { display: flex; align-items: center; gap: 10px; padding-bottom: 14px; }
.cp-hero { position: relative; border-radius: var(--r-l); overflow: hidden; min-height: clamp(260px, 38vw, 420px); display: flex; align-items: flex-end; box-shadow: var(--shadow); }
.cp-hero .cp-banner { position: absolute; inset: 0; }
.cp-hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(23, 19, 31, 0) 30%, rgba(23, 19, 31, .6) 65%, rgba(23, 19, 31, .97)); pointer-events: none; }
.cp-hero-text { position: relative; z-index: 1; padding: 28px 32px 26px; max-width: 900px; }
.cp-title { font-size: clamp(40px, 6.4vw, 78px); font-weight: 800; line-height: .98; margin: 0 0 12px; text-wrap: balance; text-shadow: 0 3px 24px rgba(0, 0, 0, .55); }
.cp-dm { display: flex; align-items: center; gap: 8px; color: var(--brass-hi); font-size: 17px; margin: 0; }
.cp-banner-actions { position: absolute; top: 16px; right: 16px; z-index: 2; display: flex; gap: 8px; }
.cp-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 22px 0 34px; }
.cp-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 40px; align-items: start; }
.cp-main h2 { font-size: 28px; margin-bottom: 14px; }
.cp-story { margin-bottom: 40px; }
.cp-desc p { font-family: var(--serif); font-weight: 500; font-size: 19px; line-height: 1.6; max-width: 62ch; white-space: pre-wrap; }
.party-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.party-list.gms { margin-top: 10px; }
.party-row { display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 14px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-m); }
.party-who { flex: 1; min-width: 0; }
.party-char { font-family: var(--serif); font-weight: 700; font-size: 19px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.party-name { color: var(--muted); font-size: 14px; }
.cp-side { display: flex; flex-direction: column; gap: 18px; }
.cp-facts { margin: 0; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-l); padding: 6px 20px; }
.fact { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.fact:last-child { border-bottom: 0; }
.fact dt { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin-bottom: 3px; }
.fact dt .icon { color: var(--brass); }
.fact dd { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 20px; line-height: 1.25; }
.fact dd small { display: block; font-family: var(--sans); font-weight: 400; font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.cp-invite { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-l); padding: 16px 20px; }
.cp-invite h3 { display: flex; align-items: center; gap: 8px; font-size: 19px; margin-bottom: 4px; }
.cp-invite h3 .icon { color: var(--amethyst-hi); }
.invite-row { display: flex; gap: 8px; align-items: center; }
.invite-url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-s); padding: 6px 9px; font-size: 13px; color: var(--amethyst-hi); }
.cp-danger { padding-left: 4px; }
.cp-danger .btn { gap: 6px; }

/* edit dialog */
.edit-banner-row { display: flex; gap: 16px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.edit-banner { width: 220px; aspect-ratio: 16 / 7; border-radius: var(--r-m); overflow: hidden; border: 1px solid var(--line); }
.edit-banner .banner { width: 100%; height: 100%; }
.row.fields { align-items: flex-start; gap: 12px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 6, 16, .7); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s ease-out; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); width: 100%; max-width: 460px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: rise .18s ease-out; }
.modal.wide { max-width: 780px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
.modal-head h3 { margin: 0; font-size: 24px; }
.modal-body { padding: 8px 20px 12px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-soft); }
.modal-foot .danger:not(.primary) { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .modal, .modal-back { animation: none; } .cover-art .banner { transition: none; } }
.field { display: flex; flex-direction: column; gap: 5px; margin: 9px 0; flex: 1; min-width: 120px; }
.field > span { font-size: 14px; color: var(--muted); font-weight: 500; }
.field small { color: var(--muted); font-size: 12.5px; }
.check { display: flex; align-items: flex-start; gap: 8px; margin: 9px 0; cursor: pointer; flex-wrap: wrap; }
.check > span { flex: 1; min-width: 0; }
.check small { flex-basis: 100%; color: var(--muted); font-size: 12.5px; padding-left: 22px; margin-top: -4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-m); padding: 6px 14px 10px; margin: 0; min-width: 0; }
legend { font-family: var(--serif); color: var(--brass-hi); font-weight: 700; font-size: 17px; padding: 0 6px; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #2f2740; border: 1px solid var(--line); border-left: 3px solid var(--amethyst); padding: 10px 16px; border-radius: var(--r-m); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); transition: opacity .4s; }
.toast.error { border-left-color: var(--ember); }
.toast.hide { opacity: 0; }

.ctx-menu { position: fixed; z-index: 150; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 5px; min-width: 200px; box-shadow: var(--shadow); }
.ctx-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 7px 11px; border-radius: var(--r-s); font: inherit; cursor: pointer; }
.ctx-menu button:hover { background: var(--hover); }
.ctx-menu button.danger { color: #ff9d8c; }
.ctx-sep { height: 1px; background: var(--line-soft); margin: 4px 0; }

/* ---------- game layout ---------- */
.game { height: 100%; display: flex; flex-direction: column; }
.topbar { position: relative; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 5px 10px; background: var(--surface); border-bottom: 1px solid var(--line-soft); min-height: 50px; }
.topbar-logo { width: 30px; height: 30px; object-fit: contain; }
.camp-name { font-family: var(--serif); font-weight: 700; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; margin-right: 6px; }
.page-bar { display: flex; gap: 4px; align-items: center; flex: 1 1 auto; min-width: 0; }
.page-strip { display: flex; gap: 4px; align-items: center; flex: 0 1 auto; min-width: 0; overflow: hidden; }
.page-tab { flex: none; display: flex; align-items: center; gap: 2px; border-radius: var(--r-s); }
.page-card { position: relative; display: block; width: 108px; height: 81px; padding: 0; border: 1.5px solid var(--line); border-radius: 5px; overflow: hidden; background: var(--ink); cursor: pointer; font: inherit; color: var(--text); }
.page-card:hover { border-color: var(--muted); }
.page-card:focus-visible { outline: 2px solid var(--amethyst); outline-offset: 2px; }
.page-tab.current .page-card { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.page-thumb { display: block; }
.page-label { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 6px 3px; font-size: 13px; font-weight: 600; line-height: 1.15; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: linear-gradient(transparent, rgba(16, 13, 22, .92) 55%); }
.page-card .players-here { position: absolute; top: 3px; left: 3px; padding: 2px; border-radius: 4px; background: rgba(16, 13, 22, .85); }
.page-tab { position: relative; }
.page-tools { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; z-index: 2; }
.page-tool { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: rgba(16, 13, 22, .85); color: var(--text); cursor: pointer; }
.page-tool:hover { border-color: var(--brass); color: var(--brass-hi); }
.page-tool:focus-visible { outline: 2px solid var(--amethyst); outline-offset: 1px; }
.page-menu-card .page-tools { top: 6px; right: 6px; }
.page-menu-card .page-tool { width: 28px; height: 28px; }
.page-more { position: absolute; left: 50%; bottom: -21px; transform: translateX(-50%); z-index: 31; display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 12px 1px 9px;
  border: 1px solid var(--line-soft); border-top: 0; border-radius: 0 0 10px 10px; background: var(--surface); color: var(--muted); font: 600 12px var(--sans, inherit); cursor: pointer; }
.page-more:hover, .page-more.open { color: var(--text); }
.page-more:focus-visible { outline: 2px solid var(--amethyst); outline-offset: 2px; }
.page-tab.dragging, .page-menu-card.dragging { opacity: .4; }
.page-tab.drop-before .page-card, .page-menu-card.drop-before .page-menu-pic { box-shadow: -4px 0 0 var(--brass); }
.page-tab.drop-after .page-card, .page-menu-card.drop-after .page-menu-pic { box-shadow: 4px 0 0 var(--brass); }
.page-more .icon.down { transform: rotate(90deg); transition: transform .15s; }
.page-more.open .icon.down { transform: rotate(-90deg); }
.page-more-count { font-size: 12px; font-weight: 700; color: var(--brass-hi); }
.page-menu { position: fixed; z-index: 140; left: 50%; transform: translateX(-50%); width: min(1120px, calc(100vw - 16px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--shadow); padding: 12px; }
.page-menu-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; font-family: var(--serif); font-size: 17px; }
/* four rows of pages, then it scrolls */
.page-menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); grid-auto-rows: 155px; gap: 12px; max-height: calc(4 * 155px + 3 * 12px); max-height: min(calc(4 * 155px + 3 * 12px), calc(100vh - 170px)); overflow-y: auto; padding: 2px 4px 2px 2px; }
.page-menu-card { position: relative; width: 168px; }
.page-menu-open { display: flex; flex-direction: column; gap: 5px; padding: 0; background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.page-menu-pic { position: relative; width: 168px; height: 126px; border: 1.5px solid var(--line); border-radius: var(--r-s); overflow: hidden; background: var(--ink); display: grid; place-items: center; color: var(--muted); }
.page-menu-card:hover .page-menu-pic { border-color: var(--muted); }
.page-menu-card.current .page-menu-pic { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.page-menu-card.add .page-menu-pic { border-style: dashed; }
.page-menu-open:focus-visible .page-menu-pic { outline: 2px solid var(--amethyst); outline-offset: 2px; }
.page-menu-pic .players-here { position: absolute; top: 6px; left: 6px; gap: 4px; padding: 2px 7px 2px 5px; border-radius: 99px; font-size: 12px; font-weight: 700; background: rgba(16, 13, 22, .88); }
.page-menu-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 168px; }
.players-here { color: var(--brass-hi); display: inline-flex; }
.conn-status { font-size: 13px; }
.conn-status.bad { color: var(--ember); }
.game-body { flex: 1; display: flex; min-height: 0; }
.toolbar { width: 66px; background: var(--surface); border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; align-items: center; padding: 8px 5px; gap: 3px; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.toolbar::-webkit-scrollbar { display: none; }
.tool { display: grid; place-items: center; width: 48px; min-height: 42px; background: none; border: 1px solid transparent; border-radius: var(--r-m); color: var(--muted); cursor: pointer; flex-shrink: 0; font: inherit; }
.tool:hover { background: var(--hover); color: var(--text); }
.tool.active { background: rgba(212, 162, 76, .16); border-color: rgba(212, 162, 76, .7); color: var(--brass-hi); }
.tool.layer { width: 56px; min-height: 30px; font-size: 12.5px; font-weight: 500; line-height: 1.1; padding: 4px 2px; gap: 2px; }
.tool-sep { width: 40px; height: 1px; background: var(--line-soft); margin: 6px 0; flex-shrink: 0; }
.tool-label { font-size: 12px; color: var(--muted); }
.board-wrap { flex: 1; position: relative; overflow: hidden; min-width: 0; background: #0f0c15; }
canvas.board { display: block; touch-action: none; }
.page-fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .6s ease; z-index: 8; }
.page-fade.on { opacity: 1; pointer-events: auto; }
.board-hud { position: absolute; bottom: 10px; right: 10px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); background: rgba(23, 19, 31, .85); border: 1px solid var(--line-soft); padding: 4px 12px; border-radius: 999px; }
.hud-text { pointer-events: none; white-space: nowrap; }
.hud-zoom { width: 130px; margin: 0; }
.hud-zoom-pct { min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; pointer-events: none; }
@media (max-width: 800px) { .hud-zoom { width: 90px; } .hud-text { display: none; } }
.presence { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 10px; align-items: flex-end; pointer-events: none; z-index: 5; max-width: calc(100% - 140px); flex-wrap: wrap-reverse; }
.presence-card { width: 85px; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: auto; }
.presence-pic { position: relative; width: 75px; height: 75px; border-radius: 13px; border: 4px solid var(--pc); box-shadow: 0 4px 14px rgba(0, 0, 0, .55), 0 0 12px color-mix(in srgb, var(--pc) 45%, transparent); background: #2b2438; overflow: visible; }
.presence-pic img, .presence-letter { width: 100%; height: 100%; border-radius: 9px; object-fit: cover; display: grid; place-items: center; }
.presence-letter { font: 700 32px var(--serif); color: #fff; background: color-mix(in srgb, var(--pc) 55%, #2b2438); }
.presence-dm { position: absolute; top: -10px; left: -10px; box-shadow: 0 1px 4px rgba(0,0,0,0.5); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brass); color: var(--brass-ink); }
.presence-name { max-width: 85px; font-size: 15px; font-weight: 700; color: var(--text); background: rgba(23, 19, 31, .85); border: 1px solid var(--pc); padding: 0 8px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 800px) { .presence-card { width: 61px; } .presence-pic { width: 53px; height: 53px; } .presence-name { display: none; } }
.sidebar { width: 370px; background: var(--surface); border-left: 1px solid var(--line-soft); position: relative; flex: none; display: flex; flex-direction: column; min-height: 0; }
.sidebar-grip { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 5; touch-action: none; }
.sidebar-grip::after { content: ''; position: absolute; left: 3px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background .15s; }
.sidebar-grip:hover::after, .resizing-sidebar .sidebar-grip::after { background: var(--brass); }
.resizing-sidebar { cursor: col-resize; user-select: none; }
.no-sidebar .sidebar { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--line-soft); padding: 0 6px; }
.tab { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 12px 4px 10px; cursor: pointer; font: 500 15px var(--sans); position: relative; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--brass); }
.tab .badge { position: absolute; top: 8px; margin-left: 3px; width: 7px; height: 7px; border-radius: 50%; font-size: 0; }
.tab .badge:not(:empty) { background: var(--amethyst-hi); }
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-body > * { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }
.panel-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.panel-head h4 { margin: 0; }
.panel-head input[type=search] { flex: 1; }

/* ---------- chat ---------- */
.panel-body > .chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { background: var(--raised); border-radius: var(--r-m); padding: 7px 10px; word-wrap: break-word; }
.msg.whisper { background: #2a2140; border: 1px dashed #6d58a0; }
.msg.system { background: none; color: var(--muted); font-style: italic; font-size: 13px; padding: 2px 4px; }
.msg.emote { background: none; color: #dccca6; font-family: var(--serif); font-style: italic; font-size: 16px; }
.msg-head { display: flex; gap: 6px; align-items: center; font-size: 13px; margin-bottom: 2px; }
.who { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.whisper-tag { color: var(--amethyst-hi); }
.time { margin-left: auto; color: var(--muted); font-size: 12px; }
.msg-text { white-space: pre-wrap; }
.roll-card { margin-top: 5px; background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-m); padding: 8px 10px; text-align: center; }
.roll-card.success { border-color: var(--moss); box-shadow: 0 0 14px rgba(134, 192, 138, .3); }
.roll-card.fail { border-color: var(--ember); box-shadow: 0 0 14px rgba(224, 98, 79, .3); }
.roll-label { font-family: var(--serif); font-weight: 700; font-size: 16px; color: var(--brass-hi); }
.roll-formula { color: var(--muted); font-size: 13px; }
.roll-total { font-family: var(--serif); font-size: 34px; font-weight: 800; line-height: 1.1; }
.breakdown { font-size: 13px; color: var(--muted); }
.breakdown .notation { color: var(--text); }
.d.dropped { text-decoration: line-through; opacity: .5; }
.d.max { color: var(--moss); font-weight: 700; }
.d.min { color: #ff9d8c; font-weight: 700; }
.crit-text { font-size: 13px; font-weight: 700; }
.success .crit-text { color: var(--moss); }
.fail .crit-text { color: #ff9d8c; }
.dice-bar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 8px 12px; border-top: 1px solid var(--line-soft); align-items: stretch; }
.dice-bar .die.adv, .dice-bar .die.dis, .dice-bar .hidden-roll { grid-column: span 2; }
.dice-bar .mod { width: auto; }
.die { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; background: var(--ink); border: 1px solid var(--line); color: var(--text); border-radius: var(--r-s); padding: 4px 5px 3px; cursor: pointer; font: 500 12px var(--sans); }
.die .icon { color: var(--amethyst-hi); }
.die:hover { border-color: var(--brass); }
.die:hover .icon { color: var(--brass-hi); }
.die.adv, .die.dis { justify-content: center; font-weight: 700; padding: 4px 8px; }
.die.adv { color: var(--moss); }
.die.dis { color: #ff9d8c; }
.die.adv.on { background: rgba(134, 192, 138, .18); border-color: var(--moss); box-shadow: 0 0 0 1px var(--moss) inset; }
.die.dis.on { background: rgba(224, 98, 79, .18); border-color: var(--ember); box-shadow: 0 0 0 1px var(--ember) inset; }
.mod { width: 56px; padding: 5px 6px; }
.hidden-roll { display: flex; gap: 4px; align-items: center; font-size: 13px; color: var(--muted); }
.speak-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; }
.speak-as { flex: 1; padding: 5px 8px; font-weight: 500; }
.who.as-char .avatar { border-radius: 30%; }
.player-tag { color: var(--muted); font-weight: 400; font-size: 12px; }
.chat-input { display: flex; gap: 6px; padding: 8px 12px 12px; }
.chat-input textarea { flex: 1; }

/* ---------- journal ---------- */
.panel-body > .journal { display: flex; flex-direction: column; }
.journal-item { background: var(--raised); border-radius: var(--r-m); padding: 9px 12px; margin-bottom: 6px; cursor: pointer; border: 1px solid transparent; }
.journal-item:hover { border-color: var(--line); }
.ji-title { display: flex; align-items: center; gap: 6px; font-family: var(--serif); font-weight: 700; font-size: 17px; }
.ji-title .icon { color: var(--amethyst-hi); }
.ji-preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ji-title-input { font-family: var(--serif); font-size: 21px; font-weight: 700; margin-bottom: 8px; width: 100%; }
.ji-body { flex: 1; width: 100%; min-height: 300px; font-family: var(--serif); font-weight: 500; font-size: 17px; line-height: 1.6; }
.ji-foot { padding-top: 4px; }
.journal-notice { background: #33291a; border: 1px solid #6b5530; border-radius: var(--r-s); padding: 7px 9px; margin-bottom: 6px; font-size: 13px; }

.panel-body > .notes { display: flex; flex-direction: column; gap: 6px; }
.notes-box { flex: 1; width: 100%; min-height: 200px; resize: none; font-family: var(--serif); font-weight: 500; font-size: 17px; line-height: 1.6; padding: 14px 16px; background: #1b1624; border-color: var(--line-soft); }
.notes-status { min-height: 1.4em; }

/* ---------- library ---------- */
.library.dropping { outline: 2px dashed var(--brass); outline-offset: -6px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; }
.seg button { background: none; border: 0; color: var(--muted); padding: 5px 9px; cursor: pointer; font: inherit; font-size: 13px; }
.seg button.active { background: var(--hover); color: var(--text); }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.asset { position: relative; background: var(--raised); border-radius: var(--r-m); overflow: hidden; cursor: grab; border: 1px solid transparent; }
.asset:hover { border-color: var(--line); }
.asset img, .audio-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #0f0c15; }
.audio-thumb { display: grid; place-items: center; color: var(--amethyst-hi); }
.asset-name { font-size: 12px; padding: 4px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-menu { position: absolute; top: 3px; right: 3px; background: rgba(23, 19, 31, .75); color: var(--text); padding: 3px; }
.tag { font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 4px; margin-right: 4px; background: #4a3f5e; }
.tag.map { background: #2f5a3c; }
.tag.token { background: #4a3a74; }
.lib-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin: 2px 0 10px; }
.crumb { display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid transparent; color: var(--muted); padding: 4px 7px; border-radius: var(--r-s); font: 500 14.5px var(--sans); cursor: pointer; }
.crumb:hover { color: var(--text); background: var(--hover); }
.crumb.here { color: var(--text); font-family: var(--serif); font-weight: 700; font-size: 16px; }
.crumb .icon { color: var(--brass); }
.crumb-sep { color: #6c6280; }
.folder-tile { cursor: pointer; background: transparent; border: 1px solid var(--line-soft); }
.folder-tile:hover { border-color: var(--line); background: var(--raised); }
.folder-art { aspect-ratio: 1.6; display: grid; place-items: center; color: var(--brass); }
.folder-tile .asset-name { font-weight: 500; font-size: 13px; padding-bottom: 0; }
.folder-count { font-size: 11.5px; color: var(--muted); padding: 0 7px 6px; }
.drop-here { border-color: var(--brass) !important; background: rgba(212, 162, 76, .14) !important; color: var(--text); }
.folder-tile { position: relative; }
.folder-tile.dragging { opacity: .4; }
.folder-tile.drop-before::before, .folder-tile.drop-after::after { content: ''; position: absolute; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: var(--brass); pointer-events: none; }
.folder-tile.drop-before::before { left: -5px; }
.folder-tile.drop-after::after { right: -5px; }
.asset.selected { border-color: var(--brass); box-shadow: 0 0 0 2px rgba(212, 162, 76, .55); }
.asset.selected .asset-name { background: rgba(212, 162, 76, .18); }
.lib-marquee { position: fixed; z-index: 120; border: 1px solid var(--amethyst-hi); background: rgba(155, 107, 223, .15); pointer-events: none; }
.drag-ghost { position: fixed; top: -100px; left: -100px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--brass); color: var(--brass-ink); font: 700 14px var(--sans); }
.sel-info:empty { display: none; }
.sel-info { margin-bottom: 8px; }
.asset-grid { user-select: none; min-height: 220px; align-content: start; }
.lib-empty { grid-column: 1 / -1; }
.lib-help { margin-top: 12px; }
.upload-progress { background: var(--raised); padding: 7px 10px; border-radius: var(--r-s); margin-bottom: 8px; }

/* ---------- music ---------- */
.music-actions { margin-bottom: 10px; }
.music-group { position: relative; border-radius: var(--r-m); border: 1px solid transparent; margin-bottom: 4px; }
.music-group.dragging { opacity: .45; }
.music-folder .folder-grip { width: 18px; opacity: 0; }
.music-folder:hover .folder-grip, .folder-grip:focus-visible { opacity: 1; }
.music-group.drop-before::before, .music-group.drop-after::after { content: ''; position: absolute; left: 4px; right: 4px; height: 2px; border-radius: 2px; background: var(--brass); pointer-events: none; }
.music-group.drop-before::before { top: -3px; }
.music-group.drop-after::after { bottom: -3px; }
.music-group.loose { min-height: 36px; }
.music-folder { display: flex; align-items: center; gap: 4px; border-radius: var(--r-s); }
.music-folder:hover { background: var(--raised); }
.music-folder-name { flex: 1; display: flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--text); font: 600 15px var(--sans); padding: 6px 6px; cursor: pointer; text-align: left; }
.music-folder-name .icon:nth-child(2) { color: var(--brass); }
.music-folder-name .icon.open { transform: rotate(90deg); }
.music-folder.has-playing .music-folder-name { color: var(--brass-hi); }
.music-group .track { margin-left: 4px; }
.music-loose-label { padding: 8px 6px 2px; }
.add-music { display: flex; flex-direction: column; }
.add-group { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--brass-hi); margin: 10px 0 2px; }
.add-item { margin: 4px 0 4px 18px; }
.track { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr); grid-template-areas: "grip name" ". controls"; column-gap: 6px; row-gap: 3px; align-items: center; padding: 9px 8px 8px 2px; border-bottom: 1px solid var(--line-soft); }
.track > .track-grip { grid-area: grip; opacity: 0; }
.track:hover > .track-grip, .track > .track-grip:focus-visible { opacity: 1; }
.track > .track-name { grid-area: name; font-weight: 700; }
.track-controls { grid-area: controls; display: flex; align-items: center; gap: 6px; min-width: 0; }
.track-controls input[type=range] { flex: 1 1 auto; min-width: 60px; }
.track-controls .icon-btn { flex: none; }
.track.dragging { opacity: .45; }
.track-grip { display: grid; place-items: center; color: var(--muted); cursor: grab; touch-action: none; transition: opacity .12s; }
.track-grip:active { cursor: grabbing; }
.track.drop-before::before, .track.drop-after::after { content: ''; position: absolute; left: 4px; right: 4px; height: 2px; border-radius: 2px; background: var(--brass); pointer-events: none; }
.track.drop-before::before { top: -1px; }
.track.drop-after::after { bottom: -1px; }
.loop-toggle { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid transparent; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.loop-toggle:hover { color: var(--text); }
.loop-toggle.on { border-color: var(--brass); color: var(--brass-hi); background: rgba(212, 162, 76, .1); }
.loop-toggle:focus-visible { outline: 2px solid var(--amethyst); outline-offset: 2px; }
.track.playing { background: rgba(212, 162, 76, .12); border-radius: var(--r-s); }
.track-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .play { color: var(--brass-hi); }
.np { display: flex; align-items: center; gap: 4px; padding: 3px 0; }
.np .icon { color: var(--amethyst-hi); }
.unlock-audio { width: 100%; margin-bottom: 8px; }
.floating-unlock { position: fixed; bottom: 18px; right: 18px; z-index: 90; box-shadow: var(--shadow); }

/* ---------- players ---------- */
.invite-box { background: var(--raised); border-radius: var(--r-m); padding: 12px; margin-bottom: 12px; }
.invite-code { font: 800 28px var(--serif); letter-spacing: .2em; color: var(--brass-hi); margin: 4px 0 8px; }
.member { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.member-name { flex: 1; min-width: 120px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #5d5370; }
.dot.on { background: var(--moss); box-shadow: 0 0 6px var(--moss); }
.role { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 6px; background: #3f3462; }
.role.gm { background: #5e4720; color: var(--brass-hi); }
.help { margin-top: 14px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.help summary { cursor: pointer; font-family: var(--serif); font-weight: 700; font-size: 16px; padding: 4px 0; }
.help ul { padding-left: 18px; }
.member-name > div:first-child { display: flex; align-items: center; flex-wrap: wrap; }
.member-token { width: 42px; height: 42px; border-radius: var(--r-s); overflow: hidden; border: 1px solid var(--line); background: var(--ink); cursor: grab; flex-shrink: 0; display: grid; place-items: center; padding: 0; color: var(--muted); }
.member-token img { width: 100%; height: 100%; object-fit: cover; }
.member-token.empty { border-style: dashed; cursor: pointer; }
.member-token.empty:hover { color: var(--brass-hi); border-color: var(--brass); }
.member-token:not(.empty):hover { border-color: var(--brass); }
.member-actions { flex-basis: 100%; padding-left: 43px; }
.token-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.token-choice { display: flex; flex-direction: column; gap: 4px; background: var(--raised); border: 1px solid transparent; border-radius: var(--r-m); padding: 6px; cursor: pointer; color: var(--text); font: 12px var(--sans); overflow: hidden; }
.token-choice img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-s); }
.token-choice span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.token-choice:hover, .token-choice.current { border-color: var(--brass); }
.help li { margin: 4px 0; }
.invite-link { width: 100%; margin: 6px 0; font-size: 13px; }
.invite-code-inline { color: var(--brass-hi); letter-spacing: .1em; }

/* ---------- profile dialog ---------- */
.profile-photo { display: flex; gap: 16px; align-items: center; margin: 6px 0 10px; }
.pw-details { margin-top: 8px; }
.pw-details summary { cursor: pointer; color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 28px 16px; gap: 18px; }
  .auth-art { align-items: center; }
  .auth-dragon { width: 150px; }
  .auth-card { justify-self: center; text-align: left; }
  .cp-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}
@media (max-width: 800px) {
  .sidebar { position: absolute; right: 0; top: 50px; bottom: 0; width: min(370px, 100vw) !important; z-index: 20; }
  .sidebar-grip { display: none; }
  .camp-name { max-width: 110px; }
  .topbar-logo { display: none; }
  .toolbar { width: 54px; }
  .tool { width: 44px; }
  .tool.layer { width: 46px; font-size: 11px; }
  .me-name { display: none; }
  .me-chip { padding: 3px; }
}
@media (max-width: 560px) {
  .lobby, .campaign-page { padding-left: 16px; padding-right: 16px; }
  .covers { grid-template-columns: 1fr; }
  .cover-title h2 { font-size: 27px; }
  .cp-hero-text { padding: 20px; }
  .cp-banner-actions .btn:not(.icon-only) { font-size: 0; gap: 0; padding: 7px 9px; }
}

/* token bars in the token dialogs */
.bar-row { display: grid; grid-template-columns: 14px 1fr; column-gap: 8px; align-items: center; margin: 6px 0 2px; }
.bar-row > .row { grid-column: 1 / -1; flex-wrap: wrap; }
.bar-row > .row .field { flex: 1 1 70px; min-width: 70px; }
.bar-swatch { width: 14px; height: 14px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); }
.form-stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---------- groups & chronicles ---------- */

.group-hero { padding: 26px 0 30px; border-bottom: 1px solid var(--line-soft); margin-bottom: 30px; }
.group-kicker { display: flex; align-items: center; gap: 7px; color: var(--brass-hi); margin: 0 0 6px; }
.group-title { display: flex; align-items: center; gap: 10px; font-size: clamp(38px, 5.6vw, 64px); font-weight: 800; line-height: 1; margin: 0 0 12px; }
.group-hero .muted { max-width: 62ch; font-size: 17px; margin: 0; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.chronicle-list { display: flex; flex-direction: column; gap: 22px; }
.chronicle { display: grid; grid-template-columns: 220px minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-l); overflow: hidden; }
.chronicle-art { position: relative; min-height: 180px; }
.chronicle-art .banner { position: absolute; inset: 0; }
.chronicle-body { padding: 18px 22px 20px; min-width: 0; }
.chronicle-head { display: flex; align-items: flex-start; gap: 8px; }
.chronicle-head h3 { flex: 1; font-size: 24px; line-height: 1.1; margin: 0 0 6px; }
.chronicle-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 14.5px; margin: 0 0 10px; }
.chronicle-meta span { display: inline-flex; align-items: center; gap: 6px; }
.chronicle-meta .icon { color: var(--brass); }
.chronicle-summary p { font-family: var(--serif); font-weight: 500; font-size: 15.5px; line-height: 1.55; max-width: 62ch; margin: 0 0 10px; }
.chronicle-party { border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 6px; }
.chronicle-party ul { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.chronicle-party li { display: flex; align-items: center; gap: 10px; }
.chronicle-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 40px 20px; border: 1.5px dashed var(--line); border-radius: var(--r-l); color: var(--muted); }
.chronicle-empty .icon { color: var(--brass); }
.chronicle-empty p { max-width: 44ch; margin: 0; }
.gm-list { list-style: none; padding: 0; margin: 8px 0 0; }
.gm-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.gm-row:last-child { border-bottom: 0; }
.gm-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 2px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 5px 4px; border-radius: var(--r-s); cursor: pointer; }
.pick-row:hover { background: var(--raised); }
.pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-code-line { margin-top: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chron-players { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 14px; margin: 6px 0; }
.chron-player { display: grid; grid-template-columns: minmax(0, 1fr) auto 130px; gap: 8px; align-items: center; }
.chron-player.extra { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) 30px; margin-bottom: 6px; }
.chron-pic { position: relative; display: inline-flex; }
.chron-portrait { position: relative; display: inline-flex; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
.chron-portrait > .icon { position: absolute; right: -3px; bottom: -3px; padding: 2px; box-sizing: content-box; border-radius: 50%; background: var(--surface); color: var(--brass); opacity: 0; transition: opacity .15s; }
.chron-portrait:hover > .icon, .chron-portrait:focus-visible > .icon, .chron-pic .chron-portrait > .icon { opacity: 1; }
.chron-portrait:hover .avatar { outline: 2px solid var(--brass); outline-offset: 1px; }
.chron-pic-clear { position: absolute; top: -5px; right: -7px; display: inline-flex; padding: 1px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; }
.players-pick .cp-invite { padding: 12px 14px; margin-bottom: 12px; }
@media (max-width: 700px) {
  .chronicle { grid-template-columns: minmax(0, 1fr); }
  .chronicle-art { min-height: 140px; }
}
.edit-campaign > select { margin-bottom: 12px; max-width: 100%; }

/* bar bubbles above the selected token (green, blue, red) */
.bubbles { position: absolute; z-index: 6; display: flex; gap: 6px; transform: translate(-50%, -100%); pointer-events: none; }
.bubble { pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 3px solid; padding: 0; text-align: center;
  font: 700 14px var(--sans, 'Alegreya Sans', sans-serif); color: #fff; background: rgba(16,12,22,0.88); box-shadow: 0 2px 6px rgba(0,0,0,0.5); outline: none; }
.bubble.green { border-color: #43a047; } .bubble.blue { border-color: #3f8cff; } .bubble.red { border-color: #d9483b; }
.bubble.empty { background: rgba(16,12,22,0.55); }
.bubble:hover { filter: brightness(1.2); }
.bubble:focus { font-size: 16px !important; width: 64px; border-radius: 20px; box-shadow: 0 0 0 2px var(--amethyst, #9b6bdf), 0 2px 6px rgba(0,0,0,0.5); }
.thumb-wait { color: var(--muted); opacity: .6; }

/* characters in the Players tab */
.member-chars { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; padding-left: 43px; }
.char-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 9px 3px 3px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); color: var(--text); font: 13px var(--sans); }
.char-chip.can { cursor: pointer; }
.char-chip[draggable="true"] { cursor: grab; }
.char-chip.can:hover { border-color: var(--brass); }
.char-chip img, .char-initials { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.char-initials { display: grid; place-items: center; background: var(--ink); color: var(--muted); font-size: 11px; font-weight: 700; }
.char-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.char-looks { color: var(--amethyst, #9b6bdf); display: inline-flex; }
.char-add { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: none; border: 1px dashed var(--line); color: var(--muted); font: 12.5px var(--sans); cursor: pointer; }
.char-add:hover { color: var(--brass-hi); border-color: var(--brass); }
/* the pictures (looks) of a token */
.looks { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.look { position: relative; width: 76px; display: flex; flex-direction: column; gap: 3px; padding: 4px; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--raised); cursor: pointer; font: 11.5px var(--sans); color: var(--text); }
.look img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-s); }
.look span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.look.current { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.look-x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: none; background: rgba(10,8,14,.75); color: var(--text); display: grid; place-items: center; cursor: pointer; padding: 0; }
.look-x:hover { color: #ff8a80; }
.span-all { grid-column: 1 / -1; margin: 0; }

/* wall tools flyout, beside the wall button */
.tool-flyout { position: fixed; z-index: 40; display: flex; gap: 3px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.tool-flyout .tool { width: 40px; min-height: 36px; }
/* short screens: smaller buttons, so the toolbar never needs to scroll */
@media (max-height: 860px) {
  .toolbar { gap: 1px; padding: 6px 5px; }
  .tool { min-height: 36px; }
  .tool.layer { min-height: 26px; }
  .tool-sep { margin: 4px 0; }
}
@media (max-height: 760px) {
  .tool { min-height: 31px; }
  .tool-sep { margin: 2px 0; }
}

/* ---------- tables (start page) ---------- */
.lobby-lead { margin: -10px 0 26px; max-width: 64ch; }
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 22px; margin-bottom: 34px; }
.tables-sub { font-size: 26px; margin: 8px 0 16px; }
.table-card { display: flex; align-items: center; gap: 20px; padding: 20px 22px; border-radius: var(--r-l); border: 1px solid var(--line); background:
  radial-gradient(120% 140% at 0% 50%, rgba(212, 162, 76, .08), transparent 60%), var(--surface);
  color: var(--text); text-align: left; cursor: pointer; font: inherit; transition: border-color .15s, transform .15s; }
.table-card:hover { border-color: var(--brass); transform: translateY(-2px); }
.table-card:focus-visible { outline: 2px solid var(--amethyst); outline-offset: 3px; }
/* a round tabletop, its people seated around it */
.table-ring { position: relative; width: 132px; height: 132px; flex: none; }
.table-top { position: absolute; inset: 22px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(circle at 35% 30%, #5a3f26, #3a2715 62%, #2a1b0e); box-shadow: inset 0 0 0 3px rgba(212, 162, 76, .55), inset 0 0 18px rgba(0, 0, 0, .55), 0 6px 16px rgba(0, 0, 0, .45); }
.table-count { font-family: var(--serif); font-size: 28px; font-weight: 800; color: var(--brass-hi); line-height: 1; }
.table-top small { color: #d9c7a5; font-size: 11px; }
.seat { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; box-shadow: 0 0 0 2px var(--surface), 0 2px 6px rgba(0, 0, 0, .5); }
.seat.dm { box-shadow: 0 0 0 2px var(--brass), 0 2px 6px rgba(0, 0, 0, .5); }
.table-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.table-info h2 { margin: 0; font-size: 26px; line-height: 1.1; overflow-wrap: anywhere; }
.table-role { display: inline-flex; align-items: center; gap: 6px; color: var(--brass-hi); font-size: 13px; }
.new-table { flex-direction: column; justify-content: center; text-align: center; border-style: dashed; min-height: 172px; color: var(--muted); gap: 8px; }
.new-table b { font-family: var(--serif); font-size: 22px; color: var(--text); }
.table-campaigns { margin-bottom: 40px; }
.cp-table-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
@media (max-width: 560px) {
  .tables { grid-template-columns: 1fr; }
  .table-card { padding: 16px; gap: 14px; }
  .table-ring { width: 110px; height: 110px; }
}
