@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Montserrat:wght@700&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold: #D39A39;
  --gold-light: #e2b96f;
  --bg-body: #111212;
  --bg-solid: #222323;
  --bg-glass: rgba(26, 27, 27, 0.75);
  --bg-glass-light: rgba(40, 42, 42, 0.7);
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.18);
  --text: #e0e0e0;
  --text-muted: #888;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --radius: 10px;
  --radius-sm: 6px;
  --header-height: 56px;
  --accent: #e0e0e0;
  --hover-shadow: 0 6px 24px rgba(199,95,180,0.1);
}

@media (max-width: 480px) {
  :root { --header-height: 72px; }
}

body {
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  background-color: var(--bg-body);
  background-image: linear-gradient(160deg, rgb(0 0 0 / 82%) 0%, rgb(15 14 16 / 75%) 50%, rgb(0 0 0 / 88%) 100%), url(https://raw.githubusercontent.com/jt1919191919/dnd-tool/refs/heads/main/data/images/background-texture5.jpg);
  background-repeat: repeat;
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Times New Roman', serif;
  color: var(--gold);
}

.hidden { display: none !important; }

html {
  overflow-x: clip;
  max-width: 100vw;
}
body {
  max-width: 100vw;
}

/* ── HEADER ─────────────────────────────────────────────────────── */
header {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background-color: rgba(20, 21, 21, 0.92);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  isolation: isolate;
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
#site-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.header-right { display: flex; align-items: center; gap: 12px; }
#player-name-display { font-size: 0.85rem; color: var(--text-muted); }
#hamburger {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}
#search-input,
#token-bar input {
  width: 100%;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 0.95rem;
  font-family: 'Roboto', sans-serif;
  transition: border-color 0.2s, background 0.2s;
}
#search-input:focus,
#token-bar input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
}

/* ── NAV ─────────────────────────────────────────────────────────── */
#side-menu {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background-color: rgba(20, 21, 21, 0.98);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  position: sticky;
  top: 95px;
  z-index: 98;
  box-shadow: var(--shadow-sm);
}
#side-menu ul { list-style: none; }
#side-menu li { padding: 4px 0; }
#side-menu a {
  color: #e0e0e0;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}
#side-menu a:hover { color: #fff; }
#side-menu a > span.nav-icon {
  display: inline-flex;
  width: 20px;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

/* ── MAIN ─────────────────────────────────────────────────────────── */
main { padding: 16px; }

/* ── CARDS ─────────────────────────────────────────────────────────── */
#cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (min-width: 1366px) {
  #cards-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.card {
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background-color: rgba(30, 31, 31, 0.88);
  border: 1px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  box-shadow: var(--shadow-sm);
}
.card:hover {
  box-shadow: var(--hover-shadow);
  transform: translateY(-2px);
}
.card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.card-no-img {
  width: 100%;
  aspect-ratio: 4/3;
  background: rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.card-body { padding: 10px; }
.card-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
}
.card-desc { font-size: 0.75rem; color: var(--text-muted); }
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.card.drag-over {
  border-color: var(--gold);
  opacity: 0.7;
}

/* ── PAGE VIEW ──────────────────────────────────────────────────────── */
#page-outline-wrap {
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background-color: rgba(26,27,27,0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
}
#page-outline { padding-left: 16px; margin-top: 6px; }
#page-outline li { margin: 3px 0; }
#page-outline a { color: var(--gold); text-decoration: none; }

#dm-page-controls {
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background-color: rgba(26,27,27,0.9);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}
#dm-page-controls button {
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: #e0e0e0;
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
  transition: background 0.15s;
}
#dm-page-controls button:hover { background: rgba(255,255,255,0.07); }
#visibility-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
#visibility-checkboxes label { display: flex; align-items: center; gap: 4px; font-size: 0.85rem; }

#page-content {
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  line-height: 1.7;
  box-shadow: var(--shadow);
  overflow-x: hidden;
  max-width: 100%;
}
#page-content h1 { font-size: 22px; color: var(--gold); margin: 20px 0 10px; font-weight: 400; }
#page-content h2 { font-size: 20px; color: var(--gold); margin: 18px 0 8px; font-weight: 400; }
#page-content h3 { font-size: 18px; color: var(--gold); margin: 14px 0 6px; font-weight: 400; }
#page-content h4 { font-size: 16px; color: var(--gold); margin: 12px 0 6px; font-weight: 400; }
#page-content p { margin-bottom: 10px; font-size: 14px; }
#page-content a { color: #ffffff; }
#page-content a[style*="color"] { color: unset; }
#page-content img { max-width: 100%; border-radius: var(--radius-sm); margin: 10px 0; }
#page-content ul, #page-content ol {
  margin: 6px 0 10px 24px;
  padding-left: 8px;
}
#page-content li { margin-bottom: 4px; }

#page-content * {
  max-width: 100%;
}
#page-content div,
#page-content p,
#page-content span {
  width: auto !important;
  min-width: 0 !important;
}

/* ── EDITOR ──────────────────────────────────────────────────────────── */
#view-dm-editor input[type=text] {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-family: 'Roboto', sans-serif;
  transition: border-color 0.2s;
}
#view-dm-editor input[type=text]:focus {
  outline: none;
  border-color: var(--gold);
}
.content-editable {
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 16px;
  min-height: 300px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 0;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  overflow-y: auto;
}
.content-editable ul, .content-editable ol {
  margin: 6px 0 10px 24px;
  padding-left: 8px;
}
.content-editable li { margin-bottom: 4px; }
.content-editable a { color: #ffffff; }
.content-editable a[style*="color"] { color: unset; }

#view-dm-editor button {
  padding: 8px 16px;
  margin-right: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: 'Roboto', sans-serif;
  transition: background 0.15s;
}
#view-dm-editor button:hover { background: rgba(255,255,255,0.07); }

/* ── EDITOR TOOLBAR ──────────────────────────────────────────────────── */
.editor-toolbar {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(20,21,21,0.98);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0;
  position: sticky;
  top: 94px;
  z-index: 50;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.editor-toolbar.active { display: flex; }
.toolbar-group {
  display: flex;
  gap: 2px;
  align-items: center;
  padding-right: 6px;
  border-right: 1px solid rgba(255,255,255,0.08);
  margin-right: 2px;
}
.toolbar-group:last-child { border-right: none; }
.tb-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  border-radius: 4px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: 'Roboto', sans-serif;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s;
}
.tb-btn:hover { background: rgba(211,154,57,0.12); border-color: var(--gold); }
.tb-btn.active { background: rgba(211,154,57,0.15); border-color: var(--gold); color: var(--gold); }
#toolbar-heading {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.85rem;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
}
.color-picker-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background-color: rgba(20,21,21,0.97);
  border: 1px solid var(--border-strong);
  border-radius: 6px 6px 0 0;
  padding: 10px;
  z-index: 200;
  position: fixed;
  bottom: 52px;
  left: 0;
  right: 0;
  max-width: 700px;
  margin: 0 auto;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
}
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: border-color 0.15s, transform 0.1s;
}
.color-swatch:hover { border-color: #fff; transform: scale(1.15); }

/* ── EDITOR TABLE ────────────────────────────────────────────────────── */
.editor-table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
}
.editor-table td, .editor-table th {
  border: none;
  padding: 6px 10px;
  min-width: 60px;
  vertical-align: top;
  position: relative;
}
.editor-table th {
  background: rgba(40,40,40,0.9);
  color: var(--gold);
}
.editor-table tbody tr:nth-child(odd) td {
  background: rgba(255,255,255,0.03);
}
.editor-table tbody tr:nth-child(even) td {
  background: rgba(255,255,255,0.06);
}
.editor-table tbody tr:hover td {
  background: rgba(255,255,255,0.09);
}
.content-editable .editor-table td,
.content-editable .editor-table th {
  border: 1px dashed rgba(255,255,255,0.15) !important;
}

blockquote {
  border-left: 3px solid var(--gold);
  margin: 10px 0;
  padding: 6px 14px;
  color: var(--text-muted);
  font-style: italic;
  background: rgba(211,154,57,0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ── EDITOR Scrollboxes ────────────────────────────────────────────────────── */
.scroll-box {
  overflow: auto;
  max-width: 100%;
  max-height: 70vh;
  margin: 10px 0;
  scrollbar-color: #D39A39 rgba(211,154,57,0.08);
  scrollbar-width: auto;
}
.content-editable .scroll-box {
  border: 1px dashed rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 4px;
}
.scroll-box::-webkit-scrollbar { height: 8px; }
.scroll-box::-webkit-scrollbar-track { background: rgba(211,154,57,0.08); border-radius: 4px; }
.scroll-box::-webkit-scrollbar-thumb { background: rgba(211,154,57,0.7); border-radius: 4px; }
.scroll-box::-webkit-scrollbar-thumb:hover { background: #D39A39; }

/* ── EDITOR ACTIONS ──────────────────────────────────────────────────── */
#editor-actions {
  position: sticky;
  bottom: 0;
  background: rgba(20,21,21,0.99);
  padding: 10px 0;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  z-index: 100;
}

/* ── SEARCH RESULTS ──────────────────────────────────────────────────── */
#search-results { margin-bottom: 20px; }
.search-result-item {
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background-color: rgba(30,31,31,0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-result-item:hover {
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 2px 12px rgba(255,255,255,0.06);
}
.search-result-title { color: #ffffff; font-weight: bold; font-size: 0.9rem; }
.search-result-snippet { font-size: 0.8rem; color: #888; margin-top: 4px; }
.search-result-heading { font-size: 0.75rem; color: #aaa; margin: 3px 0; }
.sr-label { font-size: 0.7rem; color: #888; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.sr-tag-hint { font-size: 0.6rem; opacity: 0.25; margin-left: 3px; vertical-align: middle; }
.sr-title { color: #ffffff; font-weight: bold; font-size: 0.9rem; margin-bottom: 2px; }
.sr-heading { font-size: 0.75rem; color: #aaa; margin: 2px 0; }
.sr-snippet { font-size: 0.8rem; color: #888; margin-top: 3px; }
mark {
  background: rgba(211,154,57,0.28);
  color: #f0d080;
  border-radius: 2px;
  padding: 0 2px;
}

/* ── ACCESS DENIED ───────────────────────────────────────────────────── */
#access-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  gap: 12px;
  padding: 20px;
}

/* ── CONFIG ──────────────────────────────────────────────────────────── */
#config-player-list { font-size: 0.9rem; }
.config-player-row {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
}
.config-player-row strong { color: var(--gold); }

/* ── SHARE ───────────────────────────────────────────────────────────── */
.share-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.7rem;
  opacity: 0.35;
  padding: 0 3px;
  vertical-align: middle;
  transition: opacity 0.15s;
}
.share-btn:hover { opacity: 1; }
.share-panel-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background-color: rgba(20,21,21,0.97);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px;
  width: 200px;
  z-index: 500;
  box-shadow: var(--shadow);
}
.share-player-row {
  padding: 7px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  margin-bottom: 3px;
  transition: background 0.15s;
}
.share-player-row:hover { background: rgba(255,255,255,0.06); }

/* ── TABLE ENGINE ────────────────────────────────────────────────────── */
.spell-table-wrap { width: 100%; }
.spell-table-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.tbl-btn {
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: 'Roboto', sans-serif;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
.tbl-btn:hover { border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.08); }
.col-panel {
  background: rgba(20,21,21,0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #e0e0e0;
}
.spell-table-scroll {
  overflow: auto;
  max-height: 600px;
  border-radius: var(--radius-sm);
  border: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.spell-table-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.spell-table-scroll::-webkit-scrollbar-track { background: rgba(211,154,57,0.08); border-radius: 4px; }
.spell-table-scroll::-webkit-scrollbar-thumb { background: rgba(211,154,57,0.7); border-radius: 4px; }
.spell-table-scroll::-webkit-scrollbar-thumb:hover { background: #D39A39; }
.spell-table-scroll::-webkit-scrollbar-corner { background: transparent; }
.spell-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.spell-table th {
  background: rgba(25,25,25,0.98);
  color: #e0e0e0;
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  user-select: none;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.spell-table th:hover { background: rgba(50,50,50,0.97); }
.spell-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(211,154,57,0.08);
  vertical-align: top;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.spell-row { cursor: pointer; }
.spell-row:hover td { background: rgba(255,255,255,0.04); }
.spell-row:nth-child(even) td { background: rgba(255,255,255,0.02); }
.spell-row:nth-child(even):hover td { background: rgba(255,255,255,0.05); }

/* ── SPELL POPUP ─────────────────────────────────────────────────────── */
.spell-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.spell-popup {
  background: var(--bg-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
.spell-popup-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.spell-popup-close:hover { color: var(--text); background: rgba(255,255,255,0.08); }
.spell-popup-title {
  font-family: 'Times New Roman', serif;
  color: #ffffff;
  font-size: 1.3rem;
  margin-bottom: 4px;
  padding-right: 30px;
}
.spell-popup-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 14px;
  font-style: italic;
}
.spell-popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.85rem;
}
.spell-popup-grid div {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.spell-popup-grid strong {
  color: #aaa;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.spell-popup-full { grid-column: 1 / -1; }
.spell-popup-text {
  font-size: 0.85rem;
  line-height: 1.7;
  margin-bottom: 10px;
  color: var(--text);
}
.spell-popup-higher {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 0.85rem;
  line-height: 1.6;
}
.spell-popup-higher strong { color: #ccc; }

.spell-popup {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.spell-popup::-webkit-scrollbar { width: 6px; }
.spell-popup::-webkit-scrollbar-track { background: transparent; }
.spell-popup::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.spell-popup::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

/* ── BACK TO TOP ─────────────────────────────────────────────────────── */
#back-to-top {
  transition: opacity 0.2s;
}
#back-to-top:hover {
  background: rgba(255,255,255,0.1) !important;
  box-shadow: 0 4px 16px rgba(255,255,255,0.1) !important;
}

/* ── DM VIEWS ────────────────────────────────────────────────────────── */
#view-dm-config h2,
#view-dm-config h3,
#view-dm-tables h2,
#view-dm-images h2 {
  font-family: 'Times New Roman', serif;
  color: var(--gold);
  margin-bottom: 10px;
}
#view-dm-config input,
#view-dm-config select {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.9rem;
}
#view-dm-config input:focus { outline: none; border-color: var(--gold); }

/* ── TOKEN BAR ───────────────────────────────────────────────────────── */
#token-bar button {
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
  font-size: 0.85rem;
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  color: #e0e0e0;
}

/* ── bottom margin ───────────────────────────────────────────────────────── */
#view-home, #view-page {
  padding-bottom: 70px;
}

/* ── dropdown options ───────────────────────────────────────────────────────── */
#toc-level-filter option {
  background: #222323;
  color: #e0e0e0;
}

select option {
  background: #222323;
  color: #e0e0e0;
}

/* ── Custom checkboxes sitewide ───────────────────────────────────────────────────────── */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  vertical-align: middle;
}
input[type="checkbox"]:checked {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.5);
}
input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}
input[type="checkbox"]:hover {
  border-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.08);
}

/* ── Popups centered on mobile ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .visibility-popup,
  .share-panel-popup,
  .heading-level-popup {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    top: auto !important;
    bottom: 16px !important;
    width: 90vw !important;
    max-width: 360px !important;
  }
  .spell-popup-overlay {
    position: fixed !important;
    inset: 0 !important;
    padding: 12px !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
  }
  .spell-popup {
    max-width: 100% !important;
    width: 100% !important;
    max-height: none !important;
    margin-top: 8px !important;
  }
}

/* ── Search Tags and Priority  ───────────────────────────────────────────────────────── */
.search-tag {
  background: rgba(226, 185, 111, 0.15);
  border-bottom: 1px dashed #e2b96f;
  border-radius: 2px;
  color: inherit;
}

.search-result-priority {
  border-left: 2px solid #e2b96f;
  background: rgba(226, 185, 111, 0.05);
}

/* ── Link to Higher than the Heading  ───────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  scroll-margin-top: 100px;
}

.heading-anchor-btn {
  font-size: 0.55em !important;
  opacity: 0.3;
  margin-left: -1.4em;
  margin-right: 0.3em;
  vertical-align: middle;
  padding: 0 2px !important;
  position: relative;
  top: -1px;
}
.heading-anchor-btn:hover { opacity: 1 !important; }

/* ── Sticky HTML tables ───────────────────────────────────────────── */
/* sticky-col works inside any scroll container */
.scroll-box .sticky-col td:first-child,
.scroll-box .sticky-col th:first-child,
.sticky-header-wrap .sticky-col td:first-child,
.sticky-header-wrap .sticky-col th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #222323 !important;
}
.scroll-box .sticky-col tbody tr:nth-child(odd) td:first-child,
.sticky-header-wrap .sticky-col tbody tr:nth-child(odd) td:first-child {
  background: #1e1f1f !important;
}
.scroll-box .sticky-col tbody tr:nth-child(even) td:first-child,
.sticky-header-wrap .sticky-col tbody tr:nth-child(even) td:first-child {
  background: #252626 !important;
}
.scroll-box .sticky-col tbody tr:hover td:first-child,
.sticky-header-wrap .sticky-col tbody tr:hover td:first-child {
  background: #2a2b2b !important;
}
/* sticky-header: wrap table in a div with max-height for vertical scroll */
.sticky-header-wrap {
  overflow: auto;
  max-height: 500px;
  scrollbar-color: #D39A39 rgba(211,154,57,0.08);
  scrollbar-width: auto;
}
.sticky-header-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.sticky-header-wrap::-webkit-scrollbar-track { background: rgba(211,154,57,0.08); }
.sticky-header-wrap::-webkit-scrollbar-thumb { background: rgba(211,154,57,0.7); border-radius: 4px; }
.sticky-header-wrap::-webkit-scrollbar-thumb:hover { background: #D39A39; }
.scroll-box .sticky-header thead th,
.scroll-box .sticky-header tbody tr:first-child td,
.scroll-box .sticky-header tbody tr:first-child th,
.sticky-header-wrap .sticky-header thead th,
.sticky-header-wrap .sticky-header tbody tr:first-child td,
.sticky-header-wrap .sticky-header tbody tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(40,40,40,0.97);
}
.scroll-box .sticky-header.sticky-col thead th:first-child,
.scroll-box .sticky-header.sticky-col tbody tr:first-child td:first-child,
.sticky-header-wrap .sticky-header.sticky-col thead th:first-child,
.sticky-header-wrap .sticky-header.sticky-col tbody tr:first-child td:first-child {
  z-index: 4;
}

/* ── Cell paste button ───────────────────────────────────────────── */
.cell-paste-btn {
  position: fixed;
  background: rgba(211,154,57,0.15);
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.72rem;
  cursor: pointer;
  z-index: 400;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: background 0.15s;
}
.cell-paste-btn:hover { background: rgba(211,154,57,0.3); }

/* ── Gold scrollbars everywhere ──────────────────────────────────── */
#page-content::-webkit-scrollbar { height: 8px; }
#page-content::-webkit-scrollbar-track { background: rgba(211,154,57,0.08); border-radius: 4px; }
#page-content::-webkit-scrollbar-thumb { background: rgba(211,154,57,0.7); border-radius: 4px; }
#page-content::-webkit-scrollbar-thumb:hover { background: #D39A39; }

.content-editable::-webkit-scrollbar { width: 6px; height: 8px; }
.content-editable::-webkit-scrollbar-track { background: rgba(211,154,57,0.08); border-radius: 4px; }
.content-editable::-webkit-scrollbar-thumb { background: rgba(211,154,57,0.7); border-radius: 4px; }
.content-editable::-webkit-scrollbar-thumb:hover { background: #D39A39; }

/* Firefox gold scrollbars */
.scroll-box { scrollbar-color: #D39A39 rgba(211,154,57,0.08); scrollbar-width: auto; }
.spell-table-scroll { scrollbar-color: #D39A39 rgba(211,154,57,0.08); scrollbar-width: auto; }


/* ── Scroll hint indicators ───────────────────────────────────────── */
.scroll-box {
  position: relative;
}
.scroll-hint-right {
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(211,154,57,0.35));
  pointer-events: none;
  border-radius: 0 4px 4px 0;
  transition: opacity 0.3s;
  z-index: 5;
}
.spell-table-scroll {
  position: relative;
}


/* ── Force sticky via attribute — bypasses all specificity issues ── */
/* Sticky header — only thead, never tbody fallback */
table[data-sticky-header] > thead > tr > th {
  position: sticky !important;
  top: 0 !important;
  z-index: 3 !important;
  background: rgba(40,40,40,0.97) !important;
}
/* Sticky col — all rows, tbody and thead */
table[data-sticky-col] > thead > tr > th:first-child,
table[data-sticky-col] > tbody > tr > td:first-child,
table[data-sticky-col] > tbody > tr > th:first-child {
  position: sticky !important;
  left: 0 !important;
  z-index: 2 !important;
  background: #222323 !important;
}
/* Corner cell — sticky both axes */
table[data-sticky-header][data-sticky-col] > thead > tr > th:first-child {
  z-index: 4 !important;
  background: rgba(40,40,40,0.97) !important;
}

</style>
