:root {
  --sidebar-w:  270px;
  --legend-w:   195px;
  --landing-panel-w: 480px;
}
@media (max-width: 1400px) { :root { --landing-panel-w: 380px; } }
@media (max-width: 1100px) { :root { --landing-panel-w: 300px; } }

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

/* ── App tooltip ──────────────────────────────────────────────── */

#app-tooltip {
  display: none;
  position: fixed;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 7px;
  color: #d1d5db;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 0.80rem;
  padding: 0.4rem 0.7rem;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 4000;
}
#app-tooltip.tip-wrap {
  white-space: normal;
  max-width: 260px;
  line-height: 1.6;
}

/* ── Custom confirm dialog ────────────────────────────────────── */

#confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}
#confirm-overlay.active { display: flex; }

#choice-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}
#choice-overlay.active { display: flex; }
#choice-dialog {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  width: min(520px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
#choice-message {
  font-size: 0.82rem;
  color: #d1d5db;
  line-height: 1.5;
}
#choice-dialog .confirm-actions {
  flex-wrap: nowrap;
}
#choice-a, #choice-b, #choice-cancel {
  border-radius: 6px;
  padding: 0.3rem 0.85rem;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
  border: 1px solid #4b5563;
}
#choice-a {
  background: #374151;
  color: #f9fafb;
}
#choice-a:hover { background: #4b5563; }
#choice-b {
  background: #7f1d1d;
  color: #fca5a5;
  border-color: #991b1b;
}
#choice-b:hover { background: #991b1b; }
#choice-cancel {
  background: #374151;
  color: #9ca3af;
}
#choice-cancel:hover { background: #4b5563; color: #d1d5db; }

#confirm-dialog {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}

#confirm-message {
  font-size: 0.92rem;
  color: #d1d5db;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

#confirm-ok {
  background: #7f1d1d;
  color: #fca5a5;
  border: 1px solid #991b1b;
  border-radius: 6px;
  padding: 0.3rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
#confirm-ok:hover { background: #991b1b; }
#confirm-ok.warn {
  background: #f5a623;
  color: #111827;
  border-color: #e09518;
}
#confirm-ok.warn:hover { background: #e09518; }

#confirm-cancel {
  background: #374151;
  color: #9ca3af;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 0.3rem 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.12s;
}
#confirm-cancel:hover { background: #4b5563; color: #d1d5db; }

/* ── vis-network tooltip ──────────────────────────────────────── */

.vis-tooltip {
  background:    #1f2937 !important;
  border:        1px solid #374151 !important;
  border-radius: 7px !important;
  color:         #d1d5db !important;
  font-family:   'Segoe UI', system-ui, sans-serif !important;
  font-size:     0.82rem !important;
  padding:       0.45rem 0.75rem !important;
  box-shadow:    0 8px 24px rgba(0,0,0,0.5) !important;
  white-space:   nowrap !important;
}

/* ── Node context menu ────────────────────────────────────────── */

#bg-ctx-menu {
  display: none;
  position: fixed;
  z-index: 1000;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 7px;
  padding: 0.3rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 160px;
}
#bg-ctx-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: #d1d5db;
  padding: 0.45rem 0.75rem;
  text-align: left;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 5px;
}
#bg-ctx-menu button:hover { background: #374151; }

#bg-move-overlay {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(17,24,39,0.85);
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.5rem 1.2rem;
  font-size: 0.8rem;
  color: #9ca3af;
  pointer-events: none;
}

#node-ctx-menu {
  display: none;
  position: fixed;
  z-index: 1000;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 7px;
  padding: 0.3rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 115px;
}

#node-ctx-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: #d1d5db;
  padding: 0.45rem 0.75rem;
  text-align: left;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 5px;
}
#node-ctx-menu button:hover { background: #374151; }
#ctx-delete-btn { color: #f87171 !important; }
#ctx-delete-btn:hover { background: #7f1d1d !important; }

.ctx-submenu-wrap { position: relative; }
.ctx-submenu-trigger {
  display: flex;
  align-items: center;
}
.ctx-submenu-panel {
  display: none;
  position: absolute;
  left: 100%;
  top: -0.3rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 7px;
  padding: 0.3rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 140px;
  z-index: 1001;
}
.ctx-submenu-wrap:hover .ctx-submenu-panel { display: block; }
#ctx-priority-high-btn { color: #4ade80; }
#ctx-priority-low-btn  { color: #f87171; }
#ctx-priority-high-btn:hover { background: #14532d !important; }
#ctx-priority-low-btn:hover  { background: #450a0a !important; }
#ctx-color-wrap .ctx-submenu-panel { min-width: 0; width: fit-content; }
.ctx-color-grid {
  display: grid;
  grid-template-columns: repeat(4, 22px);
  gap: 4px;
  padding: 0.35rem 0.35rem 0.2rem;
}
.ctx-color-swatch {
  width: 22px !important; height: 22px !important;
  padding: 0 !important;
  border: 2px solid rgba(0,0,0,0.4) !important;
  border-radius: 4px !important;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.ctx-color-swatch:hover { transform: scale(1.15); border-color: rgba(255,255,255,0.75) !important; }
.ctx-color-swatch.active { box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(255,255,255,0.4) !important; }
#ctx-color-clear-btn { color: #9ca3af !important; font-size: 0.78rem !important; padding: 0.25rem 0.75rem !important; }

/* ── Edit modal ───────────────────────────────────────────────── */

#note-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
#note-modal-overlay.active { display: flex; }

#note-modal {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}

#note-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: #f5a623;
}

#edit-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
#edit-modal-overlay.active { display: flex; }

#start-node-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
#start-node-modal-overlay.active { display: flex; }
#start-node-input {
  width: 4rem;
  text-align: center;
  background: #111827;
  border: 1px solid #4b5563;
  color: #f9fafb;
  border-radius: 5px;
  padding: 0.2rem 0.3rem;
  font-size: 0.9rem;
}
#start-node-modal .modal-actions { justify-content: flex-end; }
#start-node-modal .modal-actions .primary-btn,
#start-node-modal .modal-actions .secondary-btn {
  flex: none; width: auto; padding: 0.25rem 0.8rem; font-size: 0.82rem;
}
#start-node-modal {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  width: fit-content;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#start-node-modal .modal-title {
  font-size: 0.9rem;
  margin-bottom: 0;
}

#edit-modal {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}

.modal-title, #edit-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: #f5a623;
}

.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-close-btn {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  flex-shrink: 0;
}
.modal-close-btn:hover { color: #d1d5db; }

.modal-actions {
  display: flex;
  gap: 0.5rem;
}

.modal-actions .primary-btn { flex: 1; }

#profile-modal .modal-actions {
  justify-content: flex-end;
}
#profile-modal .modal-actions .primary-btn,
#profile-modal .modal-actions #profile-cancel-btn {
  flex: none !important;
  width: auto !important;
  padding: 0.25rem 0.65rem !important;
  font-size: 0.78rem !important;
}
#edit-book-modal .modal-actions,
.new-book-form .modal-actions,
#edit-modal .modal-actions,
#note-modal .modal-actions,
#add-book-overlay .modal-actions,
#add-comp-overlay .modal-actions,
#add-series-overlay .modal-actions,
#add-stash-overlay .modal-actions,
#edit-stash-overlay .modal-actions,
#edit-comp-overlay .modal-actions,
#edit-series-overlay .modal-actions {
  justify-content: flex-end;
}
#edit-book-modal .modal-actions .primary-btn,
#edit-book-modal .modal-actions #edit-book-cancel,
.new-book-form .modal-actions .primary-btn,
.new-book-form .modal-actions #new-book-cancel-btn,
#edit-modal .modal-actions .primary-btn,
#edit-modal .modal-actions #edit-modal-cancel,
#note-modal .modal-actions .primary-btn,
#note-modal .modal-actions #note-modal-cancel,
#add-book-overlay .modal-actions .primary-btn,
#add-book-overlay .modal-actions #cb-cancel,
#add-comp-overlay .modal-actions .primary-btn,
#add-comp-overlay .modal-actions #cc-cancel,
#add-series-overlay .modal-actions .primary-btn,
#add-series-overlay .modal-actions #csr-cancel,
#add-stash-overlay .modal-actions .primary-btn,
#add-stash-overlay .modal-actions #cst-cancel,
#edit-stash-overlay .modal-actions .primary-btn,
#edit-stash-overlay .modal-actions #est-cancel,
#edit-comp-overlay .modal-actions .primary-btn,
#edit-comp-overlay .modal-actions #ecc-cancel,
#edit-series-overlay .modal-actions .primary-btn,
#edit-series-overlay .modal-actions #esr-cancel {
  flex: none !important;
  width: auto !important;
  padding: 0.25rem 0.65rem !important;
  font-size: 0.78rem !important;
}

#edit-modal-cancel, #edit-book-cancel, #profile-cancel-btn, #crop-cancel-btn, #note-modal-cancel,
#feedback-cancel-btn, #inbox-close-btn, #inbox-conv-close-btn, #new-book-cancel-btn,
#cb-cancel, #cc-cancel, #csr-cancel, #cst-cancel, #est-cancel, #ecc-cancel, #esr-cancel {
  flex: 1;
  background: #374151;
  color: #9ca3af;
  border: 1px solid #4b5563;
  border-radius: 7px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
}
#edit-modal-cancel:hover, #edit-book-cancel:hover, #profile-cancel-btn:hover, #crop-cancel-btn:hover,
#note-modal-cancel:hover, #inbox-close-btn:hover, #inbox-conv-close-btn:hover,
#cb-cancel:hover, #cc-cancel:hover, #csr-cancel:hover, #cst-cancel:hover, #est-cancel:hover, #ecc-cancel:hover, #esr-cancel:hover { background: #4b5563; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #111827;
  color: #d1d5db;
  height: 100vh;
  overflow: hidden;
}

/* ── Landing layout ───────────────────────────────────────────────────────── */

#covers-panel {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: var(--landing-panel-w);
  height: 100vh;
  flex-direction: column;
  border-right: 1px solid #1f2937;
  padding: 1rem 1.1rem;
  overflow: hidden;
  background: rgba(17,24,39,0.45);
  transition: transform 0.25s ease;
}

#covers-panel.covers-lazy,
#covers-panel.covers-searching {
  direction: rtl;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #374151 transparent;
}
#covers-panel.covers-lazy > *,
#covers-panel.covers-searching > * {
  direction: ltr;
}
#covers-panel.covers-lazy::-webkit-scrollbar,
#covers-panel.covers-searching::-webkit-scrollbar { width: 5px; }
#covers-panel.covers-lazy::-webkit-scrollbar-track,
#covers-panel.covers-searching::-webkit-scrollbar-track { background: transparent; }
#covers-panel.covers-lazy::-webkit-scrollbar-thumb,
#covers-panel.covers-searching::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
#covers-panel.covers-lazy::-webkit-scrollbar-thumb:hover,
#covers-panel.covers-searching::-webkit-scrollbar-thumb:hover { background: #4b5563; }
#covers-panel.covers-lazy #covers-header,
#covers-panel.covers-searching #covers-header {
  position: sticky;
  top: 0;
  background: #111827;
  z-index: 50;
}

#covers-panel.active { display: flex; }
body.covers-collapsed #covers-panel {
  transform: translateX(calc(-1 * var(--landing-panel-w)));
  border-right: none;
}

#covers-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.covers-search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

#covers-search-icon {
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 0.15em 0.2em;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: color 0.12s;
  flex-shrink: 0;
}
#covers-search-icon:hover { color: #f5a623; }

#covers-search {
  display: none;
  background: transparent;
  border: none;
  border-bottom: 1px solid #374151;
  color: #d1d5db;
  font-size: 0.75rem;
  font-family: inherit;
  padding: 0.1em 1.2em 0.1em 0.25em;
  outline: none;
  width: 0;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  transition: border-color 0.15s;
}
#covers-search::placeholder { color: #4b5563; }
#covers-search:focus { border-bottom-color: #f5a623; }

#covers-header.covers-search-open #covers-header-label { display: none; }
#covers-header.covers-search-open .covers-search-wrap { flex: 1; }
#covers-header.covers-search-open #covers-search { display: block; width: 100%; }
#covers-header.covers-search-open #covers-search-icon { color: #f5a623; }

@keyframes covers-sort-flash {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
#covers-sort {
  position: relative;
  display: inline-block;
  vertical-align: baseline;
  color: #f5a623;
  cursor: pointer;
}
#covers-sort:hover, #covers-sort:focus { opacity: 1; outline: none; }
#covers-sort-label { display: inline; }
#covers-sort-label { animation: covers-sort-flash 4s ease-in-out infinite; }
#covers-sort-menu,
#covers-kind-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.25rem 0;
  margin: 0;
  list-style: none;
  z-index: 600;
  min-width: 6rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
}
#covers-sort.open #covers-sort-menu { display: block; }
#covers-kind {
  position: relative;
  display: inline-block;
  vertical-align: baseline;
  color: #a855f7;
  cursor: pointer;
}
#covers-kind:hover, #covers-kind:focus { opacity: 1; outline: none; }
#covers-kind-label { display: inline; animation: covers-sort-flash 4s ease-in-out infinite; }
#covers-kind.open #covers-kind-menu { display: block; }
#covers-sort-menu li,
#covers-kind-menu li {
  padding: 0.3rem 0.75rem;
  color: #d1d5db;
  cursor: pointer;
  font-size: 0.8rem;
  white-space: nowrap;
}
#covers-sort-menu li:hover,
#covers-kind-menu li:hover { background: #374151; color: #f9fafb; }
#covers-sort-menu li.active { color: #f5a623; }
#covers-kind-menu li.active { color: #a855f7; }

#covers-search-clear {
  display: none;
  position: absolute;
  right: 0;
  background: transparent;
  border: none;
  color: #6b7280;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0.1em 0.2em;
  line-height: 1;
  transition: color 0.12s;
}
#covers-search-clear:hover { color: #f5a623; }

#covers-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

#cover-preview-popup {
  display: none;
  position: fixed;
  z-index: 9999;
  width: 220px;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
  pointer-events: none;
}
#cover-preview-popup.visible { display: block; }
#cover-preview-popup-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 75vh;
  object-fit: contain;
}
#cover-preview-popup-series {
  display: none;
  position: relative;
  width: 220px;
  aspect-ratio: 2 / 3;
  background: #111827;
}
#cover-preview-popup.series-preview #cover-preview-popup-img { display: none; }
#cover-preview-popup.series-preview #cover-preview-popup-series { display: block; }
#cover-preview-popup.series-preview #cover-preview-popup-title { display: block; }
#cover-preview-popup-title,
#cover-tooltip-settings-preview {
  padding: 0.22rem 0.6rem;
  font-size: var(--cover-preview-title-size, 0.84rem);
  font-weight: 500;
  color: #d1d5db;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
 #cover-preview-popup-title {
  border-top: 1px solid #374151;
 }
body.cover-tooltip-title-bold #cover-preview-popup-title {
  font-weight: 700;
}

#cover-tooltip-settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(0,0,0,0.18);
}
#cover-tooltip-settings-overlay.active {
  display: block;
}
#cover-tooltip-settings {
  position: fixed;
  top: 1rem;
  left: calc(var(--landing-panel-w) + 1rem);
  width: 210px;
  background: rgba(17,24,39,0.96);
  border: 1px solid #374151;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
  padding: 0.7rem 0.8rem;
  color: #d1d5db;
}
.cover-tooltip-settings-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #f5a623;
  margin-bottom: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cover-tooltip-settings-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.84rem;
  color: #e5e7eb;
  cursor: pointer;
  margin-bottom: 0.45rem;
}
.cover-tooltip-settings-row--size {
  justify-content: space-between;
}
.cover-tooltip-settings-row input {
  accent-color: #f5a623;
}
.cover-tooltip-size-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}
.cover-tooltip-size-controls button {
  width: 1.55rem;
  height: 1.55rem;
  border: 1px solid #374151;
  border-radius: 5px;
  background: #111827;
  color: #d1d5db;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}
.cover-tooltip-size-controls button:hover {
  border-color: #6b7280;
  color: #f3f4f6;
}
#cover-tooltip-size-value {
  min-width: 3.2rem;
  text-align: center;
  font-size: 0.8rem;
  color: #f5a623;
  font-weight: 700;
}
#cover-tooltip-settings-preview-frame {
  margin-top: 0.35rem;
  border: 1px solid #374151;
  border-radius: 6px;
  background: #0f172a;
  overflow: hidden;
}
body.cover-tooltip-title-bold #cover-tooltip-settings-preview {
  font-weight: 700;
}
.cover-tooltip-settings-hint {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: #6b7280;
}

#shortcuts-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(0,0,0,0.18);
}
#shortcuts-modal-overlay.active {
  display: block;
}
#shortcuts-modal {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: 680px;
  max-width: min(94vw, 680px);
  background: rgba(17,24,39,0.98);
  border: 1px solid #374151;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
  padding: 0.7rem 0.8rem;
  color: #d1d5db;
}
#shortcuts-modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #f5a623;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
#shortcuts-modal-close {
  background: none;
  border: none;
  color: #d1d5db;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
#shortcuts-modal-close:hover {
  color: #f9fafb;
}
#shortcuts-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.shortcuts-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 0.65rem;
  align-items: center;
}
.shortcuts-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.6rem;
  padding: 0.1rem 0.45rem;
  border-radius: 5px;
  border: 1px solid #374151;
  background: rgba(31,41,55,0.9);
  color: #f5a623;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.shortcuts-desc {
  color: #d1d5db;
  font-size: 0.84rem;
  line-height: 1.25;
  white-space: nowrap;
}
@media (max-width: 760px) {
  .shortcuts-desc {
    white-space: normal;
  }
}

.cover-thumb {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #374151;
  background: #1f2937;
  cursor: pointer;
  transition: border-color 0.15s;
}
.cover-fav-btn {
  position: absolute;
  top: 0.32rem;
  right: 0.32rem;
  z-index: 3;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid rgba(230, 180, 80, 0.34);
  border-radius: 5px;
  background: rgba(18, 22, 28, 0.84);
  color: #9ca3af;
  font-size: 0.95rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s, background 0.12s;
}
.cover-thumb:hover .cover-fav-btn,
.cover-thumb:focus-within .cover-fav-btn {
  opacity: 1;
  pointer-events: auto;
}
.cover-fav-btn:hover {
  color: #f5a623;
  border-color: rgba(230, 180, 80, 0.72);
  background: rgba(18, 22, 28, 0.92);
}
.cover-fav-btn.is-favorite {
  color: #f5a623;
  border-color: rgba(230, 180, 80, 0.72);
}

.cover-load-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, #0891b2, #67e8f9);
  z-index: 1;
  pointer-events: none;
}
.cover-thumb:hover { border-color: #6b7280; }
.cover-thumb--anthology { border-color: rgba(167,139,250,0.5); }
.cover-thumb--anthology:hover { border-color: rgba(167,139,250,0.85); }
.cover-thumb--series { border-color: rgba(245,166,35,0.55); }
.cover-thumb--series:hover { border-color: rgba(245,166,35,0.9); }
.cover-anthology-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #a78bfa;
  background: rgba(17,24,39,0.82);
  border: 1px solid rgba(167,139,250,0.4);
  border-radius: 3px;
  padding: 1px 4px;
  pointer-events: none;
}
.cover-series-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #f5a623;
  background: rgba(17,24,39,0.82);
  border: 1px solid rgba(245,166,35,0.45);
  border-radius: 3px;
  padding: 1px 4px;
  pointer-events: none;
}
.cover-series-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 1px;
  background: #111827;
}
.cover-series-grid--single {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.cover-series-cell {
  position: relative;
  overflow: hidden;
  background: #1f2937;
}
.cover-series-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 1 !important;
}
.cover-series-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem;
  color: #f59e0b;
  font-size: 0.62rem;
  line-height: 1.3;
  background:
    linear-gradient(135deg, rgba(245,166,35,0.16), rgba(17,24,39,0.92)),
    radial-gradient(circle at top left, rgba(251,191,36,0.25), transparent 55%);
}

.cover-no-img {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  font-size: 0.65rem;
  color: #6b7280;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
  hyphens: auto;
}

.cover-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#landing-wrapper {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-right: var(--landing-panel-w);
  padding-left:  var(--landing-panel-w);
  transition: padding-left 0.25s ease, padding-right 0.25s ease;
}
#landing-wrapper::-webkit-scrollbar { display: none; }

#landing-bg-a,
#landing-bg-b {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.5s ease;
  will-change: auto;
}
body.covers-collapsed #landing-wrapper { padding-left: 0; }
body.right-collapsed  #landing-wrapper { padding-right: 0; }
body.feed-collapsed #feed-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-18px);
  max-height: 0;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
}

#app-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #1f2937 url('/banner-bg.svg') center / cover no-repeat;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.5rem;
}

#app-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

#app-banner-title {
  font-size: 1rem;
  font-weight: 700;
  color: #f9fafb;
  letter-spacing: -0.01em;
}
.mobile-lite-suffix { display: none; }

#app-version {
  font-size: 0.75rem;
  font-weight: 400;
  color: #c8894a;
  vertical-align: middle;
  margin-left: 0.3rem;
}

#app-footer {
  text-align: center;
  font-size: 0.7rem;
  color: #4b5563;
  padding: 1.5rem 0 1rem;
  pointer-events: none;
  user-select: none;
}

#app-banner-sub {
  font-size: 0.75rem;
  color: #6b7280;
}

#app-banner-guide-btn {
  display: inline-block;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 7px;
  color: #9ca3af;
  font-size: 0.82rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding: 0.35rem 0.9rem;
  line-height: normal;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s;
}
#app-banner-guide-btn:hover { border-color: #6b7280; color: #e2e8f0; }

#app-banner-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

#app-banner-brand {
  font-size: 0.75rem;
  color: #c8894a;
  letter-spacing: 0.04em;
}
.brand-flag {
  background: linear-gradient(to right, #ffffff 33%, #00966E 33% 66%, #D62612 66%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#app-banner-text { min-width: 0; }
#app-banner-title { white-space: nowrap; }
#app-banner-sub   { white-space: nowrap; }

#app-banner-btns {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Progressive banner simplification as center narrows */
@media (max-width: 1400px) {
  #app-banner-brand { display: none; }
}
@media (max-width: 1100px) {
  #app-banner-sub { display: none; }
  #app-banner { padding: 0.55rem 0.75rem; gap: 0.5rem; }
}

#demo-btn,
#stats-btn,
#forum-btn,
#feedback-btn,
#notif-btn,
#inbox-btn {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 7px;
  color: #9ca3af;
  font-size: 0.82rem;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s;
}
#stats-btn:hover { border-color: #6b7280; color: #e2e8f0; }
#demo-btn:hover      { border-color: #f5a623; color: #f5a623; }
#forum-btn:hover                      { border-color: #6b7280; color: #e2e8f0; }
#forum-btn.forum-btn--active          { border-color: #16a34a; color: #4ade80; animation: notif-pulse 1.8s ease-in-out infinite; }
#forum-btn.forum-btn--active:hover    { border-color: #22c55e; color: #86efac; animation: none; }
#feedback-btn:hover  { border-color: #6b7280; color: #e2e8f0; }
#notif-btn:hover     { border-color: #6b7280; color: #e2e8f0; }
#inbox-btn:hover     { border-color: #6b7280; color: #e2e8f0; }
#inbox-btn.inbox-btn--active       { border-color: #16a34a; color: #4ade80; }
#inbox-btn.inbox-btn--active:hover { border-color: #22c55e; color: #86efac; }

.bell-icon {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  vertical-align: -0.1em;
  background: currentColor;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6V11c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6V11c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

@keyframes notif-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
  50%       { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0.3); }
}
#notif-btn.notif-btn--active {
  border-color: #16a34a;
  color: #4ade80;
  animation: notif-pulse 1.8s ease-in-out infinite;
}
#notif-btn.notif-btn--active:hover { border-color: #22c55e; color: #86efac; animation: none; }

#notif-dropdown {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-height: 380px;
  overflow-y: auto;
  background: #1a2235;
  border: 1px solid #374151;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 9000;
  padding: 0.25rem 0;
  scrollbar-width: thin;
  scrollbar-color: #374151 transparent;
}
#notif-empty {
  padding: 0.6rem 0.75rem;
  color: #6b7280;
  font-size: 0.82rem;
  text-align: center;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  border-bottom: 1px solid #1f2937;
  cursor: default;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.notif-unseen { background: #1e2d3e; }
.notif-item-icon {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  margin-top: 0.1rem;
}
.notif-item-icon.icon-level { background: #1e3a5f; color: #60a5fa; }
.notif-item-icon.icon-coin  { background: #3b2a0a; color: #f5a623; }
.notif-item-icon.icon-role-author      { background: #3b2a0a; color: #f5a623; }
.notif-item-icon.icon-role-contributor { background: #0a2a1a; color: #34d399; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-text { color: #d1d5db; line-height: 1.35; }
.notif-item-text strong { color: #f9fafb; }
.notif-item-time { color: #6b7280; font-size: 0.75rem; margin-top: 0.15rem; }
.notif-unseen-dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  margin-top: 0.45rem;
}

/* ── Demo banner ──────────────────────────────────────────────────────────── */

#demo-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #92400e;
  color: #fef3c7;
  font-size: 0.85rem;
  padding: 0.45rem 1rem;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
#demo-banner.active { display: flex; }
#demo-exit-btn {
  background: #78350f;
  border: 1px solid #b45309;
  border-radius: 5px;
  color: #fef3c7;
  font-size: 0.8rem;
  padding: 0.22rem 0.7rem;
  cursor: pointer;
}
#demo-exit-btn:hover { background: #92400e; border-color: #d97706; }

/* Push page content down when banner is visible */
body.demo-active #landing-wrapper,
body.demo-active #main-screen {
  margin-top: 34px;
}

/* Fixed elements that need to clear the demo banner */
body.demo-active #main-screen        { height: calc(100vh - 34px); }
body.demo-active #covers-panel,
body.demo-active #landing-right      { top: 34px; height: calc(100vh - 34px); }
body.demo-active #run-trail-float,
body.demo-active #legend             { top: calc(12px + 34px); }

/* Hide profile/logout in demo */
body.demo-active #profile-btn,
body.demo-active #logout-btn {
  display: none;
}

#feed-panel {
  width: min(max(896px, 35vw), calc(100vw - 2rem));
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 1.2rem 2rem;
  transition: opacity 0.2s ease, transform 0.2s ease, max-height 0.25s ease, padding 0.25s ease;
}

#feed-header {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin-bottom: 0.4rem;
}
.feed-header-sub {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.72rem;
}

.feed-day-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
}

.feed-day-header {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.feed-entry {
  font-size: 0.85rem;
  color: #d1d5db;
  padding: 0.2rem 0;
  line-height: 1.4;
}
.feed-entry--party {
  border-left: 2px solid #2dd4bf;
  padding-left: 0.5rem;
  margin-left: -0.5rem;
}
.feed-user-group .feed-entry--party {
  border-left: none;
  padding-left: 0;
  margin-left: 0;
}
.feed-party-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: #2dd4bf;
  background: rgba(45,212,191,0.12);
  border: 1px solid rgba(45,212,191,0.3);
  border-radius: 4px;
  padding: 0.05em 0.4em;
  vertical-align: middle;
  letter-spacing: 0.03em;
}

.feed-user  { font-weight: 600; color: #f5a623; }
.feed-book  { font-weight: 600; color: #e2e8f0; }
.feed-run   { font-size: 0.75rem; color: #fde047; }
.feed-verb.died    { color: #e74c3c; }
.feed-verb.lost    { color: #e74c3c; }
.feed-verb.won     { color: #27ae60; }
.feed-verb.neutral { color: #9ca3af; }
.feed-level { font-weight: 600; color: #67e8f9; }
.feed-title { color: #0891b2; font-style: italic; font-weight: 600; }
.feed-ability { color: #a78bfa; font-size: 0.88em; }

.feed-empty {
  font-size: 0.8rem;
  color: #4b5563;
}

.feed-user-group {
}
.feed-user-group--party {
  border-left: 2px solid #2dd4bf;
  padding-left: calc(0.5rem - 2px);
  margin: 0.15rem 0 0.15rem -0.5rem;
}
.feed-group-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: #9ca3af;
  padding: 0.2rem 0;
  width: 100%;
  text-align: left;
}
.feed-group-toggle:hover { color: #d1d5db; }
.feed-group-chevron {
  font-size: 0.65rem;
  color: #6b7280;
  transition: color 0.15s;
}
.feed-group-body {
  border-left: 2px solid #374151;
  padding-top: 0.1rem;
  padding-left: 0.5rem;
  margin-left: -0.5rem;
}
.feed-group-count {
  color: #9ca3af;
  font-weight: 400;
}
.feed-group-name { display: inline; }
.feed-group-toggle .feed-user       { color: #f5a623; }
.feed-group-toggle .author-badge    { color: #fbbf24; }
.feed-group-toggle .contributor-badge { color: #34d399; }
.feed-group-toggle .admin-badge     { color: #60a5fa; }

.feed-announcement {
  position: relative;
  border: 1.5px solid #f59e0b;
  border-radius: 7px;
  padding: 0.55rem 0.8rem 0.5rem;
  margin: 0.15rem 0;
}
.feed-ann-title {
  position: absolute;
  top: -0.62em;
  left: 0.7rem;
  background: #1f2937;
  padding: 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #f59e0b;
  letter-spacing: 0.04em;
}
.feed-ann-body {
  font-size: 0.85rem;
  color: #e5e7eb;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.feed-pinned-card {
  border: 1.5px solid #f59e0b;
  border-radius: 7px;
  padding: 0.2rem 0.8rem 0.5rem;
  margin: 0.4rem 0;
}
.feed-pinned-legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #f3f4f6;
  padding: 0 0.35rem;
}
.feed-pin-icon {
  width: 13px;
  height: 13px;
  color: #f59e0b;
  flex-shrink: 0;
}
.feed-pinned-body {
  font-size: 0.85rem;
  color: #e5e7eb;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

#landing-right {
  position: fixed;
  right: 0;
  top: 0;
  width: var(--landing-panel-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #1f2937;
  padding: 1rem 1.1rem 0.4rem;
  overflow-y: auto;
  background: rgba(17,24,39,0.45);
  transition: transform 0.25s ease;
}
body.right-collapsed #landing-right { transform: translateX(var(--landing-panel-w)); border-left: none; }

/* ── Panel toggle buttons ─────────────────────────────────────────── */

.panel-toggle {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 200;
  width: 16px;
  height: 52px;
  background: #1f2937;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, left 0.25s ease, right 0.25s ease;
  padding: 0;
}
.panel-toggle:hover { color: #f9fafb; }
.panel-toggle.visible { display: flex; }

#covers-toggle {
  left: var(--landing-panel-w);
  border-left: none;
  border-radius: 0 4px 4px 0;
}
body.covers-collapsed #covers-toggle { left: 0; }

#right-toggle {
  right: var(--landing-panel-w);
  border-right: none;
  border-radius: 4px 0 0 4px;
}
body.right-collapsed #right-toggle { right: 0; }

#feed-toggle {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 210;
  width: 52px;
  height: 16px;
  border: 1px solid #374151;
  border-top: none;
  border-radius: 0 0 6px 6px;
  background: rgba(31, 41, 55, 0.88);
  color: #6b7280;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, top 0.25s ease, opacity 0.2s ease;
  padding: 0;
}
#feed-toggle:hover { color: #f9fafb; background: rgba(31, 41, 55, 0.92); }
body.feed-collapsed #feed-toggle {
  top: 0;
}

#sidebar-toggle {
  left: 270px;
  border-left: none;
  border-radius: 0 4px 4px 0;
  transition: color 0.15s, border-color 0.15s, left 0.25s ease;
}
body.sidebar-collapsed #sidebar-toggle { left: 0; }

/* ── Login screen ─────────────────────────────────────────────── */

#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

#mobile-guest-btn { display: none; }

#login-screen h1 {
  font-size: 2.4rem;
  color: #f5a623;
  letter-spacing: -0.5px;
}

.login-sub {
  color: #6b7280;
  font-size: 0.95rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 280px;
}

.auth-error {
  font-size: 0.8rem;
  color: #f87171;
}

.auth-alt-btn {
  background: none;
  border: 1px solid #374151;
  border-radius: 7px;
  color: #9ca3af;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.auth-alt-btn:hover { background: #1f2937; color: #d1d5db; }

/* ── Books screen ─────────────────────────────────────────────── */

#books-screen {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
}

.books-container {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

#books-tip-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.5rem 0.9rem 0.6rem;
  margin-bottom: 0.5rem;
  min-height: 2rem;
  position: relative;
  overflow: hidden;
}
#tip-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 1px;
  width: 100%;
  background: #f5a623;
  transform-origin: left;
  transform: scaleX(1);
}
@keyframes tip-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
.tip-label {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  color: #f5a623;
  flex-shrink: 0;
}
#books-tip-text {
  font-size: 0.8rem;
  line-height: 1;
  color: #d1d5db;
  transition: opacity 0.5s ease;
}
#books-tip-text.fading { opacity: 0; }

.books-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow: hidden;
}

.books-header h2 {
  font-size: 1.1rem;
  color: #f5a623;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.books-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.books-username {
  font-size: 0.8rem;
  color: #6b7280;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  flex-shrink: 1;
}

@media (max-width: 520px) {
  .books-username { display: none; }
}

.logout-btn {
  background: none;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #9ca3af;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.12s;
}
.logout-btn:hover { background: #1f2937; color: #d1d5db; }

/* ── Shop button ────────────────────────────────────────────────── */
.shop-btn {
  background: #1c2a18;
  border: 1px solid #2d5a1b;
  border-radius: 6px;
  color: #86efac;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: inherit;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  transition: background 0.12s;
  letter-spacing: 0.03em;
}
.shop-btn:hover { background: #243520; border-color: #4ade80; color: #4ade80; }
.coin-icon { width: 14px; height: 14px; vertical-align: -2px; display: inline-block; }

/* ── Shop modal ─────────────────────────────────────────────────── */
#shop-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 2000;
  align-items: flex-start; justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
#shop-modal-overlay.active { display: flex; }
#shop-modal {
  background: #111827; border: 1px solid #374151; border-radius: 12px;
  width: 520px; max-width: min(92vw, 520px); max-height: calc(100vh - 2rem);
  margin: auto 0;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.shop-modal-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #1f2937;
}
.shop-modal-title {
  font-size: 0.95rem; font-weight: 700; color: #f3f4f6; flex: 1;
}
.shop-modal-balance {
  font-size: 0.82rem; font-weight: 700;
  color: #86efac; background: #1c2a18;
  border: 1px solid #2d5a1b; border-radius: 5px;
  padding: 0.15rem 0.5rem;
}
.shop-close-btn {
  background: none; border: none; color: #6b7280;
  font-size: 0.9rem; cursor: pointer; padding: 0.1rem 0.2rem;
  line-height: 1; transition: color 0.12s;
}
.shop-close-btn:hover { color: #f3f4f6; }
#shop-items {
  padding: 0.6rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  min-height: 0;
}
.shop-item {
  display: flex; align-items: center; gap: 1rem;
  background: #1f2937; border: 1px solid #374151; border-radius: 8px;
  padding: 0.4rem 1rem;
}
.shop-item-info { flex: 1; }
.shop-item-label { font-size: 0.88rem; font-weight: 600; color: #f3f4f6; }
.shop-item-desc  { font-size: 0.78rem; color: #6b7280; margin-top: 0.15rem; }
.shop-item-owned { font-size: 0.75rem; color: #86efac; margin-top: 0.2rem; }
.shop-item-buy   { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.shop-item-cost  { font-size: 0.75rem; font-weight: 700; color: #86efac; }
.shop-buy-btn {
  background: #1c2a18; border: 1px solid #2d5a1b; border-radius: 6px;
  color: #86efac; font-size: 0.78rem; font-weight: 600;
  font-family: inherit; padding: 0.25rem 0.7rem; cursor: pointer;
  transition: background 0.12s; white-space: nowrap;
}
.shop-buy-btn:hover { background: #243520; border-color: #4ade80; color: #4ade80; }
.shop-buy-btn--disabled, .shop-buy-btn[disabled] {
  opacity: 0.35; cursor: default;
}
.shop-buy-btn--disabled:hover, .shop-buy-btn[disabled]:hover {
  background: #1c2a18; border-color: #2d5a1b; color: #86efac;
}
.shop-error   { font-size: 0.8rem; color: #f87171; min-height: 1.2em; padding: 0 1.25rem 0.75rem; }
.shop-loading { font-size: 0.85rem; color: #6b7280; padding: 1rem 0; text-align: center; }

@media (max-width: 640px) {
  #shop-modal-overlay {
    padding: 0.5rem;
  }
  #shop-modal {
    max-height: calc(100vh - 1rem);
  }
  .shop-item {
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.55rem 0.8rem;
  }
  .shop-item-buy {
    align-self: stretch;
  }
}

.books-empty {
  font-size: 0.85rem;
  color: #4b5563;
  padding: 0.5rem 0;
}

#party-invites-section:empty { display: none; }

#books-xp-summary {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  margin-top: 0;
  margin-bottom: -0.82rem;
  color: #d1d5db;
}
#books-xp-summary:empty {
  display: none;
}
#books-xp-level-row {
  display: flex;
  align-items: baseline;
  gap: 0.42rem;
}
#books-xp-level {
  font-size: 0.8rem;
  font-weight: 700;
  color: #f5a623;
  line-height: 1.15;
}
#books-xp-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e5e7eb;
  line-height: 1.15;
}
#books-xp-bar {
  height: 5px;
  background: #1f2937;
  border-radius: 3px;
  overflow: hidden;
}
#books-xp-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(to right, #f5a623, #fbbf24);
  border-radius: 3px;
  transition: width 0.4s ease;
}
#books-xp-sub-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
}
#books-xp-text {
  font-size: 0.76rem;
  color: #9ca3af;
  line-height: 1.15;
  white-space: nowrap;
}
#books-xp-boost {
  font-size: 0.74rem;
  color: #f59e0b;
  line-height: 1.15;
  text-align: right;
  white-space: nowrap;
}

.books-add-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: -0.6rem;
  margin-bottom: -0.4rem;
}
.books-add-btn {
  background: #f5a623;
  border: none;
  border-radius: 6px;
  color: #111827;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  padding: 0.28rem 0.65rem;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.books-add-btn:hover {
  background: #e09518;
}
#open-add-stash-btn {
  background: transparent;
  color: #9ca3af;
  border: 1px solid #6b7280;
}
#open-add-stash-btn:hover {
  background: rgba(107, 114, 128, 0.12);
  color: #d1d5db;
  border-color: #9ca3af;
}
/* ── Series header row ──────────────────────────────────────────── */
.series-header-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem 0.45rem;
  background: #0d1117;
  border: 1px solid rgba(245,166,35,0.45);
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  user-select: none;
  transition: background 0.1s;
}
.series-header-row:hover { background: #111827; }
.series-header-chevron {
  font-size: 0.6rem;
  color: #f5a623;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.series-header-row[data-expanded="1"] .series-header-chevron {
  transform: rotate(90deg);
}
.series-header-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f5a623;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.series-header-count {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  color: #6b7280;
  line-height: 1;
  flex-shrink: 0;
  white-space: nowrap;
}
.series-edit-btn {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s;
}
.series-edit-btn:hover { color: #f5a623; }
.series-edit-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.series-del-btn {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s;
}
.series-del-btn:hover { color: #ef4444; }
.series-header-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(245,166,35,0.5);
  transition: width 0.3s;
  border-radius: 0 2px 0 0;
}

.series-books-group {
  border: 1px solid rgba(245,166,35,0.45);
  border-top: none;
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}
.series-empty-hint {
  padding: 0.6rem 0.9rem;
  font-size: 0.78rem;
  color: #6b7280;
}
.series-browse-btn {
  background: none;
  border: none;
  color: #f5a623;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.series-books-group > .book-item:not(.book-item--container) {
  border-radius: 0;
  border: none;
  border-top: 1px solid #1f2937;
}
.series-books-group > .book-item:not(.book-item--container):first-child { border-top: none; }

.stash-block {
  border: 1px solid rgba(52,211,153,0.55);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(15,27,24,0.35);
}
.stash-header-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem 0.45rem;
  background: #0f1b18;
  border: none;
  border-radius: 0;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  user-select: none;
  transition: background 0.1s;
}
.stash-block > .stash-header-row[data-expanded="1"] {
  border-bottom: 1px solid rgba(52,211,153,0.55);
}
.stash-header-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(52,211,153,0.5);
  transition: width 0.3s;
  border-radius: 0 2px 0 0;
}
.stash-header-row:hover { background: #13221f; }
.stash-header-chevron {
  font-size: 0.6rem;
  color: #34d399;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.stash-header-row[data-expanded="1"] .stash-header-chevron { transform: rotate(90deg); }
.stash-header-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #34d399;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stash-header-count {
  display: inline-flex;
  align-items: center;
  font-size: 0.76rem;
  color: #9ca3af;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.stash-del-btn {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
}
.stash-edit-btn {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
}
.stash-edit-btn:hover { color: #34d399; }
.stash-del-btn:hover { color: #ef4444; }
.stash-items-group {
  border: none;
  border-radius: 0;
  overflow: visible;
}
.stash-items-group > .series-header-row {
  margin: 0.4rem 0.4rem 0;
  border-radius: 6px 6px 0 0;
}
.stash-items-group > .series-books-group {
  margin: 0 0.4rem 0.4rem;
  border-radius: 0 0 6px 6px;
}
.stash-items-group > .book-item,
.stash-items-group > .book-children-group {
  margin: 0.4rem;
}
.stash-items-group > .book-item:first-child,
.stash-items-group > .series-header-row:first-child {
  margin-top: 0;
}
.stash-items-group > .book-item--container[data-expanded="1"] {
  margin: 0.4rem 0.4rem 0;
}
.stash-items-group > .book-item--container[data-expanded="1"]:first-child {
  margin-top: 0;
}
.stash-items-group > .book-children-group {
  margin-top: 0;
}
.stash-items-group > .book-item--container[data-expanded="1"] + .book-children-group {
  margin: -1px 0.4rem 0.4rem;
}
.stash-items-group > .series-header-row[data-expanded="1"] + .series-books-group {
  margin-top: 0;
}


/* ── Add-entity modals ────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active {
  display: flex;
}
.modal-inner {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 10px;
  width: min(520px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
#add-stash-modal,
#edit-stash-modal {
  width: min(560px, 92vw);
  height: min(760px, 88vh);
  max-height: min(760px, 88vh);
  overflow: hidden;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 0.55rem;
}
#add-stash-modal > *,
#edit-stash-modal > * {
  min-width: 0;
}
#add-stash-modal .input-group:last-of-type,
#edit-stash-modal .input-group:last-of-type {
  grid-row: 3;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#add-stash-modal .auth-error,
#edit-stash-modal .auth-error {
  grid-row: 4;
  flex-shrink: 0;
}
#add-stash-modal .modal-actions,
#edit-stash-modal .modal-actions {
  grid-row: 5;
  margin-top: auto;
  padding-top: 0.65rem;
  flex-shrink: 0;
  background: #111827;
}

.stash-pick-list {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  min-width: 0;
  max-height: none;
  overflow-y: auto;
  border: 1px solid #374151;
  border-radius: 8px;
  background: #0f172a;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stash-search-input {
  width: 100%;
  min-width: 0;
  margin: 0 0 0.45rem;
  padding: 0.38rem 0.55rem;
  border: 1px solid #374151;
  border-radius: 7px;
  background: #0b1220;
  color: #d1d5db;
  font: inherit;
}
.stash-search-input:focus {
  outline: none;
  border-color: #6b7280;
  box-shadow: 0 0 0 2px rgba(107,114,128,0.16);
}
.stash-search-input::placeholder {
  color: #6b7280;
}
.stash-pick-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  background: #111827;
}
.stash-pick-row--selected {
  background: #15252a;
  box-shadow: inset 0 0 0 1px rgba(16,185,129,0.22);
}
.stash-pick-row:hover { background: #162032; }
.stash-pick-row--series .stash-pick-meta {
  color: #f5a623;
}
.stash-pick-row--anthology .stash-pick-meta {
  color: #a78bfa;
}
.stash-pick-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 30px;
  height: 17px;
  margin: 0;
  background: #374151;
  border-radius: 9px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s;
}
.stash-pick-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  background: #9ca3af;
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}
.stash-pick-row input[type="checkbox"]:checked {
  background: #10b981;
}
.stash-pick-row input[type="checkbox"]:checked::after {
  transform: translateX(13px);
  background: #fff;
}
.stash-pick-label {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  color: #d1d5db;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stash-pick-meta {
  font-size: 0.7rem;
  color: #6b7280;
  flex-shrink: 0;
}

#books-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#books-list > .series-header-row[data-expanded="1"] + .series-books-group,
#books-list > .book-item--container[data-expanded="1"] + .book-children-group {
  margin-top: -0.5rem;
}

.book-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
}
.book-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1 1 auto;
  padding-right: 0.75rem;
}

.book-name-btn,
.book-name-text {
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: #d1d5db;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}
.book-name-btn:hover,
.book-name-text:hover { color: #f5a623; }

.book-sections {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  color: #6b7280;
  line-height: 1.1;
}

.book-isbn {
  color: #4b5563;
  font-variant-numeric: tabular-nums;
}

.book-ids {
  font-size: 0.72rem;
  color: #374151;
}

.book-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex-shrink: 0;
}

.book-actions .primary-btn {
  width: 100%;
  padding: 0.2rem 0.5rem;
  font-size: 0.82rem;
}

.book-secondary-actions {
  display: flex;
  gap: 0.25rem;
  width: 100%;
}

.book-edit-btn {
  background: #374151;
  color: #d1d5db;
  border: 1px solid #4b5563;
  border-radius: 7px;
  padding: 0.15rem 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
  flex: 1;
}
.book-edit-btn:hover { background: #4b5563; }
.book-edit-btn:disabled { opacity: 0.35; cursor: default; }
.book-edit-btn:disabled:hover { background: #374151; }

.book-del-btn {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #6b7280;
  padding: 0.15rem 0.4rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.12s;
}
.book-del-btn:hover { background: #7f1d1d; border-color: #991b1b; color: #fca5a5; }

.new-book-form {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.3rem;
}

.new-book-title {
  font-size: 0.8rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.new-book-form textarea {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #d1d5db;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  font-family: inherit;
  resize: vertical;
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
}
.new-book-form textarea:focus { outline: none; border-color: #f5a623; }
.new-book-form textarea::placeholder { color: #4b5563; }


/* ── Main screen ──────────────────────────────────────────────── */

#main-screen {
  display: flex;
  height: 100vh;
  background-size: cover;
  background-position: center;
  background-position-y: 50%;
  background-repeat: no-repeat;
}

#sidebar {
  width: 270px;
  min-width: 270px;
  background: rgba(31,41,55,0.45);
  border-right: 1px solid #374151;
  display: flex;
  flex-direction: column;
  padding: 0.9rem;
  gap: 0.9rem;
  overflow: hidden;
  transition: width 0.25s ease, min-width 0.25s ease, padding 0.25s ease, border-width 0.25s ease;
}
body.sidebar-collapsed #sidebar {
  width: 0;
  min-width: 0;
  padding: 0;
  border-right-width: 0;
}

/* Floating elements reposition when sidebar collapses */
body.sidebar-collapsed #run-trail-float { left: 12px; }
body.sidebar-collapsed #dice-roller     { left: 12px; }
body.sidebar-collapsed #play-btns-bar   { left: 50vw; }

#graph-container {
  flex: 1;
  background-color: transparent;
}

/* ── Book title ───────────────────────────────────────────────── */

.book-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-top: -0.5rem;
}

#book-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f5a623;
  padding: 0.2rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

#edit-book-btn {
  background: none;
  border: none;
  color: #4b5563;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}
#edit-book-btn:hover { color: #f5a623; background: #374151; }

/* ── Edit book modal ──────────────────────────────────────────── */

#edit-book-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
#edit-book-modal-overlay.active { display: flex; }

#edit-book-modal {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 10px;
  width: min(520px, 92vw);
  max-height: 88vh;
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  overflow-y: auto;
}

/* ── Book cover upload ────────────────────────────────────────── */

.cover-upload-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.cover-upload-group > label {
  font-size: 0.8rem;
  color: #9ca3af;
}

.optional-hint {
  color: #4b5563;
  font-size: 0.75rem;
}

.cover-preview-wrap {
  width: 100px;
  height: 150px;           /* 2:3 ratio */
  border: 1px solid #374151;
  border-radius: 6px;
  overflow: hidden;
  background: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.cover-placeholder {
  font-size: 0.75rem;
  color: #4b5563;
  text-align: center;
}

/* ── Stats ────────────────────────────────────────────────────── */

#stats {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.52rem 0.75rem;
  margin: -0.9rem -0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #9ca3af;
}

.stats-row--missing {
  padding-bottom: 0.18rem;
}

.stats-row--playthroughs {
  border-top: 1px solid #374151;
  padding-top: 0.22rem;
}

.missing-label {
  color: #f9fafb;
  cursor: default;
}

#mapped-count, #total-count       { color: #3d9be9; }
#discovered-count, #discovered-total { color: #606060; }

.pt-lost { color: #ef4444; }
.pt-won  { color: #4ade80; }
#pt-outcomes { font-size: 0.75rem; font-weight: 400; margin-left: 0.3rem; }

.stat-value {
  color: #f5a623;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Buttons ──────────────────────────────────────────────────── */

.primary-btn {
  background: #f5a623;
  color: #111827;
  border: none;
  border-radius: 7px;
  padding: 0.4rem 0.75rem;
  font-weight: 700;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}
.primary-btn:hover { background: #e09518; }
#record-btn { padding: 0.2rem 0.75rem; }

/* ── Playthrough panel ────────────────────────────────────────── */

#playthrough-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow: hidden;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.05rem 0 0.1rem;
}

.section-display {
  font-size: 2rem;
  font-weight: 700;
  color: #f5a623;
  line-height: 1;
}

.section-label {
  font-size: 0.72rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.run-controls-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.undo-ft-row {
  display: flex;
  gap: 0.35rem;
}

.undo-run-btn, .fasttravel-btn {
  flex: 1;
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
  background: #374151;
  color: #d1d5db;
  border: 1px solid #4b5563;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.undo-run-btn:hover:not(:disabled), .fasttravel-btn:hover:not(:disabled) { background: #4b5563; color: #f3f4f6; }
.undo-run-btn:disabled, .fasttravel-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.end-run-group { display: flex; flex-direction: column; gap: 0.2rem; }
.win-loss-row { display: flex; gap: 0.35rem; }
.win-btn, .loss-btn {
  flex: 1; padding: 0.1rem 0.4rem; font-size: 0.75rem;
  border-radius: 4px; cursor: pointer; text-align: center; border: 1px solid;
  display: inline-flex; align-items: center; justify-content: center;
}
.win-btn  { background: #14532d; color: #86efac; border-color: #166534; }
.win-btn:hover  { background: #166534; color: #bbf7d0; }
.loss-btn { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
.loss-btn:hover { background: #7f1d1d; color: #fecaca; }
.battle-death-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 0;
  padding: 0.1rem 0.6rem;
  font-size: 0.75rem;
  background: #431407;
  color: #fb923c;
  border: 1px solid #7c2d12;
  border-radius: 4px;
  cursor: pointer;
}
.battle-death-btn:hover { background: #7c2d12; color: #fed7aa; }

/* ── Fast travel dialog ─────────────────────────────────────────── */
#ft-dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}
#ft-dialog-overlay.active { display: flex; }

#ft-dialog {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}

.ft-dialog-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #d1d5db;
}

.ft-dialog-input {
  flex: 1;
  min-width: 0;
  background: #111827;
  border: 1px solid #374151;
  border-left: none;
  border-right: none;
  border-radius: 0;
  padding: 0.35rem 0.4rem;
  font-size: 0.88rem;
  color: #f9fafb;
  text-align: center;
  font-family: inherit;
}
.ft-dialog-input:focus { outline: none; background: #1a2332; }

.ft-dialog-modes {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ft-dialog-mode-btn {
  background: #374151;
  color: #d1d5db;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 0.28rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.12s;
}
.ft-dialog-mode-btn:hover { background: #4b5563; color: #f3f4f6; }

.ft-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.ft-dialog-cancel,
.ft-dialog-ok {
  border-radius: 6px;
  padding: 0.32rem 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}
.ft-dialog-cancel {
  background: #374151;
  color: #9ca3af;
  border: 1px solid #4b5563;
}
.ft-dialog-cancel:hover { background: #4b5563; color: #d1d5db; }
.ft-dialog-ok {
  background: #1d4ed8;
  color: #f9fafb;
  border: 1px solid #3b82f6;
}
.ft-dialog-ok:hover { background: #2563eb; }

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#cb-authors-row,
#edit-book-authors-row {
  display: flex !important;
  flex-direction: column;
}

.autocomplete-wrap {
  position: relative;
}
.autocomplete-wrap input {
  width: 100%;
  box-sizing: border-box;
}
.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 999;
  background: #1f2937;
  border: 1px solid #374151;
  border-top: none;
  border-radius: 0 0 6px 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
}
.autocomplete-dropdown.open { display: block; }
.autocomplete-dropdown li {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: #d1d5db;
  cursor: pointer;
  border-bottom: 1px solid #374151;
}
.autocomplete-dropdown li:last-child { border-bottom: none; }
.autocomplete-dropdown li:hover,
.autocomplete-dropdown li.ac-active { background: #374151; color: #f9fafb; }
.autocomplete-dropdown li .ac-sub {
  font-size: 0.72rem;
  color: #6b7280;
  margin-left: 0.4rem;
}

.autocomplete-dropdown li .ac-sub.ac-owned {
  color: #f5a623;
}

.input-group label {
  font-size: 0.78rem;
  color: #9ca3af;
}

.input-group small {
  font-size: 0.72rem;
  color: #4b5563;
}

.input-group textarea {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #d1d5db;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 0.85rem;
  padding: 0.5rem 0.6rem;
  resize: none;
  line-height: 1.5;
}
.input-group textarea:focus {
  outline: none;
  border-color: #6b7280;
}
.input-group textarea::placeholder { color: #4b5563; }

.label-optional {
  font-size: 0.72rem;
  color: #4b5563;
  font-weight: 400;
}

.choices-label {
  font-size: 0.78rem;
  color: #9ca3af;
}

.choice-buttons {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  max-height: 9rem;
  overflow-y: auto;
}

.choice-btn {
  background: #374151;
  color: #d1d5db;
  border: 1px solid #4b5563;
  border-radius: 5px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 0;
  width: 100%;
  text-align: center;
  transition: background 0.12s, border-color 0.12s;
}
.choice-btn:hover { background: #4b5563; border-color: #6b7280; }

.death-btn { background: #7f1d1d; border-color: #991b1b; color: #fca5a5; }
.death-btn:hover { background: #991b1b; }

.win-btn { background: #14532d; border-color: #166534; color: #86efac; }
.win-btn:hover { background: #166534; }

.terminal-msg {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.4rem 0;
}
.terminal-msg.death { color: #f87171; }
.terminal-msg.win   { color: #4ade80; }

.pt-done-count {
  text-align: center;
  font-size: 0.75rem;
  color: #4b5563;
  margin-top: 0.15rem;
}

/* ── Inputs ───────────────────────────────────────────────────── */

/* Publication type selector + identifier fields */
.series-row {
  display: flex;
  gap: 0.4rem;
  width: 100%;
}
.series-row input[type="text"] { flex: 1; min-width: 0; }

.series-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  color: #a78bfa;
  background: rgba(167,139,250,0.1);
  border: 1px solid rgba(167,139,250,0.3);
  border-radius: 4px;
  padding: 0.05em 0.45em;
  margin-top: 0.2rem;
  white-space: nowrap;
}

.book-item--container {
  border-color: rgba(167,139,250,0.75);
  border-left: 3px solid rgba(167,139,250,0.9);
  background: rgba(167,139,250,0.04);
}
.book-item--container[data-expanded="1"] {
  border-radius: 8px;
}
.book-item--container[data-expanded="1"]:has(+ .book-children-group:not(:empty)) {
  border-radius: 8px 8px 0 0;
  border-bottom: none;
}

.book-children-group {
  margin: 0;
  padding: 0;
  border: 1px solid rgba(167,139,250,0.65);
  border-left: 3px solid rgba(167,139,250,0.9);
  border-top: none;
  border-radius: 0 0 8px 8px;
  background: rgba(167,139,250,0.03);
}
.book-children-group:empty {
  display: none;
}
#books-list > .book-item--container[data-expanded="1"] + .book-children-group {
  margin-top: -0.5rem;
}
.series-books-group > .book-item--container[data-expanded="1"] + .book-children-group {
  margin-top: -1px;
}
.book-item--container .book-container-label {
  font-size: 0.68rem;
  color: #a78bfa;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}
.book-item--container {
  cursor: pointer;
}
.book-item--container .book-secondary-actions {
  cursor: default;
}
.book-item--container .book-name-text {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.book-item--container .book-name-text::before {
  content: '▶';
  display: inline-block;
  flex-shrink: 0;
  font-size: 0.6rem;
  color: #a78bfa;
  transition: transform 0.15s;
  transform: rotate(0deg);
  line-height: 1;
}
.book-item--container[data-expanded="1"] .book-name-text::before {
  transform: rotate(90deg);
}

.book-item--child {
  margin-left: 1.2rem;
  border-left: 2px solid rgba(167,139,250,0.3);
  padding-left: 0.5rem;
  font-size: 0.92em;
}
.book-item--child .book-sections { font-size: 0.72rem; }

.book-item--party {
  border-color: rgba(52,211,153,0.5);
  border-left: 3px solid rgba(52,211,153,0.8);
  background: rgba(52,211,153,0.04);
}

.pub-type-row {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  width: 100%;
}

.app-select,
.pub-type-select {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #d1d5db;
  padding: 0.45rem 1.7rem 0.45rem 0.6rem;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236b7280' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.45rem center;
  transition: border-color 0.15s;
}
.app-select:focus,
.pub-type-select:focus {
  outline: none;
  border-color: #f5a623;
}
.pub-type-select {
  flex-shrink: 0;
}
.app-select {
  flex: 1;
  min-width: 0;
}

.pub-id-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.pub-id-fields input {
  width: 100%;
}

input[type="text"],
input[type="number"],
input[type="password"] {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #d1d5db;
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
  width: 100%;
  transition: border-color 0.15s;
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: #f5a623;
}
input[type="text"]:disabled,
input[type="password"]:disabled {
  opacity: 0.6;
  cursor: default;
  background: #1f2937;
  color: #9ca3af;
}

/* ── Runs list ────────────────────────────────────────────────── */

.runs-section {
  flex: 1;
  min-height: 0;
  margin-top: 0.5rem;
  border-top: 1px solid #374151;
  padding-top: 0.6rem;
  display: flex;
  flex-direction: column;
}


.runs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.72rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.new-run-btn {
  background: #374151;
  color: #d1d5db;
  border: 1px solid #4b5563;
  border-radius: 5px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
  text-transform: none;
  letter-spacing: 0;
}
.new-run-btn:hover { background: #4b5563; }

@keyframes pulse-new-run {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0); }
  50%       { box-shadow: 0 0 0 5px rgba(245, 166, 35, 0.35); }
}
.new-run-btn.pulse {
  border-color: #f5a623;
  color: #f5a623;
  animation: pulse-new-run 1.8s ease-in-out infinite;
}

.runs-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow-y: auto;
}

.runs-empty {
  font-size: 0.78rem;
  color: #4b5563;
  text-align: center;
  padding: 0.3rem 0;
}

.run-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
}

.run-item-active {
  border-color: #f5a623;
}

.run-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.run-num {
  font-size: 0.78rem;
  font-weight: 600;
  color: #d1d5db;
}

.run-status {
  font-size: 0.72rem;
  color: #6b7280;
}
.run-active-label { color: #f5a623; }
.run-death        { color: #f87171; }
.run-battle       { color: #fb923c; }
.run-win          { color: #4ade80; }

.run-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.run-item-viewing {
  border-color: #60a5fa;
  background: #1e3a5f;
  box-shadow: inset 3px 0 0 #60a5fa;
}

.run-load-btn, .run-view-btn, .run-del-btn {
  background: #1f2937;
  color: #9ca3af;
  border: 1px solid #374151;
  border-radius: 5px;
  padding: 0 0.5rem;
  height: 1.5rem;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.run-load-btn:hover, .run-view-btn:hover { background: #374151; color: #d1d5db; }
.run-view-active { background: #1e3a5f; border-color: #3d9be9; color: #93c5fd; }
.run-del-btn { color: #6b7280; }
.run-del-btn:hover { background: #7f1d1d; border-color: #991b1b; color: #fca5a5; }

/* ── Path trail ───────────────────────────────────────────────── */

/* ── Run public toggle ─────────────────────────────────────────── */
.run-public-btn {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  width: 3rem;
}
.run-public-btn:hover { background: #2d3748; border-color: #4b5563; color: #9ca3af; }
.run-public-btn.is-public { background: #0f2e1a; border-color: #27ae60; color: #4ade80; }
.run-public-btn.is-public:hover { background: #14532d; }

/* ── Public modal ──────────────────────────────────────────────── */
.pub-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.pub-overlay.active { display: flex; }

.pub-modal {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 10px;
  width: min(560px, 92vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}
.pub-modal.pub-modal--run {
  width: 75vw;
  height: 75vh;
  max-height: none;
}

.pub-modal-hdr {
  display: flex;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #1f2937;
  gap: 0.75rem;
  flex-shrink: 0;
}

.pub-modal-hdr span {
  flex: 1;
  font-weight: 600;
  color: #f5a623;
  font-size: 0.95rem;
}
.pub-modal-hdr span .pub-modal-type,
.pub-modal-type {
  font-weight: 400 !important;
  font-size: 0.78rem;
  color: #6b7280 !important;
}

.pub-back-btn {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
}
.pub-back-btn:hover { color: #e2e8f0; }

.pub-close-btn {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem 0.4rem;
}
.pub-close-btn:hover { color: #e2e8f0; }

.pub-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 1rem;
}

#pub-graph-container {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

.pub-profile-header {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding-bottom: 1.2rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #1f2937;
}

.pub-profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.pub-profile-avatar-placeholder {
  background: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: #9ca3af;
}

.pub-profile-info {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pub-profile-username {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f5a623;
}

.pub-level-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: #f5a623;
  background: rgba(245,166,35,0.12);
  border-radius: 4px;
  padding: 1px 6px;
}
.pub-level-title {
  font-size: 0.78rem;
  color: #9ca3af;
}

.pub-profile-stats {
  display: flex;
  gap: 0.5rem 0.75rem;
  flex-wrap: wrap;
}

.pub-stat {
  font-size: 0.8rem;
  color: #6b7280;
}

.pub-stat-val {
  font-weight: 700;
  color: #d1d5db;
}

.pub-stat-win  .pub-stat-val { color: #4ade80; }
.pub-stat-death .pub-stat-val { color: #f87171; }

.pub-book {
  margin-bottom: 1.5rem;
}

.pub-book-name {
  font-weight: 600;
  color: #e2e8f0;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.pub-run-btn {
  display: block;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.3rem;
  cursor: pointer;
  font-size: 0.82rem;
  text-align: left;
  width: 100%;
}
.pub-run-btn:hover { background: #2d3748; border-color: #4b5563; }
.pub-run-btn.pub-run-death { color: #f87171; }
.pub-run-btn.pub-run-win   { color: #4ade80; }

.pub-run-locked {
  display: block;
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  color: #4b5563;
}

.pub-loading, .pub-error, .pub-empty {
  color: #6b7280;
  font-size: 0.85rem;
}

/* ── Book modal header ────────────────────────────────────────── */

.book-modal-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding-bottom: 0.9rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid #374151;
}

.book-modal-cover {
  width: 72px;
  height: auto;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: cover;
}

.book-modal-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.book-modal-sections {
  font-size: 0.8rem;
  color: #9ca3af;
}

.book-modal-ids {
  font-size: 0.75rem;
  color: #6b7280;
  font-family: 'Consolas', monospace;
}

.book-modal-in-collection {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  margin-bottom: 0.1rem;
}
.in-collection-label {
  color: #6b7280;
  flex-shrink: 0;
}
.book-modal-parent-btn {
  background: none;
  border: none;
  padding: 0.15rem 0.45rem;
  color: #a78bfa;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  background: rgba(167,139,250,0.1);
  border: 1px solid rgba(167,139,250,0.3);
  border-radius: 4px;
  transition: background 0.12s, color 0.12s;
}
.book-modal-parent-btn:hover {
  background: rgba(167,139,250,0.2);
  color: #c4b5fd;
}

.book-modal-children-section {
  margin: 0 -1rem 0.9rem;
  border-top: 1px solid #1f2937;
  border-bottom: 1px solid #1f2937;
}
.book-modal-children-header {
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.5rem 1rem 0.35rem;
}
.book-modal-children-list {
  display: flex;
  flex-direction: column;
}
.book-modal-child-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  border-top: 1px solid #1f2937;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.1s;
  color: #d1d5db;
  width: 100%;
}
.book-modal-child-row:hover { background: #1f2937; }
.child-row-name {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 500;
}
.child-row-sections {
  font-size: 0.75rem;
  color: #6b7280;
  flex-shrink: 0;
}
.child-row-arrow {
  color: #4b5563;
  font-size: 1rem;
  flex-shrink: 0;
}

.feed-anthology-tag {
  font-size: 0.72rem;
  color: #a78bfa;
  background: rgba(167,139,250,0.1);
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  white-space: nowrap;
  vertical-align: middle;
  margin-left: 0.2rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}
.feed-anthology-tag:hover { background: rgba(167,139,250,0.2); }
.feed-series-tag {
  font-size: 0.72rem;
  color: #f5a623;
  background: rgba(245,166,35,0.1);
  border: 1px solid rgba(245,166,35,0.25);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  white-space: nowrap;
  vertical-align: middle;
  margin-left: 0.2rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}
.feed-series-tag:hover { background: rgba(245,166,35,0.2); }
.book-modal-series-btn {
  background: rgba(245,166,35,0.1);
  border: 1px solid rgba(245,166,35,0.3);
  border-radius: 4px;
  color: #f5a623;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}
.book-modal-series-btn:hover { background: rgba(245,166,35,0.2); }

.book-modal-authors {
  font-size: 0.8rem;
  color: #d1d5db;
  font-style: italic;
}

.book-modal-description {
  font-size: 0.85rem;
  color: #9ca3af;
  line-height: 1.5;
  margin-top: 0.25rem;
  white-space: pre-wrap;
}

/* ── Star rating widget ───────────────────────────────────────── */

.star-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  margin-top: 0.15rem;
  cursor: pointer;
  user-select: none;
}

.star-rating .star {
  font-size: 1.15rem;
  line-height: 1;
  color: #374151;
  transition: color 0.07s;
}

.star-rating .star.on   { color: #f5a623; }

.star-rating .star.half {
  background: linear-gradient(90deg, #f5a623 50%, #374151 50%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.star-label {
  font-size: 0.75rem;
  margin-left: 0.4rem;
}

.star-avg      { color: #f5a623; font-weight: 600; }
.star-avg-none { color: #6b7280; }
.star-votes    { color: #6b7280; }

.book-rating-row {
  margin-top: 0;
}

/* ── Add to library button ────────────────────────────────────── */

.add-to-library-btn {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.35rem 0.9rem;
  background: #1f2937;
  border: 1px solid #f59e0b;
  color: #f59e0b;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.add-to-library-btn:hover:not(:disabled) { background: #2d3748; }
.add-to-library-btn:disabled { opacity: 0.6; cursor: default; }
.add-to-library-btn.add-to-library-done {
  border-color: #4ade80;
  color: #4ade80;
}
.add-series-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}
.add-series-actions .add-to-library-btn {
  margin-top: 0;
}
.add-series-all-btn {
  border-color: #6b7280;
  color: #9ca3af;
}
.add-series-all-btn:hover:not(:disabled) { border-color: #f59e0b; color: #f59e0b; }

/* ── Checkbox label (edit book modal) ────────────────────────── */

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #d1d5db;
}
.checkbox-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 30px;
  height: 17px;
  background: #374151;
  border-radius: 9px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s;
}
.checkbox-label input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  background: #9ca3af;
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}
.checkbox-label input[type="checkbox"]:checked {
  background: #f59e0b;
}
.checkbox-label input[type="checkbox"]:checked::after {
  transform: translateX(13px);
  background: #fff;
}
.field-hint {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: #6b7280;
}
.create-public-row {
  margin-top: 0.95rem;
  padding-top: 0.15rem;
}
.create-public-row .checkbox-label span {
  color: #f5a623;
  font-weight: 750;
  text-shadow: 0 0 6px rgba(245, 158, 11, 0.1);
  animation: create-public-pulse 4s ease-in-out infinite;
}

@keyframes create-public-pulse {
  0%, 100% {
    opacity: 0.72;
    filter: brightness(1);
  }
  50% {
    opacity: 1;
    filter: brightness(1.14);
  }
}

/* ── Cover activity view ──────────────────────────────────────── */

.cover-activity-view {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cover-act-entry {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.9rem 1rem;
}

.cover-act-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.cover-act-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.cover-act-avatar-ph {
  background: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #9ca3af;
}

.cover-act-username {
  background: none;
  border: none;
  color: #f5a623;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
}
.cover-act-username:hover { text-decoration: underline; }

.cover-act-username-plain {
  color: #e2e8f0;
  font-weight: 600;
  font-size: 0.9rem;
}

.cover-act-altname {
  font-size: 0.72rem;
  color: #6b7280;
  font-style: italic;
  margin-bottom: 0.5rem;
}

.cover-act-runs {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* Feed clickable links */
.feed-user-pub {
  background: none;
  border: none;
  font-weight: 600;
  color: #f5a623;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.feed-user-pub:hover { color: #fbbf24; }

.feed-verb-pub {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.feed-verb-pub.died { color: #e74c3c; }
.feed-verb-pub.died:hover { color: #f87171; }
.feed-verb-pub.lost { color: #e74c3c; }
.feed-verb-pub.lost:hover { color: #f87171; }
.feed-verb-pub.won  { color: #27ae60; }
.feed-verb-pub.won:hover  { color: #4ade80; }

.feed-book-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  font-weight: 600;
  color: #e2e8f0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.feed-book-btn:hover { color: #f5a623; }

/* Feed image preview */
#feed-img-preview {
  position: fixed;
  z-index: 9999;
  display: none;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  pointer-events: none;
}
#feed-img-preview.feed-img-preview--avatar {
  overflow: visible;
  background: transparent;
  border: none;
  box-shadow: none;
}
#feed-img-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, #0891b2, #67e8f9);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}
#feed-img-preview-img {
  display: block;
  object-fit: cover;
}
#feed-img-preview.feed-img-preview--avatar #feed-img-preview-img {
  border: 1px solid #374151;
  border-radius: 6px;
  background: #111827;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
#feed-img-preview-footer {
  display: none;
  width: 100%;
  box-sizing: border-box;
  padding: 0.22rem 0.5rem;
  border-top: 1px solid #374151;
  background: #111827;
}
#feed-img-preview.feed-img-preview--avatar #feed-img-preview-footer {
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  min-width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.18rem 0.42rem;
  border: 1px solid #374151;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
#feed-img-preview-level {
  display: none;
  color: #67e8f9;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
  text-align: center;
  white-space: normal !important;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  width: 100%;
  max-width: 100%;
  pointer-events: none;
}
.feed-hover-level-kicker {
  font-weight: 800;
}
.feed-hover-level-title {
  white-space: nowrap;
}

/* Profile public toggle */
.profile-public-row {
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
}
.profile-public-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #d1d5db;
  font-size: 0.9rem;
  cursor: pointer;
}
.profile-public-hint {
  font-size: 0.75rem;
  color: #6b7280;
}

/* ── Custom scrollbars (global) ───────────────────────────────── */

* {
  scrollbar-width: thin;
  scrollbar-color: #374151 transparent;
}
*::-webkit-scrollbar { width: 5px; height: 5px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ── Run trail float (graph overlay) ─────────────────────────── */

#run-trail-float {
  position: fixed;
  top: 12px;
  left: calc(var(--sidebar-w) + 12px);
  max-width: calc(100vw - var(--sidebar-w) - var(--legend-w) - 36px);
  z-index: 10;
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.5rem 0.85rem 0.6rem;
  backdrop-filter: blur(6px);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: left 0.25s ease, max-width 0.25s ease;
}

#run-trail-float:empty {
  display: none;
}

.trail-header {
  font-size: 0.72rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  pointer-events: auto;
  cursor: pointer;
}
.trail-toggle-btn {
  pointer-events: auto;
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  user-select: none;
  margin-left: auto;
  transition: transform 0.15s, color 0.12s;
}
.trail-toggle-btn:hover { color: #d1d5db; }
#run-trail-float.trail-collapsed .trail { display: none; }
#run-trail-float.trail-collapsed .trail-header { margin-bottom: 0; }
#run-trail-float.trail-collapsed .trail-toggle-btn { transform: rotate(-90deg); }

.trail {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
}

.trail-node {
  background: #374151;
  color: #9ca3af;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}
.trail-current  { background: #f5a623; color: #111827; }
.trail-death    { background: #991b1b; color: #fca5a5; }
.trail-battle   { background: #7c2d12; color: #fdba74; }
.trail-win      { background: #166534; color: #86efac; }
.trail-arrow    { color: #4b5563; font-size: 0.7rem; padding: 0 1px; }

/* ── Legend (floating overlay, top-right of graph) ───────────── */

#legend {
  position: fixed;
  top: 12px;
  right: 12px;
  width: var(--legend-w);
  z-index: 10;
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.5rem 0.85rem 0.6rem;
  backdrop-filter: blur(6px);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

#legend-header {
  pointer-events: auto;
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  gap: 0.5rem;
}

.legend-title {
  font-size: 0.72rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 1;
}

.legend-collapse-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: transform 0.15s, color 0.12s;
}
.legend-collapse-btn:hover { color: #d1d5db; }
#legend.legend-collapsed .legend-collapse-btn { transform: rotate(-90deg); }
#legend.legend-collapsed #legend-body { display: none; }
#legend.legend-collapsed { padding-bottom: 0.5rem; gap: 0; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: #9ca3af;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid transparent;
  flex-shrink: 0;
}

/* ── Dice roller ──────────────────────────────────────────────── */

#dice-roller {
  position: fixed;
  bottom: 1rem;
  left: calc(var(--sidebar-w) + 12px);
  z-index: 10;
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.4rem 0.6rem 0.5rem;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  min-width: 180px;
  display: none; /* shown only in tracker */
  transition: left 0.25s ease;
}
#dice-roller.visible { display: block; }

#dice-roller-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.dice-roller-title {
  font-size: 0.72rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dice-collapse-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: transform 0.15s;
}
.dice-collapse-btn:hover { color: #d1d5db; }
#dice-roller.dice-collapsed .dice-collapse-btn { transform: rotate(-90deg); }

#dice-roller-body {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#dice-roller.dice-collapsed #dice-roller-body { display: none; }

.dice-shortcuts-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.dice-shortcut-btn {
  background: rgba(55, 65, 81, 0.75);
  border: 1px solid #4b5563;
  color: #cbd5e1;
  border-radius: 999px;
  padding: 0.16rem 0.42rem;
  font-size: 0.66rem;
  line-height: 1.2;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.dice-shortcut-btn:hover {
  background: rgba(75, 85, 99, 0.95);
}
.dice-shortcut-btn.active {
  border-color: #9ca3af;
  color: #f9fafb;
  background: rgba(107, 114, 128, 0.95);
}

.dice-count-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.dice-count-label {
  font-size: 0.68rem;
  color: #9ca3af;
  letter-spacing: 0.02em;
  margin-right: 0.12rem;
}

.dice-adj-btn {
  background: #374151;
  border: 1px solid #4b5563;
  color: #d1d5db;
  border-radius: 5px;
  width: 1.38rem;
  height: 1.38rem;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.dice-adj-btn:hover { background: #4b5563; }

.dice-throw-row {
  display: flex;
}

#dice-count-input {
  width: 1.72rem;
  text-align: center;
  background: #111827;
  border: 1px solid #4b5563;
  color: #f9fafb;
  border-radius: 5px;
  font-size: 0.78rem;
  padding: 0.14rem 0;
}

#dice-throw-btn {
  width: 100%;
  background: #4b5563;
  border: 1px solid #6b7280;
  color: #9ca3af;
  border-radius: 5px;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
#dice-throw-btn:hover { background: #6b7280; }

#dice-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  min-height: 0;
}
#dice-result:empty { display: none; }

.die-face {
  position: relative;
  width: 3rem;
  height: 3rem;
  background: #1f2937;
  border: 2px solid #6b7280;
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 0.34rem;
  gap: 0.06rem;
  color: #f9fafb;
  flex-shrink: 0;
  box-sizing: border-box;
  animation: die-pop 0.18s ease-out;
}
.die-face[data-val="1"] { border-color: #dc2626; color: #ef4444; }
.die-face[data-tone="low"] { border-color: #dc2626; color: #ef4444; }
.die-face[data-tone="high"] { border-color: #86efac; color: #86efac; }
.die-face[data-tone="max"] { border-color: #86efac; color: #86efac; }
.die-face--numeric {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-template-columns: none;
  grid-template-rows: none;
  padding: 0;
  gap: 0;
  overflow: hidden;
}
.die-face.no-anim { animation: none; }
.die-face--preview {
  border-color: #4b5563;
  color: rgba(209, 213, 219, 0.55);
  background: rgba(31, 41, 55, 0.72);
}

.die-pip {
  border-radius: 50%;
  width: 0.36rem;
  height: 0.36rem;
  margin: auto;
}
.die-pip.on { background: currentColor; }
.die-pip--preview {
  background: rgba(209, 213, 219, 0.4);
}

.die-shape {
  position: absolute;
  inset: 0.19rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(156, 163, 175, 0.38);
  pointer-events: none;
}
.die-shape svg {
  width: 100%;
  height: 100%;
}
.die-shape path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.die-type {
  position: absolute;
  top: 0.22rem;
  left: 0.34rem;
  font-size: 0.54rem;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(209, 213, 219, 0.8);
}

.die-value {
  position: relative;
  z-index: 1;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
}
.die-value--preview {
  color: rgba(209, 213, 219, 0.48);
  font-size: 1.32rem;
}

.die-face--percentile .die-value {
  font-size: 1.1rem;
}

.die-percent-pair {
  position: absolute;
  right: 0.3rem;
  bottom: 0.22rem;
  font-size: 0.5rem;
  line-height: 1;
  color: rgba(209, 213, 219, 0.68);
  letter-spacing: 0.02em;
}

.dice-op,
.dice-mod {
  color: #9ca3af;
  font-weight: 700;
  font-size: 1.08rem;
  line-height: 1;
}

.dice-sum {
  font-size: 1.26rem;
  font-weight: 700;
  color: #9ca3af;
  padding: 0 0.2rem;
}
.dice-sum-sep {
  color: #6b7280;
  font-size: 0.85rem;
}

@keyframes die-pop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── Data controls ────────────────────────────────────────────── */

#data-controls {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid #374151;
}

#find-node-row, #export-reset-row {
  display: flex;
  flex-direction: row;
  gap: 0.3rem;
}
#export-reset-row button { flex: 1; }
#find-node-input {
  flex: 1 1 0;
  min-width: 0;
  box-sizing: border-box;
  background: #1f2937;
  color: #d1d5db;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.28rem 0.5rem;
  font-size: 0.78rem;
  outline: none;
  transition: border-color 0.15s;
}
#find-node-input:focus { border-color: #6b7280; }
#find-node-input.not-found { border-color: #ef4444; }
#find-node-btn {
  flex: 1 1 0;
  background: #1f2937;
  color: #9ca3af;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.28rem 0.5rem;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.12s, color 0.12s;
}
#find-node-btn:hover { background: #374151; color: #d1d5db; }
#data-controls button {
  background: #1f2937;
  color: #9ca3af;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 0.28rem 0.5rem;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.12s, color 0.12s;
  width: 100%;
}
#data-controls button:hover { background: #374151; color: #d1d5db; }
#data-controls button:disabled { opacity: 0.35; cursor: not-allowed; }
#data-controls button:disabled:hover { background: #1f2937; color: #9ca3af; }
#reset-btn { color: #f87171 !important; }
#reset-btn:hover { background: #7f1d1d !important; border-color: #991b1b !important; }
#export-book-btn { color: #93c5fd !important; }
#export-book-btn:hover { background: #1e3a5f !important; border-color: #2563eb !important; }


/* ── Avatar circle ────────────────────────────────────────────── */

.avatar-circle {
  display: inline-block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #374151 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b7280'%3E%3Cpath d='M12 12c2.7 0 4.8-2.1 4.8-4.8S14.7 2.4 12 2.4 7.2 4.5 7.2 7.2 9.3 12 12 12zm0 2.4c-3.2 0-9.6 1.6-9.6 4.8v2.4h19.2v-2.4c0-3.2-6.4-4.8-9.6-4.8z'/%3E%3C/svg%3E") center/60% no-repeat;
  border: 2px solid #4b5563;
  overflow: hidden;
  flex-shrink: 0;
  vertical-align: middle;
}
.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-large {
  width: 80px;
  height: 80px;
}

/* ── Profile button ───────────────────────────────────────────── */

.profile-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  transition: opacity 0.12s;
}
.profile-btn:hover { opacity: 0.75; }

/* ── Feedback & Inbox ─────────────────────────────────────────── */

.inbox-badge {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  border-radius: 9999px;
  font-size: 0.65rem;
  padding: 0 0.35em;
  margin-left: 0.25rem;
  vertical-align: middle;
  line-height: 1.4;
}

#feedback-modal-overlay,
#stats-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1100;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4rem;
}
#stats-modal-overlay.active { display: flex; }
#stats-modal {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 10px;
  width: 520px;
  max-width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#stats-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #1f2937;
  flex-shrink: 0;
}
#stats-modal-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #f3f4f6;
  letter-spacing: 0.03em;
}
#stats-modal-close {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.3rem;
}
#stats-modal-close:hover { color: #d1d5db; }
#stats-modal-body {
  overflow-y: auto;
  padding: 0.8rem 1rem 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.stats-loading {
  font-size: 0.82rem;
  color: #6b7280;
  grid-column: 1 / -1;
}
.stats-section { }
.stats-section-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6b7280;
  margin-bottom: 0.35rem;
}
.stats-table { border-collapse: collapse; width: 100%; }
.stats-table tr + tr td { padding-top: 0.15rem; }
.stats-key {
  font-size: 0.78rem;
  color: #9ca3af;
  padding-right: 0.5rem;
  white-space: nowrap;
}
.stats-val {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e5e7eb;
  text-align: right;
  white-space: nowrap;
}
.stats-pct {
  font-size: 0.72rem;
  font-weight: 400;
  color: #6b7280;
}

#inbox-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#feedback-modal-overlay.active,
#inbox-modal-overlay.active { display: flex; }

#feedback-modal,
#inbox-modal {
  background: var(--bg-card, #1f2937);
  border-radius: 0.75rem;
  padding: 0.9rem 1rem;
  width: min(600px, 95vw);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

#feedback-message-input {
  width: 100%;
  resize: none;
  min-height: 5rem;
  box-sizing: border-box;
}

#inbox-modal {
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}
#inbox-threads-view,
#inbox-conv-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.75rem;
}
#inbox-threads-view .modal-actions {
  justify-content: flex-end;
}
#inbox-close-btn {
  flex: none !important;
  padding: 0.25rem 0.65rem !important;
  font-size: 0.78rem !important;
}
#feedback-modal .modal-actions {
  justify-content: flex-end;
}
#feedback-modal .modal-actions .primary-btn,
#feedback-cancel-btn {
  flex: none !important;
  width: auto !important;
  padding: 0.25rem 0.65rem !important;
  font-size: 0.78rem !important;
}
#inbox-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
  max-height: 50vh;
}
.inbox-item {
  border: 1px solid #374151;
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.inbox-item:hover { border-color: #6b7280; }
.inbox-item--unread {
  border-color: #7c3aed;
  background: rgba(124,58,237,.08);
}
.inbox-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}
.inbox-item-date  { color: #9ca3af; }
.inbox-item-count { color: #6b7280; }
.inbox-item-from  { color: #f5a623; font-weight: 600; }
.inbox-item-preview {
  color: #9ca3af;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-empty { color: #9ca3af; text-align: center; padding: 1rem 0; }

.inbox-conv-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.inbox-conv-date { font-size: 0.8rem; color: #9ca3af; }
#inbox-messages {
  flex: 1;
  overflow-y: auto;
  min-height: 100px;
  max-height: 40vh;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.25rem 0;
}
.inbox-msg {
  max-width: 80%;
  padding: 0.45rem 0.7rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  word-break: break-word;
}
.inbox-msg--user {
  align-self: flex-end;
  background: #1d4ed8;
  color: #fff;
  border-bottom-right-radius: 0.2rem;
}
.inbox-msg--admin {
  align-self: flex-start;
  background: #374151;
  color: #e5e7eb;
  border-bottom-left-radius: 0.2rem;
}
.inbox-msg-body { white-space: pre-wrap; }
.inbox-msg-time {
  font-size: 0.65rem;
  opacity: 0.55;
  margin-top: 0.15rem;
  text-align: right;
}
.inbox-msg--admin .inbox-msg-time { text-align: left; }
#inbox-reply-area { display: flex; flex-direction: column; }
#inbox-back-btn {
  background: none;
  border: 1px solid #4b5563;
  border-radius: 6px;
  color: #9ca3af;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
#inbox-back-btn:hover { border-color: #6b7280; color: #e2e8f0; }

#inbox-reply-input {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  min-height: 8rem;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #e5e7eb;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 0.5rem 0.6rem;
  transition: border-color 0.15s;
}
#inbox-reply-input:focus { outline: none; border-color: #6b7280; }
#inbox-reply-input::placeholder { color: #4b5563; }
.inbox-conv-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}
/* Use class+ID specificity to beat both .primary-btn (class) and #id (ID) rules */
.inbox-conv-actions #inbox-reply-send-btn,
.inbox-conv-actions #inbox-conv-delete-btn,
.inbox-conv-actions #inbox-conv-close-btn {
  flex: none;
  width: auto;
  padding: 0.35rem 1rem;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  border-radius: 7px;
  cursor: pointer;
}
.inbox-conv-actions #inbox-conv-delete-btn {
  background: #dc2626;
  color: #fff;
  border: none;
}
.inbox-conv-actions #inbox-conv-delete-btn:hover { background: #b91c1c; }
.inbox-conv-actions #inbox-conv-close-btn { margin-left: 0; }

/* ── Profile modal ────────────────────────────────────────────── */

#profile-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}
#profile-modal-overlay.active { display: flex; }

#profile-modal {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  width: 360px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #374151 transparent;
}
#profile-modal::-webkit-scrollbar { width: 5px; }
#profile-modal::-webkit-scrollbar-track { background: transparent; }
#profile-modal::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
#profile-modal::-webkit-scrollbar-thumb:hover { background: #4b5563; }

.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

#profile-xp-block {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

#profile-level-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

#profile-level-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: #f5a623;
}

#profile-title-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
}

#profile-xp-bar {
  height: 6px;
  background: #1f2937;
  border-radius: 3px;
  overflow: hidden;
}

#profile-xp-bar-fill {
  height: 100%;
  background: linear-gradient(to right, #f5a623, #fbbf24);
  border-radius: 3px;
  transition: width 0.4s ease;
}

#profile-xp-sub-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
#profile-own-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-top: 0.32rem;
  padding-top: 0.32rem;
  border-top: 1px solid #374151;
}
#profile-xp-text {
  font-size: 0.72rem;
  color: #6b7280;
}
#profile-xp-boost-earned {
  font-size: 0.7rem;
  color: #f59e0b;
}

.profile-section-divider {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-top: 1px solid #374151;
  padding-top: 0.28rem;
  margin-top: 0;
}

#profile-modal .input-group {
  gap: 0.22rem;
}

#profile-modal .input-group input,
#profile-modal .input-group textarea {
  padding-top: 0.38rem;
  padding-bottom: 0.38rem;
}

.profile-success {
  font-size: 0.85rem;
  color: #34d399;
}

.secondary-btn {
  background: #374151;
  color: #d1d5db;
  border: 1px solid #4b5563;
  border-radius: 7px;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.12s;
}
.secondary-btn:hover { background: #4b5563; }

/* ── Crop modal ───────────────────────────────────────────────── */

#crop-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 4000;
  align-items: center;
  justify-content: center;
}
#crop-modal-overlay.active { display: flex; }

#crop-modal {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.7);
  align-items: center;
}

.crop-hint {
  font-size: 0.82rem;
  color: #6b7280;
  text-align: center;
}

#crop-viewport {
  position: relative;
  width: 320px;
  height: 320px;
  overflow: hidden;
  background: #111827;
  border-radius: 6px;
  cursor: grab;
  user-select: none;
}
#crop-viewport:active { cursor: grabbing; }

#crop-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

#crop-frame {
  position: absolute;
  inset: 0;
  border: 3px solid #f5a623;
  border-radius: 4px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
}

/* ── Language switcher (UI hidden; infrastructure kept for future use) ── */

/* ── Character sheet ─────────────────────────────────────────────────────────
   Remove block + charsheet.js + import lines in main.js/ui.js to uninstall.  */

/* Play area button bar (Guide + Notebook) */
#play-bottom-stack {
  display: none;
  position: fixed;
  bottom: 1rem;
  left: calc((100vw + var(--sidebar-w)) / 2);
  transform: translateX(-50%);
  z-index: 100;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  transition: left 0.25s ease;
}
body.sidebar-collapsed #play-bottom-stack { left: 50vw; }

#play-btns-bar {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
#guide-btn, #notebook-btn, #party-btn {
  background: rgba(31, 41, 55, 0.88);
  border: 1px solid #374151;
  border-radius: 7px;
  color: #9ca3af;
  padding: 0.4rem 0.85rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  white-space: nowrap;
}
#guide-btn:hover, #notebook-btn:hover, #party-btn:hover { background: #374151; }
#party-btn.party-active { color: #34d399; border-color: #34d399; }
#party-btn.party-active:hover { background: #064e3b; }

#play-xp-summary {
  min-width: 300px;
  max-width: min(92vw, 420px);
  width: 100%;
  background: rgba(31, 41, 55, 0.9);
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 0.5rem 0.85rem 0.6rem;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  color: #d1d5db;
}
#play-xp-summary:empty {
  display: none;
}
#play-xp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.play-xp-kicker {
  font-size: 0.72rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.play-xp-collapse-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: transform 0.15s, color 0.12s;
}
.play-xp-collapse-btn:hover { color: #d1d5db; }
#play-xp-summary.play-xp-collapsed .play-xp-collapse-btn { transform: rotate(-90deg); }
#play-xp-summary.play-xp-collapsed #play-xp-body { display: none; }
#play-xp-summary.play-xp-collapsed { padding-bottom: 0.5rem; gap: 0; }
#play-xp-body {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}
#play-xp-level-row {
  display: flex;
  align-items: baseline;
  gap: 0.42rem;
}
#play-xp-level {
  font-size: 0.8rem;
  font-weight: 700;
  color: #f5a623;
  line-height: 1.15;
}
#play-xp-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e5e7eb;
  line-height: 1.15;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#play-xp-bar {
  height: 5px;
  background: #1f2937;
  border-radius: 3px;
  overflow: hidden;
}
#play-xp-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(to right, #f5a623, #fbbf24);
  border-radius: 3px;
  transition: width 0.4s ease;
}
#play-xp-sub-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
}
#play-xp-text {
  font-size: 0.76rem;
  color: #9ca3af;
  line-height: 1.15;
  white-space: nowrap;
}
#play-xp-boost {
  font-size: 0.74rem;
  color: #f59e0b;
  line-height: 1.15;
  text-align: right;
  white-space: nowrap;
}

/* Party invite cards in library */
#party-invites-section { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.party-invite-card {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: rgba(52,211,153,0.07); border: 1px solid rgba(52,211,153,0.25);
  border-radius: 8px; padding: 0.65rem 0.9rem;
}
.party-invite-text { font-size: 0.82rem; color: #d1fae5; line-height: 1.4; }
.party-invite-text strong { color: #6ee7b7; }
.party-invite-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.party-invite-accept { background: #065f46; border: 1px solid #34d399; color: #34d399; border-radius: 6px; padding: 0.3rem 0.75rem; font-size: 0.78rem; cursor: pointer; }
.party-invite-accept:hover { background: #047857; }
.party-invite-decline { background: transparent; border: 1px solid #4b5563; color: #9ca3af; border-radius: 6px; padding: 0.3rem 0.75rem; font-size: 0.78rem; cursor: pointer; }
.party-invite-decline:hover { background: #374151; }

/* Party modal */
#party-modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 3000; align-items: center; justify-content: center;
}
#party-modal-overlay.active { display: flex; }
#party-modal {
  background: #1f2937; border: 1px solid #374151; border-radius: 8px;
  padding: 0.55rem 0.75rem; width: min(280px, 92vw); max-height: 85vh;
  overflow-y: auto; display: flex; flex-direction: column; gap: 0.35rem;
}
#party-modal-hdr {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.82rem; font-weight: 600; color: #e2e8f0;
}
#party-modal-close { background: none; border: none; color: #9ca3af; font-size: 0.9rem; cursor: pointer; padding: 0; }
#party-modal-close:hover { color: #e2e8f0; }
#party-modal-body { display: flex; flex-direction: column; gap: 0.35rem; }
.party-member-row {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.8rem; color: #d1d5db;
}
.party-member-avatar { width: 22px; height: 22px; border-radius: 50%; background: #374151; object-fit: cover; }
.party-member-you { font-size: 0.68rem; color: #6b7280; margin-left: 0.2rem; }
.party-invite-row { display: flex; gap: 0.4rem; align-items: center; }
.party-invite-input { flex: 1; background: #111827; border: 1px solid #374151; border-radius: 5px; color: #e2e8f0; padding: 0.3rem 0.5rem; font-size: 0.78rem; }
.party-invite-input:focus { outline: none; border-color: #34d399; }
.party-invite-send { background: #065f46; border: 1px solid #34d399; color: #34d399; border-radius: 5px; padding: 0.3rem 0.55rem; font-size: 0.76rem; cursor: pointer; white-space: nowrap; }
.party-invite-send:hover { background: #047857; }
.party-leave-btn { background: transparent; border: 1px solid #ef4444; color: #ef4444; border-radius: 5px; padding: 0.25rem 0.55rem; font-size: 0.74rem; cursor: pointer; align-self: flex-start; }
.party-leave-btn:hover { background: rgba(239,68,68,0.1); }
#party-invite-msg { min-height: 0 !important; }
.party-section-label[style*="margin-top"] { margin-top: 0.2rem !important; }
.party-section-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: #6b7280; }
.party-msg { font-size: 0.8rem; color: #9ca3af; line-height: 1.3; }
.party-invite-wrap { position: relative; flex: 1; }
.party-invite-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #111827; border: 1px solid #374151; border-radius: 6px;
  z-index: 10; overflow: hidden;
}
.party-invite-dropdown button {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%; padding: 0.4rem 0.65rem; background: none; border: none;
  color: #d1d5db; font-size: 0.83rem; cursor: pointer; text-align: left;
}
.party-invite-dropdown button:hover { background: #1f2937; }

/* Guide modal */
#guide-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}
#guide-modal-overlay.active { display: flex; }
#guide-modal {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  width: min(900px, 95vw);
  height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
}
#guide-modal-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #374151;
  color: #f3f4f6;
  font-size: 0.88rem;
  font-weight: 600;
  flex-shrink: 0;
}
#guide-modal-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}
#guide-modal-close:hover { background: #374151; color: #f3f4f6; }
#guide-modal-frame {
  flex: 1;
  border: none;
  width: 100%;
}

/* Notebook modal */
#notebook-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}
#notebook-modal-overlay.active { display: flex; }
#notebook-modal {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  width: min(600px, 92vw);
  height: min(520px, 80vh);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.7rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
#notebook-modal-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
#notebook-modal-title {
  color: #f5a623;
  font-size: 0.82rem;
  font-weight: 600;
}
#notebook-modal-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}
#notebook-modal-close:hover { background: #374151; color: #f3f4f6; }
#notebook-modal-input {
  flex: 1;
  background: #111827;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #d1d5db;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.55;
  padding: 0.6rem 0.75rem;
  resize: none;
  outline: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #374151 transparent;
}
#notebook-modal-input:focus { border-color: #6b7280; }
#notebook-modal-input::placeholder { color: #4b5563; }
#notebook-modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
#notebook-modal-right-actions { display: flex; gap: 0.4rem; }
#notebook-modal-cancel {
  background: #374151;
  color: #9ca3af;
  border: 1px solid #4b5563;
  border-radius: 7px;
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}
#notebook-modal-cancel:hover { background: #4b5563; }
#notebook-modal-save {
  flex: none !important;
  width: auto !important;
  padding: 0.28rem 0.7rem !important;
  font-size: 0.78rem !important;
}
#notebook-pin-toggle {
  gap: 0.5rem;
  user-select: none;
}
#notebook-pin-label {
  font-size: 0.78rem;
  color: #9ca3af;
}

#notes-display {
  display: none;
  position: fixed;
  left: calc(var(--sidebar-w) + 1rem);
  top: 50%;
  transform: translateY(-50%);
  width: 20vw;
  max-height: 65vh;
  z-index: 100;
  border-radius: 6px;
  transition: left 0.25s ease, background-color 0.15s;
}
#notes-display.visible { display: flex; flex-direction: column; }
#notes-display.hovering {
  height: 65vh;
  background: rgba(17, 24, 39, 0.78);
  border: 1px solid #374151;
}
body.sidebar-collapsed #notes-display { left: 1rem; }
#notes-display-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.6rem;
  scrollbar-width: none;
}
#notes-display.hovering #notes-display-body {
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
#notes-display-text {
  font-size: 0.75rem;
  color: #e5e7eb;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.6);
}
#notes-display-input {
  display: none;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: transparent;
  border: none;
  color: #e5e7eb;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1.65;
  resize: none;
  outline: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
#notes-display.hovering #notes-display-text { display: none; }
#notes-display.hovering #notes-display-input { display: flex; }
#notes-display-footer {
  display: none;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-top: 1px solid #374151;
  flex-shrink: 0;
}
#notes-display.hovering #notes-display-footer { display: flex; }
#notes-display-cancel {
  background: #374151;
  color: #9ca3af;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 0.22rem 0.55rem;
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
}
#notes-display-cancel:hover { background: #4b5563; }
#notes-display-save {
  background: #1d4ed8;
  color: #e0e7ff;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  padding: 0.22rem 0.6rem;
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
}
#notes-display-save:hover { background: #2563eb; }

/* Open button */
#charsheet-btn {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 100;
  background: rgba(31, 41, 55, 0.88);
  border: 1px solid #374151;
  border-radius: 7px;
  color: #9ca3af;
  padding: 0.4rem 0.85rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
#charsheet-btn:hover { background: #374151; }

/* Compact plain-text display — no background, just text */
#charsheet-display {
  position: fixed;
  bottom: 3.1rem;
  right: 1rem;
  z-index: 100;
  font-size: 0.75rem;
  color: #e5e7eb;
  line-height: 1.65;
  pointer-events: none;
  text-align: right;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.6);
}
.cs-line  { display: block; }
.cs-label { color: #9ca3af; }

/* Modal overlay */
.cs-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
.cs-overlay.active { display: flex; }

.cs-modal {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 10px;
  width: min(700px, 95vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.cs-modal-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #374151;
  color: #f3f4f6;
  font-size: 0.88rem;
  font-weight: 600;
  flex-shrink: 0;
}
#cs-modal-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}
#cs-modal-close:hover { background: #374151; color: #f3f4f6; }

.cs-field-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 80px;
}
.cs-empty {
  color: #6b7280;
  font-size: 0.8rem;
  text-align: center;
  padding: 1.5rem 1rem;
  margin: 0;
}

/* Field rows */
.cs-field-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #111827;
  border: 1px solid #2d3748;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
}

/* Drag handle */
.cs-drag-handle {
  cursor: grab;
  color: #4b5563;
  font-size: 1rem;
  flex-shrink: 0;
  user-select: none;
  padding: 0 0.1rem;
}
.cs-drag-handle:active { cursor: grabbing; }
.cs-field-row.cs-dragging  { opacity: 0.35; }
.cs-field-row.cs-drag-over { border-color: #f5a623; background: #1a2236; }

/* Visible toggle */
.cs-vis-toggle {
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.cs-vis-toggle input { display: none; }
.cs-dot {
  display: inline-block;
  width: 2rem;
  height: 1.1rem;
  border-radius: 999px;
  background: #374151;
  border: 1px solid #4b5563;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
.cs-dot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: #6b7280;
  transition: left 0.15s, background 0.15s;
}
.cs-vis-toggle input:checked + .cs-dot {
  background: rgba(96, 165, 250, 0.2);
  border-color: #60a5fa;
}
.cs-vis-toggle input:checked + .cs-dot::after {
  left: calc(100% - 0.7rem - 3px);
  background: #60a5fa;
}

/* Name input */
.cs-name-inp {
  flex: 2;
  min-width: 80px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  color: #f3f4f6;
  padding: 0.22rem 0.45rem;
  font-size: 0.8rem;
}

/* Type selector */
.cs-type-sel {
  flex: 0 0 90px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  color: #d1d5db;
  padding: 0.22rem 0.3rem;
  font-size: 0.8rem;
}

/* Value wrapper */
.cs-val-wrap {
  flex: 3;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* Number field — hide native spinners, use custom ±  */
.cs-val-num,
.cs-num-wrap input[type="number"],
.cs-num-wrap input[type="text"] { -moz-appearance: textfield; text-align: center; }
.cs-val-num::-webkit-inner-spin-button,
.cs-val-num::-webkit-outer-spin-button,
.cs-num-wrap input[type="number"]::-webkit-inner-spin-button,
.cs-num-wrap input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.sections-pages-row {
  display: flex;
  gap: 0.75rem;
}
.sections-pages-col {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 0;
}

.cs-num-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
}
.cs-num-wrap .cs-val-num {
  flex: 1;
  min-width: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
}
.cs-num-btn {
  flex-shrink: 0;
  width: 26px;
  background: #2d3748;
  border: 1px solid #374151;
  color: #9ca3af;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.22rem 0;
  transition: background 0.1s, color 0.1s;
  font-family: inherit;
}
.cs-num-btn:first-child { border-radius: 4px 0 0 4px; }
.cs-num-btn:last-child  { border-radius: 0 4px 4px 0; }
.cs-num-btn:hover { background: #374151; color: #f3f4f6; }

/* Value inputs (shared) */
.cs-val {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  color: #f3f4f6;
  padding: 0.22rem 0.45rem;
  font-size: 0.8rem;
  width: 100%;
  box-sizing: border-box;
}
select.cs-val { color: #d1d5db; }

.cs-bool-wrap { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.cs-bool-label { font-size: 0.8rem; color: #d1d5db; }

/* Enum options config (smaller, de-emphasised) */
.cs-enum-opts {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 4px;
  color: #6b7280;
  padding: 0.18rem 0.45rem;
  font-size: 0.72rem;
  width: 100%;
  box-sizing: border-box;
}

/* Delete button */
.cs-del-btn {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.cs-del-btn:hover { background: #7f1d1d; color: #f87171; }

/* Footer */
.cs-modal-ftr {
  padding: 0.7rem 1rem;
  border-top: 1px solid #374151;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 0.5rem;
}
.cs-ftr-actions {
  display: flex;
  gap: 0.4rem;
}
.cs-btn-add {
  background: none;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  padding: 0.25rem 0.65rem;
}
.cs-btn-add:hover { background: #374151; color: #f3f4f6; }
.cs-btn-cancel {
  background: none;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  padding: 0.25rem 0.65rem;
}
.cs-btn-cancel:hover { background: #374151; color: #f3f4f6; }
.cs-btn-template {
  background: none;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #d1d5db;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  padding: 0.25rem 0.65rem;
}
.cs-btn-template:hover { background: #374151; color: #f3f4f6; }
.cs-btn-save {
  background: #1d4ed8;
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  padding: 0.25rem 0.65rem;
}
.cs-btn-save:hover { background: #2563eb; }

/* ── vis.js tooltip ──────────────────────────────────────────── */

.vis-tooltip {
  background: #1f2937 !important;
  border: 1px solid #4b5563 !important;
  border-radius: 6px !important;
  color: #d1d5db !important;
  font-family: 'Segoe UI', system-ui, sans-serif !important;
  font-size: 0.78rem !important;
  padding: 0.4rem 0.65rem !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
  max-width: 260px !important;
  line-height: 1.5 !important;
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
}
.vis-tooltip div {
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
  max-width: 260px !important;
}

/* ── PDF link ─────────────────────────────────────────────────── */

.pdf-link {
  color: #60a5fa;
  font-size: 0.82rem;
  text-decoration: none;
}
.pdf-link:hover { text-decoration: underline; }

.book-pdf-btn {
  font-size: 0.75rem;
  color: #60a5fa;
  background: none;
  border: 1px solid #374151;
  border-radius: 5px;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.book-pdf-btn:hover { background: #1f2937; }

/* ── Admin badge ──────────────────────────────────────────────── */

.admin-badge,
.author-badge,
.contributor-badge {
  font-size: 0.65em;
  margin-left: 0.2em;
  vertical-align: super;
  cursor: default;
  user-select: none;
}
.admin-badge { color: #60a5fa; }
.author-badge { color: #fbbf24; }
.contributor-badge { color: #34d399; }

/* ── Responsive: compact sidebar for short viewports (e.g. 1366×768) ── */

@media (max-height: 750px) {
  #sidebar {
    padding: 0.5rem;
    gap: 0.45rem;
  }

  #stats {
    padding: 0.35rem 0.6rem;
    gap: 0.15rem;
  }

  .stats-row {
    font-size: 0.76rem;
  }

  .section-display {
    font-size: 1.35rem;
  }

  .section-label {
    font-size: 0.68rem;
  }

  .undo-run-btn,
  .fasttravel-btn,
  .battle-death-btn {
    padding: 0.1rem 0.4rem;
  }

  .choices-label {
    font-size: 0.72rem;
  }

  .choice-btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.72rem;
  }

  #sidebar .primary-btn {
    padding: 0.4rem 0.75rem;
  }

  .input-group {
    gap: 0.2rem;
  }

  .runs-section {
    margin-top: 0.25rem;
    padding-top: 0.35rem;
  }

  #data-controls {
    padding-top: 0.25rem;
    gap: 0.2rem;
  }

  #data-controls button {
    padding: 0.3rem;
  }
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-lite-suffix { display: inline; }
  /* Hide desktop-only panels and toggles */
  #covers-panel, #covers-toggle, #right-toggle, #feed-toggle { display: none !important; }
  #demo-btn, #app-banner-guide-btn             { display: none !important; }
  #main-screen                                 { display: none !important; }
  #landing-bg-a, #landing-bg-b                { display: none !important; }

  /* Single-column layout */
  #landing-wrapper {
    padding: 0 !important;
    display: block !important;
  }
  #feed-panel {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0.75rem !important;
    padding-top: calc(0.75rem + env(safe-area-inset-top)) !important;
    box-sizing: border-box;
  }

  /* Right panel: hidden by default, shown as full-screen overlay when not logged in */
  #landing-right {
    display: none !important;
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    z-index: 500;
    padding: 2rem 1.5rem !important;
    padding-top: calc(2rem + env(safe-area-inset-top)) !important;
    box-sizing: border-box;
    overflow-y: auto;
    border: none !important;
  }
  body.mobile-auth #landing-right {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-direction: column;
  }
  body.mobile-auth #feed-panel { display: none !important; }

  #mobile-guest-btn {
    display: block;
    margin-top: 1.25rem;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
  }

  /* App banner */
  #app-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
  }
  #app-banner-brand { display: none !important; }
  #app-banner-sub   { display: none !important; }
  #app-banner-right {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }
  #app-banner-btns  { flex-wrap: wrap; gap: 0.35rem; justify-content: flex-end; }
  #books-tip-bar    { padding: 0.4rem 0.75rem 0.5rem; }

  /* Feed cards full width */
  .feed-card        { border-radius: 6px; }

  /* Public modal full screen — fixed inset so header always stays at top */
  .pub-overlay {
    align-items: flex-start !important;
    justify-content: flex-start !important;
  }
  .pub-modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
  }
  .pub-modal.pub-modal--run {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
  }

  /* Disable hover image preview on mobile */
#feed-img-preview { display: none !important; }

  /* Inline modals full screen */
  .modal-inner {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    overflow-y: auto;
  }

  /* Stats modal */
  #stats-modal-inner {
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
  }
}

#reward-float-layer {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  pointer-events: none;
  z-index: 3200;
}

.reward-float {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  max-width: min(280px, 72vw);
  padding: 0.45rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(103, 232, 249, 0.55);
  background: rgba(8, 47, 73, 0.94);
  color: #67e8f9;
  box-shadow: 0 10px 24px rgba(0,0,0,0.38), 0 0 18px rgba(34, 211, 238, 0.18);
  font-size: 0.83rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transform: translateY(0);
  opacity: 0;
  animation: reward-float-rise 3.6s ease-out forwards;
}

.reward-float--xp {
  border-color: rgba(103, 232, 249, 0.55);
  background: rgba(8, 47, 73, 0.94);
  color: #67e8f9;
  box-shadow: 0 10px 24px rgba(0,0,0,0.38), 0 0 18px rgba(34, 211, 238, 0.18);
}

.reward-float--coins {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.reward-float--level {
  gap: 0.55rem;
  padding-inline: 0.9rem;
  border-color: rgba(245, 158, 11, 0.62);
  background: rgba(69, 26, 3, 0.94);
  color: #fde68a;
  box-shadow: 0 12px 28px rgba(0,0,0,0.42), 0 0 22px rgba(245, 158, 11, 0.24);
}

.reward-float-kicker {
  color: #fbbf24;
  letter-spacing: 0.08em;
}

.reward-float-title {
  color: #fff7cc;
}

.reward-float .coin-icon {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
}

.reward-float--coins .coin-icon {
  width: 1.15rem;
  height: 1.15rem;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.35)) drop-shadow(0 0 12px rgba(245, 158, 11, 0.28));
}

@keyframes reward-float-rise {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  12% {
    opacity: 1;
    transform: translateY(0);
  }
  72% {
    opacity: 1;
    transform: translateY(-18px);
  }
  100% {
    opacity: 0;
    transform: translateY(-40px);
  }
}
