:root {
  color-scheme: dark;
  --sidebar-width: 330px;
  --panel: #17191d;
  --panel-2: #202329;
  --border: #343941;
  --text: #f2f4f7;
  --muted: #aeb5bf;
  --accent: #d9a441;
  --accent-strong: #f1bb50;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #0f1013;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #58606d;
}

#app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
  width: 100%;
  height: 100%;
}

#map-shell {
  display: grid;
  grid-template-rows: 96px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

#toolbar {
  z-index: 10;
  display: grid;
  grid-template-rows: 48px 48px;
  min-width: 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.toolbar-primary,
.toolbar-map-controls {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 14px;
}

.toolbar-primary {
  justify-content: space-between;
}

.toolbar-map-controls {
  gap: 8px;
  border-top: 1px solid rgb(255 255 255 / 6%);
  overflow-x: auto;
  scrollbar-width: thin;
}

.toolbar-title {
  min-width: 0;
  white-space: nowrap;
}

.build-label {
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: 1px;
}

.milestone-label {
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.toolbar-primary button,
.toolbar-map-controls button {
  padding: 7px 11px;
  white-space: nowrap;
}

#map-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at center, #272b31 0, #17191d 70%);
  cursor: grab;
  touch-action: none;
}

#map-viewport.dragging {
  cursor: grabbing;
}

#map-stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  user-select: none;
  will-change: transform;
}

#map-image {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  pointer-events: none;
}

#hex-overlay {
  position: absolute;
  inset: 0;
  overflow: visible;
}

.hex-hit-area {
  fill: transparent;
  stroke: transparent;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 100ms ease, stroke 100ms ease;
}

.hex-hit-area:focus {
  outline: none !important;
}

.hex-hit-area:hover {
  fill: rgb(217 164 65 / 22%);
  stroke: var(--accent-strong);
}

/* Keyboard focus follows the hex shape instead of drawing a rectangle. */
.hex-hit-area:focus-visible {
  fill: rgb(217 164 65 / 22%);
  stroke: #78b7ff;
  stroke-width: 4;
  outline: none !important;
}

.hex-hit-area.selected {
  fill: rgb(217 164 65 / 32%);
  stroke: var(--accent-strong);
}

/* v23: temporary blue preview for a rumor's linked destination hex. */
.hex-hit-area.linked-preview,
.hex-hit-area.linked-preview:hover,
.hex-hit-area.selected.linked-preview {
  fill: rgb(70 145 235 / 34%);
  stroke: #69b3ff;
  stroke-width: 4;
}

#map-help {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 8px 11px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 8px;
  background: rgb(15 16 19 / 78%);
  color: #d6d9df;
  font-size: 0.82rem;
  pointer-events: none;
  backdrop-filter: blur(5px);
}

#sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px;
  border-left: 1px solid var(--border);
  background: var(--panel);
}

.sidebar-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#hex-title {
  margin: 0;
  font-size: 1.5rem;
}

#hex-empty-state {
  margin-top: 20px;
  color: var(--muted);
  line-height: 1.5;
}

#hex-form {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

#hex-form label {
  margin-top: 8px;
  color: #d9dde3;
  font-size: 0.88rem;
  font-weight: 600;
}

#hex-form input,
#hex-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101216;
  color: var(--text);
  padding: 10px;
}

#hex-form textarea {
  resize: vertical;
  min-height: 160px;
}

#hex-form input:focus,
#hex-form textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgb(217 164 65 / 18%);
}

.save-row {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

#save-status {
  color: var(--muted);
  font-size: 0.82rem;
}

#save-hex {
  padding: 8px 14px;
  border-color: #7b5a22;
  background: #5b421d;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  color: #7f8791;
  font-size: 0.76rem;
}

.map-error {
  display: grid;
  place-items: center;
  width: 1200px;
  height: 800px;
  padding: 40px;
  background:
    linear-gradient(30deg, #1d2025 12%, transparent 12.5%, transparent 87%, #1d2025 87.5%, #1d2025),
    linear-gradient(150deg, #1d2025 12%, transparent 12.5%, transparent 87%, #1d2025 87.5%, #1d2025),
    linear-gradient(30deg, #1d2025 12%, transparent 12.5%, transparent 87%, #1d2025 87.5%, #1d2025),
    linear-gradient(150deg, #1d2025 12%, transparent 12.5%, transparent 87%, #1d2025 87.5%, #1d2025),
    #252931;
  background-position: 0 0, 0 0, 40px 70px, 40px 70px;
  background-size: 80px 140px;
  color: #f2f4f7;
  text-align: center;
}

.map-error div {
  max-width: 560px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgb(15 16 19 / 88%);
}

.map-error code {
  color: var(--accent-strong);
}

@media (max-width: 800px) {
  :root {
    --sidebar-width: 280px;
  }
}

@media (max-width: 650px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 260px;
  }

  #sidebar {
    border-top: 1px solid var(--border);
    border-left: 0;
    overflow-y: auto;
  }
}


.hex-count {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}


.debug-hex-label {
  display: none;
  fill: #fff;
  stroke: #111;
  stroke-width: 3px;
  paint-order: stroke;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

#hex-overlay.debug-grid .hex-hit-area {
  fill: rgb(217 164 65 / 10%);
  stroke: var(--accent-strong);
  stroke-width: var(--grid-line-weight, 2);
}

#hex-overlay.debug-grid .debug-hex-label {
  display: block;
}

/* Milestone 3 hex information editor */
#sidebar {
  overflow-y: auto;
}

#hex-form textarea {
  min-height: 88px;
}

#hex-notes {
  min-height: 120px;
}

.form-actions {
  display: flex;
  gap: 8px;
}

#reset-hex {
  padding: 8px 12px;
  color: #d4d8df;
}

#save-hex:disabled {
  cursor: default;
  opacity: 0.48;
}

#hex-form.is-dirty #save-status {
  color: var(--accent-strong);
}

/* Milestone 3.1: card-based People editor */
.entity-section {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.entity-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.entity-section-header label {
  margin: 0 !important;
}

.entity-add-button {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border-color: #725726;
  border-radius: 50%;
  background: #4a381b;
  color: var(--accent-strong);
  font-size: 1.25rem;
  line-height: 1;
}

.entity-add-button:hover {
  border-color: var(--accent-strong);
  background: #5b421d;
}

.entity-list {
  display: grid;
  gap: 7px;
}

.entity-card {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border-color: var(--border);
  background: #101216;
  text-align: left !important;
}

.entity-card:hover {
  border-color: #725726;
  background: #18181a;
}

.entity-card-content {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left !important;
}

.entity-card-title {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  width: 100%;
  text-align: left !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-card-description {
  display: -webkit-box;
  overflow: hidden;
  color: #b8bec7;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.4;
  width: 100%;
  text-align: left !important;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.entity-card-action {
  display: block;
  margin-top: 8px;
  color: var(--accent);
  font-size: 0.78rem;
  text-align: left;
}

.entity-empty {
  margin: 0;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: #858c96;
  font-size: 0.82rem;
  text-align: center;
}

.entity-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgb(0 0 0 / 55%);
}

.entity-dialog::backdrop {
  background: rgb(5 6 8 / 72%);
  backdrop-filter: blur(3px);
}

.entity-dialog form {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 20px;
}

.dialog-header {
  display: block;
  padding: 0 42px 12px 0;
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.45rem;
  line-height: 1;
}

.dialog-close:hover {
  background: #25282e;
  color: var(--text);
}

[hidden] {
  display: none !important;
}

.dialog-field {
  display: grid;
  gap: 7px;
}

.entity-dialog label {
  font-size: 0.88rem;
  font-weight: 600;
}

.entity-dialog textarea {
  width: 100%;
  min-height: 130px;
  padding: 10px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101216;
  color: var(--text);
}

.entity-dialog textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgb(217 164 65 / 18%);
}

.dialog-error {
  min-height: 1.1em;
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 0.82rem;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.dialog-actions button {
  padding: 8px 12px;
}

.dialog-spacer {
  flex: 1;
}

.primary-button {
  border-color: #7b5a22;
  background: #5b421d;
}

.danger-button {
  border-color: #713c3c;
  color: #ffb0b0;
}

/* Milestone 3.2: People, Places, and Rumors card editors */
.entity-section + .entity-section { margin-top: 14px; }
#places-list .entity-card-title, #rumors-list .entity-card-title { white-space: normal; }


/* v20: linked rumor navigation lives inside the rumor card */
.entity-card-wrapper {
  display: grid;
}

.entity-card-wrapper.has-linked-hex {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101216;
}

.entity-card-wrapper.has-linked-hex .entity-card {
  border: 0;
  border-radius: 0;
}

.rumor-hex-link {
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-top: 1px solid #2d4055;
  border-radius: 0;
  background: #172435;
  color: #8fc2ff;
  font-size: 0.78rem;
  text-align: left;
}

.rumor-hex-link:hover {
  background: #1d3048;
}

.rumor-hex-link:disabled {
  cursor: wait;
  opacity: 0.75;
}

.entity-dialog input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101216;
  color: var(--text);
}

.entity-dialog input:focus {
  border-color: var(--accent);
  outline: 2px solid rgb(217 164 65 / 18%);
}

.dialog-field-hint {
  margin: -1px 0 0;
  color: #8d949e;
  font-size: 0.76rem;
  line-height: 1.35;
}

/* v22: reusable collapsible Hex Inspector sections */
.inspector-section {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.inspector-section-header {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 8px;
}

.inspector-section-toggle {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 7px;
  padding: 5px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d9dde3;
  text-align: left;
}

.inspector-section-toggle:hover {
  background: rgb(255 255 255 / 4%);
}

.inspector-section-toggle:focus-visible {
  outline: 2px solid rgb(217 164 65 / 55%);
  outline-offset: 2px;
}

.section-chevron {
  width: 12px;
  flex: 0 0 12px;
  color: var(--muted);
  font-size: 0.76rem;
  transform-origin: center;
  transition: transform 140ms ease;
}

.inspector-section.is-collapsed .section-chevron {
  transform: rotate(-90deg);
}

.section-icon {
  width: 20px;
  flex: 0 0 20px;
  text-align: center;
}

.section-title {
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-count {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.section-dirty {
  color: var(--accent-strong);
  font-size: 1.2rem;
  line-height: 0.8;
}

.inspector-section-content {
  display: grid;
  gap: 8px;
  padding-left: 19px;
}

.inspector-section-content[hidden] {
  display: none !important;
}

/* The add control remains available even while its section is collapsed. */
.inspector-section-header .entity-add-button {
  flex: 0 0 30px;
}

/* v22 supersedes the older entity-section spacing rules. */
.entity-section,
.entity-section + .entity-section {
  margin-top: 10px;
}

#notes-content #hex-notes {
  margin: 0;
}

/* v25: global campaign index */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.global-index-dialog {
  width: min(840px, calc(100vw - 32px));
  height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgb(0 0 0 / 60%);
}

.global-index-dialog::backdrop {
  background: rgb(5 6 8 / 76%);
  backdrop-filter: blur(3px);
}

.global-index-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
  padding: 20px;
}

.global-index-header {
  position: relative;
}

.global-index-controls {
  display: grid;
  gap: 12px;
  padding: 14px 0;
}

#global-index-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101216;
  color: var(--text);
}

#global-index-search:focus {
  border-color: var(--accent);
  outline: 2px solid rgb(217 164 65 / 18%);
}

.global-index-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.global-index-tabs button {
  padding: 8px 12px;
}

.global-index-tabs button.is-active {
  border-color: #7b5a22;
  background: #5b421d;
  color: #fff4d8;
}

.global-index-tabs span {
  margin-left: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.global-index-content {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.global-index-list {
  display: grid;
  gap: 10px;
}

.global-index-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #101216;
}

.global-index-item h3 {
  margin: 0;
  font-size: 0.98rem;
}

.global-index-item p {
  margin: 6px 0 0;
  color: #b8bec7;
  font-size: 0.84rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.global-index-links {
  display: grid;
  gap: 7px;
  min-width: 150px;
}

.global-index-hex-link {
  padding: 8px 10px;
  text-align: left;
  font-size: 0.78rem;
}

.global-index-hex-link.origin {
  border-color: #725726;
  background: #332817;
  color: #f0c56c;
}

.global-index-hex-link.destination {
  border-color: #2d527a;
  background: #172435;
  color: #8fc2ff;
}

.global-index-empty {
  margin: 20px 0;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 620px) {
  .global-index-item {
    grid-template-columns: 1fr;
  }
  .global-index-links {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
  }
}

/* v26 Global Index sorting */
.global-index-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(180px, 0.42fr);
  gap: 10px;
  align-items: center;
}

.global-index-sort-label {
  color: var(--muted-text, #b8b3aa);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#global-index-sort {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(13, 16, 20, 0.92);
  color: inherit;
  padding: 8px 34px 8px 10px;
}

#global-index-sort:focus-visible {
  outline: 2px solid #5aa7ff;
  outline-offset: 2px;
}

@media (max-width: 680px) {
  .global-index-toolbar {
    grid-template-columns: 1fr;
  }

  .global-index-sort-label {
    margin-bottom: -6px;
  }
}


/* v27 fog of war */
.fog-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.15rem 0 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.fog-checkbox-row input { width: 1rem; height: 1rem; margin: 0; }
#hex-overlay.fog-preview-active .hex-hit-area.fogged {
  fill: rgba(8, 12, 18, 0.86);
  stroke: rgba(20, 26, 34, 0.95);
  stroke-width: 4;
}
#hex-overlay.fog-preview-active .hex-hit-area.fogged:hover {
  fill: rgba(12, 20, 32, 0.78);
}
#hex-overlay.fog-preview-active .hex-hit-area.fogged.selected {
  stroke: #ff8a00;
  stroke-width: 8;
}
#hex-overlay.fog-preview-active .hex-hit-area.fogged.linked-preview {
  stroke: #2f9fff;
  stroke-width: 8;
}


/* v28: top-bar campaign map selector */
.map-selector {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.map-selector select {
  width: 170px;
  max-width: 170px;
  padding: 6px 30px 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
}

.map-selector select:hover,
.map-selector select:focus-visible {
  border-color: #58606d;
}

.map-selector select:disabled {
  opacity: 0.65;
  cursor: wait;
}


/* v29: hex grid calibration dialog */
.grid-setup-dialog {
  width: min(620px, calc(100vw - 32px));
  position: fixed;
  inset: 96px 24px auto auto;
  margin: 0;
  z-index: 30;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgb(0 0 0 / 60%);
}
.grid-setup-dialog::backdrop { background: transparent; backdrop-filter: none; }
#grid-setup-form { padding: 20px; }
.grid-setup-intro { margin: 10px 0 16px; color: var(--muted); line-height: 1.45; }
.grid-setup-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-setup-fields label { display: grid; gap: 6px; color: #d9dde3; font-size: 0.84rem; font-weight: 700; }
.grid-setup-fields input { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 7px; background: #101216; color: var(--text); }
.grid-setup-fields input:focus { border-color: var(--accent); outline: 2px solid rgb(217 164 65 / 18%); }
@media (max-width: 620px) { .grid-setup-fields { grid-template-columns: 1fr; } }


/* Build 31: development data source controls */
.toolbar-primary-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#data-source-button {
  border-color: #4a5563;
  background: #1b2027;
  color: #cfd6df;
}

.data-source-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgb(0 0 0 / 55%);
}

.data-source-dialog::backdrop {
  background: rgb(5 6 8 / 72%);
  backdrop-filter: blur(3px);
}

.data-source-shell {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 20px;
  overflow-y: auto;
}

.data-source-section {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111318;
}

.data-source-section p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.data-source-label {
  display: block;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.data-source-row button,
.data-source-section button {
  padding: 8px 11px;
}

.data-source-status {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.data-source-status[data-state="ok"] { color: #8dd69b; }
.data-source-status[data-state="warning"] { color: #e2bd69; }
.data-source-status[data-state="error"] { color: #ff8d8d; }

.data-source-rules {
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111318;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.data-source-rules summary {
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.data-source-rules ul {
  margin: 8px 0;
  padding-left: 22px;
}

.data-source-rules p:last-child {
  margin-bottom: 0;
}

/* v32: authenticated PocketBase accounts and campaign roles */
.access-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  color: #cbd5e1;
  background: rgba(255,255,255,.05);
}
.access-badge[data-role="owner"] { color: #f6d58b; }
.access-badge[data-role="editor"] { color: #9fd7ff; }
.access-badge[data-role="viewer"] { color: #b9c1cc; }
.account-dialog {
  width: min(480px, calc(100vw - 32px));
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  padding: 0;
  background: #18202b;
  color: #eef2f7;
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
}
.account-dialog::backdrop { background: rgba(4,8,14,.62); backdrop-filter: blur(3px); }
.account-shell { padding: 20px; }
.account-intro { color: #b8c1cd; line-height: 1.5; margin: 8px 0 16px; }
#account-login-form { display: grid; gap: 12px; }
#account-login-form label { display: grid; gap: 6px; font-size: 13px; color: #cbd5df; }
#account-login-form input {
  width: 100%; box-sizing: border-box; padding: 10px 11px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.16); background: #101720; color: #f3f6fa;
}
.account-user-card { display: grid; gap: 4px; padding: 14px; margin: 8px 0 14px; border-radius: 10px; background: rgba(255,255,255,.05); }
.account-user-card span { color: #b8c1cd; font-size: 13px; }
#account-role { text-transform: capitalize; font-weight: 700; }
#hex-form.is-read-only input,
#hex-form.is-read-only textarea { opacity: .78; }
.entity-card:disabled { cursor: default; opacity: .88; }
.entity-card:disabled .entity-card-action { color: #8f9aa8; }


/* Build 33: Owner campaign access management */
#open-access-management {
  border-color: #70562b;
  background: #231d14;
  color: #e9c87d;
}
.access-management-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(820px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 70px rgb(0 0 0 / 55%);
}
.access-management-dialog::backdrop { background: rgb(5 6 8 / 72%); backdrop-filter: blur(3px); }
.access-management-shell { position: relative; display: grid; gap: 14px; padding: 20px; overflow-y: auto; }
.access-intro { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.access-section { display: grid; gap: 10px; padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: #111318; }
.access-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.access-section-heading > div { display: grid; gap: 4px; }
.access-members-list { display: grid; gap: 8px; }
.access-member {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 130px auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px;
  background: rgba(255,255,255,.025);
}
.access-member-identity { min-width: 0; display: grid; gap: 2px; }
.access-member-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.access-member-identity span { color: var(--muted); font-size: .78rem; }
.access-member select,
.access-add-form select,
.access-add-form input {
  width: 100%; box-sizing: border-box; padding: 8px 9px; border: 1px solid var(--border);
  border-radius: 7px; background: #101216; color: var(--text);
}
.access-member button { padding: 8px 10px; }
.access-add-form { display: grid; grid-template-columns: minmax(180px, 1fr) 140px auto; gap: 10px; align-items: end; }
.access-add-form label { display: grid; gap: 6px; color: #d9dde3; font-size: .82rem; font-weight: 700; }
.access-empty { margin: 0; color: var(--muted); font-size: .84rem; }
.access-self-note { color: #d9b76f !important; }
@media (max-width: 680px) {
  .access-member { grid-template-columns: 1fr 120px; }
  .access-member .access-save-role, .access-member .access-remove-member { width: 100%; }
  .access-add-form { grid-template-columns: 1fr; }
}
