/* ════════════════════════════════════════════════════════
   GM BOARD  ·  Professional Design System v2
   ════════════════════════════════════════════════════════ */

:root {
  /* Sidebar */
  --sb-w: 220px;
  --sb-bg: #0c0a09;
  --sb-border: rgba(255,255,255,0.07);
  --sb-text: #7a746d;
  --sb-text-h: #c8c0b4;
  --sb-active-bg: rgba(160,30,30,0.13);
  --sb-active-bar: #c0282828;
  --sb-active-text: #f0dabb;
  --sb-group: #3c3a37;

  /* Content */
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #f1ede7;
  --border: #e5e0d7;
  --border-s: #ccc6b8;

  /* Text */
  --text: #1c1914;
  --text-2: #4a4540;
  --muted: #8a7f74;

  /* Brand / accent */
  --accent: #8b1a1a;
  --accent-h: #a82020;
  --accent-10: rgba(139,26,26,0.09);
  --accent-20: rgba(139,26,26,0.18);

  /* Status */
  --danger: #c62828;
  --danger-bg: rgba(198,40,40,0.08);
  --warn: #b45309;
  --warn-bg: rgba(180,83,9,0.09);
  --ok: #15803d;
  --ok-bg: rgba(21,128,61,0.09);

  /* Shadows */
  --sh0: 0 1px 2px rgba(0,0,0,0.05);
  --sh1: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --sh2: 0 4px 12px rgba(0,0,0,0.09), 0 1px 3px rgba(0,0,0,0.05);
  --sh3: 0 10px 28px rgba(0,0,0,0.13), 0 3px 8px rgba(0,0,0,0.06);

  /* Radius */
  --r: 8px;
  --r-sm: 5px;
  --r-lg: 12px;

  --t: 0.14s ease;
}

/* ── Reset / Base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3, h4, h5 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  letter-spacing: 0.02em;
  color: var(--text);
}
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
h4 { font-size: 0.875rem; }

p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── App Shell ───────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ═══════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sb-w);
  flex-shrink: 0;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--sb-border);
  user-select: none;
}

/* Brand */
.sb-brand {
  padding: 1rem 0.875rem 0.75rem;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sb-brand-logo {
  font-family: "Palatino Linotype", serif;
  font-size: 1rem;
  font-weight: 700;
  color: #e8d4a8;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.25rem;
}

.sb-brand-campaign {
  font-size: 0.725rem;
  color: var(--sb-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* Nav */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.07) transparent;
}

.sb-group-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--sb-group);
  padding: 0.8rem 0.875rem 0.25rem;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 0.875rem;
  color: var(--sb-text);
  font-size: 0.82rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: color var(--t), background var(--t);
  position: relative;
  text-decoration: none;
  border-radius: 0;
  line-height: 1.3;
}

.sb-link:hover {
  color: var(--sb-text-h);
  background: rgba(255,255,255,0.045);
}

.sb-link.active {
  color: var(--sb-active-text);
  background: rgba(160,30,30,0.13);
  font-weight: 600;
}

.sb-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px;
  background: #c03030;
  border-radius: 0 2px 2px 0;
}

.sb-count {
  margin-left: auto;
  font-size: 0.65rem;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.3);
  border-radius: 10px;
  padding: 0.1rem 0.38rem;
  min-width: 18px;
  text-align: center;
}
.sb-link.active .sb-count {
  background: rgba(192,48,48,0.25);
  color: #f09090;
}

/* Footer */
.sb-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--sb-border);
  padding: 0.625rem 0.875rem;
}

.sb-time {
  font-size: 0.7rem;
  color: var(--sb-text);
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.sb-time-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}

.sb-foot-btns {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.sb-foot-btn {
  font-size: 0.7rem;
  padding: 0.22rem 0.5rem;
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: var(--r-sm);
  background: none;
  color: var(--sb-text);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--t);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.sb-foot-btn:hover { border-color: rgba(255,255,255,0.18); color: var(--sb-text-h); }
.sb-foot-btn.red { border-color: rgba(192,48,48,0.25); color: #d07070; }
.sb-foot-btn.red:hover { background: rgba(192,48,48,0.1); }

/* ═══════════════════════════════════════════════════════
   PANELS
   ═══════════════════════════════════════════════════════ */
.panels-area {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.panel {
  display: none;
  height: 100%;
  overflow-y: auto;
  flex-direction: column;
}
.panel.active { display: flex; }

/* Panel header */
.panel-hd {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  flex: 1;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Panel body */
.panel-bd {
  flex: 1;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

/* Split layout (left sidebar + right content) */
.panel-split {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.split-left {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--surface);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.split-right {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  min-width: 0;
}

/* ═══════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh1);
}

.card-hd {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-bd { padding: 0.875rem 1rem; }

.card-ft {
  padding: 0.625rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* Character / Entity card */
.entity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh0);
  overflow: hidden;
  transition: box-shadow var(--t), border-color var(--t);
}
.entity-card:hover { box-shadow: var(--sh1); border-color: var(--border-s); }

.entity-card-hd {
  padding: 0.75rem 0.875rem 0.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.entity-name {
  font-family: "Palatino Linotype", serif;
  font-size: 0.95rem;
  font-weight: 700;
  flex: 1;
  line-height: 1.2;
}

.entity-meta {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* HP bar */
.hp-wrap { padding: 0 0.875rem 0.625rem; }

.hp-bar-track {
  height: 5px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.hp-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
  background: var(--ok);
}
.hp-bar-fill.hp-warn { background: var(--warn); }
.hp-bar-fill.hp-crit { background: var(--danger); }

.hp-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}

/* Entity quick actions */
.entity-btns {
  padding: 0 0.875rem 0.75rem;
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

/* Expandable details */
.entity-detail {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.875rem;
}

/* Grid of cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.875rem;
}

/* ═══════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════ */
.tbl-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead tr { background: var(--surface-2); }

th {
  padding: 0.45rem 0.75rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.tbl-sm td { padding: 0.35rem 0.6rem; font-size: 0.8rem; }

/* Initiative table row types */
.row-pc td { background: rgba(21,128,61,0.03); }
.row-mon td { background: rgba(198,40,40,0.03); }
.row-active td { background: rgba(139,26,26,0.07); font-weight: 600; }

/* ═══════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 0.22rem; }

.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.44rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-10);
}

input[type="file"] { padding: 0.3rem; }
textarea { resize: vertical; min-height: 70px; }
input[type="number"].mini { width: 64px; text-align: center; }

.form-stack { display: flex; flex-direction: column; gap: 0.8rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.65rem; }

.checkline {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.84rem;
}
.checkline input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

.inline-form { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }

/* Radio source toggle */
.source-toggle { display: flex; gap: 0.75rem; }
.source-toggle label { display: flex; align-items: center; gap: 0.3rem; cursor: pointer; font-size: 0.82rem; }

/* ═══════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.44rem 0.875rem;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t);
  line-height: 1.3;
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }

.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-s); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn-warn { background: var(--warn); color: #fff; border-color: var(--warn); }
.btn-warn:hover { background: #92400e; }

.btn-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-ok:hover { background: #166534; }

.btn-sm { padding: 0.27rem 0.6rem; font-size: 0.75rem; }
.btn-xs { padding: 0.14rem 0.38rem; font-size: 0.7rem; border-radius: 4px; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-group { display: flex; gap: 0.25rem; align-items: center; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.42rem;
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.badge-gray { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: rgba(21,128,61,0.2); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(180,83,9,0.2); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(198,40,40,0.2); }
.badge-accent { background: var(--accent-10); color: var(--accent); border-color: var(--accent-20); }

/* ═══════════════════════════════════════════════════════
   ENCOUNTER / COMBAT COMPONENTS
   ═══════════════════════════════════════════════════════ */
.enc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--r);
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 0.84rem;
  transition: all var(--t);
}
.enc-item:hover { background: var(--surface-2); border-color: var(--border); }
.enc-item.enc-active {
  background: var(--accent-10);
  border-color: var(--accent-20);
  color: var(--accent);
  font-weight: 600;
}

.enc-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border-s);
}
.enc-item.enc-active .enc-dot { background: var(--ok); }

.enc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Initiative dots in table */
.type-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  vertical-align: middle;
  margin-right: 0.3rem;
}
.dot-pc { background: var(--ok); }
.dot-mon { background: var(--danger); }

/* ═══════════════════════════════════════════════════════
   NOTES
   ═══════════════════════════════════════════════════════ */
.note-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.75rem 0.875rem;
  transition: box-shadow var(--t);
}
.note-item:hover { box-shadow: var(--sh0); }

.note-hd {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.note-title { font-weight: 600; font-size: 0.875rem; }
.note-ts { font-size: 0.68rem; color: var(--muted); flex-shrink: 0; }
.note-body { font-size: 0.82rem; color: var(--text-2); line-height: 1.5; }
.note-tags { font-size: 0.68rem; color: var(--muted); margin-top: 0.25rem; }

/* ═══════════════════════════════════════════════════════
   QUESTS
   ═══════════════════════════════════════════════════════ */
.quest-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.quest-hd {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  cursor: pointer;
}
.quest-hd:hover { background: var(--surface-2); }
.quest-name { font-weight: 600; font-size: 0.875rem; flex: 1; }

.quest-bd {
  padding: 0.75rem 0.875rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: none;
}
.quest-item.open .quest-bd { display: block; }

/* ═══════════════════════════════════════════════════════
   NPC / COLLAPSIBLE LIST ITEMS
   ═══════════════════════════════════════════════════════ */
.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.list-item-hd {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.875rem;
  cursor: pointer;
}
.list-item-hd:hover { background: var(--surface-2); }
.list-item-name { font-weight: 600; font-size: 0.875rem; flex: 1; }
.list-item-meta { font-size: 0.72rem; color: var(--muted); }

.list-item-bd {
  padding: 0.75rem 0.875rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: none;
}
.list-item.open .list-item-bd { display: block; }
.list-item-toggle { color: var(--muted); font-size: 0.65rem; transition: transform var(--t); }
.list-item.open .list-item-toggle { transform: rotate(180deg); }

/* ═══════════════════════════════════════════════════════
   SOUNDBOARD
   ═══════════════════════════════════════════════════════ */
.sb-section-hd {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.sb-btn-row { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.soundboard-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-2);
  transition: all var(--t);
  min-width: 85px;
  max-width: 130px;
}
.soundboard-btn:hover { background: var(--surface-2); border-color: var(--border-s); box-shadow: var(--sh0); }
.soundboard-btn.is-playing { background: var(--accent-10); border-color: var(--accent-20); color: var(--accent); }

.soundboard-track { display: flex; align-items: center; gap: 0.25rem; }
.sb-name { text-align: center; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.sb-status { font-size: 0.62rem; color: var(--muted); min-height: 0.8em; }
.soundboard-btn.is-playing .sb-status { color: var(--accent); }
.sb-icon { font-size: 0.9rem; }

/* ═══════════════════════════════════════════════════════
   PLAYER SCREEN
   ═══════════════════════════════════════════════════════ */
.ps-status-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 1.25rem;
}

.ps-slides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.ps-slide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.75rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: box-shadow var(--t), border-color var(--t);
}
.ps-slide-card:hover { box-shadow: var(--sh1); border-color: var(--border-s); }

.ps-slide-name { font-weight: 600; font-size: 0.875rem; }
.ps-slide-meta { font-size: 0.7rem; color: var(--muted); }
.ps-slide-actions { display: flex; gap: 0.3rem; margin-top: 0.25rem; align-items: center; }

.ps-slide-edit-panel {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
  display: none;
}
.ps-slide-card.editing .ps-slide-edit-panel { display: block; }

/* Reorder buttons */
.reorder-btns { display: flex; gap: 0.15rem; }
.reorder-btn {
  padding: 0.12rem 0.28rem;
  font-size: 0.62rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: none;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  transition: all var(--t);
}
.reorder-btn:hover { background: var(--surface-2); color: var(--text); }

/* Old selector compatibility */
.slide-reorder-btn { padding: 0.12rem 0.28rem; font-size: 0.62rem; border: 1px solid var(--border); border-radius: 3px; background: none; cursor: pointer; color: var(--muted); }

/* ═══════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12,10,9,0.68);
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}
.modal-overlay.is-open { display: flex; }

.modal-dialog {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh3);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in 0.18s ease;
}
.modal-dialog.is-active { display: flex; }

@keyframes modal-in {
  from { transform: scale(0.96) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 1.05rem; }

.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: all var(--t);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.125rem 1.25rem;
}

.modal-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
  background: var(--surface-2);
}

/* ═══════════════════════════════════════════════════════
   TOASTS & FLASH
   ═══════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  padding: 0.6rem 1rem;
  background: #1c1914;
  color: #f0e8dc;
  border-radius: var(--r);
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--sh2);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s, transform 0.18s;
  max-width: 320px;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--danger); }

/* Legacy class */
.ajax-toast { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 9999; padding: 0.6rem 1rem; background: #1c1914; color: #f0e8dc; border-radius: var(--r); font-size: 0.82rem; box-shadow: var(--sh2); opacity: 0; transform: translateY(8px); transition: opacity 0.18s, transform 0.18s; }
.ajax-toast.is-visible { opacity: 1; transform: translateY(0); }
.ajax-toast.is-error { background: var(--danger); }

.flash {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 9999;
  padding: 0.7rem 1rem;
  border-radius: var(--r);
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--sh1);
  max-width: 360px;
  animation: flash-slide 0.22s ease;
}
@keyframes flash-slide { from { opacity:0; transform: translateY(-6px); } to { opacity:1; transform: none; } }
.flash-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid rgba(21,128,61,0.2); }
.flash-error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(198,40,40,0.2); }

/* Autosave indicator */
.autosave-indicator { font-size: 0.72rem; padding: 0.18rem 0.45rem; border-radius: var(--r-sm); display: none; }
.autosave-indicator.is-saving { display: inline-flex; background: var(--warn-bg); color: var(--warn); }
.autosave-indicator.is-saved  { display: inline-flex; background: var(--ok-bg);   color: var(--ok); }
.autosave-indicator.is-error  { display: inline-flex; background: var(--danger-bg); color: var(--danger); }

/* ═══════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: auto;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh2);
  padding: 2rem 2rem 1.75rem;
  width: 360px;
}

.login-box h2 {
  font-size: 1.4rem;
  text-align: center;
  margin-bottom: 0.25rem;
}

.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 1.5rem;
}

.login-hint {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  margin-top: 1rem;
}

/* ═══════════════════════════════════════════════════════
   SECTION LABELS / UTILITIES
   ═══════════════════════════════════════════════════════ */
.section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.hstack { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.text-xs { font-size: 0.72rem; }
.font-bold { font-weight: 700; }
.font-semi { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.w-full { width: 100%; }

/* Quick-add area styling */
.quick-add {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.875rem 1rem;
}

.quick-add-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.quick-add-toggle:hover { color: var(--text); }
.quick-add-body { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); display: none; }
.quick-add.open .quick-add-body { display: block; }

/* Settings / admin section */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.settings-hd {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 700;
  font-size: 0.875rem;
}
.settings-bd { padding: 1rem; }

/* ═══════════════════════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════════════════════ */
body.dark {
  --bg: #100e0d;
  --surface: #1a1714;
  --surface-2: #211e1a;
  --border: #2e2a25;
  --border-s: #3d3830;
  --text: #e8ddd0;
  --text-2: #b0a090;
  --muted: #6a6050;
  --sb-bg: #080706;
  --sh1: 0 1px 3px rgba(0,0,0,0.3);
  --sh2: 0 4px 12px rgba(0,0,0,0.35);
}

body.dark .entity-card:hover,
body.dark tbody tr:hover { background: var(--surface-2); }

/* ═══════════════════════════════════════════════════════
   ADVENTURE PDF VIEWER
   ═══════════════════════════════════════════════════════ */
.pdf-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: box-shadow var(--t);
}
.pdf-list-item:hover { box-shadow: var(--sh0); }
.pdf-title { font-weight: 600; font-size: 0.875rem; flex: 1; }
.pdf-hint { font-size: 0.72rem; color: var(--muted); }

/* ═══════════════════════════════════════════════════════
   QUEST FILTER BAR & ARCHIVE
   ═══════════════════════════════════════════════════════ */
.quest-filter-bar {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: .6rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-wrap: wrap;
}
.quest-filter-bar select {
  padding: .28rem .55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .78rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.quest-filter-bar select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.quest-archive {
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.quest-archive-summary {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1rem;
  cursor: pointer;
  background: var(--bg);
  font-weight: 600;
  font-size: .82rem;
  user-select: none;
  color: var(--muted);
  list-style: none;
}
.quest-archive-summary::-webkit-details-marker { display: none; }
.quest-archive-summary::before { content: '▶'; font-size: .65rem; transition: transform .15s; }
details[open] .quest-archive-summary::before { transform: rotate(90deg); }
.quest-archive-summary:hover { background: var(--surface); color: var(--text); }
.quest-archive-hint { font-weight: 400; font-size: .72rem; margin-left: auto; }

.list-item-archived { opacity: .7; }
.list-item-archived:hover { opacity: 1; }

.upload-progress-wrap { height: 6px; border-radius: 3px; background: var(--border); margin-bottom: .5rem; overflow: hidden; }
.upload-progress-bar { height: 100%; width: 0%; background: var(--accent); border-radius: 3px; transition: width .1s linear; }
