/* =====================================================================
   DnDCast — styles.css
   Dark, mobile-first, landscape-optimized.
   ===================================================================== */

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

/* Ensure [hidden] wins over any display: flex/block in author CSS */
[hidden] { display: none !important; }

/* Hide the mouse cursor after inactivity for a clean mirrored view */
body.cursor-hidden,
body.cursor-hidden * { cursor: none !important; }

/* =====================================================================
   Home selector page
   ===================================================================== */

body.home-page { overflow: auto; }

#home {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  gap: 2rem;
}

#home-header { text-align: center; }

#home-header h1 {
  font-size: clamp(2.2rem, 8vw, 3.5rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #e0e0e0;
}

#home-header h1 span { color: #c9a84c; }

#home-header p {
  color: #555;
  margin-top: 0.4rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

#home-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  width: 100%;
  max-width: 760px;
}

.home-card {
  flex: 1 1 200px;
  max-width: 240px;
  background: #111;
  border: 1px solid #222;
  border-radius: 10px;
  padding: 1.5rem 1.25rem;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.6rem;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.home-card:hover  { background: #161616; border-color: #3a3a3a; }
.home-card:active { transform: scale(0.985); }

.home-card-icon  { font-size: 2rem; color: #c9a84c; }
.home-card-title { font-size: 1.05rem; font-weight: 600; color: #e0e0e0; }
.home-card-desc  { font-size: 0.8rem; color: #666; line-height: 1.5; }

#home-footer {
  color: #444;
  font-size: 0.8rem;
  text-align: center;
  max-width: 520px;
  line-height: 1.6;
}

#home-footer strong { color: #777; font-weight: 600; }

/* ── Login page ──────────────────────────────────────────────────────── */

#login-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 280px;
}

#login-form input[type="password"] {
  width: 100%;
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 7px;
  color: #e0e0e0;
  font-size: 1rem;
  padding: 0.65rem 1rem;
  text-align: center;
  letter-spacing: 0.1em;
  outline: none;
}

#login-form input[type="password"]:focus { border-color: #c9a84c; }

.login-btn {
  width: 100%;
  padding: 0.65rem;
  background: #c9a84c;
  color: #0a0a0a;
  border: none;
  border-radius: 7px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.05em;
}

.login-btn:hover { background: #d9b85c; }

#login-error {
  color: #c05050;
  font-size: 0.85rem;
}

/* =====================================================================
   DM mode chrome
   ===================================================================== */

/* "do not cast this tab" badge — top-left, DM role only */
#dm-badge {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 35;
  background: rgba(140, 40, 40, 0.85);
  color: #ffd9d9;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 4px;
  pointer-events: none;
}

/* Deploy badge — bottom-right, neutral; QA only (see /api/deploy-info) */
#deploy-badge {
  position: fixed;
  bottom: 10px;
  right: 12px;
  z-index: 35;
  background: rgba(40, 44, 52, 0.85);
  color: #9fb3c8;
  font-family: monospace;
  font-size: 0.68rem;
  padding: 3px 9px;
  border-radius: 4px;
  pointer-events: none;
}

/* Stage badge — centered top, amber; shown when DM is staging (cast frozen) */
#dm-stage-badge {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  background: rgba(160, 110, 10, 0.92);
  color: #ffe680;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 12px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
}

/* Readable notes/script overlay — two side-by-side cards (Script | Notes),
   legible over any art. Script is on the left since it's read first. */
#dm-notes-overlay {
  position: fixed;
  top: 3rem;
  left: 1rem;
  right: 1rem;
  bottom: 92px;
  z-index: 16;
  display: flex;
  gap: 1rem;
  /* Cards size to their text and only grow to fill (then scroll) when long. */
  align-items: flex-start;
}

.dm-note-card {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 60%;
  max-height: 100%;            /* cap at the overlay area; longer text scrolls */
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  overflow: hidden;
}

/* Notes card (second) is the secondary read — keep it a touch narrower. */
.dm-note-card:nth-child(2) { max-width: 40%; }

.dm-note-label {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c9a84c;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(201, 168, 76, 0.25);
}

.dm-note-body {
  min-height: 0;               /* allow the body to shrink so overflow-y can scroll */
  overflow-y: auto;
  font-size: 1.05rem;
  line-height: 1.65;
  white-space: pre-wrap;
  color: #f0f0f0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
}

#dm-script-text { color: #fff; }

/* Stack the cards on narrow/portrait screens */
@media (max-width: 700px) {
  #dm-notes-overlay { flex-direction: column; }
  .dm-note-card,
  .dm-note-card:nth-child(2) { max-width: 100%; }
  /* When both cards show, cap each so two long ones each scroll; a lone card
     (overlay.single) keeps the full height. */
  #dm-notes-overlay:not(.single) .dm-note-card { max-height: 50%; }
}

/* Waiting-for-DM overlay (player follower) */
#waiting-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(5, 5, 5, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#waiting-box { display: flex; flex-direction: column; gap: 1rem; }

#waiting-msg {
  color: #888;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  color-scheme: dark;   /* native form controls (selects, inputs, popups) render dark by default */
  background: #0a0a0a;
  color: #e0e0e0;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Start Session overlay ─────────────────────────────────────────── */

#start-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

#start-box h1 {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #e0e0e0;
  margin-bottom: 0.3em;
}

#start-box h1 span { color: #c9a84c; }

#start-box p {
  color: #666;
  margin-bottom: 2.5rem;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#start-btn {
  padding: 1rem 3.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: #c9a84c;
  color: #0a0a0a;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}

#start-btn:active { opacity: 0.75; }

/* ── Campaign / Session pickers ────────────────────────────────────── */

#campaign-overlay,
#adventure-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(5, 5, 5, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.picker-box {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.picker-heading {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 1rem;
  text-align: center;
}

.picker-box ul {
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.picker-card {
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 60px;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}

.picker-card:active { background: #1a1a1a; border-color: #333; }

.picker-title {
  font-size: 1rem;
  font-weight: 500;
  color: #e0e0e0;
}

.picker-meta {
  font-size: 0.78rem;
  color: #555;
}

.picker-desc {
  font-size: 0.78rem;
  color: #444;
  font-style: italic;
}

.picker-all {
  margin-top: 0.5rem;
  border-color: #2a2a2a;
}

.picker-all .picker-title { color: #c9a84c; }

.picker-back {
  padding: 0.6rem 0 0;
  text-align: center;
}

/* ── Scene display ─────────────────────────────────────────────────── */

#scene-display {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: #0a0a0a;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* ── Scene placeholder (no image / image error) ────────────────────── */

#scene-placeholder {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  pointer-events: none;
}

#placeholder-content {
  text-align: center;
  padding: 2rem;
  max-width: 80vw;
}

#placeholder-title {
  font-size: clamp(1.2rem, 4vw, 2.5rem);
  font-weight: 600;
  color: #2a2a2a;
  letter-spacing: 0.03em;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

#placeholder-error {
  font-size: 0.8rem;
  color: #5a2020;
  font-family: 'Courier New', monospace;
}

/* ── Blackout ──────────────────────────────────────────────────────── */

#blackout {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #000;
}

/* ── Invisible tap zones ───────────────────────────────────────────── */

#tap-prev,
#tap-next {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 30%;
  z-index: 10;
  cursor: pointer;
}

#tap-prev { left: 0; }
#tap-next { right: 0; }

/* ── Title overlay ─────────────────────────────────────────────────── */

#title-overlay {
  position: fixed;
  bottom: 96px;
  left: 1.25rem;
  z-index: 15;
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.95);
  opacity: 0.88;
  pointer-events: none;
  transition: opacity 0.3s;
  max-width: 60vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#title-overlay.hidden { opacity: 0; }

/* ── Controls panel ────────────────────────────────────────────────── */

#controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(8, 8, 8, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.45rem 0.75rem 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  transition: opacity 0.35s;
}

#controls.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ── Info row (notes toggle · session label · errors) ──────────────── */

#info-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
}

.text-btn {
  background: none;
  border: none;
  color: #ccc;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 0;
  min-height: 28px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.text-btn:hover  { color: #fff; }
.text-btn:active { color: #aaa; }

#adventure-label {
  font-size: 0.72rem;
  color: #444;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

#scene-counter {
  font-size: 0.72rem;
  color: #3a3a3a;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

#error-msg {
  color: #c05050;
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
}

#notes-content {
  background: #111;
  border-radius: 4px;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: #aaa;
  line-height: 1.5;
  margin-bottom: 0.35rem;
  max-height: 72px;
  overflow-y: auto;
}

/* ── Button row ────────────────────────────────────────────────────── */

#btn-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: nowrap;
}

#btn-row button {
  min-width: 46px;
  min-height: 46px;
  background: #1a1a1a;
  color: #d0d0d0;
  border: 1px solid #282828;
  border-radius: 6px;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

#btn-row button:active { background: #2a2a2a; }

#btn-row button.active {
  background: #c9a84c;
  color: #0a0a0a;
  border-color: #c9a84c;
}

#overflow-wrap {
  position: relative;
  flex-shrink: 0;
}

#overflow-panel {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background: rgba(18, 18, 18, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-width: 168px;
}

/* Overflow panel buttons inherit #btn-row button styles already.
   Shrink slightly so 4 fit in a row on the min-width. */
#overflow-panel button {
  min-width: 36px;
  min-height: 36px;
  font-size: 0.95rem;
}

#vol-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  color: #555;
  cursor: pointer;
}

#volume-slider {
  flex: 1;
  min-width: 50px;
  max-width: 130px;
  height: 4px;
  accent-color: #c9a84c;
  cursor: pointer;
}

/* ── Presentation mode re-show dot ────────────────────────────────── */

#present-dot {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(201, 168, 76, 0.4);
  z-index: 32;
  cursor: pointer;
  display: none;
  transition: background 0.2s;
}

#present-dot:active { background: rgba(201, 168, 76, 0.8); }

/* ── Presentation mode ─────────────────────────────────────────────── */

.presentation-mode #controls    { display: none; }
.presentation-mode #title-overlay { display: none; }
.presentation-mode #present-dot  { display: block; }

/* ── Scene list drawer ─────────────────────────────────────────────── */

#drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.55);
}

#scene-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 41;
  background: #111;
  border-top: 1px solid #222;
  max-height: 65vh;
  display: flex;
  flex-direction: column;
}

#drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #1e1e1e;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

#drawer-search-wrap {
  padding: 0.35rem 0.75rem;
  border-top: 1px solid #1a1a1a;
  flex-shrink: 0;
}

#drawer-search {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid #2a2a2a;
  border-radius: 0;
  color: #888;
  font-size: 0.78rem;
  padding: 4px 2px;
  outline: none;
}

#drawer-search:focus { color: #ccc; border-bottom-color: #555; }

#close-drawer-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 1.1rem;
  cursor: pointer;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

#close-drawer-btn:active { background: #1e1e1e; }

#scene-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

#scene-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #171717;
  cursor: pointer;
  min-height: 52px;
  transition: background 0.1s;
}

#scene-list li:active  { background: #1a1a1a; }
#scene-list li.current { color: #c9a84c; }

.scene-num {
  color: #3a3a3a;
  font-size: 0.72rem;
  min-width: 1.5rem;
  text-align: right;
  flex-shrink: 0;
}

#drawer-footer {
  padding: 0.65rem 1rem;
  border-top: 1px solid #1a1a1a;
  text-align: center;
  flex-shrink: 0;
}

.editor-link {
  color: #3a3a3a;
  text-decoration: none;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}

.editor-link:hover { color: #666; }

.drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#drawer-add-btn {
  background: none;
  border: 1px solid #2a2a2a;
  color: #c9a84c;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  min-height: 34px;
  border-radius: 4px;
  cursor: pointer;
}

#drawer-add-btn:active { background: #1a1a1a; }

/* ── Quick add-scene modal (DM only) ───────────────────────────────── */

#quick-scene-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(5, 5, 5, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

#quick-scene-box {
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #111;
  border: 1px solid #222;
  border-radius: 10px;
  padding: 1.25rem;
}

#qs-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

#qs-header .picker-heading { text-align: left; margin-bottom: 0; }

#qs-close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 1.1rem;
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
}

#quick-scene-form { display: flex; flex-direction: column; gap: 0.8rem; margin-top: 0.75rem; }

.qs-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #777;
}

.qs-hint { text-transform: none; letter-spacing: 0; color: #555; font-size: 0.72rem; }

.qs-field input[type="text"],
.qs-field textarea,
.qs-field select {
  background: #0c0c0c;
  border: 1px solid #2a2a2a;
  border-radius: 5px;
  color: #ddd;
  font-size: 0.9rem;
  padding: 8px 10px;
  text-transform: none;
  letter-spacing: 0;
}

.qs-field input:focus,
.qs-field textarea:focus,
.qs-field select:focus { outline: none; border-color: #555; }

.qs-field input:disabled { opacity: 0.4; }

.qs-path-row { display: flex; gap: 0.4rem; }
.qs-path-row input[type="text"] { flex: 1; }

.qs-browse {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #aaa;
  border-radius: 5px;
  font-size: 0.8rem;
  padding: 0 12px;
  cursor: pointer;
}
.qs-browse:active { background: #222; }
.qs-browse:disabled { opacity: 0.4; cursor: default; }

.qs-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #aaa;
}

#qs-status { font-size: 0.78rem; color: #888; min-height: 1em; }
#qs-status.error { color: #c46; }

.qs-actions { display: flex; align-items: center; gap: 1rem; margin-top: 0.25rem; }

.qs-save {
  padding: 0.6rem 1.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: #c9a84c;
  color: #0a0a0a;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.qs-save:active { opacity: 0.8; }

.qs-save-ghost {
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: none;
  color: #c9a84c;
  border: 1px solid #4a4128;
  border-radius: 6px;
  cursor: pointer;
}
.qs-save-ghost:active { background: rgba(201,168,76,0.1); }

/* DM scene-drawer per-row edit pencil */
.scene-label { flex: 1; }
.scene-edit-pencil {
  background: none;
  border: none;
  color: #777;
  font-size: 1rem;
  cursor: pointer;
  min-width: 40px;
  min-height: 40px;
  border-radius: 4px;
  flex-shrink: 0;
}
.scene-edit-pencil:hover { color: #c9a84c; background: #1e1e1e; }

/* ── Notebook drawer (DM only) ─────────────────────────────────────── */

#notebook-backdrop,
#cheatsheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.55);
}

#notebook-drawer,
#cheatsheet-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 41;
  background: #111;
  border-top: 1px solid #222;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}

/* Cheat sheet: rendered Markdown flowed into as many columns as the tray is
   wide (one ## section per card), scrolling vertically when it's long. */
.cheatsheet-body {
  padding: 0.5rem 1rem 1.25rem;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 0 1.75rem;
  align-items: start;
  font-size: 0.86rem;
  line-height: 1.45;
  color: #ddd;
}
.cs-section { break-inside: avoid; margin-bottom: 0.5rem; }
.cs-full { grid-column: 1 / -1; }   /* a # heading spans every column */
.cheatsheet-body h3 {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #c9a84c;
  margin: 0.75rem 0 0.35rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid #2a2a2a;
}
.cs-full h3 { font-size: 0.95rem; color: #e0c97a; border-bottom: none; }
.cheatsheet-body h4 { font-size: 0.84rem; color: #d8b85a; margin: 0.5rem 0 0.15rem; }
.cheatsheet-body p  { margin: 0.25rem 0; }
.cheatsheet-body ul { margin: 0.2rem 0; padding-left: 1.1rem; }
.cheatsheet-body li { margin: 0.18rem 0; }
.cheatsheet-body strong { color: #fff; }
.cheatsheet-body em { color: #9fb0c8; font-style: normal; }

.nb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #1e1e1e;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

#notebook-close-btn,
#cheatsheet-close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 1.1rem;
  cursor: pointer;
  min-width: 40px;
  min-height: 40px;
  border-radius: 4px;
}
#notebook-close-btn:active,
#cheatsheet-close-btn:active { background: #1e1e1e; }
#cheatsheet-close-btn:hover { color: #ccc; }

#notebook-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* One clickable line: tag · title · truncated preview → opens the viewer. */
.nb-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #171717;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
}
.nb-item:hover { background: #161616; }

.nb-tag {
  flex-shrink: 0;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c9a84c;
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 3px;
  padding: 1px 5px;
}

.nb-title { flex-shrink: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; color: #eee; font-weight: 600; font-size: 0.88rem; }
.nb-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: #888; font-size: 0.85rem; }

.nb-empty {
  padding: 1rem;
  color: #555;
  font-size: 0.82rem;
  font-style: italic;
}

.nb-header-actions { display: flex; align-items: center; gap: 0.5rem; }
.nb-new-btn {
  background: none;
  border: 1px solid #2a2a2a;
  color: #c9a84c;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  min-height: 32px;
  border-radius: 4px;
  cursor: pointer;
}
.nb-new-btn:active { background: #1a1a1a; }

/* ── Note modal: read-only viewer + create/edit form ───────────────── */
#note-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(5, 5, 5, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

#note-modal-box {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: #111;
  border: 1px solid #222;
  border-radius: 10px;
  padding: 1.25rem;
}

.note-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}
.note-modal-head .picker-heading { text-align: left; margin-bottom: 0; }

.nb-modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1.1rem;
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
}

#note-view-title { color: #eee; font-size: 1.25rem; font-weight: 700; margin-bottom: 0.6rem; word-break: break-word; }
#note-view-body  { color: #ddd; font-size: 0.95rem; line-height: 1.6; white-space: pre-wrap; max-height: 55vh; overflow-y: auto; }

#note-edit-form { display: flex; flex-direction: column; gap: 0.6rem; }

.nb-scope-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #777;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#note-scope-select {
  background: #0c0c0c;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  color: #ddd;
  font-size: 0.82rem;
  padding: 4px 8px;
}

#note-title,
#note-text {
  background: #0c0c0c;
  border: 1px solid #2a2a2a;
  border-radius: 5px;
  color: #ddd;
  font-size: 0.9rem;
  font-family: inherit;
  padding: 8px 10px;
}
#note-text { resize: vertical; }
#note-title:focus, #note-text:focus, #note-scope-select:focus { outline: none; border-color: #555; }

.note-modal-actions { display: flex; align-items: center; gap: 1rem; margin-top: 0.5rem; }

.nb-primary {
  background: #c9a84c;
  color: #0a0a0a;
  border: none;
  border-radius: 5px;
  font-weight: 700;
  padding: 0.5rem 1.3rem;
  cursor: pointer;
}
.nb-primary:active { opacity: 0.8; }

.nb-danger {
  background: none;
  color: #b05050;
  border: 1px solid #3a1a1a;
  border-radius: 5px;
  font-weight: 600;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
}
.nb-danger:hover { background: #1a0a0a; }

#note-status { font-size: 0.78rem; color: #888; }
#note-status.error { color: #c46; }

/* ── Combat tracker drawer (DM only) ───────────────────────────────── */
#combat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.55);
}

#combat-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 41;
  background: #111;
  border-top: 1px solid #222;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.cb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #1e1e1e;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.cb-header-actions { display: flex; align-items: center; gap: 0.5rem; }

#combat-close-btn, #audit-log-close-btn {
  background: none; border: none; color: #888;
  font-size: 1.1rem; cursor: pointer;
  min-width: 40px; min-height: 40px; border-radius: 4px;
}
#combat-close-btn:active, #audit-log-close-btn:active { background: #1e1e1e; }

.cb-clear-btn {
  background: none; color: #b05050;
  border: 1px solid #3a1a1a; border-radius: 5px;
  font-weight: 600; font-size: 0.78rem; padding: 0.35rem 0.7rem; cursor: pointer;
}
.cb-clear-btn:hover { background: #1a0a0a; }

.cb-roundbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; padding: 0.6rem 1rem;
  border-bottom: 1px solid #1e1e1e; flex-shrink: 0;
}
#combat-round { font-weight: 700; color: #c9a84c; letter-spacing: 0.04em; }
.cb-turnbtns { display: flex; align-items: center; gap: 0.5rem; }
.cb-roundbar button {
  background: #1a1a1a; color: #ddd; border: 1px solid #2a2a2a;
  border-radius: 5px; padding: 0.4rem 0.9rem; cursor: pointer; font-size: 0.85rem;
}
.cb-roundbar button:active { background: #222; }
.cb-primary {
  background: #c9a84c !important; color: #0a0a0a !important; border: none !important;
  font-weight: 700; border-radius: 5px; padding: 0.45rem 1.2rem; font-size: 0.85rem; cursor: pointer;
}
.cb-primary:active { opacity: 0.8; }

/* Dice tool — two explicit rows (roll controls, then result/Resolver) rather
   than one flat wrapping row: letting the Resolver button fall wherever the
   flex-wrap happened to land it made it drift out from under the Roll
   button on narrow screens. */
.cb-dice {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.55rem 1rem; border-bottom: 1px solid #1e1e1e; flex-shrink: 0;
}
.cb-dice-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.cb-dice-buttons { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.cb-dice-buttons button {
  background: #1a1a1a; color: #cfcfcf; border: 1px solid #2a2a2a;
  border-radius: 5px; padding: 0.35rem 0.6rem; min-width: 42px;
  cursor: pointer; font-size: 0.82rem;
}
.cb-dice-buttons button:active { background: #c9a84c; color: #0a0a0a; }
.cb-dice-result { font-weight: 700; color: #c9a84c; font-size: 0.95rem; min-height: 1.2em; }
.cb-dice-result.flash { animation: cb-flash 0.45s ease-out; }
@keyframes cb-flash { from { transform: scale(1.4); } to { transform: scale(1); } }
.cb-dice-result.crit   { color: #74d18a; }
.cb-dice-result.fumble { color: #d97a7a; }
.cb-crit   { color: #74d18a; font-weight: 800; letter-spacing: 0.05em; }
.cb-fumble { color: #d97a7a; font-weight: 800; letter-spacing: 0.05em; }
/* Resolver-only (calc-* is that component's own naming convention, see
   calc-pass/calc-fail below) — a distinct amber, not the same green
   calc-pass/.cb-crit use for a plain hit/pass, so a crit reads as its own
   thing at a glance instead of just a bolder hit. Kept separate from
   .cb-crit (shared with the unrelated dice-bar tool in app/combatPanel.ts)
   so recoloring the Resolver's crit doesn't also recolor that tool's. */
.calc-crit { color: #ffb347; font-weight: 800; letter-spacing: 0.05em; }

/* Dice-bar options: modifier field + adv/dis toggle + calculator launcher */
.cb-dice-opts { display: flex; align-items: center; gap: 0.4rem; }
.cb-dice-mod {
  width: 3rem; text-align: center; background: #0c0c0c; color: #eee;
  border: 1px solid #2a2a2a; border-radius: 5px; padding: 0.3rem 0.2rem; font-size: 0.82rem;
}
.cb-dice-mod:focus { outline: none; border-color: #c9a84c; }
.cb-dice-pool {
  width: 6rem; background: #0c0c0c; color: #eee; border: 1px solid #2a2a2a;
  border-radius: 5px; padding: 0.3rem 0.45rem; font-size: 0.82rem;
}
.cb-dice-pool:focus { outline: none; border-color: #c9a84c; }
.cb-mode-toggle { display: inline-flex; border: 1px solid #2a2a2a; border-radius: 5px; overflow: hidden; }
.cb-mode-toggle button {
  background: #131313; color: #aaa; border: none; border-left: 1px solid #2a2a2a;
  padding: 0.3rem 0.5rem; font-size: 0.78rem; cursor: pointer;
}
.cb-mode-toggle button:first-child { border-left: none; }
.cb-mode-toggle button.active { background: #c9a84c; color: #0a0a0a; font-weight: 700; }
/* Resolver launches a separate workflow — pin it to the far right so it isn't
   mistaken for part of the dice readout sitting just before it. */
.cb-resolver-btn { margin-left: auto; }

#combat-list { list-style: none; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

.cb-row {
  display: grid; grid-template-columns: 3rem auto 1fr; gap: 0.7rem;
  align-items: start; padding: 0.6rem 1rem; border-bottom: 1px solid #171717;
}
@media (max-width: 720px) { .cb-row { grid-template-columns: 3rem 1fr auto; } }
.cb-row.current { background: rgba(201, 168, 76, 0.08); border-left: 3px solid #c9a84c; padding-left: calc(1rem - 3px); }

.cb-init {
  width: 3rem; flex-shrink: 0; text-align: center;
  background: #0c0c0c; color: #eee; border: 1px solid #262626;
  border-radius: 5px; padding: 0.35rem 0.2rem; font-weight: 700; font-size: 0.95rem;
}

/* Fixed-width buckets clustered together (not stretched across the screen),
   so a single combatant's info reads at a glance. Stacks on narrow. */
.cb-content { display: flex; gap: 0.9rem; min-width: 0; }
.cb-bucket { flex: 0 0 auto; min-width: 0; }
.cb-who  { width: 11rem;   display: flex; flex-direction: column; gap: 0.3rem; }
.cb-res  { width: 12.5rem; display: flex; flex-direction: column; gap: 0.25rem; }
.cb-cond-bucket { width: 13rem; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 0.3rem; }
@media (max-width: 720px) {
  .cb-content { flex-direction: column; gap: 0.45rem; }
  .cb-who, .cb-res, .cb-cond-bucket { width: auto; }
}

.cb-namerow { display: flex; align-items: center; gap: 0.4rem; min-width: 0; }
.cb-name {
  font: inherit; font-weight: 600; color: #eee; background: none; border: none; padding: 0;
  text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; min-width: 0;
}
.cb-name:hover { text-decoration: underline; text-decoration-color: #444; }
.cb-name:focus-visible { outline: 2px solid #c9a84c; outline-offset: 1px; border-radius: 3px; }
.cb-pc {
  flex-shrink: 0; font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: #6fae6f; border: 1px solid rgba(111, 174, 111, 0.35); border-radius: 3px; padding: 0 4px;
}
.cb-statlink { flex-shrink: 0; text-decoration: none; font-size: 0.9rem; opacity: 0.85; }
.cb-statlink:hover { opacity: 1; }

.cb-ac {
  align-self: flex-start; font-size: 0.78rem; color: #cdd6e0; font-weight: 600;
  border: 1px solid #2a2f36; border-radius: 4px; padding: 1px 6px;
}
.cb-ac.modified { color: #e0c060; border-color: rgba(201, 168, 76, 0.5); }

.cb-traits { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.cb-trait {
  display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.72rem;
  color: #a9cbe4; background: #12202c; border: 1px solid rgba(120, 170, 215, 0.45);
  border-radius: 3px; padding: 1px 6px;
}
.cb-trait button { background: none; border: none; color: #678; cursor: pointer; font-size: 0.85rem; line-height: 1; padding: 0; }
.cb-trait button:hover { color: #9fc0d8; }

/* Defense chips: damage responses + condition immunities + granted senses */
.cb-defenses { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.cb-dr, .cb-imm, .cb-sense {
  display: inline-flex; align-items: center; font-size: 0.68rem;
  border-radius: 3px; padding: 1px 5px; font-weight: 600;
}
.cb-dr-resistant  { background: #1c1500; color: #c9a84c; border: 1px solid rgba(201,168,76,0.4); }
.cb-dr-immune     { background: #0d1a0d; color: #74d18a; border: 1px solid rgba(116,209,138,0.4); }
.cb-dr-vulnerable { background: #1a0a0a; color: #d97a7a; border: 1px solid rgba(217,122,122,0.4); }
.cb-imm           { background: #12102a; color: #a89fd8; border: 1px solid rgba(168,159,216,0.4); }
.cb-sense         { background: #0a1a1c; color: #6fc4d4; border: 1px solid rgba(111,196,212,0.4); }

/* Resource lines (HP + slots) with the shared stepper */
.cb-res-line { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.cb-hp-label, .cb-res-name { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; color: #6a6a6a; }
.cb-res-name { color: #9a86bb; }
.cb-hp { font-variant-numeric: tabular-nums; color: #9fbf9f; font-weight: 600; font-size: 0.88rem; }
.cb-hp.down { color: #b05050; }
.cb-res-count { font-variant-numeric: tabular-nums; color: #b7a3d8; font-weight: 600; font-size: 0.85rem; }
.cb-temp { font-size: 0.72rem; color: #7fc4d8; font-weight: 600; }

.cb-step { display: inline-flex; align-items: center; gap: 0.15rem; }
.cb-step-minus, .cb-step-plus {
  cursor: pointer; border: 1px solid; border-radius: 4px; font-size: 0.95rem; font-weight: 700;
  line-height: 1; width: 1.4rem; height: 1.4rem;
}
.cb-step-minus { background: #1f1010; border-color: #5a2020; color: #d98080; }
.cb-step-plus  { background: #101f10; border-color: #205a20; color: #80d980; }
.cb-step-minus:active { background: #3a1414; }
.cb-step-plus:active  { background: #143a14; }
.cb-step-input {
  width: 2.6rem; background: #0c0c0c; color: #eee; border: 1px solid #2a2a2a;
  border-radius: 4px; padding: 0.2rem; text-align: center; font-size: 0.82rem;
}
.cb-step-input:focus { outline: none; border-color: #c9a84c; }

.cb-cond {
  display: inline-flex; align-items: center; gap: 0.2rem; align-self: flex-start;
  font-size: 0.72rem; color: #d8caa0; background: #1c1810;
  border: 1px solid rgba(201, 168, 76, 0.25); border-radius: 10px; padding: 1px 4px 1px 8px;
}
.cb-cond button { background: none; border: none; color: #998; cursor: pointer; font-size: 0.9rem; line-height: 1; padding: 0; }
.cb-cond button:hover { color: #c9a84c; }
.cb-cond-input {
  background: none; border: none; border-bottom: 1px dashed #333; color: #ccc;
  font-size: 0.75rem; width: 100%; max-width: 8rem; padding: 1px 2px; align-self: flex-start;
}
.cb-cond-input:focus { outline: none; border-bottom-color: #c9a84c; }

.cb-empty { padding: 1rem; color: #555; font-size: 0.82rem; font-style: italic; }

/* Audit log drawer — same backdrop/header/scroll-list chrome as #combat-drawer,
   nested on top of it (z-index one higher) since it opens from a button inside it.
   Below the 721px breakpoint this is a full-screen overlay (mobile — see the
   media query at the bottom of this block for the desktop side-by-side sidebar
   presentation instead, where there's room for it alongside the tracker). */
#audit-log-backdrop {
  position: fixed; inset: 0; z-index: 42; background: rgba(0, 0, 0, 0.55);
}
#audit-log-drawer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 43;
  background: #111; border-top: 1px solid #222; max-height: 85vh;
  display: flex; flex-direction: column;
}
.al-root { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.al-panel { display: flex; flex-direction: column; height: 100%; }
/* Sticky within `.al-root` (the actual scroller) so the tabs stay put once
   the entry list grows tall enough to scroll, instead of scrolling away
   with it. */
.al-tabs { display: flex; gap: 0.4rem; padding: 0.5rem 1rem; flex-shrink: 0; position: sticky; top: 0; z-index: 1; background: #111; border-bottom: 1px solid #171717; }
.al-tab {
  background: none; border: 1px solid #2a2a2a; color: #999;
  border-radius: 5px 5px 0 0; padding: 0.35rem 0.7rem; cursor: pointer; font-size: 0.78rem;
}
.al-tab.active { color: #c9a84c; border-color: #c9a84c; border-bottom-color: transparent; }
.al-list { list-style: none; }
.al-entry { padding: 0.6rem 1rem; border-bottom: 1px solid #171717; }
.al-meta { font-size: 0.72rem; color: #777; display: flex; align-items: center; gap: 0.4rem; }
.al-source {
  font-size: 0.68rem; color: #8fa8c9; background: #131a22;
  border: 1px solid rgba(143, 168, 201, 0.25); border-radius: 8px; padding: 0 5px;
}
.al-summary-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-top: 0.15rem; }
.al-summary { font-size: 0.85rem; color: #ddd; }
.al-roll .al-summary { color: #aaa; }
.al-breakdown { list-style: none; margin-top: 0.3rem; padding-left: 0.6rem; border-left: 2px solid #222; }
.al-breakdown li { font-size: 0.78rem; color: #aaa; padding: 0.1rem 0; }
.al-entry.undone .al-summary { color: #666; text-decoration: line-through; }
.al-undone-tag { font-size: 0.72rem; color: #666; font-style: italic; }

/* Desktop: the audit log sits beside the combat tracker instead of covering it —
   #combat-drawer's own JS-toggled `.log-open` (see app/combatPanel.ts's
   openAuditLog/closeAuditLog) shrinks it to make room, and there's no blocking
   backdrop since the tracker stays interactive. */
@media (min-width: 721px) {
  :root { --audit-log-width: 380px; }
  #audit-log-backdrop { display: none; }
  #combat-drawer.log-open { right: var(--audit-log-width); }
  #audit-log-drawer {
    left: auto; right: 0; width: var(--audit-log-width);
    border-top: none; border-left: 1px solid #222;
  }
}

.cb-add-row { display: flex; gap: 0.5rem; padding: 0.6rem 1rem; border-top: 1px solid #1e1e1e; flex-shrink: 0; }
.cb-add-btn {
  background: none; border: 1px solid #2a2a2a; color: #c9a84c;
  border-radius: 5px; padding: 0.45rem 0.8rem; cursor: pointer; font-size: 0.82rem;
}
.cb-add-btn:active { background: #1a1a1a; }

.cb-add-form { padding: 0.6rem 1rem 0.9rem; border-top: 1px solid #1e1e1e; display: flex; flex-direction: column; gap: 0.5rem; flex-shrink: 0; }
.cb-form-row { display: flex; gap: 0.5rem; }
.cb-name-input, .cb-num-input, .cb-url-input {
  background: #0c0c0c; color: #eee; border: 1px solid #262626;
  border-radius: 5px; padding: 0.45rem 0.55rem; font-size: 0.85rem;
}
.cb-name-input { flex: 1; }
.cb-num-input { width: 4.5rem; text-align: center; }
.cb-url-input { width: 100%; }
.cb-form-actions { display: flex; align-items: center; gap: 0.8rem; }
#cb-add-status { font-size: 0.78rem; color: #888; }
#cb-add-status.error { color: #c46; }

.cb-autoroll { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: #aaa; }

/* Bestiary picker — one row per monster template: info, a qty field, Add. */
.cb-bestiary { padding: 0.6rem 1rem 0.9rem; border-top: 1px solid #1e1e1e; display: flex; flex-direction: column; gap: 0.5rem; flex-shrink: 0; max-height: 45vh; overflow-y: auto; }
.cb-bestiary-row { display: flex; align-items: center; gap: 0.5rem; }
.cb-bestiary-info { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.cb-bestiary-name { color: #eee; font-size: 0.88rem; }
.cb-bestiary-meta { color: #888; font-size: 0.74rem; }
.cb-bestiary-row .cb-num-input { flex: 0 0 3.5rem; width: 3.5rem; }
.cb-autoroll input { width: auto; }

/* List header — column labels aligned to the row grid */
.cb-listhead {
  display: grid; grid-template-columns: 3rem auto 1fr; gap: 0.7rem;
  padding: 0.35rem 1rem; border-bottom: 1px solid #1e1e1e; flex-shrink: 0;
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; color: #6a6a6a;
}
.cb-lh-init { text-align: center; }
.cb-lh-content { display: flex; gap: 0.9rem; min-width: 0; }
.cb-lh-content span:nth-child(1) { width: 11rem; }
.cb-lh-content span:nth-child(2) { width: 12.5rem; }
.cb-lh-content span:nth-child(3) { width: 13rem; }
@media (max-width: 720px) { .cb-listhead { display: none; } }

/* Manage column — matched icon buttons, pinned far right */
.cb-manage { justify-self: end; display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.cb-details, .cb-remove {
  flex-shrink: 0; width: 1.7rem; height: 1.7rem; padding: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 4px; cursor: pointer;
}
.cb-details { color: #888; font-size: 1.15rem; }
.cb-details:hover { color: #c9a84c; background: #1a1a1a; }
.cb-remove { color: #5e5e5e; font-size: 0.95rem; }
.cb-remove:hover { color: #c0504e; background: #1e1010; }

/* Combatant detail modal */
#combatant-modal, #calc-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; }
.cb-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.cb-modal-box {
  position: relative; z-index: 1; width: min(440px, 92vw); max-height: 88vh; overflow-y: auto;
  background: #141414; border: 1px solid #2a2a2a; border-radius: 8px;
  padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem;
}
.cb-modal-head { display: flex; align-items: center; gap: 0.5rem; }
.cb-modal-name { flex: 1; background: #0c0c0c; color: #fff; border: 1px solid #2a2a2a; border-radius: 5px; padding: 0.5rem 0.6rem; font-size: 1rem; font-weight: 600; }
.cb-modal-grid { display: flex; gap: 0.6rem; }
.cb-modal-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.78rem; color: #aaa; flex: 1 1 0; min-width: 0; }
.cb-modal-field input, .cb-modal-field textarea {
  width: 100%; box-sizing: border-box;
  background: #0c0c0c; color: #eee; border: 1px solid #262626; border-radius: 5px;
  padding: 0.45rem 0.55rem; font-size: 0.88rem; font-family: inherit;
}
.cb-modal-field textarea { resize: vertical; }
.cb-hint { color: #666; font-weight: 400; text-transform: none; letter-spacing: 0; }
.cb-res-title { font-size: 0.78rem; color: #aaa; margin-bottom: 0.3rem; }
.cb-trait-list { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.35rem; }
.cb-res-list { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.4rem; }
.cbd-actions { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
.cbd-action { display: flex; align-items: center; gap: 0.4rem; }
.cbd-action-name { flex: 1 1 0; min-width: 0; color: #ddd; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbd-action-result { flex: 0 0 auto; color: #9fbf9f; font-variant-numeric: tabular-nums; font-size: 0.82rem; min-width: 2.5rem; text-align: right; }
/* Upcast-level picker on a leveled spell row — fixed/shrink-resistant width so
   it never crowds .cbd-action-name's flex:1 down to invisible (found via a
   manual click-through: no rule existed for this at all, so the browser's
   default <select> min-content width was squeezing the name to nothing).
   The Spells tab wraps its rows in .field-label/.spellcasting-block (shared
   with the editor's styling, see sheet.css) — `.field-label select` there
   sets width:100%, which beats a bare .cbd-slot-level rule on specificity
   alone, so this needs the compound selector to reliably win. */
.field-label .cbd-slot-level, .cbd-slot-level { flex: 0 0 auto; width: auto; font-size: 0.78rem; padding: 0.2rem 0.3rem; }
/* Versatile weapon's 2H toggle, next to its Attack button (.cbd-action). */
.cbd-weapon-2h { flex: 0 0 auto; display: flex; align-items: center; gap: 0.2rem; font-size: 0.72rem; color: #999; }
.cb-res-item { display: flex; align-items: center; gap: 0.35rem; }
.cb-res-label { flex: 1; color: #ddd; font-size: 0.85rem; min-width: 0; }
.cb-res-sep { color: #777; font-size: 0.72rem; }
.cb-res-item .cb-res-num {
  width: 3rem; flex: 0 0 3rem; box-sizing: border-box; text-align: center;
  background: #0c0c0c; color: #eee; border: 1px solid #262626; border-radius: 4px; padding: 0.3rem 0.2rem; font-size: 0.82rem;
}
.cb-res-remove { background: none; border: none; color: #774; cursor: pointer; font-size: 0.85rem; }
.cb-res-remove:hover { color: #b05050; }
.cb-res-add { display: flex; gap: 0.4rem; align-items: center; }
.cb-res-label-input { flex: 1; min-width: 0; background: #0c0c0c; color: #eee; border: 1px solid #262626; border-radius: 5px; padding: 0.4rem 0.5rem; font-size: 0.82rem; }
/* Override the full-width .cb-modal-field input rule inside the add row. */
.cb-res-add .cb-res-label-input { width: auto; flex: 1 1 auto; }
.cb-res-add .cb-num-input { width: 4rem; flex: 0 0 4rem; text-align: center; }
.cb-res-add .cb-add-btn { flex: 0 0 auto; }
.cb-modal-actions { display: flex; justify-content: flex-end; }

/* Combatant detail modal — tabbed layout matching the character/monster sheet
   (Phase 3). Fixed height so the frame doesn't jump between tabs; the active
   tab scrolls inside while the head, sub-tabs and Done row stay put. */
#combatant-modal .cb-modal-box { width: min(480px, 94vw); height: min(82vh, 760px); }
/* combatDetailSheet.tsx mounts .cbd-subtabs + .cbd-tabs into #cbd-sheet-root,
   a plain div — without its own flex participation, .cbd-tabs' `flex:1 1
   auto; min-height:0` below is a no-op, so it grows to fit content instead
   of scrolling internally (same fix as .sheet-modal's #char/#mon-sheet-root
   in editor.css). */
#cbd-sheet-root { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.cbd-subtabs { display: flex; flex-wrap: wrap; gap: 0.2rem; flex: 0 0 auto; border-bottom: 1px solid #2a2a2a; padding-bottom: 0.4rem; }
.cbd-subtab-btn { background: none; border: 1px solid transparent; color: #999; padding: 0.3rem 0.55rem; border-radius: 5px; cursor: pointer; font-size: 0.8rem; }
.cbd-subtab-btn:hover { color: #ddd; }
.cbd-subtab-btn.active { color: #fff; background: #232323; border-color: #333; }
.cbd-tabs { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.7rem; }
.cbd-tab { display: flex; flex-direction: column; gap: 0.7rem; }
.cbd-tab[hidden] { display: none; }
/* A PC combatant mounts the unified characterSheet.tsx into #cbd-sheet-root
   instead (see combatPanel.ts) — same .subtab-nav/.char-tab classes (and
   selectors) as its other mount point, the campaign editor's #char-sheet-root
   (see editor.css's ".sheet-modal .subtab-nav"/".sheet-modal .char-tab"), but
   that fix is scoped to editor.html's .sheet-modal wrapper, which doesn't
   exist around this modal — so it needs the same flex-participation fix
   re-scoped to #cbd-sheet-root's own direct children. */
#cbd-sheet-root > .subtab-nav { flex: 0 0 auto; }
#cbd-sheet-root > .char-tab { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* Combatant detail modal — new info sections */
.cbd-attrs-grid { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.cbd-attr-cell  { display: flex; flex-direction: column; align-items: center; background: #111; border: 1px solid #2a2a2a; border-radius: 4px; padding: 0.25rem 0.5rem; min-width: 3rem; }
.cbd-attr-id    { font-size: 0.65rem; color: #888; text-transform: uppercase; letter-spacing: 0.04em; }
.cbd-attr-val   { font-size: 0.95rem; font-weight: 600; color: #ddd; font-variant-numeric: tabular-nums; }

.cbd-skills-list { display: flex; flex-direction: column; gap: 0.35rem; }
.cbd-bucket-row  { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
.cbd-bucket-label { font-size: 0.72rem; color: #777; min-width: 5rem; }
.cbd-skill-chip  { font-size: 0.75rem; padding: 0.15rem 0.4rem; border-radius: 3px; background: #1a1a2e; color: #9999cc; border: 1px solid rgba(153,153,204,0.3); }
.cbd-skill-prof  { background: #0d1a0d; color: #74d18a; border-color: rgba(116,209,138,0.35); }
.cbd-skill-expert{ background: #0d1030; color: #7ab0ff; border-color: rgba(122,176,255,0.35); }

.cbd-inventory-list { display: flex; flex-direction: column; gap: 0.3rem; }
.cbd-inv-row  { display: flex; align-items: center; gap: 0.5rem; }
.cbd-inv-name { flex: 1; font-size: 0.82rem; color: #ccc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbd-inv-qty  { font-size: 0.78rem; color: #888; min-width: 1.8rem; text-align: right; }
.cbd-inv-eq   { font-size: 0.7rem; color: transparent; min-width: 3.5rem; }
.cbd-inv-eq-yes { color: #74d18a; }

/* Resolver modal (target → saves → apply) — wider than the detail modal so the
   target grid gets ~3+ columns on a laptop; still caps at the viewport. */
#calc-modal .cb-modal-box { width: min(640px, 94vw); }
.cb-modal-title { color: #c9a84c; font-size: 1.05rem; flex: 1; }
/* Banner: what's being cast (and, mid-cast, its flavor-text description) —
   replaces the old bare "Casting X at level Y" bar. */
.calc-banner { margin: 0.4rem 0 0.7rem; }
.calc-banner-desc { margin-top: 0.25rem; font-size: 0.82rem; color: #bbb; line-height: 1.4; }

.calc-targets, .calc-saves { list-style: none; max-height: 30vh; overflow-y: auto; overflow-x: hidden; }
.calc-saves { display: flex; flex-direction: column; gap: 0.2rem; }
/* The Apply section's rows carry an info-bubble popover (see
   .calc-apply-row below) — its .info-bubble-body is position:absolute
   and needs to escape its row's height to be visible, but .calc-saves'
   overflow-y:auto (needed for a long save-throw list to scroll) clips
   any absolutely-positioned descendant that extends past a row's own
   box, popover included. The Apply list's rows are already short
   (one field each), so it doesn't need its own internal scrollbar —
   the modal itself already scrolls (.cb-modal-box) — drop the clipping
   here so the popover isn't trapped invisible inside it. */
.calc-apply-list { max-height: none; overflow: visible; }
/* Targets: a responsive multi-column grid (no HP here) so a big mob stays
   scannable; columns collapse to one on a narrow screen. */
.calc-targets { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.1rem 0.6rem; }
.calc-target label { display: flex; width: 100%; box-sizing: border-box; align-items: center; gap: 0.45rem; cursor: pointer; padding: 0.15rem 0; }
/* Override the modal's input{width:100%} so the checkbox/radio stays its
   native size instead of stretching across the cell and shoving the name
   off-screen. Single-target casts use a radio here instead of a checkbox
   (see combatResolver.tsx's `single` shape). */
.calc-target input[type="checkbox"], .calc-target input[type="radio"] { width: auto; flex: 0 0 auto; margin: 0; padding: 0; }
.calc-target-name { flex: 1 1 auto; min-width: 0; color: #ddd; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Amount field: a number or a dice expression, with a roll button + breakdown.
   One row — the amount flexes/shrinks while the toggle, Roll, and ½ stay put. */
.calc-apply { display: flex; align-items: center; gap: 0.5rem; }
.calc-apply .calc-amount-input {
  flex: 1 1 0; min-width: 4rem; box-sizing: border-box;
  background: #0c0c0c; color: #eee; border: 1px solid #262626; border-radius: 5px; padding: 0.4rem 0.5rem; font-size: 0.88rem;
}
.calc-apply .cb-add-btn { flex: 0 0 auto; font-size: 1rem; padding: 0.35rem 0.6rem; }
.calc-half { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 0.25rem; color: #ccc; font-size: 0.95rem; white-space: nowrap; }
/* Only takes a line once a roll populates it, so it isn't a permanent third row. */
.calc-amount-result:empty { display: none; }
.calc-amount-result { font-size: 0.85rem; color: #cfcfcf; margin-top: 0.3rem; }
.calc-amount-result.error { color: #d97a7a; }
.calc-amount-result .calc-rolls { color: #888; font-size: 0.8rem; }
/* :not() excludes a crit/fumble roll rather than relying on source order —
   .calc-save-result b's specificity (0,1,1) would otherwise always beat
   .calc-crit/.cb-fumble's (0,1,0), silently overriding the crit color. */
.calc-amount-result b:not(.calc-crit):not(.cb-fumble),
.calc-save-result b:not(.calc-crit):not(.cb-fumble) { color: #c9a84c; }
/* Tag chip-builder: type + Enter adds a chip (like the row's Conditions
   field); chips wrap onto the row as they accumulate. */
.calc-tag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-top: 0.45rem; }
.calc-tag-row .cb-cond-input { flex: 0 0 auto; align-self: center; }
.calc-tags { display: contents; }   /* chips flow in the flex row alongside the input */

/* These inputs live inside .cb-modal-field, whose `input { width: 100% }`
   rule (specificity 0,1,1) would otherwise blow them up — so qualify them. */
.cb-res-title .calc-dc {
  width: 3rem; flex: 0 0 auto; box-sizing: border-box; text-align: center;
  background: #0c0c0c; color: #eee; border: 1px solid #262626; border-radius: 4px; padding: 0.2rem; font-size: 0.82rem;
}
/* Save-type picker: sits inline on the "Saving throws" row (DC · Save · Roll). */
.calc-save-type { margin-left: 0.5rem; }
.calc-save-type .calc-save-attr {
  max-width: 11rem; vertical-align: middle;
  background: #0c0c0c; color: #eee; border: 1px solid #262626; border-radius: 4px;
  padding: 0.2rem 0.3rem; font-size: 0.82rem;
}
.calc-save { display: flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0; }
/* Name takes the leftover space via flex-basis 0 (its content never sets its
   width), so the items after it never shift when the result text changes. */
.calc-save-name { flex: 1 1 0; min-width: 0; color: #ddd; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calc-save-hp { flex: 0 0 auto; color: #9fbf9f; font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.calc-save-hp.down { color: #b05050; }
.calc-save-modes { flex: 0 0 auto; }
.calc-save-modes button { padding: 0.2rem 0.4rem; font-size: 0.72rem; }
.calc-save-modlabel { flex: 0 0 auto; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; color: #777; }
.calc-save .calc-save-mod {
  width: 2.6rem; flex: 0 0 auto; box-sizing: border-box; text-align: center;
  background: #0c0c0c; color: #eee; border: 1px solid #262626; border-radius: 4px; padding: 0.2rem; font-size: 0.8rem;
}
/* Fixed width + right-aligned so pass/fail never resizes the box (which would
   shrink the name and shift the mod field). Full breakdown lives in the tooltip. */
.calc-save-result { flex: 0 0 4.5rem; width: 4.5rem; text-align: right; white-space: nowrap; overflow: hidden; font-size: 0.82rem; color: #cfcfcf; font-variant-numeric: tabular-nums; }
.calc-pass { color: #74d18a; font-weight: 700; }
.calc-fail { color: #d97a7a; font-weight: 700; }

/* Apply row: reuses DerivedStatField (see sheet.css's .field-label/.derived-*)
   inline in a compact list row instead of its usual standalone block —
   override the column layout to a tight row, and drop the empty label
   (only the info bubble + input/revert are shown; the target name is
   already the row's own .calc-save-name). */
.calc-apply-row { flex-wrap: nowrap; }
.calc-apply-row .field-label { flex-direction: row; align-items: center; gap: 0.3rem; margin-bottom: 0; flex: 0 0 auto; }
.calc-apply-row .derived-label-row:empty { display: none; }
.calc-apply-row .derived-override-input { width: 4rem; flex: 0 0 4rem; box-sizing: border-box; text-align: center; padding: 0.2rem; font-size: 0.8rem; }

/* Instance allocation (Scorching Ray / Magic Missile): a running list of
   (target, count) rows the DM builds up, each with its own roll/apply
   step, instead of the usual one-target-for-the-whole-spell picker. */
.calc-alloc-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; max-height: 40vh; overflow-y: auto; }
.calc-alloc-row { border: 1px solid #242424; border-radius: 6px; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.35rem; }
.calc-alloc-head { display: flex; align-items: center; gap: 0.4rem; }
.calc-alloc-attack { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.82rem; }
.calc-alloc-draft { display: flex; align-items: center; gap: 0.4rem; }
.calc-alloc-draft select { flex: 1 1 auto; min-width: 0; }
.calc-alloc-draft input[type="number"] { width: 3.2rem; flex: 0 0 3.2rem; box-sizing: border-box; text-align: center; }
.calc-alloc-draft .cb-add-btn { flex: 0 0 auto; }

/* ── Landscape adjustments ─────────────────────────────────────────── */

@media (orientation: landscape) and (max-height: 480px) {
  #title-overlay  { bottom: 72px; font-size: 0.85rem; }
  #controls       { padding: 0.25rem 0.6rem 0.3rem; }
  #notes-content  { max-height: 48px; }
  #btn-row button { min-height: 40px; min-width: 40px; font-size: 1rem; }
}

/* ── Scrollbars ────────────────────────────────────────────────────── */

::-webkit-scrollbar       { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }
