:root {
  color-scheme: dark;
  --bg: #0a0912;
  --bg-2: #100e1b;
  --surface: #161325;
  --surface-2: #1e1a31;
  --border: #2b2643;
  --text: #ece9f6;
  --muted: #a29dba;
  --faint: #6f6a88;
  --accent: #8b5cf6;
  --accent-2: #c4b5fd;
  --gold: #e9c46a;
  --yes: #22c55e;
  --maybe: #eab308;
  --no: #ef4444;
  --radius: 14px;
  --heading: "Cinzel", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(139, 92, 246, .22), transparent),
    radial-gradient(ellipse 50% 40% at 90% 10%, rgba(233, 196, 106, .07), transparent);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--heading); font-weight: 600; letter-spacing: .02em; line-height: 1.2; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1100px; width: 100%; margin: 0 auto; padding: 18px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--heading); font-weight: 700; font-size: 1.15rem; letter-spacing: .06em; }
.brand:hover { text-decoration: none; }
.sigil {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2a1f4d, #07060d 70%);
  border: 1px solid var(--accent); color: var(--gold); font-size: 1rem;
  box-shadow: 0 0 18px rgba(139, 92, 246, .45);
}
#nav { display: flex; align-items: center; gap: 18px; font-size: .95rem; }
#nav a:not(.btn) { color: var(--muted); }
#nav a:not(.btn):hover { color: var(--text); text-decoration: none; }
#nav .who { color: var(--text); font-weight: 500; }

/* ---------- Buttons & forms ---------- */
.btn, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: transform .12s, box-shadow .2s, background .2s, border-color .2s;
}
.btn { color: #fff; background: linear-gradient(135deg, var(--accent), #6d28d9); }
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(139, 92, 246, .35); }
.btn-ghost { color: var(--text); background: transparent; border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); text-decoration: none; }
.btn-danger { color: #fecaca; background: transparent; border-color: #7f1d1d; padding: 6px 12px; font-size: .85rem; }
.btn-danger:hover { background: #450a0a; }
.btn-small { padding: 6px 12px; font-size: .88rem; }
button:disabled { opacity: .55; cursor: default; transform: none !important; box-shadow: none !important; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: .9rem; color: var(--muted); font-weight: 500; }
.field .hint { font-size: .8rem; color: var(--faint); }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=url], input[type=search] {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font: inherit;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.form-error { color: #fca5a5; font-size: .92rem; min-height: 1.4em; margin-bottom: 8px; }
.form-ok { color: #86efac; font-size: .92rem; min-height: 1.4em; margin-bottom: 8px; }

/* ---------- Layout ---------- */
main.wrap { max-width: 1100px; width: 100%; margin: 0 auto; padding: 0 20px 60px; flex: 1; }
.hero { text-align: center; padding: 48px 0 36px; }
.hero h1 {
  font-size: clamp(2.1rem, 6vw, 3.6rem); font-weight: 700;
  background: linear-gradient(180deg, #fff 10%, var(--accent-2) 60%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(139, 92, 246, .25);
}
.hero p { color: var(--muted); margin-top: 10px; font-size: 1.08rem; }
.banner {
  margin: 22px auto 0; max-width: 620px; padding: 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.banner a { font-weight: 600; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-top: 24px; }
.panel > h2, .panel-head h2 { font-size: 1.25rem; color: var(--gold); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------- Campaign cards ---------- */
.campaigns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.campaign {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 22px 20px;
}
.campaign::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--c); }
.campaign::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%);
  pointer-events: none;
}
.campaign h2 { font-size: 1.4rem; color: var(--c); }
.campaign .when { margin-top: 4px; color: var(--text); font-weight: 500; }
.campaign .local { font-size: .88rem; color: var(--muted); }
.campaign .next { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.campaign .next-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); }

/* ---------- Session rows ---------- */
.upcoming { display: grid; gap: 12px; }
.session {
  display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 16px;
  padding: 14px 16px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border);
  border-left: 3px solid var(--c);
}
.session-date { text-align: center; line-height: 1.1; }
.session-date .dow { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.session-date .dnum { display: block; font-family: var(--heading); font-size: 1.6rem; font-weight: 700; color: var(--text); }
.session-date .mon { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.session-info h3 { font-size: 1.05rem; color: var(--c); }
.session-info p { font-size: .9rem; }
.session-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.counts { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.counts .y { color: var(--yes); } .counts .m { color: var(--maybe); } .counts .n { color: var(--no); }

/* RSVP segmented control */
.rsvp { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.rsvp button {
  font: inherit; font-size: .86rem; font-weight: 600; padding: 7px 12px; cursor: pointer;
  background: transparent; color: var(--muted); border: 0; border-right: 1px solid var(--border);
}
.rsvp button:last-child { border-right: 0; }
.rsvp button:hover { color: var(--text); background: var(--surface-2); }
.rsvp button.on.yes { background: color-mix(in srgb, var(--yes) 22%, transparent); color: #bbf7d0; }
.rsvp button.on.maybe { background: color-mix(in srgb, var(--maybe) 22%, transparent); color: #fef08a; }
.rsvp button.on.no { background: color-mix(in srgb, var(--no) 22%, transparent); color: #fecaca; }

/* ---------- Calendar ---------- */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav h2 { min-width: 190px; text-align: center; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-weekdays div { text-align: center; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); padding-bottom: 6px; }
.cal-day {
  min-height: 96px; padding: 6px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.cal-day.other { opacity: .38; }
.cal-day.today { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.cal-day .num { font-size: .82rem; color: var(--muted); font-weight: 600; }
.cal-day.today .num { color: var(--gold); }
.chip {
  display: flex; align-items: center; gap: 5px; width: 100%; text-align: left;
  font: inherit; font-size: .76rem; font-weight: 600; line-height: 1.25; cursor: pointer;
  padding: 4px 6px; border-radius: 6px; border: 0; color: var(--text);
  background: color-mix(in srgb, var(--c) 22%, transparent); border-left: 3px solid var(--c);
}
.chip:hover { background: color-mix(in srgb, var(--c) 34%, transparent); }
.chip.past { opacity: .55; }
.chip .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.chip .mark { flex: none; font-size: .8rem; }
.mark.yes { color: var(--yes); } .mark.maybe { color: var(--maybe); } .mark.no { color: var(--no); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; font-size: .84rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--c); display: inline-block; }

/* ---------- Session dialog ---------- */
dialog {
  margin: auto; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-top: 3px solid var(--c, var(--accent));
  border-radius: var(--radius); padding: 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(5, 4, 10, .7); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.dialog-head h2 { color: var(--c, var(--accent-2)); font-size: 1.4rem; }
.close { background: none; border: 0; color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.close:hover { color: var(--text); }
.dialog-section { margin-top: 18px; }
.dialog-section h3 { font-family: inherit; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); margin-bottom: 8px; }
.note-row { display: flex; gap: 8px; margin-top: 10px; }
.note-row input { flex: 1; padding: 8px 12px; }
.people { list-style: none; display: grid; gap: 6px; }
.people li { display: flex; align-items: baseline; gap: 8px; font-size: .94rem; }
.people .note { color: var(--muted); font-size: .85rem; font-style: italic; }
.people.none li { color: var(--faint); }

/* ---------- Auth pages ---------- */
.auth-card { max-width: 420px; margin: 40px auto 0; }
.auth-card h1 { font-size: 1.8rem; text-align: center; color: var(--gold); margin-bottom: 6px; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; }
.auth-card .btn { width: 100%; margin-top: 4px; }
.auth-card .switch { text-align: center; margin-top: 18px; color: var(--muted); font-size: .94rem; }

/* ---------- Account / admin ---------- */
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; align-items: start; }
.account-grid .panel { margin-top: 0; }
.invite { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 6px; }
.invite code {
  font-family: ui-monospace, Consolas, monospace; font-size: 1.3rem; letter-spacing: .12em; color: var(--gold);
  background: var(--bg-2); border: 1px dashed var(--border); padding: 8px 14px; border-radius: 10px;
}
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--faint); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.badge { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); margin-left: 6px; }

.footer { text-align: center; padding: 28px 20px; color: var(--faint); font-size: .85rem; border-top: 1px solid var(--border); }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .topbar { padding: 14px 16px; }
  main.wrap { padding: 0 16px 48px; }
  #nav { gap: 12px; font-size: .9rem; }
  #nav .hide-sm { display: none; }
  .session { grid-template-columns: 52px 1fr; }
  .session-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .cal-day { min-height: 64px; padding: 4px; }
  .chip { padding: 3px 4px; font-size: .68rem; }
  .chip .label { display: none; }
  .chip { justify-content: center; }
  .cal-nav h2 { min-width: 0; font-size: 1.05rem; }
}
.members-head { margin-top: 28px; }
.brand, #nav a, #nav button { white-space: nowrap; }
@media (max-width: 480px) {
  .brand { font-size: .98rem; gap: 8px; letter-spacing: .03em; }
  .sigil { width: 30px; height: 30px; }
  #nav { gap: 10px; }
  #nav .who { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 480px) {
  .brand-text { display: none; }
  #nav .who { max-width: 150px; }
}

/* ---------- Rosters, notes links, awaiting count ---------- */
.counts .a { color: var(--accent-2); }
.roster { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin-top: 12px; font-size: .9rem; }
.roster dt { color: var(--faint); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; padding-top: 2px; }
.roster dd { color: var(--text); }
.card-links { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.card-links a { color: var(--c); font-weight: 600; }
.people .badge { margin-left: 0; }

/* ---------- Form controls ---------- */
select, input[type=time], input[type=date] {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font: inherit;
}
input[type=color] { width: 100%; height: 42px; padding: 4px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-2); cursor: pointer; }
textarea {
  width: 100%; min-height: 360px; padding: 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font: .95rem/1.6 ui-monospace, Consolas, monospace; resize: vertical;
}
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .94rem; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Admin ---------- */
.section-intro { margin-bottom: 18px; max-width: 760px; font-size: .94rem; }
.games { display: grid; gap: 18px; }
.game-card {
  background: var(--bg-2); border: 1px solid var(--border); border-left: 4px solid var(--c);
  border-radius: 12px; padding: 18px 20px; display: grid; gap: 4px;
}
.game-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.game-card-head h3 { color: var(--c); font-size: 1.2rem; }
.swatch.big { width: 16px; height: 16px; border-radius: 50%; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; }
.game-grid .field { margin-bottom: 14px; }
.players-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 16px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.muted-badge { background: color-mix(in srgb, var(--faint) 25%, transparent); color: var(--muted); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: var(--surface-2); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 18px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.panel > h2 + .invite { margin-top: 14px; }
.admin-link { text-align: center; margin-top: 28px; }

/* ---------- Help text blocks ---------- */
.format-help { margin: 10px 0 6px; color: var(--muted); font-size: .9rem; }
.format-help summary { cursor: pointer; }
.format-help ul { margin: 8px 0 0 1.2em; display: grid; gap: 4px; }
.format-help code { color: var(--gold); font-size: .88rem; }

/* ---------- Characters, cancellations, DM tools ---------- */
.roster .you, .people .you { color: var(--gold); font-weight: 600; }
.card-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.card-links .muted { font-size: .88rem; }
.session-actions.start { justify-content: flex-start; }
.tag { font-family: "Inter", sans-serif; font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; margin-left: 8px; vertical-align: middle; }
.tag.cancelled { background: color-mix(in srgb, var(--no) 22%, transparent); color: #fecaca; }
.tag.moved { background: color-mix(in srgb, var(--maybe) 22%, transparent); color: #fef08a; }
.cancelled-text { color: #fca5a5; font-size: .9rem; }
.moved-text { color: #fde68a; font-size: .88rem; }
.session.is-cancelled { opacity: .75; }
.session.is-cancelled .session-info h3 { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--c) 60%, transparent); }
.chip.cancelled { opacity: .6; }
.chip.cancelled .label { text-decoration: line-through; }
.chip.moved { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--maybe) 70%, transparent); }
.people li { flex-wrap: wrap; }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pick { justify-content: center; padding: 14px; font-family: var(--heading); font-size: 1.05rem; color: var(--c); }
.dm-tools { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--bg-2); }
.dm-tools summary { cursor: pointer; font-weight: 600; color: var(--gold); }
.dm-tools[open] summary { margin-bottom: 12px; }
.dm-tools .field { margin-bottom: 10px; }
.dm-move { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dm-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 4px 0 10px; }
.dm-tools .check { margin-bottom: 8px; }
.dm-tools .hint, .dialog-section .hint { display: block; font-size: .8rem; color: var(--faint); margin-top: 8px; }

/* Admin character editor */
.char-editor { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.char-rows { display: grid; gap: 8px; }
.char-rows:empty { display: none; }
.char-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.char-editor > .btn-ghost { justify-self: start; }
.mail-status p { display: flex; align-items: center; gap: 8px; }
.ok-dot, .off-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.ok-dot { background: var(--yes); box-shadow: 0 0 8px var(--yes); }
.off-dot { background: var(--faint); }
.format-help ol { margin: 8px 0 0 1.2em; display: grid; gap: 6px; }

/* Account: characters + notifications */
.characters-panel { margin-bottom: 24px; }
.my-chars { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.my-char { padding: 14px 16px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); border-left: 4px solid var(--c); display: grid; gap: 8px; }
.my-char h3 { color: var(--c); font-size: 1.1rem; }
.notify-check { margin: -4px 0 16px; align-items: flex-start; }
.notify-check input { margin-top: 3px; }
@media (max-width: 720px) {
  .char-row { grid-template-columns: 1fr 1fr; }
  .char-row .btn-ghost { grid-column: 1 / -1; justify-self: start; }
  .dm-move { grid-template-columns: 1fr; }
}

/* Notes link on game cards */
.notes-link { display: inline-flex; align-items: baseline; gap: 10px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: .85rem; color: var(--muted); text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--text); }
dialog input[type=url] { margin-bottom: 4px; }
.discord-panel { margin-bottom: 24px; }
.link-code { font-size: 1.05rem !important; letter-spacing: .02em !important; }

/* Admin: send a Discord reminder */
.remind-box { margin: 18px 0 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.remind-box h3 { font-size: 1rem; margin-bottom: 4px; }
.remind-box > .hint { display: block; font-size: .85rem; color: var(--faint); margin-bottom: 12px; }
.remind-list { display: grid; gap: 8px; }
.remind-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, .8fr) auto; gap: 12px; align-items: center;
  padding: 10px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); border-left: 4px solid var(--c); }
.remind-game { font-weight: 600; color: var(--c); }
@media (max-width: 720px) { .remind-row { grid-template-columns: 1fr auto; } .remind-row .muted { grid-column: 1; } }

/* Warren import page */
.back { margin-top: 8px; font-size: .92rem; }
.steps ol { margin: 12px 0 4px 1.3em; display: grid; gap: 10px; }
.steps .hint { font-size: .82rem; color: var(--faint); margin-left: 6px; }
.bookmarklet { cursor: grab; margin-left: 6px; }
kbd { font: .82rem ui-monospace, Consolas, monospace; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--bg-2); }
.upload-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0 6px; }
.upload-row input[type=file] { color: var(--muted); }
.import-list { margin: 6px 0 14px 1.3em; }

/* ---------- Gallery ---------- */
.game-tabs { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 4px; }
.game-tab {
  font: inherit; font-family: var(--heading); font-weight: 600; font-size: 1.02rem; cursor: pointer;
  padding: 10px 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  display: inline-flex; align-items: center; gap: 10px; border-bottom: 3px solid transparent;
}
.game-tab:hover { color: var(--text); }
.game-tab.on { color: var(--c); border-color: color-mix(in srgb, var(--c) 45%, var(--border)); border-bottom-color: var(--c); }
.count { font-family: "Inter", sans-serif; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 8px; vertical-align: middle; }
.game-tab .count { margin-left: 0; }
.gallery-section { border-top: 3px solid var(--c); }
.gallery-section .panel-head h2 { color: var(--c); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.gallery-card { margin: 0; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.gallery-card .thumb { display: block; padding: 0; border: 0; background: #07060d; cursor: zoom-in; aspect-ratio: 4 / 3; width: 100%; }
.gallery-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.gallery-card .thumb:hover img { transform: scale(1.04); }
.gallery-card figcaption { padding: 10px 12px; display: grid; gap: 3px; font-size: .9rem; }
.gallery-card .cap { color: var(--text); overflow-wrap: anywhere; }
.gallery-card .by { color: var(--faint); font-size: .78rem; }
dialog.viewer { width: min(1100px, calc(100vw - 32px)); }
.viewer-img { display: block; margin-top: 14px; text-align: center; background: #07060d; border-radius: 10px; }
.viewer-img img { max-width: 100%; max-height: calc(100vh - 220px); display: inline-block; vertical-align: middle; }
.viewer-actions { margin-top: 14px; justify-content: flex-end; }
.upload-preview { display: block; max-width: 100%; max-height: 260px; margin: 0 auto 14px; border-radius: 10px; border: 1px solid var(--border); }
input[type=file] { color: var(--muted); font: inherit; }
@media (max-width: 480px) { .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .game-tab { font-size: .9rem; padding: 8px 12px; } }

/* Gallery: multi-upload list */
dialog#uploader { width: min(640px, calc(100vw - 32px)); }
.upload-list { list-style: none; display: grid; gap: 10px; margin: 0 0 12px; max-height: 52vh; overflow-y: auto; }
.upload-list:empty { display: none; }
.upload-item { display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: start; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); }
.upload-item img, .upload-thumb-placeholder { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: #07060d; display: block; }
.upload-item-body { display: grid; gap: 6px; min-width: 0; }
.upload-name { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item input[type=text] { padding: 8px 10px; }
.upload-status { font-size: .8rem; color: var(--accent-2); }
.upload-status.ok { color: var(--yes); }
.upload-item-error { font-size: .82rem; color: #fca5a5; }
.upload-item.failed { border-color: #7f1d1d; }
.upload-item.done { opacity: .6; }
.upload-item .close { font-size: 1.3rem; }

/* Gallery cards: same-height frames so pictures and captions line up across each row.
   Player Characters show the whole figure standing on the bottom edge; Scenes fill a widescreen frame. */
.gallery-card .thumb { aspect-ratio: auto; height: 280px; display: flex; align-items: flex-end; justify-content: center;
  padding: 14px 10px 0; background: transparent; overflow: hidden; }
.gallery-card .thumb img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: 50% 100%; }
.gallery-grid.scenes .thumb { height: auto; aspect-ratio: 16 / 10; padding: 0; align-items: stretch; background: #07060d; }
.gallery-grid.scenes .thumb img { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; transform-origin: 50% 50%; }
.gallery-card figcaption { border-top: 1px solid var(--border); flex: 1; align-content: start; }
@media (max-width: 480px) { .gallery-card .thumb { height: 200px; } }

/* Gallery: NPC locations */
.section-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.npc-locations { display: grid; gap: 10px; }
.npc-location { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-2); overflow: hidden; }
.loc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 6px 10px 6px 4px; }
.loc-toggle { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--text); cursor: pointer;
  font: inherit; font-family: var(--heading); font-weight: 600; font-size: 1.05rem; padding: 8px 10px; border-radius: 8px; }
.loc-toggle:hover { background: var(--surface-2); }
.loc-toggle .chev { display: inline-block; color: var(--c); transition: transform .15s; font-size: .9rem; }
.npc-location.open .loc-toggle .chev { transform: rotate(90deg); }
.loc-toggle .count { margin-left: 0; }
.loc-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.icon-btn { font: inherit; font-weight: 700; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover:not(:disabled) { border-color: var(--accent); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.loc-default { font-size: .82rem; color: var(--muted); margin: 0 4px; }
.loc-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.loc-body .gallery-grid { margin-top: 12px; }
.loc-body > .muted { margin-top: 12px; }
.viewer-location { margin-top: 12px; max-width: 320px; }
.gallery-section .hint { display: block; font-size: .85rem; color: var(--faint); margin-bottom: 10px; }
@media (max-width: 720px) { .loc-head { padding-left: 0; } .loc-actions { padding: 0 8px 4px; } }

/* Gallery: current location */
.npc-location.current { border: 2px solid var(--gold); background: color-mix(in srgb, var(--gold) 7%, var(--bg-2));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--gold) 25%, transparent), 0 6px 22px rgba(233, 196, 106, .12); }
.npc-location.current .loc-name { color: var(--gold); }
.npc-location.current .loc-body { border-top-color: color-mix(in srgb, var(--gold) 35%, var(--border)); }
.loc-toggle.static { cursor: default; }
.loc-toggle.static:hover { background: none; }
.npc-location.current .chev { transform: none !important; }
.current-badge { font-family: "Inter", sans-serif; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; background: var(--gold); color: #1a1405; }

/* Gallery: discussions */
.gallery-card .by { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comment-count { background: none; border: 0; padding: 0; font: inherit; font-size: .78rem; color: var(--accent-2); cursor: pointer; }
.comment-count:hover { text-decoration: underline; }
.discussion { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.discussion h3 { font-family: "Inter", sans-serif; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); margin-bottom: 10px; }
.comment-list { list-style: none; display: grid; gap: 10px; margin-bottom: 14px; }
.comment { padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); }
.comment-meta { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; font-size: .85rem; }
.comment-actions { margin-left: auto; display: inline-flex; gap: 12px; }
.comment-body { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.comment-form textarea, .comment-edit textarea { min-height: 0; font: inherit; margin-bottom: 6px; }
.comment-edit { margin-top: 6px; }
.link-btn.danger { color: #fca5a5; }
/* Keep the discussion in view under tall pictures */
.viewer-img img { max-height: min(58vh, calc(100vh - 260px)); }
dialog.viewer { scroll-behavior: smooth; }

/* Gallery: editing a caption in the viewer */
.caption-heading { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.caption-heading .link-btn { font-size: .85rem; }
.caption-editor { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.caption-editor input { flex: 1 1 280px; padding: 8px 12px; }
.dialog-head > div:has(.caption-heading) { flex: 1; min-width: 0; }
.caption-editor { flex-wrap: nowrap; margin-right: 8px; }
.caption-editor input { flex: 1 1 auto; min-width: 0; }
@media (max-width: 480px) { .caption-editor { flex-wrap: wrap; } .caption-editor input { flex-basis: 100%; } }
.caption-heading > .caption-editor { flex: 1 1 100%; }

/* Gallery: names for characters / NPCs */
.gallery-card .card-name { font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.gallery-card .card-name + .cap { color: var(--muted); font-size: .85rem; }
.caption-block { min-width: 0; }
.viewer-caption { color: var(--text); margin-top: 2px; overflow-wrap: anywhere; }
.caption-editor .name-input { flex: 0 1 220px; }
.upload-item input.missing { border-color: #ef4444; box-shadow: 0 0 0 1px #ef4444; }
.dialog-head > div:has(.caption-block) { flex: 1; min-width: 0; }

/* ---------- Image Forge ---------- */
.forge { --c: var(--accent); }
.forge .hero .back { margin-top: 12px; }
.gallery-tools { display: flex; justify-content: center; margin: 14px 0 -4px; }
.forge-notices { display: grid; gap: 10px; margin-top: 20px; }
.banner.warn { border-color: #854d0e; color: #fde68a; max-width: none; margin: 0; }
.forge-admin .num-input { width: 90px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.forge-admin .dm-row label:not(.check) { color: var(--muted); font-size: .92rem; }
.forge .panel { border-top: 3px solid var(--c); }
.forge .panel-head h2 { color: var(--c); }
.forge-style .style-text { line-height: 1.6; max-width: 900px; }
.forge-style .style-avoid { margin-top: 8px; color: var(--muted); font-size: .92rem; }
.forge-style .label { color: var(--faint); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.style-refs { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.style-refs img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.forge textarea { min-height: 0; width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); font: inherit; resize: vertical; }
.forge input[type=search] { padding: 7px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); font: inherit; min-width: 0; flex: 1 1 160px; max-width: 260px; }
.forge select { width: 100%; }
.small { font-size: .85rem; }

.composer-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 28px; }
.composer-side { border-left: 1px solid var(--border); padding-left: 24px; }
.composer .field { margin-bottom: 12px; }
.composer .hint { display: block; font-size: .82rem; color: var(--faint); margin: -2px 0 10px; }
.step { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; color: var(--text); margin: 4px 0 8px; }
.composer-main .step:not(:first-child) { margin-top: 22px; }
.step .num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-family: "Inter", sans-serif; font-size: .85rem;
  background: color-mix(in srgb, var(--c) 25%, transparent); color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pick-bar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.pick-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.pick-tab { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .86rem; cursor: pointer; }
.pick-tab:hover { color: var(--text); }
.pick-tab.on { color: var(--c); border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; padding: 2px; }
.pick-grid.small { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); max-height: 240px; }
.pick-item { position: relative; display: grid; padding: 0; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; background: #07060d; cursor: pointer; color: var(--text); font: inherit; text-align: left; }
.pick-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.pick-name { font-size: .72rem; padding: 3px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--bg-2); }
.pick-item:hover { border-color: color-mix(in srgb, var(--c) 60%, var(--border)); }
.pick-item.on { border-color: var(--c); box-shadow: 0 0 0 1px var(--c); }
.pick-item.on::after { content: "\2713"; position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c); color: #0a0912; font-weight: 800; font-size: .8rem; }
.pick-grid > .muted { grid-column: 1 / -1; }

.chosen { display: grid; gap: 8px; margin-top: 12px; }
.chosen-head { font-size: .84rem; color: var(--muted); }
.chosen-head.over { color: #fca5a5; font-weight: 600; }
.chosen-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--border); border-left: 3px solid var(--c); border-radius: 10px; background: var(--bg-2); }
.chosen-row.role-style { border-left-color: var(--accent-2); }
.chosen-row.role-setting { border-left-color: #38bdf8; }
.chosen-row.role-base { border-left-color: var(--gold); }
.chosen-row img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.chosen-name { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chosen-name .kind { font-weight: 400; color: var(--faint); font-size: .76rem; margin-left: 8px; text-transform: uppercase; letter-spacing: .06em; }
.chosen-controls { display: grid; grid-template-columns: minmax(0, 190px) minmax(0, 1fr); gap: 6px; margin-top: 4px; }
.chosen-controls select, .chosen-controls input { padding: 6px 10px; font-size: .86rem; }
.prompt-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

.aspect-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.aspect { display: grid; justify-items: center; align-content: end; gap: 4px; height: 58px; padding: 6px 2px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-2); color: var(--muted); font: inherit; font-size: .72rem; cursor: pointer; }
.aspect .shape { display: block; border: 2px solid currentColor; border-radius: 3px; }
.aspect:hover { color: var(--text); }
.aspect.on { color: var(--c); border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--bg-2)); }
.settings-group { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 6px; }
.settings-group summary { cursor: pointer; font-weight: 600; color: var(--gold); margin-bottom: 10px; font-size: .92rem; }
.settings-group .check { margin-bottom: 10px; }
.style-bits.off { opacity: .45; pointer-events: none; }
.composer-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.btn-generate { padding: 12px 26px; font-size: 1.02rem; }
.composer > .form-error { margin-top: 10px; }

.job-list { display: grid; gap: 14px; }
.job { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-2); }
.job.failed { border-color: #7f1d1d; }
.job-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.job-actions { display: flex; gap: 14px; }
.job-prompt { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.job-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip-tag { font-size: .74rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.job-refs { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.job-refs img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.job-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.result-tile { margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #07060d; display: flex; flex-direction: column; }
.result-tile .thumb { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; }
.result-tile .thumb img { width: 100%; display: block; }
.result-tile figcaption, .result-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 10px; background: var(--surface); }
.result-actions { background: none; padding: 12px 0 0; justify-content: center; }
.result-tile .saved, .result-actions .saved { font-size: .85rem; color: var(--yes); }
.result-tile a.link-btn, .result-actions a.link-btn { text-decoration: underline; }
.result-tile.pending { display: grid; place-items: center; min-height: 160px; background: linear-gradient(110deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--c); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tag.working { margin-left: 8px; background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--c); }
.job-error { margin: 10px 0 0; }
.job .hint { margin-top: 8px; font-size: .84rem; color: var(--faint); }
.job-full { margin-top: 10px; font-size: .85rem; }
.job-full summary { cursor: pointer; color: var(--muted); }
.prompt-text { white-space: pre-wrap; overflow-wrap: anywhere; font: .84rem/1.55 ui-monospace, Consolas, monospace; color: var(--muted);
  background: #07060d; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 8px; max-height: 60vh; overflow-y: auto; }
dialog.prompt-dialog { width: min(820px, calc(100vw - 32px)); }
dialog#save-dialog { width: min(520px, calc(100vw - 32px)); }
@media (max-width: 860px) {
  .composer-grid { grid-template-columns: 1fr; }
  .composer-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 16px; }
}
@media (max-width: 520px) {
  .chosen-controls { grid-template-columns: 1fr; }
  .aspect-picker { grid-template-columns: repeat(4, 1fr); }
  .pick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .spinner, .result-tile.pending { animation: none; } }

/* Image Forge: private history (compact rows) */
.forge .panel-head input[type=search] { max-width: 280px; }
.keep-note { font-size: .85rem; color: var(--faint); margin: -6px 0 14px; }
.job-list:empty { display: none; }
.job-list { margin-bottom: 14px; }
.hist-list { display: grid; gap: 8px; }
.hist-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 14px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-2); }
.hist-thumb { width: 88px; height: 88px; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: #07060d; cursor: zoom-in; }
.hist-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.hist-thumb:hover img { transform: scale(1.05); }
.hist-body { display: grid; gap: 4px; min-width: 0; }
.hist-desc { font-size: .95rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.hist-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .78rem; color: var(--faint); }
.hist-meta .saved { color: var(--yes); }
.hist-actions { display: flex; flex-wrap: wrap; gap: 2px 14px; }
.hist-actions .link-btn { font-size: .8rem; }
.hist-actions a.link-btn, .result-actions a.link-btn { text-decoration: underline; }
.hist-more { display: flex; justify-content: center; margin-top: 12px; }
.hist-more:empty { display: none; }
.job-chips.center { justify-content: center; margin-top: 10px; }
@media (max-width: 520px) {
  .hist-row { grid-template-columns: 64px minmax(0, 1fr); gap: 10px; align-items: start; }
  .hist-thumb { width: 64px; height: 64px; }
  .forge .panel-head input[type=search] { max-width: none; }
}

/* Admin: per-member Image Forge limit */
.limit-cell { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.limit-input { width: 72px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); font: inherit; }
.limit-input:disabled { opacity: .4; }
.limit-cell .check { font-size: .85rem; }
.limit-used { font-size: .8rem; }
.table-hint { display: block; font-size: .82rem; color: var(--faint); margin-top: 10px; }

/* ---------- Session notes (WIP) ---------- */
.session-notes-link { color: var(--c); font-weight: 600; }
.notes-wrap .notes-hero h1 { background: none; -webkit-background-clip: initial; background-clip: initial; color: var(--c, var(--accent-2)); }
.notes-wrap .panel { border-top: 3px solid var(--c, var(--accent)); }
.notes-wrap .back { margin-top: 8px; font-size: .92rem; }
.wip-tag { display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px;
  border-radius: 999px; background: color-mix(in srgb, var(--maybe) 22%, transparent); color: #fef08a; margin-right: 6px; vertical-align: middle; }
.picker-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.picker-row .field { margin: 0; flex: 1; min-width: 240px; }
.overview-box { padding: 14px 16px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); margin-bottom: 20px; }
.overview-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.overview-head h3, .notes-block h3, .all-session h3 { font-family: var(--heading); color: var(--gold); font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.ai-tag { font-family: "Inter", sans-serif; font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent-2); }
.overview-body h4 { font-family: var(--heading); color: var(--c, var(--accent-2)); font-size: .98rem; margin: 12px 0 4px; }
.overview-body h4:first-child { margin-top: 0; }
.overview-body ul { margin: 0 0 4px 1.2em; display: grid; gap: 3px; }
.overview-body p { margin: 4px 0; line-height: 1.6; }
.overview-body.compact { font-size: .94rem; padding: 10px 14px; border-left: 3px solid var(--c, var(--accent)); background: var(--bg-2); border-radius: 0 10px 10px 0; margin: 8px 0; }
.overview-box textarea, .note-composer textarea, .note-edit textarea { min-height: 0; font: inherit; line-height: 1.55; margin-bottom: 6px; }
.note-list { list-style: none; display: grid; gap: 10px; margin: 10px 0 16px; }
.note-entry { padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--border); }
.note-text { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.note-composer { margin-top: 6px; }
.all-session { padding: 14px 0; border-top: 1px solid var(--border); }
.all-session:first-child { border-top: 0; padding-top: 0; }
.all-session-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.all-session-head .btn-ghost { margin-left: auto; }
.all-notes-list summary { cursor: pointer; color: var(--muted); font-size: .9rem; margin-top: 6px; }

/* NPC links and pop-out */
.npc-link { font: inherit; color: var(--gold); background: none; border: 0; padding: 0; cursor: pointer;
  border-bottom: 1px dotted color-mix(in srgb, var(--gold) 70%, transparent); line-height: inherit; }
.npc-link:hover, .npc-link:focus-visible { color: #fde68a; border-bottom-style: solid; }
.npc-flyout { position: absolute; z-index: 50; width: 250px; background: var(--surface-2); border: 1px solid var(--gold);
  border-radius: 12px; box-shadow: 0 18px 50px rgba(0, 0, 0, .6); overflow: hidden; }
.npc-flyout img { display: block; width: 100%; max-height: 260px; object-fit: contain; background: var(--bg-2); }
.npc-flyout-body { padding: 10px 12px; display: grid; gap: 4px; font-size: .88rem; }
.npc-flyout-body strong { font-family: var(--heading); color: var(--gold); font-size: 1rem; }
.flyout-loc { color: var(--muted); }

/* NPC suggestions while typing */
.npc-suggest { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; }
.npc-suggest .hint { font-size: .78rem; color: var(--faint); }
.npc-chip { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .85rem; padding: 3px 10px 3px 3px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text); cursor: pointer; }
.npc-chip img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: #07060d; }
.npc-chip.active { border-color: var(--gold); color: var(--gold); }

/* Session notes: known NPCs & places */
.lore-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.lore-filter { flex: 1 1 180px; min-width: 0; }
.lore-list { display: grid; gap: 10px; max-height: 560px; overflow-y: auto; padding-right: 4px; overscroll-behavior: contain; }
.lore-entry { display: flex; gap: 12px; align-items: flex-start; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; scroll-margin: 12px; }
.lore-entry.editing { border-color: var(--c, var(--accent)); }
.lore-entry.flash { animation: lore-flash 1.6s ease-out; }
@keyframes lore-flash { 0%, 30% { border-color: var(--gold); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 35%, transparent); } 100% { box-shadow: none; } }
.lore-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex: none; }
.lore-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.lore-main > input, .lore-main > textarea { width: 100%; }
.lore-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.lore-head h3 { font-family: var(--heading); color: var(--gold); font-size: 1rem; margin: 0; }
.lore-aka { font-size: .82rem; color: var(--faint); margin: 0; }
.lore-text { margin: 0; line-height: 1.55; font-size: .93rem; overflow-wrap: anywhere; }
.lore-form-row { display: flex; gap: 8px; }
.lore-form-row input { flex: 1; min-width: 0; }
.npc-link.place-link { color: var(--accent-2); border-bottom-color: color-mix(in srgb, var(--accent-2) 60%, transparent); }
.flyout-info { margin: 0; line-height: 1.45; color: var(--text); }
.flyout-links { display: flex; gap: 12px; flex-wrap: wrap; }
.chip-icon { font-size: .85rem; }
@media (max-width: 520px) { .lore-thumb { width: 48px; height: 48px; } .lore-form-row { flex-direction: column; } }
.lore-body { display: grid; gap: 4px; }
.lore-entry:not(.open) .lore-body { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.lore-entry:not(.open) .lore-body .lore-text { display: inline; }
.lore-entry:not(.open) .lore-body .lore-text + .lore-text::before { content: " "; }
.lore-entry:not(.open) .lore-meta { display: none; }
.lore-toggle { justify-self: start; }

/* Formatted notes (shared by notes, overviews and entries) */
.note-text.rich { white-space: normal; }
.rich p { margin: 0 0 .7em; line-height: 1.65; }
.rich > :last-child { margin-bottom: 0; }
.rich h4, .rich h5 { font-family: var(--heading); color: var(--c, var(--accent-2)); margin: 1em 0 .35em; line-height: 1.3; }
.rich h4 { font-size: 1.05rem; }
.rich h5 { font-size: .95rem; letter-spacing: .02em; }
.rich > h4:first-child, .rich > h5:first-child { margin-top: .2em; }
.rich ul, .rich ol { margin: 0 0 .7em 1.3em; display: grid; gap: 2px; line-height: 1.55; }
.rich ul { list-style: disc; }
.rich ol { list-style: decimal; }
.rich blockquote { margin: 0 0 .7em; padding: 4px 12px; border-left: 3px solid var(--c, var(--accent)); color: var(--muted); font-style: italic; }
.rich hr { border: 0; border-top: 1px solid var(--border); margin: 1em 0; }
.rich strong { color: var(--text); font-weight: 600; }
.overview-body.rich p, .overview-body p { margin: 4px 0; }
.fmt-bar { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.fmt-btn { font: inherit; font-size: .82rem; min-width: 32px; padding: 4px 9px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-2); color: var(--muted); cursor: pointer; }
.fmt-btn:hover { color: var(--text); border-color: var(--accent); }
.fmt-spacer { flex: 1; }
.fmt-preview { border: 1px dashed var(--border); border-radius: 10px; padding: 12px 14px; background: var(--bg-2); min-height: 110px; max-height: 520px; overflow-y: auto; }
.lore-entry:not(.open) .lore-body :is(p, h4, h5, ul, ol, li, blockquote) { display: inline; margin: 0; padding: 0; border: 0; font: inherit; color: inherit; }
.lore-entry:not(.open) .lore-body :is(p, li)::after { content: " "; }
.lore-entry:not(.open) .lore-body br { content: " "; }
.lore-body p { margin: 0 0 4px; line-height: 1.55; font-size: .93rem; }
.all-preview { margin: 6px 0 2px; color: var(--muted); font-size: .93rem; line-height: 1.55; }

/* Live shared note box */
.note-composer.live { border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 45%, var(--border)); border-radius: 12px; padding: 12px; background: color-mix(in srgb, var(--c, var(--accent)) 5%, transparent); }
.live-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; font-size: .92rem; }
.live-head strong { font-family: var(--heading); color: var(--gold); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px color-mix(in srgb, #34d399 25%, transparent); animation: live-pulse 2s ease-in-out infinite; }
@keyframes live-pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
.live-people { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.live-person { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; padding: 2px 9px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--pc) 55%, transparent); color: var(--text); background: color-mix(in srgb, var(--pc) 12%, transparent); }
.live-person .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pc); }
.live-person em { color: var(--muted); font-size: .76rem; }
.live-person.typing .dot { animation: live-pulse 1s ease-in-out infinite; }
.save-status { margin-left: 4px; }
.note-composer.live textarea[readonly] { opacity: .7; }
.danger-ghost { color: #fca5a5; border-color: color-mix(in srgb, #f87171 45%, var(--border)); }
.danger-ghost:hover { color: #fecaca; border-color: #f87171; }

/* Collapsible known NPCs & places panel */
.lore-panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lore-collapse { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.lore-collapse h2 { margin: 0; }
.lore-collapse .chevron { display: inline-block; color: var(--gold); font-size: 1rem; transition: transform .2s ease; }
#lore-panel.collapsed .lore-collapse .chevron { transform: rotate(-90deg); }
.lore-collapse:hover h2 { color: var(--text); }
.lore-summary { font-size: .88rem; margin-left: auto; }
#lore-panel.collapsed .panel-head { margin-bottom: 0; }

/* Foldable overviews */
.fold-toggle { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.fold-toggle h3 { margin: 0; }
.fold-toggle .chevron { color: var(--gold); font-size: .9rem; display: inline-block; transition: transform .2s ease; }
.overview-box.folded .fold-toggle .chevron { transform: rotate(-90deg); }
.fold-toggle:hover h3 { color: var(--text); }
.all-overview { margin: 8px 0 4px; }
.all-overview > summary { cursor: pointer; font-size: .9rem; color: var(--muted); list-style-position: inside; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.all-overview > summary .all-overview-label { font-family: var(--heading); color: var(--c, var(--accent-2)); }
.all-overview[open] > summary { white-space: normal; }
.all-overview[open] > summary .muted { display: none; }

/* Entry edit form: type + name side by side, with labels */
.lore-form-row { display: flex; gap: 10px; align-items: flex-end; }
.lore-field { display: grid; gap: 4px; min-width: 0; }
.lore-field > span, .lore-field-label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.lore-field-label { margin-top: 4px; }
.lore-form-row .lore-kind { flex: 0 0 130px; }
.lore-form-row .lore-name { flex: 1 1 auto; }
.lore-form-row select, .lore-form-row input { width: 100%; }
@media (max-width: 520px) { .lore-form-row { flex-direction: column; align-items: stretch; } .lore-form-row .lore-kind { flex-basis: auto; } }

/* Notes search */
.search-panel { padding-top: 16px; padding-bottom: 16px; }
.search-bar { position: relative; }
.search-bar .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: .95rem; opacity: .7; pointer-events: none; }
.search-bar input[type=search] { padding-left: 40px; font-size: 1rem; }
.search-status { margin: 8px 2px 0; }
.search-status:empty { display: none; }
#search-results { display: grid; gap: 8px; margin-top: 10px; max-height: 520px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
#search-results:empty { display: none; }
.search-result { display: grid; gap: 4px; text-align: left; font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; cursor: pointer; }
.search-result:hover, .search-result:focus-visible { border-color: var(--c, var(--accent)); }
.search-result-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.search-result-head strong { font-family: var(--heading); color: var(--gold); font-weight: 600; }
.search-count { margin-left: auto; font-size: .78rem; color: var(--faint); }
.search-snippet { margin: 0; font-size: .88rem; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.search-snippet mark, mark.search-hit { background: color-mix(in srgb, var(--gold) 35%, transparent); color: var(--text); border-radius: 3px; padding: 0 2px; }
mark.search-hit { box-shadow: 0 0 0 1px color-mix(in srgb, var(--gold) 60%, transparent); }
.notes-actions { margin-top: 12px; display: flex; justify-content: center; gap: 8px; }
