/* Compound uses the platform design tokens from /css/nexus.css —
   local vars only alias them so component rules stay short. */
:root {
  --compound-bg: var(--deep-space, #0a0e1a);
  --compound-panel: var(--surface, #111827);
  --compound-border: var(--border, #2d3748);
  --compound-text: var(--text, #f3f4f6);
  --compound-text-dim: var(--text-muted, #9ca3af);
  --compound-accent: var(--accent, #3b82f6);
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden; /* the app never scrolls — panels scroll internally */
}

compound-planner,
.compound-planner-layout {
  display: block;
  height: 100vh;
}

.compound-planner-layout {
  display: grid;
  /* minmax(0,1fr): without it the fr track grows to the palette's content
     height and the whole page scrolls */
  grid-template-rows: 48px minmax(0, 1fr);
  overflow: hidden;
}

.compound-main {
  display: grid;
  grid-template-columns: 210px 1fr 250px;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.compound-properties {
  background: var(--compound-panel);
  border-left: 1px solid var(--compound-border);
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compound-properties-empty {
  color: var(--compound-text-dim);
  font-size: 13px;
  padding: 4px 6px;
}

.compound-properties label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* caption text: small-caps utility style; inputs below reset the transform */
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--compound-text-dim);
  padding: 0 6px;
}

.compound-properties label input,
.compound-properties label select,
.compound-properties label textarea {
  text-transform: none;
  font-weight: 400;
  letter-spacing: normal;
}

.compound-properties textarea {
  background: var(--compound-bg);
  border: 1px solid var(--compound-border);
  color: var(--compound-text);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

.compound-properties input,
.compound-properties select {
  background: var(--compound-bg);
  border: 1px solid var(--compound-border);
  color: var(--compound-text);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 13px;
}

.compound-properties-meta {
  color: var(--compound-text-dim);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0 6px;
}

.compound-properties-delete {
  margin: 4px 6px;
  border-color: #e74c3c;
  color: #e74c3c;
}

#compound-map {
  width: 100%;
  height: 100%;
  position: relative;
}

.compound-left-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--compound-panel);
  border-right: 1px solid var(--compound-border);
}

/* The Lit host is the actual flex child — collapse it so the inner
   .compound-palette div takes the flex slot and can shrink+scroll */
compound-palette {
  display: contents;
}

.compound-left-column .compound-palette {
  flex: 1;
  min-height: 0; /* flex items refuse to shrink without this — palette must scroll, not grow */
  border-right: none;
}

.compound-layers-floating {
  display: contents;
}

.compound-layers-floating .compound-layers {
  position: absolute;
  top: 12px;
  left: calc(210px + 12px); /* same breathing room from the palette as from the toolbar */
  z-index: 15;
  background: rgba(29, 32, 38, 0.92);
  border: 1px solid var(--compound-border);
  border-radius: 8px;
  padding: 8px;
  min-width: 140px;
}

.compound-toolbar-opacity {
  width: 90px;
  flex-shrink: 0;
}

/* Range inputs — flat 4px track with a compact accent thumb */
.compound-toolbar input[type="range"],
.compound-sun-card input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--compound-border);
  outline: none;
  cursor: pointer;
}

.compound-toolbar input[type="range"]::-webkit-slider-thumb,
.compound-sun-card input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--compound-text);
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: background 0.15s ease;
}

.compound-toolbar input[type="range"]:hover::-webkit-slider-thumb,
.compound-sun-card input[type="range"]:hover::-webkit-slider-thumb {
  background: var(--compound-accent);
}

.compound-toolbar input[type="range"]::-moz-range-thumb,
.compound-sun-card input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--compound-text);
  border: none;
}

.compound-toolbar input[type="range"]::-moz-range-track,
.compound-sun-card input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--compound-border);
}

.compound-run-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  border-radius: 4px;
}

.compound-run-row.selected {
  background: rgba(46, 204, 113, 0.12);
}

.compound-run-row select {
  flex: 1;
  min-width: 0;
}

.compound-run-row input {
  width: 52px;
}

.compound-run-row-remove {
  background: transparent;
  border: none;
  color: var(--compound-text-dim);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.compound-run-row-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

.compound-run-row-remove:disabled {
  opacity: 0.3;
  cursor: default;
}

.compound-distance-card {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(29, 32, 38, 0.96);
  border: 1px solid var(--compound-accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}

.compound-distance-card input {
  width: 130px;
  background: var(--compound-bg);
  border: 1px solid var(--compound-border);
  color: var(--compound-text);
  border-radius: 4px;
  padding: 5px 8px;
}

.compound-properties input[type="color"] {
  padding: 2px;
  height: 30px;
  cursor: pointer;
}

.compound-layers-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--compound-text-dim);
  padding: 4px 6px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.compound-layers-item:hover {
  color: var(--compound-text);
}

.compound-layers-item input[type="checkbox"] {
  accent-color: var(--compound-accent);
  width: 13px;
  height: 13px;
}

compound-runlist-panel {
  display: contents;
}

.compound-runlist {
  position: absolute;
  left: 212px;
  right: 262px;
  bottom: 12px;
  max-height: 45%;
  overflow-y: auto;
  background: rgba(29, 32, 38, 0.96);
  border: 1px solid var(--compound-border);
  border-radius: 8px;
  padding: 12px;
  z-index: 20;
}

.compound-runlist-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.compound-runlist-header .compound-palette-heading {
  flex: 1;
}

.compound-runlist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.compound-runlist-table th {
  text-align: left;
  color: var(--compound-text-dim);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  border-bottom: 1px solid var(--compound-border);
}

.compound-runlist-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--compound-border);
}

.compound-runlist-unmapped {
  color: var(--compound-text-dim);
  font-size: 11px;
}

.compound-runlist-warning {
  color: #e74c3c;
  font-size: 11px;
  margin-left: 6px;
  white-space: nowrap;
}

.compound-runlist-totals {
  display: flex;
  gap: 16px;
  padding: 8px;
  font-size: 12px;
  color: var(--compound-text-dim);
}

.compound-runlist-add {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--compound-border);
}

.compound-runlist-add input,
.compound-runlist-add select {
  background: var(--compound-bg);
  border: 1px solid var(--compound-border);
  color: var(--compound-text);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 13px;
}

.compound-runlist-add input[name="label"] {
  flex: 1;
}

.compound-palette {
  background: var(--compound-panel);
  border-right: 1px solid var(--compound-border);
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compound-palette.disabled {
  opacity: 0.5;
}

.compound-palette-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--compound-text-dim);
  padding: 4px 6px;
}

/* Collapsible group headings (palette) */
button.compound-palette-heading-toggle {
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 600;
}

button.compound-palette-heading-toggle:hover {
  color: var(--compound-text);
}

.compound-palette-chevron {
  width: 10px;
  font-size: 9px;
  flex-shrink: 0;
}

.compound-palette .compound-palette-heading {
  position: sticky;
  top: -8px;
  background: var(--compound-panel);
  z-index: 2;
  /* symmetric vertical padding: collapsed headings sit centered between
     their divider lines instead of hugging the one below */
  margin-top: 0;
  /* 12/8 not 10/10: the palette's 4px flex gap adds below, so this centers
     the text between its divider lines */
  padding-top: 12px;
  padding-bottom: 8px;
  border-top: 1px solid var(--compound-border);
}

.compound-palette .compound-palette-heading:first-child {
  margin-top: 0;
  border-top: none;
}

.compound-palette-glyph {
  width: 10px;
  text-align: center;
  color: var(--compound-text-dim);
  flex-shrink: 0;
}

.compound-palette-item.active .compound-palette-glyph {
  color: inherit;
}

.compound-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--compound-text);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.compound-palette-item:hover {
  border-color: var(--compound-border);
}

.compound-palette-item.active {
  background: var(--accent-light, rgba(59, 130, 246, 0.15));
  border-color: var(--compound-accent);
  color: var(--compound-text);
}

.compound-palette-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.compound-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--compound-panel);
  border-bottom: 1px solid var(--compound-border);
  /* no overflow clipping — the Tools dropdown hangs below the bar */
}

.compound-toolbar-plan {
  font-size: 13px;
  font-weight: 600;
  color: var(--compound-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  flex-shrink: 1;
}

.compound-toolbar-menu {
  position: relative;
  flex-shrink: 0;
}

.compound-toolbar-menu-items {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 180px;
  background: var(--compound-panel);
  border: 1px solid var(--compound-border);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  z-index: 60;
  padding: 4px;
}

/* hover bridge so the menu doesn't close crossing the 4px gap */
.compound-toolbar-menu-items::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  width: 100%;
  height: 8px;
}

.compound-toolbar-menu:hover .compound-toolbar-menu-items,
.compound-toolbar-menu:focus-within .compound-toolbar-menu-items {
  display: flex;
  flex-direction: column;
}

.compound-toolbar-menu-items button {
  background: none;
  border: none;
  color: var(--compound-text-dim);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.compound-toolbar-menu-items button:hover {
  color: var(--compound-text);
  background: var(--compound-bg);
}

.compound-toolbar-title {
  font-weight: 600;
  letter-spacing: 0.04em;
  /* Module identity color + brand font per brand vars — identity use only */
  color: var(--nx-compound, #e8564b);
  font-family: 'WC Roughtrad', sans-serif;
  font-size: 17px;
  text-decoration: none;
}

.compound-toolbar-title:hover {
  text-decoration: underline;
}

/* Google-Docs-style collaborator avatars — pinned at the toolbar's right
   end so appearing/leaving never shifts the rest of the bar */
.compound-presence-avatars {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding-left: 4px;
}

.compound-presence-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  border: 2px solid var(--compound-panel);
  margin-left: -7px;
  cursor: default;
}

.compound-presence-avatar:first-child {
  margin-left: 0;
}

.compound-toolbar-group {
  display: flex;
  gap: 4px;
}

.compound-toolbar-btn {
  background: transparent;
  border: 1px solid var(--compound-border);
  color: var(--compound-text-dim);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
}

.compound-toolbar-btn:hover {
  color: var(--compound-text);
  border-color: var(--compound-text-dim);
}

.compound-toolbar-btn.active {
  color: #ffffff;
  background: var(--compound-accent);
  border-color: var(--compound-accent);
}

.compound-toolbar-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.compound-toolbar-select {
  background: var(--compound-bg);
  border: 1px solid var(--compound-border);
  color: var(--compound-text);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  max-width: 260px;
  flex-shrink: 0;
  font-family: inherit;
}

.compound-toolbar-status {
  color: var(--compound-text-dim);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compound-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.compound-dialog {
  background: var(--compound-panel);
  border: 1px solid var(--compound-border);
  border-radius: 8px;
  padding: 24px;
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compound-dialog h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.compound-dialog label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--compound-text-dim);
}

.compound-dialog input {
  background: var(--compound-bg);
  border: 1px solid var(--compound-border);
  color: var(--compound-text);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
}

.compound-dialog-error {
  color: #e74c3c;
  font-size: 12px;
}

.compound-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.compound-runlist-dim {
  color: var(--compound-text-dim);
}

.compound-runlist-actions {
  white-space: nowrap;
}

compound-inventory-panel,
compound-layers-panel {
  display: contents;
}

.compound-photo-gallery {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 6px;
}

.compound-photo-item img {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--compound-border);
  display: block;
}

.compound-photo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--compound-text-dim);
  overflow: hidden;
}

.compound-photo-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compound-sun-card input[type="range"] {
  width: 180px;
  accent-color: #ffd400;
}

/* ── Plans library page ── */

.compound-plans-body {
  background: var(--compound-bg);
  color: var(--compound-text);
}

/* Single first-child wrapper: nexus.css sizes body>:first-child to
   100vh - 36px on pages with the footer nav. Content scrolls inside. */
.compound-plans-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 36px);
}

.compound-plans-shell compound-plans {
  display: block;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Standard Nexus top bar (module pages define these locally — they are
   not in nexus.css). Markup mirrors kinetica/templates.html. */
.compound-plans-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  min-height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.compound-plans-topbar .top-bar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.compound-plans-topbar .top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.compound-plans-topbar .top-bar-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.compound-plans-topbar .top-bar-nav a {
  font-size: 0.825rem;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-decoration: none;
}

.compound-plans-topbar .top-bar-nav a:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.compound-plans-topbar .top-bar-nav a.active {
  color: var(--accent);
  background: var(--accent-light);
}

.compound-plans-topbar .user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.compound-plans-topbar .user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.compound-plans-topbar .user-name {
  color: var(--text);
  font-weight: 500;
}

.compound-plans-topbar .user-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.compound-plans-topbar #logoutBtn {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.compound-plans-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

.compound-plans-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 16px;
  margin-bottom: 24px;
}

.compound-plans-title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}

.compound-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.compound-plan-card {
  background: var(--compound-panel);
  border: 1px solid var(--compound-border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.compound-plan-card:hover {
  border-color: var(--compound-accent);
  transform: translateY(-2px);
}

.compound-plan-card-thumb {
  height: 160px;
  background: #1a2030;
  position: relative;
}

.compound-plan-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.compound-plan-card-nothumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--compound-text-dim);
  font-size: 13px;
}

.compound-plan-card-body {
  padding: 12px 14px 6px;
}

.compound-plan-card-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.compound-plan-card-meta {
  font-size: 12px;
  color: var(--compound-text-dim);
}

.compound-plan-card-updated {
  margin-top: 2px;
}

.compound-plan-card-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px 14px;
}

.compound-plans-empty {
  text-align: center;
  color: var(--compound-text-dim);
  padding: 80px 0;
}

.compound-plans-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

/* ── Photo lightbox ── */

.compound-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(6, 8, 14, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
}

.compound-lightbox-figure {
  margin: 0;
  max-width: min(90vw, 1400px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compound-lightbox-figure img {
  max-width: 100%;
  max-height: calc(90vh - 32px);
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.compound-lightbox-figure figcaption {
  text-align: center;
  font-size: 13px;
  color: var(--compound-text-dim);
}

.compound-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: transparent;
  border: none;
  color: var(--compound-text);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
}

.compound-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(29, 32, 38, 0.8);
  border: 1px solid var(--compound-border);
  color: var(--compound-text);
  font-size: 28px;
  line-height: 1;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
}

.compound-lightbox-nav:hover {
  border-color: var(--compound-accent);
}

.compound-lightbox-nav.prev { left: 24px; }
.compound-lightbox-nav.next { right: 24px; }

.compound-photo-item img {
  cursor: zoom-in;
}

.compound-plans-header-actions {
  display: flex;
  gap: 10px;
}

.compound-toolbar-slider {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 7px; /* clears the 13px thumb that overhangs the 4px track */
  flex-shrink: 0;
}

.compound-toolbar-slider span {
  font-size: 8.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--compound-text-dim);
  text-align: left;
  line-height: 1;
  padding-left: 1px;
}

/* Toolbar host must fill its 48px grid row from the FIRST paint — with
   display:contents the row is empty until the child component renders, the
   map lands in row 1 and MapLibre sizes its canvas to 48px */
compound-toolbar {
  display: block;
  height: 100%;
  min-height: 0;
}

.compound-toolbar {
  box-sizing: border-box;
  height: 100%;
}

/* Layers panel header — brighter + bold to separate from the checklist */
.compound-layers-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--compound-text);
  padding: 4px 6px 6px;
}

.compound-layers-row {
  display: flex;
  align-items: center;
}

.compound-layers-row .compound-layers-item {
  flex: 1;
}

.compound-layers-remove {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.compound-layers-row:hover .compound-layers-remove {
  opacity: 1;
}

.compound-layers-add {
  background: none;
  border: 1px dashed var(--compound-border);
  border-radius: 4px;
  color: var(--compound-text-dim);
  font-size: 11px;
  font-family: inherit;
  padding: 4px 8px;
  margin: 6px 6px 2px;
  cursor: pointer;
}

.compound-layers-add:hover {
  color: var(--compound-text);
  border-color: var(--compound-text-dim);
}

/* ── Public read-only viewer (mobile-friendly) ── */

compound-viewer {
  display: block;
  height: 100vh;
  height: 100dvh; /* mobile browsers: exclude collapsing chrome */
}

.compound-viewer {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.compound-viewer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--compound-panel);
  border-bottom: 1px solid var(--compound-border);
  flex-shrink: 0;
}

.compound-viewer-brand {
  flex-shrink: 0;
}

.compound-viewer-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.compound-viewer-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compound-viewer-meta {
  font-size: 11px;
  color: var(--compound-text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compound-viewer-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--compound-text-dim);
  border: 1px solid var(--compound-border);
  border-radius: 10px;
  padding: 3px 10px;
  flex-shrink: 0;
}

.compound-viewer-map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

.compound-viewer-map-wrap #compound-map {
  position: absolute;
  inset: 0;
}

.compound-viewer-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  display: flex;
  gap: 6px;
}

.compound-viewer-controls .compound-toolbar-btn {
  background: rgba(29, 32, 38, 0.92);
  min-height: 34px; /* touch target */
  padding: 6px 14px;
}

.compound-viewer-layers {
  position: absolute;
  top: 52px;
  left: 10px;
  z-index: 20;
  background: rgba(29, 32, 38, 0.95);
  border: 1px solid var(--compound-border);
  border-radius: 8px;
  padding: 8px;
  min-width: 150px;
  max-height: 60%;
  overflow-y: auto;
}

.compound-viewer-layers .compound-layers-item {
  min-height: 30px; /* comfortable touch targets */
}

.compound-viewer-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--compound-text-dim);
  font-size: 15px;
  padding: 24px;
  text-align: center;
}

@media (max-width: 640px) {
  .compound-viewer-bar {
    padding: 6px 10px;
    gap: 8px;
  }
  .compound-viewer-brand {
    display: none; /* small screens: plan name is the headline */
  }
  .compound-viewer-controls {
    top: auto;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
  }
  .compound-viewer-layers {
    top: auto;
    bottom: 74px;
    left: 10px;
    right: 10px;
  }
}

/* Plan name is a click-to-rename button styled as plain text */
button.compound-toolbar-plan {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

button.compound-toolbar-plan:hover {
  text-decoration: underline dotted;
}

.compound-toolbar-menu-sep {
  height: 1px;
  background: var(--compound-border);
  margin: 4px 6px;
}

.compound-toolbar-versions {
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
}

.compound-toolbar-version-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 4px;
}

.compound-toolbar-version-row:hover {
  background: var(--compound-bg);
}

.compound-toolbar-version-name {
  flex: 1;
  font-size: 13px;
  color: var(--compound-text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 5px 6px;
}

.compound-toolbar-version-row button {
  background: none;
  border: none;
  color: var(--compound-text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.compound-toolbar-version-row button:hover {
  color: var(--compound-text);
  background: var(--compound-border);
}

/* Viewer display sliders (inside the Layers/Display sheet) */
.compound-viewer-slider {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 6px 8px;
}

.compound-viewer-slider span {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--compound-text-dim);
}

.compound-viewer-layers input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--compound-border);
  outline: none;
  cursor: pointer;
  width: 100%;
}

.compound-viewer-layers input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; /* touch-sized */
  height: 16px;
  border-radius: 50%;
  background: var(--compound-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.compound-viewer-layers input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--compound-text);
  border: none;
}

.compound-viewer-layers-subhead {
  border-top: 1px solid var(--compound-border);
  margin-top: 4px;
  padding-top: 10px;
}

/* Viewer inspect card — tap an element to read its label/note/photos */
.compound-viewer-info {
  position: absolute;
  bottom: 16px;
  left: 10px;
  z-index: 25;
  width: 300px;
  max-width: calc(100vw - 20px);
  max-height: 45%;
  overflow-y: auto;
  background: rgba(29, 32, 38, 0.96);
  border: 1px solid var(--compound-border);
  border-radius: 8px;
  padding: 12px;
}

.compound-viewer-info-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.compound-viewer-info-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.compound-viewer-info-label {
  font-size: 14px;
  font-weight: 600;
}

.compound-viewer-info-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--compound-text-dim);
}

.compound-viewer-info-note {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--compound-text);
  white-space: pre-wrap;
  user-select: text;
}

.compound-viewer-info-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.compound-viewer-info-gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 4px;
  cursor: zoom-in;
}

@media (max-width: 640px) {
  .compound-viewer-info {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 74px; /* above the control cluster */
  }
}

/* ── 3D view (Compound Phase 3) ── */

#compound-three {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 210px;   /* clear the palette column */
  right: 250px;  /* clear the properties column */
  z-index: 12;
  background: #10141f;
}

#compound-three canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.compound-three-controls {
  position: absolute;
  top: 12px;
  left: calc(210px + 12px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(29, 32, 38, 0.92);
  border: 1px solid var(--compound-border);
  border-radius: 8px;
  padding: 8px 10px;
}

.compound-three-hint {
  font-size: 11px;
  color: var(--compound-text-dim);
  white-space: nowrap;
}

.compound-three-align {
  color: #ffd75e;
  font-weight: 600;
}

/* Scan eraser editor (3D cleanup) */
.compound-eraser-card {
  position: absolute;
  top: 64px;
  right: calc(250px + 12px); /* right side — the layers panel owns top-left */
  left: auto;
  z-index: 20;
  background: rgba(29, 32, 38, 0.95);
  border: 1px solid var(--compound-border);
  border-radius: 8px;
  padding: 10px;
  min-width: 320px;
  max-height: 50%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compound-eraser-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.compound-eraser-idx {
  font-size: 11px;
  color: var(--compound-text-dim);
  width: 16px;
  padding-bottom: 6px;
}

.compound-eraser-row label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--compound-text-dim);
}

.compound-eraser-row input {
  width: 52px;
  background: var(--compound-bg);
  border: 1px solid var(--compound-border);
  color: var(--compound-text);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
}

.compound-eraser-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

/* Layers panel shares the 3D view — sits below the 3D controls bar */
.compound-layers-3d .compound-layers {
  top: 64px;
  z-index: 22;
}

.compound-inline-check {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}

.compound-inline-check input[type="checkbox"] {
  accent-color: var(--compound-accent);
}


.compound-eraser-move {
  padding: 2px 8px;
  font-size: 13px;
  flex-shrink: 0;
}
