@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Space+Grotesk:wght@400;500;600&display=swap");

#land-drawing-canvas {
  position: absolute;
  top: 0;
  left: 0;
  /* Keep manual land/water edits above the base map, but below ocean waves. */
  z-index: 1;
  /* This lets mouse clicks pass through to the map below */
  pointer-events: none; 
}

#land-preview-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

#paint-layer-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  opacity: 1;
  display: block;
}

#land-brush-preview {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 12;
  display: none;
  border-radius: 50%;
  border: 1px solid rgba(245, 238, 219, 0.95);
  box-shadow: 0 0 0 1px rgba(26, 39, 53, 0.8);
  background: transparent;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* ==========================================================================
   DOT PATTERN
   ========================================================================== */
.dot-pattern-dot {
  position: absolute;
  border-radius: 50%;
}

/* ==========================================================================
   GLOBAL / UTILITIES
   ========================================================================== */
#continent-generator fieldset { border: 0; }

#universal-font option.not-installed {
  color: #999;
  font-style: italic;
}

.map-label svg { pointer-events: none; }

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 0.8em;
}
.form-row label { flex: 1; margin-bottom: 0; }

.travel-time-helper-text {
  margin: 0 0 12px;
  opacity: 0.82;
}

#travel-time-panel {
  display: flex;
  flex-direction: column;
}

#travel-time-panel .form-row {
  margin-bottom: 0;
}

#travel-time-panel input[type="number"],
#travel-time-panel input[type="text"],
#travel-time-panel select {
  width: 100%;
}

.travel-time-result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.travel-time-result-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-height: 84px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(26, 39, 53, 0.52);
  border: 1px solid rgba(220, 154, 29, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.travel-time-result-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}

.travel-time-result-card strong {
  color: #F5EEDB;
  font-family: 'Libre Baskerville', serif;
  font-size: 0.98rem;
  line-height: 1.3;
}

.travel-time-summary {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid #DC9A1D;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  line-height: 1.45;
}

.travel-time-status {
  margin: 0;
  font-size: 0.85em;
  line-height: 1.45;
  color: rgba(245, 238, 219, 0.78);
}

.travel-time-status.is-warning {
  color: #F4CF7C;
}

.travel-time-status.is-ready {
  color: #DDC39A;
}

.input-row {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 1em;
}

.input-row > label {
  flex: 1 1 220px;
  margin-bottom: 0;
}

.object-actions-panel {
  margin-top: 12px;
}

.object-actions-panel:not(.object-actions-floating) {
  padding-top: 12px;
  border-top: 1px solid rgba(220, 154, 29, 0.28);
}

#object-actions-panel .control-group {
  margin: 0;
}

#object-actions-panel .control-group + .control-group {
  margin-top: 16px;
}

.object-actions-title::after {
  content: '▸';
  font-size: 0.95em;
  opacity: 0.85;
  transition: transform 0.18s ease;
}

.preview-zoom-utility-btn {
  width: 100%;
  margin-top: 10px;
}

#object-actions-panel.object-actions-floating {
  position: fixed;
  top: 112px;
  left: 24px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  margin-top: 0;
  padding-top: 0;
  border: 1px solid #DC9A1D;
  border-radius: 0;
  background: var(--chrome-bg);
  box-shadow: none;
  overflow: hidden;
  z-index: 30;
}

#object-actions-panel.object-actions-floating[hidden] {
  display: none !important;
}

.object-actions-panel-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(220, 154, 29, 0.24);
  background: transparent;
  cursor: move;
  user-select: none;
}

.object-actions-floating .object-actions-title {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--chrome-fg);
  cursor: inherit;
}

.object-actions-floating .object-actions-title::after {
  content: none;
}

.object-actions-close-btn {
  padding: 0;
  margin: 0;
  border: 1px solid rgba(220, 154, 29, 0.55);
  border-radius: 0;
  background: transparent;
  color: #DDC39A;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.object-actions-close-btn:hover {
  background: rgba(220, 154, 29, 0.1);
}

#object-actions-panel.object-actions-floating .object-actions-body {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0;
  overflow: auto;
}

.object-actions-quick-tools {
  margin-bottom: 8px;
}

.object-actions-button-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
}

.object-actions-button-grid--quick {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#object-actions-panel.object-actions-floating .object-actions-button-grid > button {
  width: 100%;
  white-space: normal;
  word-break: normal;
}

.object-actions-span-2 {
  grid-column: span 2;
}

.object-selection-status {
  margin: 0 0 10px;
  opacity: 0.86;
}

.object-arrange-note {
  margin: 0 0 10px;
  opacity: 0.8;
}

#object-actions-panel .object-selection-status {
  margin: 0 0 8px;
}

.browser-performance-warning {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid rgba(220, 154, 29, 0.92);
  border-radius: 6px;
  background: rgba(220, 154, 29, 0.09);
  color: #F4CF7C;
  font-size: 0.84em;
  line-height: 1.45;
}

.shape-object-actions {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(220, 154, 29, 0.24);
}

.shape-object-actions[hidden] {
  display: none !important;
}

.shape-object-actions-title {
  margin: 0 0 10px;
  font-weight: 700;
}

.shape-fill-controls,
#shape-fill-controls,
#border-fill-controls {
  margin-top: 12px;
}

#shape-hatched-fill-controls,
#border-hatched-fill-controls {
  margin-top: 10px;
}

.shape-fill-note {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(220, 154, 29, 0.28);
  opacity: 0.82;
}

.shape-fill-toggle-row {
  margin-top: 10px;
  justify-content: space-between;
}

.stamp-toggle-row {
  white-space: nowrap;
  margin-bottom: 0 !important;
}

.shape-size-inputs {
  margin-top: 10px;
}

.shape-size-inputs label {
  flex: 0 0 auto;
}

.shape-size-inputs input[type="number"] {
  width: 5.5em;
  min-width: 5.5em;
  max-width: 5.5em;
}


/* Single source of truth for shared colors/sizes */
#continent-generator {
  --ink-color: #5a442a;
  --btn-height: 36px;
  --btn-bg: #DDC39A;
  --btn-fg: #1A2735;
  --btn-bg-hover: #333;
  --btn-fg-hover: #fff;
  --btn-radius: 4px;
  --btn-gap: 12px;        /* unified gap */
  --chrome-bg: #1A2735;
  --chrome-fg: #F5EEDB;
  --map-backdrop: #48525D;
  --control-column-max-height: calc(100vh - 150px);
  background-color: var(--map-backdrop);
  box-sizing: border-box;
  padding: 20px;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: visible;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  text-align: left;
}

#continent-generator *,
#continent-generator *::before,
#continent-generator *::after {
  -webkit-user-select: none;
  user-select: none;
}

#continent-generator img,
#continent-generator svg,
#continent-generator canvas,
#continent-generator .placed-image,
#continent-generator .image-selection-item {
  -webkit-user-drag: none;
}

#continent-generator input,
#continent-generator textarea,
#continent-generator select,
#continent-generator option,
#continent-generator [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

#top-brand-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  width: calc(100% + 40px);
  margin: -20px -20px 20px;
  padding: 14px 28px;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(26, 39, 53, 0.98), rgba(26, 39, 53, 0.94));
  border-bottom: 2px solid #DC9A1D;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.brand-mark {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand-mark img {
  display: block;
  height: 50px;
  width: auto;
}

.brand-paid-message {
  margin: 0;
  min-width: 0;
  max-height: calc(1.45em * 2);
  overflow: hidden;
  padding: 0 8px;
  color: rgba(245, 238, 219, 0.92);
  font-family: 'Libre Baskerville', serif;
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: center;
  text-wrap: balance;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.brand-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.brand-nav a {
  color: var(--chrome-fg);
  text-decoration: none;
  font-family: 'Libre Baskerville', serif;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.brand-nav a:hover {
  color: #DDC39A;
  background-color: rgba(220, 154, 29, 0.14);
  border-color: rgba(220, 154, 29, 0.55);
}

.brand-nav .brand-contact-link {
  font-size: 0.66rem;
  letter-spacing: 0.01em;
  text-transform: none;
}

@media (max-width: 1100px) {
  #top-brand-bar {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 12px;
  }

  .brand-nav {
    justify-content: center;
  }
}

#site-footer {
  width: calc(100% + 40px);
  margin: 28px -20px -20px;
  padding: 18px 28px 24px;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(26, 39, 53, 0.96), rgba(26, 39, 53, 0.99));
  border-top: 2px solid #DC9A1D;
  flex-shrink: 0;
}

.site-footer-inner {
  max-width: 1100px;
}

.site-footer-title {
  color: #DDC39A;
  font-family: 'Libre Baskerville', serif;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-footer-copy {
  margin: 8px 0 0;
  line-height: 1.5;
  color: rgba(245, 238, 219, 0.92);
}

.site-footer-copy a {
  color: #DDC39A;
  text-decoration: none;
}

/* ==========================================================================
   RAY LINE GENERATOR
   ========================================================================== */

#ray-lines-container {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 2;
}
#ray-lines-canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  -webkit-mask-image: none; mask-image: none;
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */

#generator-workspace {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: visible;
}
#control-nav-column {
  flex-shrink: 0;
  background-color: var(--chrome-bg);
  border: 2px solid #DC9A1D;
  border-radius: 8px;
  padding: 6px 4px;
  height: auto;
  max-height: var(--control-column-max-height);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Middle column (controls) */
#control-panel-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  flex-shrink: 0;
  border: 2px solid #DC9A1D;
  height: auto;
  max-height: var(--control-column-max-height);
  box-sizing: border-box;
  background-color: var(--chrome-bg);
  color: var(--chrome-fg);
  border-radius: 8px;
  padding: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#control-panel-column::-webkit-scrollbar { width: 8px; }
#control-panel-column::-webkit-scrollbar-track { background: transparent; }
#control-panel-column::-webkit-scrollbar-thumb {
  background: #ccc; border-radius: 10px;
  border: 3px solid transparent; background-clip: content-box;
}
#control-panel-column::-webkit-scrollbar-thumb:hover {
  background: #888; background-clip: content-box;
}

#manual-reference-overlay {
  position: absolute;
  top: 14px;
  right: 14px;
  left: auto;
  transform: none;
  z-index: 13;
  max-width: calc(100% - 28px);
  pointer-events: none;
}

/* ==========================================================================
   NAV / PANELS
   ========================================================================== */


/* NAV LINKS — frame the whole link */
#control-nav-column .control-nav-link {
  display: block;
  margin-bottom: 0px;
  text-decoration: none;
  color: var(--chrome-fg);
  font-size: 0.9em;
  font-weight: bold;
  cursor: pointer;

  /* new bits */
  padding: 6px;
  border: 2px solid transparent;   /* reserve space so no shift */
  border-radius: 6px;
  box-sizing: border-box;
  transition: color .2s, border-color .2s, background-color .2s;
}

#control-nav-column .control-nav-link:hover {
  background-color: rgba(220, 154, 29, 0.12);
}

#control-nav-column .control-nav-link.active {
  color: #DDC39A;          /* keep your color change */
  border-color: #DC9A1D;   /* gold frame */
  background-color: rgba(220, 154, 29, 0.18);
}

#control-nav-column .control-nav-link.control-nav-link-text {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#control-nav-column .control-nav-link:last-child { margin-bottom: 0; }

/* cleanup: kill the old active-img highlight if you had it */
#control-nav-column .control-nav-link.active img { background: none; }


.panel-content-wrapper {
  width: 300px;
  margin: 0 auto;
  padding: 16px;                 
  border: 2px solid #DC9A1D;
  border-radius: 8px;
  box-sizing: border-box;
  background-color: var(--chrome-bg);
  color: var(--chrome-fg);
}

#control-panel-column > *,
#control-panel-column .accordion-item,
#control-panel-column .accordion-content,
#control-nav-column > * {
  min-width: 0;
}

#control-panel-column .panel-content-wrapper {
  width: 100%;
  max-width: 300px;
}

.place-info-helper-text {
  margin: 0 0 12px;
  opacity: 0.82;
}

.place-info-selection-panel {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(245, 238, 219, 0.08), rgba(245, 238, 219, 0.03));
  border: 1px solid rgba(220, 154, 29, 0.24);
}

.place-info-selection-status,
.place-info-selection-preview {
  margin: 0;
}

.place-info-selection-status:not([hidden]) {
  margin-bottom: 8px;
  font-weight: 700;
}

.place-info-instruction-list {
  margin: 0;
  padding-left: 1.15em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.place-info-instruction-list li {
  margin: 0;
  line-height: 1.45;
}

.place-info-selection-preview {
  margin-top: 8px;
  font-size: 0.86em;
  color: rgba(245, 238, 219, 0.8);
  white-space: pre-line;
}

.place-info-generated-card {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
  border-left: 3px solid #DC9A1D;
}

.place-info-generated-card-compact {
  margin-bottom: 14px;
}

.place-info-generated-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.place-info-generated-header strong {
  color: #F5EEDB;
  font-family: 'Libre Baskerville', serif;
  font-size: 0.95rem;
}

.place-info-generated-header span {
  color: rgba(245, 238, 219, 0.72);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.place-info-generated-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.place-info-generated-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(245, 238, 219, 0.06);
}

.place-info-generated-item span {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(245, 238, 219, 0.68);
}

.place-info-generated-item strong {
  color: #F5EEDB;
  font-size: 0.92rem;
  line-height: 1.35;
}

.place-info-generated-summary {
  margin: 10px 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(245, 238, 219, 0.84);
}

#place-info-panel .place-info-generated-card {
  margin-bottom: 10px;
  padding: 10px 12px;
}

#place-info-panel .place-info-generated-summary {
  margin: 0;
  font-size: 0.94rem;
  color: rgba(245, 238, 219, 0.96);
}

#place-info-dialog-generated-card {
  margin-bottom: 12px;
  padding: 10px 12px;
}

#place-info-dialog-generated-card .place-info-generated-summary {
  margin: 0;
  font-size: 0.96rem;
  color: rgba(245, 238, 219, 0.96);
}

.manual-reference-card {
  width: 100%;
  line-height: 1.45;
}

.manual-reference-floating {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(360px, calc(100vw - 96px));
  max-width: calc(100vw - 96px);
  pointer-events: auto;
  background-color: rgba(26, 39, 53, 0.96);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.manual-reference-floating.is-collapsed {
  width: auto;
  max-width: calc(100vw - 96px);
  padding: 10px 12px;
  gap: 0;
}

.manual-reference-floating.is-collapsed > * + * {
  margin-top: 0;
}

.manual-toggle-btn {
  width: 100%;
  min-height: var(--btn-height);
  padding: 0.55rem 0.9rem;
  border: 1px solid #DC9A1D;
  border-radius: 6px;
  background: rgba(221, 195, 154, 0.14);
  color: #DDC39A;
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.manual-toggle-btn:hover {
  background: rgba(221, 195, 154, 0.24);
}

.manual-reference-body {
  max-height: min(68vh, 760px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.manual-reference-body[hidden] {
  display: none !important;
}

.manual-reference-body::-webkit-scrollbar { width: 8px; }
.manual-reference-body::-webkit-scrollbar-track { background: transparent; }
.manual-reference-body::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}
.manual-reference-body::-webkit-scrollbar-thumb:hover {
  background: #888;
  background-clip: content-box;
}

.font-help-block {
  margin-top: 12px;
}

.font-help-copy {
  margin-top: 12px;
}

.font-help-steps {
  margin: 10px 0 0;
  padding-left: 1.2rem;
}

.font-help-steps li + li {
  margin-top: 10px;
}

#fonts-panel .font-actions,
#fonts-panel .font-help-block,
#fonts-panel fieldset > p:not(.font-ui-note):not([style]) {
  display: none;
}

.font-ui-note {
  margin: 0.75em 0 0;
  opacity: 0.82;
}

.manual-reference-header h2,
.manual-reference-section h3 {
  margin: 0;
  color: #DDC39A;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.manual-reference-header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.manual-reference-header h2 {
  font-size: 1.1rem;
}

.manual-reference-close {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 0;
}

.manual-reference-header p {
  margin: 0.75rem 0 0;
}

.manual-reference-section {
  padding-top: 12px;
  border-top: 1px solid rgba(245, 238, 219, 0.22);
}

.manual-reference-section ul,
.manual-reference-section ol {
  margin: 0.65rem 0 0;
  padding-left: 1.15rem;
}

.manual-chapter-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.4rem 0;
  list-style: none;
  padding-left: 0;
}

.manual-chapter-list li {
  margin: 0;
}

.manual-chapter-list li + li {
  margin-top: 0;
}

.manual-reference-section li + li {
  margin-top: 0.45rem;
}

#manual-reference-body a {
  color: #DDC39A;
  text-decoration: none;
  cursor: pointer;
}

.manual-shortcut {
  color: #DDC39A;
  font-weight: 700;
}
#control-nav-column .control-nav-link img {
  display: block;      /* kills the baseline gap under the icon */
  width: 24px;
  height: auto;
}

#control-nav-column .control-nav-link {
  line-height: 1;      /* removes extra leading from the font */
}

/* vertical rhythm inside each panel */
.panel-content-wrapper > * + * {
  margin-top: 10px;     /* tweak to taste */
}

/* if you use <hr> inside panels, keep its spacing tidy */
.panel-content-wrapper hr {
  margin: 12px 0;
  border: 0;
  border-top: 1px solid rgba(245, 238, 219, 0.22);
  height: 0;
}

.panel-content-wrapper fieldset > p + hr {
  margin-top: 16px !important;
}

/* vertical rhythm inside the panel's fieldset */
.panel-content-wrapper fieldset > * + * {
  margin-top: 10px;   /* space between any two consecutive rows */
}

.labels-panel-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.labels-panel-section {
  padding: 12px 14px;
  border: 1px solid rgba(220, 154, 29, 0.24);
  background: rgba(18, 29, 40, 0.38);
}

.labels-panel-section > * + * {
  margin-top: 10px;
}

.labels-panel-section-title {
  margin: 0;
  font-weight: bold;
}

.labels-panel-conditional-section .labels-panel-section + .labels-panel-section {
  margin-top: 12px;
}

.labels-panel-note {
  margin: 0;
  opacity: 0.85;
}

.labels-batch-buttons-row {
  margin-top: 10px !important;
}

.labels-panel-section > #clear-all-labels-btn + .labels-panel-note {
  margin-top: 16px;
}

#labels-panel #create-batch-labels-btn {
  margin-top: 10px;
}

#labels-panel #create-batch-labels-btn,
#labels-panel #clear-all-labels-btn {
  width: 100%;
}

#labels-panel .labels-batch-buttons-row + #clear-all-labels-btn {
  margin-top: 10px;
}

#labels-panel .labels-auto-place-row {
  margin-top: 10px !important;
  margin-bottom: 0 !important;
}

#labels-panel .labels-auto-place-row + .labels-panel-note {
  margin-top: 12px;
}

.labels-suggest-btn {
  min-width: 108px;
  height: 42px;
  padding: 0 14px;
  margin-top: 0;
}

.labels-form-row {
  margin-bottom: 0 !important;
}

#labels-panel .labels-form-row > select,
#labels-panel .labels-suggest-btn {
  width: 100%;
}

#labels-panel .labels-suggest-btn {
  min-width: 0;
  display: inline-flex;
  justify-content: center;
  margin-top: 0;
}

.cg-checkbox-group {
  margin-top: 0.8em;
  justify-content: flex-start;
  gap: 18px;
  margin-bottom: 0.35em;
}

.panel-compact-select {
  width: auto !important;
  min-width: 10em;
  max-width: 100%;
}

.cg-checkbox-group label {
  margin-bottom: 0 !important;
}

/* 2) Headers with a right-side value (Zoom:, Line Weight:, etc.) */
.label-header {
  display: grid;
  grid-template-columns: 1fr auto;  /* label | value */
  align-items: center;
}

.label-header > :last-child {
  min-width: 3ch;           /* keeps values aligned */
  text-align: right;
  padding-inline-start: 8px; /* a little breathing room from the edge */
}

#continent-generator .accordion-content label.is-stacked:has(> input[type="range"]) {
  margin-bottom: 0.2em;
}

#continent-generator .accordion-content label.is-stacked:has(> input[type="range"]) .label-header {
  margin-bottom: 1px;
}

#continent-generator .accordion-content :is(fieldset, .labels-panel-section, .drawing-tool-section-body, .stamp-library-tool-section-body, .object-actions-tool-section-body) > label.is-stacked:has(> input[type="range"]) + label.is-stacked:has(> input[type="range"]) {
  margin-top: 4px;
}




/* ==========================================================================
   FORM ELEMENTS (inputs / labels)
   ========================================================================== */

#continent-generator .accordion-content fieldset {
  border: none; padding: 0; min-width: 0; box-sizing: border-box;
}

/* Make labels blocky by default, but allow special cases to override */
#continent-generator .accordion-content label:not(.file-upload-label) {
  display: block; margin-bottom: 0.65em; font-size: 0.95em;
}

#continent-generator .accordion-content label.dimension-control {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  gap: 0.18em;
}

.map-dimension-row {
  gap: 10px;
  flex-wrap: nowrap;
  align-items: flex-start;
  margin-bottom: 0.55em;
}

.map-dimension-row > label {
  flex: 1 1 0;
  min-width: 0;
}

.dimension-input-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.dimension-control input[type='number'] {
  width: 100% !important;
  min-width: 0;
  max-width: 100%;
  flex: 0 0 auto;
}

.canvas-resize-block {
  margin-top: 16px;
}

.canvas-resize-panel {
  margin-bottom: 12px;
}

.canvas-resize-body {
  margin-top: 0;
}

.canvas-resize-note {
  margin-top: 0;
  margin-bottom: 12px;
}

.canvas-resize-dimension-row {
  margin-bottom: 12px;
}

.canvas-resize-anchor-wrap {
  margin-bottom: 12px;
}

.canvas-resize-anchor-label {
  display: block;
  margin-bottom: 8px;
  opacity: 0.9;
}

.canvas-resize-anchor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    ". north ."
    "west center east"
    ". south .";
  gap: 8px;
}

#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn {
  min-height: 34px;
  height: 34px;
  margin-top: 0;
  padding: 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn[data-anchor='north'] {
  grid-area: north;
}

#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn[data-anchor='west'] {
  grid-area: west;
}

#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn[data-anchor='center'] {
  grid-area: center;
}

#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn[data-anchor='east'] {
  grid-area: east;
}

#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn[data-anchor='south'] {
  grid-area: south;
}

#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn.is-active {
  background: var(--btn-fg);
  color: var(--btn-bg);
}

.canvas-resize-summary {
  margin-top: 0;
  margin-bottom: 12px;
}

.canvas-resize-generate-row {
  margin-bottom: 8px;
}

.canvas-resize-generate-note {
  margin-top: 0;
  margin-bottom: 12px;
}

.dimension-print-readout {
  display: grid;
  gap: 2px;
  width: 100%;
  flex: none;
  color: #d8c5a0;
  font-size: 0.72em;
  line-height: 1.22;
  white-space: normal;
}

.dimension-print-readout > span {
  display: block;
}

.dimension-workflow-note {
  margin: 0.1em 0 0.75em;
  color: #d8c5a0;
}

.label-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25em;
}
.half-width-control { width: 50%; }

.free-text-select-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.free-text-select-row > .half-width-control {
  margin-bottom: 0 !important;
}

.compact-toggle-row--flush {
  margin-bottom: 0 !important;
}

#continent-generator .accordion-content input[type='text'],
#continent-generator .accordion-content input[type='number'],
#continent-generator .accordion-content select,
#continent-generator .accordion-content textarea {
  width: 100%; box-sizing: border-box; padding: 0.25em; font-size: 1em;
  border: 1px solid #DDC39A; border-radius: 4px; color: #000; background: #fff;
  font-family: inherit; display: block;
}

#continent-generator input[type='checkbox'],
#stamp-library-palette input[type='checkbox'],
#object-actions-panel input[type='checkbox'] {
  display: block;
  flex: 0 0 auto;
  margin: 0;
  transform: scale(1.2);
  transform-origin: center center;
  accent-color: #DDC39A;
}

#continent-generator input[type='color'] {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  border: 1px solid #DDC39A; width: 60px; height: 25px; padding: 0; cursor: pointer;
}
#continent-generator input[type='color']::-webkit-color-swatch-wrapper { padding: 0; }
#continent-generator input[type='color']::-webkit-color-swatch,
#continent-generator input[type='color']::-moz-color-swatch { border: none; }

.map-color-control {
  display: block;
  margin-bottom: 1em;
}

.map-color-control > span {
  display: block;
  margin-bottom: 5px;
}

.map-color-input-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-top: 5px;
}

.color-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.universal-ink-color-picker-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.ink-preset-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  justify-content: stretch;
  gap: 8px;
  margin-top: 10px;
}

#continent-generator button.ink-preset-btn {
  inline-size: 100% !important;
  min-inline-size: 0;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 0 4px !important;
  margin-top: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  appearance: none;
}

#continent-generator button.ink-preset-btn:hover,
#continent-generator button.ink-preset-btn:focus-visible {
  outline: none;
  transform: none;
  background: transparent !important;
  box-shadow: none !important;
}

#continent-generator button.ink-preset-btn.is-active {
  background: transparent !important;
  box-shadow: none !important;
}

.ink-preset-chip {
  inline-size: 100%;
  block-size: 32px;
  border-radius: 2px;
  border: 1px solid rgba(221, 195, 154, 0.5);
  background: var(--swatch-color, #000000);
  box-shadow: inset 0 0 0 1px rgba(26, 39, 53, 0.18);
  flex: 0 0 auto;
}

#continent-generator button.ink-preset-btn:hover .ink-preset-chip,
#continent-generator button.ink-preset-btn:focus-visible .ink-preset-chip,
#continent-generator button.ink-preset-btn.is-active .ink-preset-chip {
  border-color: rgba(221, 195, 154, 0.95);
  box-shadow:
    inset 0 0 0 1px rgba(26, 39, 53, 0.18),
    0 0 0 2px rgba(221, 195, 154, 0.35);
}

.ink-preset-chip-custom {
  background:
    linear-gradient(135deg, var(--swatch-color, #000000) 0 55%, rgba(255, 255, 255, 0.18) 55% 100%),
    linear-gradient(45deg, #2e4054 25%, #e0c690 25% 50%, #2e4054 50% 75%, #e0c690 75% 100%);
  background-size: 100% 100%, 10px 10px;
}

.ink-preset-label {
  font-size: 0.58rem;
  line-height: 1.15;
  text-align: center;
  color: rgba(245, 238, 219, 0.92);
  white-space: nowrap;
}

.ink-preset-code-readout {
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
}

.ink-preset-code-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-inline: 6px;
  background: rgba(14, 20, 28, 0.46);
}

.ink-preset-code-value {
  display: block;
  max-inline-size: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0;
  background: transparent;
  color: rgba(245, 238, 219, 0.96);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

#continent-generator button.color-swatch {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  margin-top: 0;
  border: 1px solid rgba(221, 195, 154, 0.45);
  border-radius: 999px;
  background: var(--swatch-color, #ffffff);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(26, 39, 53, 0.18);
  flex: 0 0 auto;
}

#continent-generator button.color-swatch:hover,
#continent-generator button.color-swatch:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(221, 195, 154, 0.88);
  background: var(--swatch-color, #ffffff);
  color: transparent;
  outline: none;
}

#continent-generator button.color-swatch.is-active {
  box-shadow: 0 0 0 2px rgba(221, 195, 154, 0.92), inset 0 0 0 1px rgba(26, 39, 53, 0.18);
}

.color-panel-note {
  margin: 12px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(245, 238, 219, 0.86);
}

.paint-layer-swatch-row {
  gap: 10px;
}

.paint-layer-palette-control {
  margin: 8px 0 10px;
}

.paint-layer-palette-control > span {
  display: block;
  margin-bottom: 5px;
}

#continent-generator .paint-layer-swatch-row .color-swatch {
  width: 30px;
  height: 30px;
  min-height: 30px;
  border-radius: 8px;
}

.grid-panel-note {
  margin: 0 0 10px;
  color: rgba(245, 238, 219, 0.86);
}

.grid-sync-status-note {
  margin: 0.2em 0 0.75em;
}

.grid-color-display-row {
  display: flex;
  align-items: center;
  margin-top: 5px;
}

.grid-color-display-text {
  margin-left: 0.5em;
}

#grid-panel #grid-sync-cycle-btn {
  width: 100%;
  margin-top: 6px;
}

.save-load-heading {
  margin: 0;
}

#continent-generator input[type="range"] {
  --range-fill-percent: 0%;
  --range-track-bg: rgba(245, 238, 219, 0.05);
  --range-track-border: rgba(245, 238, 219, 0.45);
  --range-fill-color: rgba(221, 195, 154, 0.95);
  -webkit-appearance: none; appearance: none; width: 100%;
  background: transparent; border: none; padding: 1px 0;
}
#continent-generator input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  border: 1px solid var(--range-track-border);
  border-radius: 999px;
  background:
    linear-gradient(to right, var(--range-fill-color) 0 var(--range-fill-percent), transparent var(--range-fill-percent) 100%),
    var(--range-track-bg);
}
#continent-generator input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  border: 1px solid var(--range-track-border);
  border-radius: 999px;
  background: var(--range-track-bg);
}
#continent-generator input[type="range"]::-moz-range-progress {
  height: 6px;
  border: 1px solid var(--range-track-border);
  border-radius: 999px;
  background: var(--range-fill-color);
}
#continent-generator input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  height: 18px; width: 10px; border-radius: 0;
  border: 2px solid #F5F1E8;
  background: var(--chrome-bg); cursor: pointer; margin-top: -7px;
}
#continent-generator input[type="range"]::-moz-range-thumb {
  height: 18px; width: 10px; border-radius: 0;
  background: var(--chrome-bg); cursor: pointer; border: 2px solid #F5F1E8;
}

/* ==========================================================================
   BUTTONS (unified height)
   ========================================================================== */

.control-group, .button-group, .checkbox-group {
  display: flex; align-items: center; gap: 10px; width: 100%;
}
.checkbox-group { justify-content: space-between; margin-bottom: 1em; }
.checkbox-group label { margin-bottom: 0; }

/* Default button layout stack */
.button-group { flex-direction: column; }
.button-group > button { flex-grow: 1; margin-top: 0; }

/* Global button style (excluding tiny stepper +/-) */
#continent-generator button:not(.stepper-btn),
#continent-generator .file-upload-label {
  font: inherit; height: var(--btn-height); min-height: var(--btn-height);
  padding: 0 1rem; border: none; border-radius: var(--btn-radius);
  cursor: pointer; margin-top: 0.5em;
  transition: background-color 0.2s, color 0.2s;
  box-sizing: border-box; background: var(--btn-bg); color: var(--btn-fg);
  display: inline-flex; align-items: center; justify-content: center; line-height: 1; text-align: center;
}

/* Hover */
#continent-generator button:not(.stepper-btn):hover,
#continent-generator .file-upload-label:hover {
  background: var(--btn-bg-hover); color: var(--btn-fg-hover);
}

/* Variants */
#continent-generator button.destructive-btn {
  border: 1px solid rgba(217, 83, 79, 0.95);
  background-color: transparent;
  color: #f2b8b5;
}
#continent-generator button.destructive-btn:hover {
  background-color: rgba(217, 83, 79, 0.95);
  color: #fff;
}
#continent-generator button.warning-btn { background-color: #f0ad4e; color: #fff; }
#continent-generator button.warning-btn:hover { background-color: #ec971f; }

/* ==========================================================================
   NUMBER STEPPERS
   ========================================================================== */

.stepper-controls-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 15px; margin-bottom: 1em;
}
.stepper-group { display: flex; flex-direction: column; align-items: center; }
.stepper-group label { font-size: 0.85em; margin-bottom: 4px; color: #666; }
.vertical-stepper-wrapper { display: flex; flex-direction: column; width: 35px; }
.vertical-stepper-wrapper .stepper-btn,
.vertical-stepper-wrapper .stepper-input {
  width: 100% !important; box-sizing: border-box !important;
  margin: 0 !important; border-radius: 0 !important; border-style: solid !important;
  border-color: #DDC39A !important; font-size: 1em !important;
}
.vertical-stepper-wrapper .stepper-btn {
  display: flex; justify-content: center; align-items: center;
  padding: 4px 0 !important; background: #DDC39A !important; color: #1A2735 !important;
  font-weight: bold; cursor: pointer; height: auto; min-height: 0;
}
.vertical-stepper-wrapper .stepper-btn:hover { background: #333 !important; color: #fff !important; }
.vertical-stepper-wrapper button:first-of-type { border-width: 1px 1px 0 1px !important; border-radius: 4px 4px 0 0 !important; }
.vertical-stepper-wrapper button:last-of-type { border-width: 1px 1px 1px 1px !important; border-radius: 0 0 4px 4px !important; }
.vertical-stepper-wrapper input {
  padding: 5px 0 !important; text-align: center; background: #fff !important; color: #000 !important;
  border-width: 0 1px !important; -moz-appearance: textfield;
}
.vertical-stepper-wrapper input::-webkit-outer-spin-button,
.vertical-stepper-wrapper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ==========================================================================
   MAP / OVERLAYS
   ========================================================================== */

#map-wrapper-container {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  background-color: var(--map-backdrop);
}
#map-wrapper { transform-origin: top left; position: relative; z-index: 1; background-color: var(--map-backdrop); overflow: hidden; }
#cg-canvas { border: 1px solid var(--ink-color); }
#reference-image-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  display: none;
  max-width: none;
  max-height: none;
  transform-origin: top left;
  pointer-events: none;
  user-select: none;
}
.placed-image { transition: box-shadow 0.2s ease-in-out; }
.placed-image:hover { box-shadow: 0 0 10px 3px rgba(255, 255, 100, 0.8); }
body.river-drawing-symbol-lock .placed-image,
body.river-drawing-symbol-lock .placed-image:hover {
  pointer-events: none !important;
  cursor: crosshair !important;
  box-shadow: none !important;
}
.placed-image.stamp-selected { box-shadow: none; }
body.show-group-highlights .placed-image.object-grouped:not(.stamp-selected) { box-shadow: 0 0 0 1px rgba(220, 154, 29, 0.52); }
.placed-image.object-locked { opacity: 0.82; cursor: default; }

#texture-overlay, #map-border, #title-on-canvas, #map-legend-on-canvas, #scale-bar-wrapper, .placed-image {
  position: absolute; user-select: none;
}
#title-on-canvas, #map-legend-on-canvas, #scale-bar-wrapper, .placed-image { cursor: grab; pointer-events: auto; }
#texture-overlay, #map-border { pointer-events: none; }

#texture-overlay {
  width: 100%; height: 100%;
  background-image: url('./Paper BG For Nova Terra/Paper 1.jpg');
  background-size: cover; mix-blend-mode: multiply; opacity: 0.5; z-index: 10; display: none;
}
#waves-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  display: none;
}
#map-zoom-selection-layer {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  display: none;
}

#map-zoom-selection-box {
  position: absolute;
  border: 2px dashed rgba(220, 154, 29, 0.96);
  background: rgba(220, 154, 29, 0.14);
  box-shadow: 0 0 0 1px rgba(245, 238, 219, 0.82), inset 0 0 0 1px rgba(26, 39, 53, 0.35);
  display: none;
  box-sizing: border-box;
}

#map-zoom-processing-overlay {
  position: absolute;
  inset: 0;
  z-index: 26;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 56px 24px 24px;
  background: rgba(8, 15, 22, 0.46);
  backdrop-filter: blur(2px);
  box-sizing: border-box;
}

#map-zoom-processing-overlay[hidden] {
  display: none !important;
}

.map-zoom-processing-card {
  max-width: 360px;
  padding: 16px 18px;
  border: 2px solid rgba(220, 154, 29, 0.96);
  border-radius: 10px;
  background: rgba(26, 39, 53, 0.98);
  color: #f5eedb;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
  text-align: center;
}

.map-zoom-processing-spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: 3px solid rgba(245, 238, 219, 0.2);
  border-top-color: rgba(220, 154, 29, 0.98);
  border-right-color: rgba(245, 238, 219, 0.72);
  animation: map-zoom-processing-spin 0.9s linear infinite;
}

.map-zoom-processing-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.02rem;
}

.map-zoom-processing-card p {
  margin: 0;
  line-height: 1.5;
  font-size: 0.92rem;
  opacity: 0.92;
}

@keyframes map-zoom-processing-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

#map-wrapper.is-local-zoom-selecting,
#map-wrapper.is-local-zoom-selecting * {
  cursor: crosshair !important;
}
#waves-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
#map-border {
  width: auto; height: auto;
  box-sizing: border-box; transform-origin: center; display: none;
  --map-border-line-width: 2px;
  --map-border-gap: 4px;
  border: var(--map-border-line-width) solid var(--ink-color);
}

#map-border .map-border-inner {
  position: absolute;
  top: calc(var(--map-border-line-width) + var(--map-border-gap));
  right: calc(var(--map-border-line-width) + var(--map-border-gap));
  bottom: calc(var(--map-border-line-width) + var(--map-border-gap));
  left: calc(var(--map-border-line-width) + var(--map-border-gap));
  box-sizing: border-box;
  border: var(--map-border-line-width) solid var(--ink-color);
  pointer-events: none;
}

#map-border-mask {
  position: absolute;
  z-index: 7;
  display: none;
  pointer-events: none;
}

#map-border-mask .map-border-mask-piece {
  position: absolute;
  background: #fff;
  pointer-events: none;
}

.title-box {
  border-style: double; background: #fff; color: var(--ink-color); border-color: var(--ink-color);
  text-align: center; padding: 1em; text-transform: uppercase;
}
.title-box p { margin: 0.3em 0; }
.title-box .title-line { font-size: 2em; }
.title-box .title-subheading { font-size: 1.1em; font-variant: small-caps; font-style: italic; }
.title-box .title-anno { font-size: 1.3em; }
.title-box .title-cart { font-size: 1.1em; }

.map-legend-box {
  display: inline-block;
  box-sizing: border-box;
  background: #fff;
  color: var(--ink-color);
  min-width: 160px;
  max-width: 540px;
  box-shadow: 0 1px 0 rgba(26, 39, 53, 0.08);
  --legend-padding: 40px;
  --legend-border-width: 2px;
  --legend-inner-border-width: 1px;
  --legend-frame-gap: 6px;
}

.map-legend-box--single {
  padding: var(--legend-padding);
  border: var(--legend-border-width) solid var(--ink-color);
}

.map-legend-box--double {
  padding: var(--legend-frame-gap);
  border: var(--legend-border-width) solid var(--ink-color);
}

.map-legend-box--double .map-legend-box__inner {
  border: var(--legend-inner-border-width) solid var(--ink-color);
  padding: var(--legend-padding);
}

.map-legend-box--none {
  padding: var(--legend-padding);
}

.map-legend-box__inner {
  box-sizing: border-box;
}

.map-legend-title {
  margin: 0 0 18px;
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1.08;
  text-transform: uppercase;
  text-align: center;
  font-variant: normal;
}

.map-legend-title::after {
  content: '';
  display: block;
  width: 80%;
  margin: 14px auto 0;
  border-top: 1px solid currentColor;
  opacity: 0.7;
}

.map-legend-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-legend-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 36px;
  align-items: center;
}

.map-legend-item-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.map-legend-item-symbol img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.map-legend-item-symbol--empty {
  border: 1px dashed rgba(26, 39, 53, 0.38);
  background: rgba(245, 238, 219, 0.45);
}

.map-legend-item-label {
  line-height: 1.3;
  word-break: break-word;
}

.map-legend-toolbar {
  display: flex;
  gap: 10px;
  margin: 0.85em 0 0;
}

.map-legend-toolbar > * {
  flex: 1 1 0;
}

.map-legend-slider-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-legend-editor-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 0.85em;
}

.map-legend-editor-empty {
  padding: 12px 14px;
  border: 1px dashed rgba(220, 154, 29, 0.55);
  color: rgba(245, 238, 219, 0.85);
  font-size: 0.92rem;
  line-height: 1.45;
}

.map-legend-editor-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px;
  border: 1px solid rgba(220, 154, 29, 0.45);
  background: rgba(18, 29, 40, 0.42);
}

.map-legend-editor-preview {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(220, 154, 29, 0.45);
  background: rgba(245, 238, 219, 0.9);
}

.map-legend-editor-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.map-legend-editor-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-legend-editor-body input[type="text"] {
  width: 100%;
}

.map-legend-editor-meta {
  font-size: 0.86rem;
  line-height: 1.35;
  color: rgba(245, 238, 219, 0.8);
  word-break: break-word;
}

.map-legend-editor-row-actions {
  display: flex;
  gap: 8px;
}

.map-legend-editor-row-actions button {
  flex: 1 1 0;
}

.map-label { color: var(--ink-color); }
.map-label svg text { fill: var(--ink-color); }
.map-label.selected { outline: 1px dashed rgba(232, 200, 142, 0.95); outline-offset: 4px; border-radius: 4px; }
.map-label.place-info-target { outline: 1px dashed rgba(220, 154, 29, 0.92); outline-offset: 4px; border-radius: 4px; }
.map-label.object-selected { outline: 2px solid rgba(220, 154, 29, 0.95); outline-offset: 4px; border-radius: 4px; }
body.show-group-highlights .map-label.object-grouped:not(.object-selected) { outline: 1px dashed rgba(220, 154, 29, 0.52); outline-offset: 4px; border-radius: 4px; }
.map-label.object-locked { opacity: 0.8; }
.place-point-marker {
  position: absolute;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border-radius: 50%;
  background: rgba(90, 68, 42, 0.92);
  border: 2px solid rgba(245, 238, 219, 0.95);
  box-shadow: 0 0 0 2px rgba(26, 39, 53, 0.4);
  cursor: grab;
  pointer-events: auto;
  box-sizing: border-box;
}

.place-point-marker::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgba(245, 238, 219, 0.95);
}

.place-point-marker.place-info-target {
  box-shadow: 0 0 0 2px rgba(220, 154, 29, 0.96), 0 0 12px rgba(220, 154, 29, 0.36);
}

.map-text-block.selected { box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.7); }
.map-text-block.object-selected { box-shadow: 0 0 0 2px rgba(220, 154, 29, 0.95), 0 0 14px rgba(220, 154, 29, 0.22); }
body.show-group-highlights .map-text-block.object-grouped:not(.object-selected) { box-shadow: 0 0 0 1px rgba(220, 154, 29, 0.52); }
.map-text-block.object-locked { opacity: 0.8; }
.free-text-hitbox {
  position: absolute;
  pointer-events: none;
  box-sizing: border-box;
  border-radius: 4px;
}
.free-text.selected .free-text-hitbox { box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.7); }
.free-text.object-selected .free-text-hitbox { box-shadow: 0 0 0 2px rgba(220, 154, 29, 0.95), 0 0 14px rgba(220, 154, 29, 0.22); }
body.show-group-highlights .free-text.object-grouped:not(.object-selected) .free-text-hitbox { box-shadow: 0 0 0 1px rgba(220, 154, 29, 0.52); }
.free-text.object-locked { opacity: 0.82; }
.free-text svg,
.free-text svg * { pointer-events: none; }
.interaction-hit.object-selected {
  stroke: rgba(220, 154, 29, 0.88) !important;
  stroke-width: 7px !important;
  stroke-dasharray: 14 8;
}
body.show-group-highlights .interaction-hit.object-grouped:not(.object-selected) {
  stroke: rgba(220, 154, 29, 0.42) !important;
  stroke-width: 5px !important;
  stroke-dasharray: 8 8;
}
.interaction-hit.object-locked {
  stroke: rgba(194, 208, 220, 0.9) !important;
  stroke-dasharray: 5 5;
}
.interaction-hit.object-locked.object-selected {
  stroke: rgba(205, 220, 235, 0.95) !important;
}

#place-info-hover-card {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 24;
  width: min(290px, calc(100% - 24px));
  max-width: 290px;
  padding: 10px 12px;
  border: 2px solid rgba(90, 68, 42, 0.95);
  border-radius: 10px;
  background: rgba(245, 238, 219, 0.98);
  color: #2c2114;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.24);
  pointer-events: none;
  box-sizing: border-box;
}

#place-info-hover-card.place-info-hover-card-summary-only {
  width: min(330px, calc(100% - 24px));
  max-width: 330px;
  padding: 8px 10px;
}

.place-info-hover-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.place-info-hover-meta {
  margin-top: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(44, 33, 20, 0.68);
}

.place-info-hover-body {
  margin-top: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: normal;
}

#place-info-hover-card.place-info-hover-card-summary-only .place-info-hover-body {
  margin-top: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.place-info-hover-summary {
  margin: 0;
}

.place-info-hover-population {
  margin: 6px 0 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: rgba(44, 33, 20, 0.78);
}

.place-info-hover-notes {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(44, 33, 20, 0.14);
}

.place-info-hover-body strong,
.place-info-hover-notes strong {
  display: block;
  margin-top: 0;
  margin-bottom: 4px;
  color: #2c2114;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.place-info-hover-notes-text {
  white-space: pre-line;
}

#place-info-panel #clear-selected-place-info-btn {
  white-space: normal;
}

#place-info-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 12, 18, 0.58);
  backdrop-filter: blur(3px);
  box-sizing: border-box;
}

#place-info-dialog-backdrop[hidden] {
  display: none !important;
}

#settlement-list-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 12, 18, 0.58);
  backdrop-filter: blur(3px);
  box-sizing: border-box;
}

#settlement-list-backdrop[hidden] {
  display: none !important;
}

#place-info-dialog {
  width: min(520px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  padding: 18px;
  border: 2px solid #DC9A1D;
  border-radius: 12px;
  background: rgba(26, 39, 53, 0.98);
  color: var(--chrome-fg);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.3);
  overflow: auto;
  box-sizing: border-box;
}

#settlement-list-dialog {
  width: min(760px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  padding: 18px;
  border: 2px solid #DC9A1D;
  border-radius: 12px;
  background: rgba(26, 39, 53, 0.98);
  color: var(--chrome-fg);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.3);
  overflow: auto;
  box-sizing: border-box;
}

.place-info-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.place-info-dialog-title-group h2 {
  margin: 0;
  font-family: 'Libre Baskerville', serif;
  font-size: 1.2rem;
  color: #DDC39A;
}

.place-info-dialog-label-meta {
  margin: 6px 0 0;
  font-size: 0.92em;
  line-height: 1.45;
  color: rgba(245, 238, 219, 0.8);
}

.place-info-dialog-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

#place-info-dialog .place-info-dialog-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin: 0;
}

#place-info-dialog .place-info-dialog-field input,
#place-info-dialog .place-info-dialog-field select {
  width: 100%;
}

.place-info-dialog-helper-text {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  line-height: 1.35;
  color: rgba(245, 238, 219, 0.76);
}

.settlement-list-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settlement-list-actions {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 14px;
}

.settlement-list-empty {
  margin: 0;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid rgba(220, 154, 29, 0.24);
  background: rgba(245, 238, 219, 0.04);
  color: rgba(245, 238, 219, 0.82);
}

.settlement-list-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settlement-list-group-title {
  margin: 0;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #DDC39A;
}

#settlement-list-dialog button.settlement-list-item {
  width: 100%;
  margin-top: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 8px 0 12px !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #F5EEDB !important;
  text-align: left !important;
  line-height: 1.4 !important;
  display: flex !important;
  flex-direction: column;
  align-items: stretch !important;
  justify-content: flex-start !important;
  text-shadow: none !important;
  white-space: normal !important;
  overflow: visible !important;
}

#settlement-list-dialog button.settlement-list-item:hover,
#settlement-list-dialog button.settlement-list-item:focus-visible {
  background: transparent !important;
  color: #F5EEDB !important;
  outline: none;
  transform: none;
}

html.nova-terra-access-locked,
html.nova-terra-access-locked body {
  overflow: hidden;
}

#paid-access-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 12, 18, 0.76);
  backdrop-filter: blur(4px);
  box-sizing: border-box;
}

.nova-terra-access-granted #paid-access-backdrop,
#paid-access-backdrop[hidden] {
  display: none !important;
}

#paid-access-dialog {
  width: calc(100vw - 32px);
  max-width: 540px;
  padding: 24px 24px 20px;
  border: 2px solid #DC9A1D;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(26, 39, 53, 0.99), rgba(18, 27, 38, 0.99));
  color: var(--chrome-fg);
  box-shadow: 0 24px 52px rgba(0, 0, 0, 0.34);
  box-sizing: border-box;
}

.paid-access-icon {
  display: block;
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
}

#paid-access-title {
  margin: 0;
  text-align: center;
  font-family: 'Libre Baskerville', serif;
  font-size: 1.45rem;
  color: #DDC39A;
}

.paid-access-copy,
.paid-access-support,
.paid-access-purchase,
.paid-access-helper,
.paid-access-error {
  margin: 0;
  font-family: 'Libre Baskerville', serif;
  line-height: 1.5;
}

.paid-access-copy {
  margin-top: 12px;
  text-align: center;
}

.paid-access-support {
  margin-top: 10px;
  color: rgba(245, 238, 219, 0.8);
  text-align: center;
  font-size: 0.96rem;
}

.paid-access-purchase {
  margin-top: 10px;
  color: rgba(245, 238, 219, 0.88);
  text-align: center;
  font-size: 0.96rem;
}

.paid-access-purchase-link {
  color: #DDC39A;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

.paid-access-purchase-link:hover,
.paid-access-purchase-link:focus-visible {
  color: #F4CF7C;
}

.paid-access-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.paid-access-field {
  gap: 8px;
  font-family: 'Libre Baskerville', serif;
}

#paid-access-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(220, 154, 29, 0.5);
  border-radius: 10px;
  background: rgba(245, 238, 219, 0.08);
  color: var(--chrome-fg);
  font-size: 1rem;
  box-sizing: border-box;
}

#paid-access-input::placeholder {
  color: rgba(245, 238, 219, 0.48);
}

#paid-access-input:focus {
  outline: 2px solid rgba(220, 154, 29, 0.38);
  outline-offset: 2px;
  border-color: rgba(220, 154, 29, 0.82);
}

#paid-access-submit {
  justify-self: center;
  min-width: 190px;
  padding-left: 22px;
  padding-right: 22px;
}

.paid-access-error {
  color: #F7B0A5;
  text-align: center;
}

.paid-access-helper {
  color: rgba(245, 238, 219, 0.72);
  text-align: center;
  font-size: 0.92rem;
}

.settlement-list-item-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.settlement-list-item-name {
  display: block;
  margin: 0 0 6px;
  font-family: 'Libre Baskerville', serif;
  font-size: 1.02rem;
  color: #F5EEDB;
}

.settlement-list-item-type {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(245, 238, 219, 0.72);
}

.settlement-list-item-summary,
.settlement-list-item-notes-text {
  display: block;
  margin: 0;
  width: 100%;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(245, 238, 219, 0.86);
  white-space: normal;
}

.settlement-list-item-notes {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.settlement-list-item-notes-label {
  display: block;
  margin: 0 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(245, 238, 219, 0.72);
}

.settlement-list-item-notes-text {
  color: rgba(245, 238, 219, 0.72);
}

.place-info-dialog-close {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 0;
}

#place-info-dialog textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 180px;
  resize: vertical;
}

.place-info-dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 14px;
}

@media (max-width: 640px) {
  #paid-access-backdrop {
    padding: 16px;
  }

  #paid-access-dialog {
    padding: 20px 18px 18px;
  }
}

#scale-svg text { font-size: 14px; fill: var(--ink-color); }
#scale-svg .scale-bar-segment-dark { fill: var(--ink-color); stroke: var(--ink-color); }
#scale-svg .scale-bar-segment-light { fill: #fff; stroke: var(--ink-color); }

#strokeSVG {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3; /* Keep the coast outline above edited water and wave bands */
  pointer-events: none; /* Crucial: lets mouse events pass through to the map */
}

/* ==========================================================================
   RULER / STAMPS GRID
   ========================================================================== */

#ruler-layer .ruler-point {
  position: absolute; width: 8px; height: 8px;
  background-color: rgba(255, 0, 0, 0.8); border-radius: 50%; border: 1px solid #fff;
  transform: translate(-50%, -50%);
}
#ruler-layer .ruler-line {
  position: absolute; background-color: rgba(255, 0, 0, 0.8);
  height: 2px; transform-origin: 0 50%;
}
#ruler-layer .ruler-path-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
#ruler-layer .ruler-path-line {
  fill: none;
  stroke: rgba(255, 0, 0, 0.86);
  stroke-width: 2.5px;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#ruler-layer .ruler-direct-line {
  fill: none;
  stroke: rgba(255, 0, 0, 0.32);
  stroke-width: 1.5px;
  stroke-dasharray: 6 6;
  stroke-linecap: round;
}
#ruler-layer .ruler-distance-label {
  position: absolute; background-color: rgba(0,0,0,0.7); color: #fff;
  padding: 3px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap;
}
#ruler-layer .ruler-distance-label.is-path {
  white-space: normal;
  text-align: center;
  line-height: 1.35;
}

#stamp-selection-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  display: none;
}

#stamp-selection-lasso {
  position: absolute;
  inset: 0;
  display: none;
  overflow: visible;
}

#stamp-selection-lasso-path {
  fill: rgba(220, 154, 29, 0.14);
  stroke: rgba(220, 154, 29, 0.95);
  stroke-width: 1.5px;
  stroke-dasharray: 7 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

#stamp-selection-marquee,
#stamp-selection-box {
  position: absolute;
  box-sizing: border-box;
  display: none;
}

#stamp-selection-marquee {
  border: 1px dashed rgba(220, 154, 29, 0.95);
  background: rgba(220, 154, 29, 0.14);
}

#stamp-selection-box {
  border: 2px solid rgba(220, 154, 29, 0.98);
  background: rgba(220, 154, 29, 0.08);
  pointer-events: auto;
  cursor: grab;
}

#stamp-selection-box.is-dragging {
  cursor: grabbing;
}

#stamp-selection-count {
  position: absolute;
  top: -30px;
  left: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(26, 39, 53, 0.96);
  color: #f5eedb;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  pointer-events: none;
}

#stamp-selection-scale-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #1a2735;
  background: #ddc39a;
  box-sizing: border-box;
  pointer-events: auto;
  cursor: nwse-resize;
}

#shape-selection-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  display: none;
}

#shape-selection-box {
  position: absolute;
  box-sizing: border-box;
  display: none;
  border: 2px solid rgba(220, 154, 29, 0.98);
  background: rgba(220, 154, 29, 0.06);
  box-shadow: 0 0 0 1px rgba(245, 238, 219, 0.75);
  pointer-events: none;
}

.shape-selection-scale-handle,
.shape-selection-rotate-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #1a2735;
  box-sizing: border-box;
  pointer-events: auto;
}

.shape-selection-scale-handle {
  background: #ddc39a;
}

.shape-selection-rotate-handle {
  width: 16px;
  height: 16px;
  background: #f5eedb;
  cursor: grab;
}

.shape-selection-rotate-handle::after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 2px solid rgba(220, 154, 29, 0.95);
  border-top-color: transparent;
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(45deg);
}

.shape-selection-rotate-handle[data-handle-position="nw"] {
  left: -16px;
  top: -16px;
  cursor: grab;
}

.shape-selection-rotate-handle[data-handle-position="ne"] {
  right: -16px;
  top: -16px;
  cursor: grab;
}

.shape-selection-rotate-handle[data-handle-position="se"] {
  right: -16px;
  bottom: -16px;
  cursor: grab;
}

.shape-selection-rotate-handle[data-handle-position="sw"] {
  left: -16px;
  bottom: -16px;
  cursor: grab;
}

.shape-selection-scale-handle[data-handle-position="n"] {
  left: 50%;
  top: -9px;
  margin-left: -7px;
  cursor: ns-resize;
}

.shape-selection-scale-handle[data-handle-position="e"] {
  right: -9px;
  top: 50%;
  margin-top: -7px;
  cursor: ew-resize;
}

.shape-selection-scale-handle[data-handle-position="s"] {
  left: 50%;
  bottom: -9px;
  margin-left: -7px;
  cursor: ns-resize;
}

.shape-selection-scale-handle[data-handle-position="w"] {
  left: -9px;
  top: 50%;
  margin-top: -7px;
  cursor: ew-resize;
}

/* Grid of stamp thumbnails */
#stamp-library-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--btn-gap);
}

#stamp-library-controls label {
  margin: 0;
}

#stamp-library-controls select {
  width: 100%;
  margin-top: 6px;
}

#stamp-library-controls .stamp-search-control {
  grid-column: 1 / -1;
}

#stamp-library-controls .stamp-search-control input {
  width: 100%;
  margin-top: 6px;
}

.stamp-library-meta {
  margin: 10px 0 0;
  opacity: 0.78;
}

.stamp-resource-block {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.external-resource-note {
  margin: 0;
  color: rgba(245, 238, 219, 0.88);
}

.texture-export-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-left: 3px solid rgba(220, 154, 29, 0.72);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.16);
  color: rgba(245, 238, 219, 0.86);
}

.texture-export-note a {
  color: #DDC39A;
  text-decoration: none;
  cursor: pointer;
}

#stamp-fill-toggle-btn.active {
  box-shadow: 0 0 0 2px rgba(220, 154, 29, 0.7) inset;
}

.stamp-library-launch-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--btn-gap);
  margin-top: 10px;
}

#stamp-library-palette {
  position: fixed;
  top: 112px;
  right: 28px;
  width: min(420px, calc(100vw - 48px));
  height: var(--stamp-library-palette-height, min(68vh, 640px));
  min-width: 320px;
  min-height: 300px;
  max-width: calc(100vw - 24px);
  max-height: var(--stamp-library-palette-height, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: rgba(26, 39, 53, 0.98);
  color: var(--chrome-fg);
  border: 2px solid #DC9A1D;
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  z-index: 30;
  resize: none;
  overflow: hidden;
}

#stamp-library-palette[hidden] {
  display: none !important;
}

.stamp-library-palette-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(220, 154, 29, 0.35);
  background: linear-gradient(180deg, rgba(245, 238, 219, 0.08), rgba(245, 238, 219, 0.03));
  cursor: move;
  user-select: none;
}

.stamp-library-palette-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #DDC39A;
}

.stamp-library-palette-subtitle {
  margin-top: 4px;
  color: rgba(245, 238, 219, 0.75);
}

.stamp-library-palette-close {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(220, 154, 29, 0.55);
  border-radius: 999px;
  background: rgba(220, 154, 29, 0.12);
  color: #DDC39A;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.stamp-library-palette-close:hover {
  background: rgba(220, 154, 29, 0.22);
}

.stamp-library-palette-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 12px;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.stamp-library-upload-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--btn-gap);
}

.stamp-library-upload-row .file-upload-label {
  width: 100%;
  margin-top: 0;
}

.stamp-library-delete-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.stamp-library-delete-row > button {
  width: 100%;
  margin-top: 0;
}

.stamp-collection-controls {
  display: grid;
  gap: 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.stamp-collection-controls label {
  margin: 0;
}

.stamp-collection-controls select {
  width: 100%;
  margin-top: 6px;
}

.stamp-collection-action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stamp-collection-action-row > button {
  width: 100%;
  margin-top: 0;
  padding-left: 8px;
  padding-right: 8px;
}

.stamp-collection-preference-row {
  display: grid;
  gap: 6px;
}

.stamp-collection-preference-row > button {
  width: 100%;
  margin-top: 0;
}

.stamp-collection-start-size-status {
  margin: 0;
}

#favorite-stamp-library-asset-btn.is-active {
  border-color: rgba(220, 154, 29, 0.88);
  box-shadow: inset 0 0 0 1px rgba(220, 154, 29, 0.45);
}

#stamp-library-palette .external-resource-note {
  margin-top: 0;
}

#stamp-library-palette #stamp-library-status {
  order: 4;
  flex: 0 0 auto;
  margin-top: 0;
}

#stamp-library-palette #image-selection-grid {
  order: 5;
  flex: 1 1 auto;
  min-height: 0;
}

#stamp-library-palette .stamp-resource-block--library {
  order: 6;
  flex: 0 0 auto;
  margin-top: 2px;
}

.stamp-placement-controls {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(221, 195, 154, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.stamp-toggle-pair-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: center;
}

.stamp-variance-control + .stamp-toggle-pair-row {
  margin-top: 14px;
}

.stamp-toggle-pair-row > label {
  margin-bottom: 0 !important;
}

.stamp-variance-control {
  margin-bottom: 0 !important;
}

.stamp-start-size-control {
  margin: 12px 0 0.75em !important;
}

.compact-slider-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compact-slider-stack > * {
  margin: 0 !important;
}

.compact-slider-stack .label-header {
  margin-bottom: 2px;
}

.compact-slider-grid {
  gap: 8px;
}

.compact-slider-grid > * {
  margin-bottom: 0 !important;
}

.compact-slider-stack .stamp-start-size-control {
  margin: 0 !important;
}

.stamp-fill-density-control {
  margin-bottom: 0.75em !important;
}

.stamp-fill-shape-control {
  margin-bottom: 0.75em !important;
}

.stamp-fill-shape-control select {
  width: 100%;
  margin-top: 6px;
}

.stamp-variance-control.is-disabled {
  opacity: 0.55;
}

.image-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 10px;
  justify-content: stretch;
  flex: 1 1 auto;
  min-height: 120px;
  margin-top: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #ddd; border-radius: 4px; padding: 10px; box-sizing: border-box; background-color: #ffffff;
}
.image-selection-item {
  border: 1px solid rgba(90, 68, 42, 0.2);
  border-radius: 4px;
  padding: 4px;
  cursor: pointer;
  background-color: transparent;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
}
.image-selection-item:hover { transform: scale(1.05); border-color: rgba(90, 68, 42, 0.45); }
.image-selection-item.fill-selected { box-shadow: inset 0 0 0 2px rgba(220, 154, 29, 0.72); border-color: rgba(220, 154, 29, 0.78); background: rgba(220, 154, 29, 0.08); }
.image-selection-item.selected { box-shadow: 0 0 0 2px rgba(230, 198, 147, 0.95); border-color: rgba(230, 198, 147, 0.95); border-radius: 4px; }
.image-selection-item.selected.fill-selected { box-shadow: 0 0 0 2px rgba(230, 198, 147, 0.95), inset 0 0 0 2px rgba(220, 154, 29, 0.78); }
.image-selection-item.is-favorite::after {
  content: '★';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.8rem;
  line-height: 1;
  color: #ddc39a;
  text-shadow: 0 1px 1px rgba(26, 39, 53, 0.8);
  pointer-events: none;
}
.image-selection-item img { max-width: 50px; max-height: 50px; display: block; margin: 0; }

.stamp-grid-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px;
  text-align: center;
  color: #5a442a;
  opacity: 0.78;
}

/* ==========================================================================
   STAMPS PANEL (upload-as-button) — equal thirds
   ========================================================================== */

/* Hide native file input so “No file chosen” never shows */
#upload-stamps,
#upload-stamp-folder {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Upload label behaves like a button */
.file-upload-label { margin: 0; gap: 8px; }

/* One tidy 4-column row: Upload | Folder | Hide | X */
#stamps-panel .control-group {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--btn-gap);
  align-items: stretch;
}

/* Flatten the two wrappers so items become direct grid children */
#stamps-panel .control-group > div { display: contents; }

/* Buttons/labels fill their grid cells */
#stamps-panel .control-group > div > .file-upload-label,
#stamps-panel .control-group > div > button,
#stamps-panel .control-group > .file-upload-label,
#stamps-panel .control-group > button {
  width: 100%;
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* X behaves like a normal button (same width as others) */
#cancel-image-placement-btn {
  width: 100%;
  min-width: 0;
  padding: 0 1rem;
}

/* ==========================================================================
   COHESIVE BUTTON ROWS (generic)
   ========================================================================== */

/* Use the same gap everywhere buttons sit in a row */
.multi-button-container,
.control-group { gap: var(--btn-gap); }

/* Equal-width for direct button/label children in flex rows */
.multi-button-container > button,
.multi-button-container > .file-upload-label,
.control-group > button,
.control-group > .file-upload-label {
  flex: 1 1 0;
  min-width: 0;
}

/* When a control-group contains only buttons, switch it to an equal grid */
#continent-generator .control-group:has(> button):not(:has(> :not(button))),
#continent-generator .multi-button-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--btn-gap);
  width: 100%;
  align-items: stretch;
}

/* Buttons (and upload labels that look like buttons) fill their cell */
#continent-generator .control-group:has(> button):not(:has(> :not(button))) > button,
#continent-generator .multi-button-container > button,
#save-load-panel .button-group > button,
#save-load-panel .button-group > .file-upload-label,
#labels-panel .control-group > button {
  width: 100%;
  margin-top: 0;
}

/* Optional breathing room around rows */
#continent-generator .multi-button-container,
#continent-generator .control-group:has(> button):not(:has(> :not(button))),
#save-load-panel .button-group {
  margin: .0em 0;
}

#save-load-panel .save-load-status {
  margin: 0 0 10px;
  opacity: 0.9;
}

#save-load-panel .save-load-meta {
  margin-top: 16px;
}

#save-load-panel .save-load-meta > * + * {
  margin-top: 10px;
}

#save-load-panel .save-load-recovery-actions {
  margin-bottom: 0;
}

#save-load-panel .save-load-recovery-actions > button {
  margin-top: 0;
}

#save-load-panel .save-load-note {
  margin-top: 0;
  margin-bottom: 0;
}

#drawing-tools-panel .multi-button-container {
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.78fr);
  align-items: start;
}

#drawing-tools-panel .multi-button-container > button:not(.destructive-btn) {
  grid-column: 1;
}

#drawing-tools-panel .multi-button-container > button.destructive-btn {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  width: 100%;
  max-width: 14rem;
}

/* ==========================================================================
   MISC
   ========================================================================== */

#continent-generator button:disabled {
  background: #9aa0a6 !important; color: #fff !important;
  opacity: .65; cursor: not-allowed; pointer-events: none;
}
#continent-generator button:disabled:hover {
  background: #9aa0a6 !important; color: #fff !important;
}

#continent-generator .file-upload-label.is-disabled,
#continent-generator .file-upload-label.is-disabled:hover {
  background: #9aa0a6 !important;
  color: #fff !important;
  opacity: .65;
  cursor: not-allowed;
  pointer-events: none;
}

/* Keep palette swatches on their actual colors instead of inheriting button chrome */
#continent-generator button.color-swatch,
#continent-generator button.color-swatch:hover,
#continent-generator button.color-swatch:focus-visible,
#continent-generator button.color-swatch:active {
  background: var(--swatch-color, #ffffff) !important;
  color: transparent !important;
}

html, body {
  margin: 0;
  padding: 0;
  overflow: hidden !important;
  height: 100%;
  overscroll-behavior: none;
  background-color: #48525D;
}

/* Equal 1/3 | 1/3 | 1/3 for Load / Hide / X, even with wrappers */
#stamps-panel .control-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--btn-gap);
  align-items: stretch;
}

/* Flatten any wrapper element types */
#stamps-panel .control-group > * { display: contents; }

/* Make the actual controls fill their grid cells */
#stamps-panel .control-group :is(button, .file-upload-label) {
  inline-size: 100%;
  min-inline-size: 0;
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Nuke any legacy outer frame */
#continent-generator > div > div:nth-child(2),
#continent-generator > div > div:nth-child(2):focus,
#continent-generator > div > div:nth-child(2):focus-within {
  outline: none !important;
  border: 0 !important;      /* in case an old border is lingering */
  box-shadow: none !important;/* in case the frame was done with a shadow */
}

/* ==========================================================================
   LEAN UI PROTOTYPE OVERRIDES
   ========================================================================== */

#continent-generator {
  --btn-radius: 0;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

#top-brand-bar,
#site-footer {
  background: var(--chrome-bg);
  box-shadow: none;
}

#top-brand-bar {
  border-bottom-width: 1px;
}

#site-footer {
  margin: 20px -20px 0;
  border-top-width: 1px;
  display: none !important;
}

#generator-workspace {
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
  overflow: hidden;
}

#control-nav-column,
#control-panel-column,
#map-wrapper-container {
  min-height: 0;
  max-height: none;
  align-self: stretch;
}

#map-wrapper-container {
  overscroll-behavior: none;
}

#control-nav-column,
#control-panel-column,
.manual-reference-body,
#place-info-dialog,
#settlement-list-dialog,
.stamp-library-palette-body {
  overscroll-behavior: contain;
}

.brand-nav a {
  border-radius: 0;
}

#control-nav-column,
#control-panel-column {
  border-width: 1px;
  border-radius: 0;
}

#control-panel-column::-webkit-scrollbar-thumb {
  border-radius: 0;
}

#control-nav-column .control-nav-link {
  border-width: 1px;
  border-radius: 0;
}

#control-nav-column .control-nav-link:hover {
  background-color: rgba(220, 154, 29, 0.08);
}

#control-nav-column .control-nav-link.active {
  background-color: rgba(220, 154, 29, 0.1);
}

.panel-content-wrapper {
  border-width: 1px;
  border-radius: 0;
  box-shadow: none;
}

.place-info-selection-panel,
.place-info-generated-card,
.place-info-generated-item,
#travel-time-panel,
.travel-time-result-card,
.travel-time-summary,
.map-zoom-processing-card {
  border-radius: 0;
  box-shadow: none;
}

.place-info-selection-panel,
.place-info-generated-item,
#travel-time-panel,
.travel-time-result-card {
  background: rgba(245, 238, 219, 0.03);
  border: 1px solid rgba(220, 154, 29, 0.22);
}

.place-info-generated-card {
  background: rgba(245, 238, 219, 0.03);
  border-top: 1px solid rgba(220, 154, 29, 0.34);
  border-right: 1px solid rgba(220, 154, 29, 0.18);
  border-bottom: 1px solid rgba(220, 154, 29, 0.18);
  border-left: 1px solid #DC9A1D;
}

.travel-time-summary,
.map-zoom-processing-card {
  background: rgba(245, 238, 219, 0.03);
  border: 1px solid rgba(220, 154, 29, 0.28);
}

#continent-generator .accordion-content input[type='text'],
#continent-generator .accordion-content input[type='number'],
#continent-generator .accordion-content select,
#continent-generator .accordion-content textarea,
#continent-generator input[type='color'] {
  border-radius: 0;
  box-shadow: none;
}

#continent-generator button:not(.stepper-btn):not(.destructive-btn):not(.warning-btn),
#continent-generator .file-upload-label {
  border: 1px solid #DC9A1D;
  border-radius: 0;
  background: rgba(245, 238, 219, 0.03);
  color: var(--chrome-fg);
  box-shadow: none;
}

#continent-generator button:not(.stepper-btn):not(.destructive-btn):not(.warning-btn):hover,
#continent-generator .file-upload-label:hover {
  background: rgba(220, 154, 29, 0.1);
  color: #F5EEDB;
}

#continent-generator button.destructive-btn,
#continent-generator button.warning-btn {
  border-radius: 0;
  box-shadow: none;
}

#top-brand-bar,
#site-footer,
#control-nav-column,
#control-panel-column,
#manual-reference-overlay,
#stamp-library-palette,
#place-info-hover-card,
#place-info-dialog,
#settlement-list-dialog,
#paid-access-dialog {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.45;
}

#top-brand-bar button,
#top-brand-bar input,
#top-brand-bar select,
#top-brand-bar textarea,
#control-nav-column button,
#control-panel-column button,
#control-panel-column input,
#control-panel-column select,
#control-panel-column textarea,
#stamp-library-palette button,
#stamp-library-palette input,
#stamp-library-palette select,
#stamp-library-palette textarea,
#place-info-dialog button,
#place-info-dialog input,
#place-info-dialog select,
#place-info-dialog textarea,
#settlement-list-dialog button,
#paid-access-dialog button,
#paid-access-dialog input {
  font: inherit;
}

.brand-paid-message,
.brand-nav a,
.site-footer-title,
.travel-time-result-card strong,
.place-info-generated-header strong,
.manual-reference-header h2,
.manual-reference-section h3,
.place-info-hover-title,
.place-info-dialog-title-group h2,
#paid-access-title,
.paid-access-copy,
.paid-access-support,
.paid-access-helper,
.stamp-library-palette-title {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

#stamp-library-palette {
  border-width: 1px;
  border-radius: 0;
  box-shadow: none;
  background: var(--chrome-bg);
}

.stamp-library-palette-header {
  padding: 12px;
  border-bottom-color: rgba(220, 154, 29, 0.24);
  background: transparent;
}

.stamp-library-palette-title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--chrome-fg);
}

.stamp-library-palette-subtitle {
  margin-top: 3px;
  font-size: 0.76rem;
  line-height: 1.35;
}

.stamp-library-palette-close {
  width: 32px;
  min-width: 32px;
  height: 32px;
  border-radius: 0;
  background: transparent;
  font-size: 1rem;
}

.stamp-library-palette-close:hover {
  background: rgba(220, 154, 29, 0.1);
}

.stamp-library-palette-body {
  gap: 10px;
  padding: 12px;
}

#stamp-library-controls label {
  font-size: 0.84rem;
  line-height: 1.45;
}

.stamp-placement-controls,
.texture-export-note,
#stamp-library-palette .image-selection-item,
#stamp-library-palette .image-selection-item.selected {
  border-radius: 0;
  box-shadow: none;
}

.stamp-placement-controls {
  background: rgba(245, 238, 219, 0.03);
}

.texture-export-note {
  border: 1px solid rgba(220, 154, 29, 0.28);
  border-left-width: 1px;
  background: rgba(245, 238, 219, 0.03);
}

#stamp-library-palette .image-selection-item.fill-selected {
  box-shadow: inset 0 0 0 1px rgba(220, 154, 29, 0.72);
}

#stamp-library-palette .image-selection-item.selected {
  border-color: rgba(230, 198, 147, 0.95);
  box-shadow: 0 0 0 1px rgba(230, 198, 147, 0.95);
  background: rgba(220, 154, 29, 0.06);
}

#stamp-library-palette .image-selection-item.selected.fill-selected {
  box-shadow:
    0 0 0 1px rgba(230, 198, 147, 0.95),
    inset 0 0 0 1px rgba(220, 154, 29, 0.78);
}

.slider-grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.slider-grid-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.stamp-slider-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.country-color-swatch-row {
  margin-top: 10px;
}

.country-region-batch-input-row,
.country-region-select-row {
  margin-bottom: 0 !important;
}

.country-region-batch-input-row {
  margin-bottom: 10px !important;
}

.country-region-batch-add-row {
  margin: 10px 0 14px;
}

.country-region-batch-add-row > button {
  width: 100%;
  margin-top: 0;
}

.country-region-select-row {
  margin-top: 8px !important;
  margin-bottom: 10px !important;
}

.country-mode-buttons button.is-active {
  background: rgba(220, 154, 29, 0.18);
  color: #F5EEDB;
}

#paint-layer-controls .paint-layer-swatch-row + .map-color-input-row {
  margin-top: 14px;
}

#country-colors-panel .country-mode-buttons + .control-group {
  margin-top: 18px;
}

#country-colors-panel .map-color-control + .panel-section-label {
  margin-top: 16px;
}

#country-colors-panel .panel-section-label + .country-paint-actions-row {
  margin-top: 10px;
}

#country-colors-panel .country-paint-actions-row + .country-paint-actions-row {
  margin-top: 10px;
}

#country-colors-panel .country-paint-actions-row + label.is-stacked {
  margin-top: 18px !important;
}

.country-paint-status {
  white-space: normal;
  line-height: 1.45;
}

.compact-select-grid,
.compact-toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.compact-select-grid > label,
.compact-toggle-grid > label {
  margin-bottom: 0;
}

.compact-toggle-row {
  min-height: var(--btn-height);
}

.text-effect-stack {
  display: grid;
  gap: 8px;
}

.text-effect-row {
  display: grid !important;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 0 !important;
}

.text-effect-row > input[type='checkbox'] {
  margin: 0;
}

.text-effect-row > input[type='range'] {
  width: 100%;
  min-width: 0;
}

.text-effect-row > :last-child {
  min-width: 3ch;
  text-align: right;
}

.stroke-color-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin-bottom: 0 !important;
}

.stroke-color-row > span {
  flex: 0 0 auto;
}

.free-text-selected-grid {
  margin-bottom: 0;
}

.free-text-select-row {
  margin: 2px 0 0;
}

.free-text-effect-stack {
  margin-top: 2px;
}

.ray-lines-meta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.ray-lines-meta-row > label {
  margin-bottom: 0 !important;
}

.ray-lines-meta-row > button {
  margin-top: 0;
}

.panel-heading-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1em;
}

.panel-heading-toggle__check {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  margin: 0;
}

.panel-heading-toggle__check input {
  margin: 0;
}

#dot-pattern-default-btn {
  margin-top: 0;
  margin-bottom: 8px;
}

.panel-heading-toggle__action {
  margin-top: 0 !important;
  margin-left: auto;
}

#place-info-panel .place-info-actions {
  display: grid;
  gap: 10px;
}

#place-info-panel .place-info-actions-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* Ensure drawing-tool headers use the shared Unicode arrow glyph. */
.drawing-tool-section-title::after {
  content: "\25B8";
}

/* Canvas resize direction control uses a single highlighted choice, with the other directions shown as plain arrows. */
#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn:not(.is-active):not([aria-pressed='true']),
#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn:not(.is-active):not([aria-pressed='true']):hover,
#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn:not(.is-active):not([aria-pressed='true']):focus-visible {
  background: transparent;
  border-color: transparent;
  color: #ddc39a;
  box-shadow: none;
}

/* Keep the selected canvas-resize anchor visibly active until a different anchor is chosen. */
#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn.is-active,
#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn[aria-pressed='true'],
#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn.is-active:hover,
#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn[aria-pressed='true']:hover,
#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn.is-active:focus-visible,
#continent-generator .canvas-resize-anchor-grid > button.canvas-resize-anchor-btn[aria-pressed='true']:focus-visible {
  background: rgba(220, 154, 29, 0.16);
  color: #f5eedb;
  border-color: #dc9a1d;
}

#place-info-panel .place-info-actions button {
  width: 100%;
  min-width: 0;
  min-height: var(--btn-height);
  height: var(--btn-height);
  margin-top: 0;
  padding: 0 10px;
  line-height: 1.15;
  white-space: normal;
}

#place-info-panel #open-settlement-list-btn {
  min-height: var(--btn-height);
  height: var(--btn-height);
  white-space: nowrap;
}

.settlement-list-content {
  gap: 14px;
}

.settlement-list-group {
  gap: 8px;
}

#settlement-list-dialog button.settlement-list-item {
  min-height: 96px !important;
  padding: 10px 12px !important;
  border: 1px solid rgba(220, 154, 29, 0.22) !important;
  background: rgba(245, 238, 219, 0.03) !important;
  justify-content: flex-start !important;
}

#settlement-list-dialog button.settlement-list-item:hover,
#settlement-list-dialog button.settlement-list-item:focus-visible {
  background: rgba(220, 154, 29, 0.06) !important;
  border-color: rgba(220, 154, 29, 0.42) !important;
}

.settlement-list-item-name {
  margin-bottom: 4px;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: 0.94rem;
  line-height: 1.25;
}

.settlement-list-item-summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.settlement-list-item-notes-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

#place-info-hover-card,
#place-info-dialog,
#settlement-list-dialog,
.settlement-list-empty {
  border-radius: 0 !important;
}

@media (max-width: 760px) {
  .slider-grid-two,
  .slider-grid-three,
  .compact-select-grid,
  .compact-toggle-grid {
    grid-template-columns: 1fr;
  }
}

/* Final consistency pass: unify collapsible sections, flatten extra sub-boxes,
   and keep the floating palettes compact so more of the map stays visible. */

.brand-paid-message {
  flex: 0 0 auto;
  align-self: center;
  padding: 0 0 0 10px;
  max-height: none;
  overflow: visible;
  color: rgba(245, 238, 219, 0.9);
  font-size: 0.84rem;
  line-height: 1;
  text-align: left;
  text-wrap: nowrap;
  white-space: nowrap;
  -webkit-line-clamp: unset;
}

:root {
  --panel-body-size: 11.5px;
  --panel-body-line: 1.45;
  --panel-section-title-size: 13px;
  --panel-label-size: 11.5px;
  --panel-label-line: 1.2;
  --panel-button-size: 11.5px;
  --panel-button-line: 1.1;
}

#continent-generator a[href*="artrealms.shop"],
#continent-generator a[href*="fantasymapsymbols.com"],
#continent-generator a[href*="mapcreator.net"] {
  text-decoration: none;
  cursor: pointer;
}

#continent-generator .accordion-content a,
#stamp-library-palette a,
#site-footer a {
  text-decoration: none;
  cursor: pointer;
}

#continent-generator .accordion-content a,
#stamp-library-palette a {
  color: #DDC39A;
}

#control-panel-column,
#stamp-library-palette,
#object-actions-panel.object-actions-floating {
  font-size: var(--panel-body-size);
  line-height: var(--panel-body-line);
}

#continent-generator .accordion-content label:not(.file-upload-label),
#stamp-library-palette label:not(.file-upload-label),
#object-actions-panel label:not(.file-upload-label) {
  font-size: var(--panel-body-size);
  line-height: var(--panel-body-line);
}

.label-header {
  font-size: var(--panel-label-size);
  line-height: var(--panel-label-line);
}

.label-header > :first-child {
  font-weight: 700;
}

.label-header > :last-child {
  font-weight: 400;
}

#control-panel-column .panel-content-wrapper fieldset > p.panel-section-title {
  font-size: var(--panel-section-title-size) !important;
  line-height: 1.2;
  font-weight: 700 !important;
}

#control-panel-column .panel-content-wrapper fieldset > p:not(.panel-section-title):not(.panel-subsection-title):not(.panel-section-label) {
  font-size: var(--panel-body-size) !important;
  line-height: var(--panel-body-line);
}

.labels-suggest-btn {
  min-height: var(--btn-height);
  height: var(--btn-height);
  margin-top: 0;
  padding: 0 14px;
  white-space: nowrap;
}

#labels-panel #city-label-controls .labels-panel-section,
#labels-panel #state-label-controls .labels-panel-section,
#labels-panel .labels-panel-stack > .labels-panel-section {
  padding: 0;
  border: 0;
  background: transparent;
}

#labels-panel #city-label-controls .labels-panel-section > * + *,
#labels-panel #state-label-controls .labels-panel-section > * + *,
#labels-panel .labels-panel-stack > .labels-panel-section > * + * {
  margin-top: 10px;
}

#labels-panel .labels-panel-section-title {
  margin: 0 0 10px;
  font-size: var(--panel-section-title-size);
  line-height: 1.2;
  font-weight: 700;
  color: inherit;
}

.panel-section-title {
  margin: 0 0 10px;
  font-size: var(--panel-section-title-size);
  line-height: 1.2;
  font-weight: 700;
  color: inherit;
}

.panel-section-title--spaced {
  margin-top: 1.5em;
}

.panel-heading-title {
  margin: 0;
  font-size: var(--panel-section-title-size);
  line-height: 1.2;
  font-weight: 700;
  color: inherit;
}

.panel-section-label,
.panel-section-title,
.drawing-tool-section-title,
.stamp-library-tool-section summary,
.panel-dropdown-section summary,
#object-actions-panel .object-actions-tool-section summary,
.panel-heading-toggle > p,
.panel-heading-toggle > span,
.panel-heading-title,
.shape-object-actions-title {
  font-size: var(--panel-section-title-size);
  line-height: 1.2;
  font-weight: 700;
}

.panel-section-label {
  margin: 15px 0 10px;
}

.panel-note {
  margin: 0;
  font-size: var(--panel-body-size);
  line-height: var(--panel-body-line);
  opacity: 0.82;
}

.panel-ink-textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  border: 1px solid var(--ink-color);
  padding: 0.25em;
}

.panel-full-width-btn {
  width: 100%;
}

.panel-full-width-btn--spaced {
  width: 100%;
  margin-bottom: 1em;
}

.panel-space-top-sm {
  margin-top: 6px !important;
}

.panel-space-top-md {
  margin-top: 8px !important;
}

.panel-space-bottom-sm {
  margin-bottom: 8px !important;
}

.panel-space-bottom-md {
  margin-bottom: 10px !important;
}

#colors-panel fieldset[data-sectionized='true'] > .drawing-tool-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

#labels-panel #state-label-controls .labels-panel-section + .labels-panel-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(220, 154, 29, 0.28);
}

#scale-bar-panel fieldset > hr {
  display: none;
}

#travel-time-panel {
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.stamp-library-action-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.stamp-library-action-row > * {
  width: 100%;
  min-width: 0;
  margin-top: 0;
}

.stamp-library-action-row > button,
.stamp-library-action-row > .file-upload-label {
  min-height: var(--btn-height);
  height: var(--btn-height);
  padding: 0 8px;
  font-size: 0.76rem;
  line-height: 1.05;
  white-space: nowrap;
}

.stamp-library-palette-header,
.object-actions-panel-header {
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.stamp-library-palette-title-group,
.object-actions-title-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.stamp-library-palette-subtitle,
.object-actions-subtitle {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1;
  color: rgba(245, 238, 219, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stamp-library-palette-close,
.object-actions-close-btn {
  width: 28px;
  min-width: 28px;
  height: 28px;
  font-size: 0.94rem;
}

.stamp-library-palette-title,
.object-actions-floating .object-actions-title {
  font-size: var(--panel-section-title-size);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.paint-heading-row {
  margin-bottom: 12px;
}

#object-actions-panel.object-actions-floating {
  width: min(300px, calc(100vw - 28px));
  min-width: 272px;
}

#object-actions-panel.object-actions-floating .object-actions-body {
  padding: 8px 10px 10px;
}

#object-actions-panel .object-actions-toggle-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 6px;
}

#object-actions-panel .object-actions-toggle-chip {
  flex: 0 0 auto;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  justify-content: flex-start;
  gap: 8px;
  font-size: 0.76rem;
}

#object-actions-panel .object-actions-button-grid {
  gap: 5px;
}

#object-actions-panel.object-actions-floating .object-actions-button-grid > button {
  min-height: 26px;
  padding: 3px 4px;
  font-size: 0.68rem;
  line-height: 1.05;
}

.stamp-library-tool-section,
.panel-dropdown-section,
#object-actions-panel .object-actions-tool-section {
  position: relative;
  margin-top: 0;
  padding-top: 12px;
  border: 0;
  border-top: 1px solid rgba(220, 154, 29, 0.28);
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

#continent-generator .panel-content-wrapper fieldset[data-sectionized='true'] > .drawing-tool-section:first-of-type,
#continent-generator .panel-content-wrapper fieldset > .panel-dropdown-section:first-of-type,
#stamp-library-palette .stamp-library-tool-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.stamp-library-tool-section summary,
.panel-dropdown-section summary,
#object-actions-panel .object-actions-tool-section summary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 0 18px 0 0;
  cursor: pointer;
  color: #f5eedb;
  font-size: var(--panel-section-title-size);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  user-select: none;
  list-style: none;
}

.stamp-library-tool-section summary::-webkit-details-marker,
.panel-dropdown-section summary::-webkit-details-marker,
#object-actions-panel .object-actions-tool-section summary::-webkit-details-marker {
  display: none;
}

.stamp-library-tool-section summary::before,
.panel-dropdown-section summary::before,
#object-actions-panel .object-actions-tool-section summary::before {
  content: none;
}

.stamp-library-tool-section summary::after,
.panel-dropdown-section summary::after,
#object-actions-panel .object-actions-tool-section summary::after {
  content: "\25B8";
  position: absolute;
  top: 50%;
  right: 10px;
  font-size: 0.95em;
  line-height: 1;
  opacity: 0.85;
  transform: translateY(-50%);
  transition: transform 0.18s ease;
}

.stamp-library-tool-section[open] summary::after,
.panel-dropdown-section[open] summary::after,
#object-actions-panel .object-actions-tool-section[open] summary::after {
  transform: translateY(-50%) rotate(90deg);
}

.stamp-library-tool-section-body,
.panel-dropdown-section-body,
#object-actions-panel .object-actions-tool-section-body {
  padding: 10px 0 0;
}

.stamp-library-tool-section-body > * + *,
.panel-dropdown-section-body > * + * {
  margin-top: 8px;
}

.stamp-placement-controls {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.stamp-library-launch-row + .stamp-placement-controls {
  margin-top: 10px;
}

.line-select-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.line-select-row > label {
  margin-bottom: 0;
}

.line-select-row select {
  width: 100%;
}

.line-select-row + #border-line-controls {
  margin-top: 12px;
}

.drawing-tool-section--with-controls {
  position: relative;
}

.drawing-tool-section {
  border-top: 1px solid rgba(220, 154, 29, 0.28);
  padding-top: 12px;
}

.drawing-tool-section summary {
  list-style: none;
}

.drawing-tool-section summary::-webkit-details-marker {
  display: none;
}

.drawing-tool-section-title {
  display: flex;
  align-items: center;
  position: relative;
  justify-content: flex-start;
  gap: 8px;
  margin: 0;
  padding-right: 18px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.drawing-tool-section-title::after {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}

.drawing-tool-section[open] .drawing-tool-section-title::after {
  transform: translateY(-50%) rotate(90deg);
}

.drawing-tool-section--with-controls > .drawing-tool-section-title {
  padding-right: 18px;
}

.drawing-tool-section-body {
  margin-top: 12px;
}

.drawing-tool-section-body > * + * {
  margin-top: 12px;
}

#save-load-panel .save-load-recovery-actions {
  margin-top: 12px;
  margin-bottom: 0;
}

#save-load-panel .button-group {
  margin-bottom: 12px;
}

#save-load-panel .save-load-meta {
  margin-top: 18px;
}

/* ==========================================================================
   PANEL TYPOGRAPHY ROLE OVERRIDES
   ========================================================================== */

#continent-generator button:not(.stepper-btn):not(.stamp-library-palette-close):not(.object-actions-close-btn),
#continent-generator .file-upload-label {
  font-size: var(--panel-button-size);
  line-height: var(--panel-button-line);
}

.place-info-helper-text,
.travel-time-helper-text,
.labels-panel-note,
.grid-panel-note,
.color-panel-note,
.font-ui-note,
.stamp-library-meta,
.external-resource-note,
.shape-fill-note,
.canvas-resize-anchor-label,
.dimension-workflow-note,
.object-selection-status,
.object-arrange-note,
.stamp-library-palette-subtitle,
.object-actions-subtitle,
.save-load-status,
.save-load-note,
.place-info-selection-status,
.place-info-selection-preview,
.texture-export-note,
#stamp-library-palette #stamp-library-status,
#stamp-library-controls label {
  font-size: var(--panel-body-size);
  line-height: var(--panel-body-line);
}

.stamp-library-action-row > button,
.stamp-library-action-row > .file-upload-label,
#object-actions-panel .object-actions-toggle-chip,
#object-actions-panel.object-actions-floating .object-actions-button-grid > button {
  font-size: var(--panel-button-size);
  line-height: var(--panel-button-line);
}

#continent-generator .accordion-content label.is-stacked:has(> input[type="range"]) .label-header,
#stamp-library-palette label.is-stacked:has(> input[type="range"]) .label-header,
#object-actions-panel label.is-stacked:has(> input[type="range"]) .label-header {
  margin-bottom: 4px;
}

#continent-generator .accordion-content :is(fieldset, .labels-panel-section, .drawing-tool-section-body, .stamp-library-tool-section-body, .object-actions-tool-section-body) > :is(.panel-section-title, .labels-panel-section-title, .panel-subsection-title, .panel-section-label) + :is(label.is-stacked:has(> input[type="range"]), .slider-grid-two, .slider-grid-three, .compact-slider-stack) {
  margin-top: 10px;
}

#continent-generator .accordion-content label.is-inline.compact-toggle-row,
#stamp-library-palette label.is-inline.compact-toggle-row,
#object-actions-panel label.is-inline.compact-toggle-row {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  width: auto !important;
}

#continent-generator .accordion-content label.is-inline.compact-toggle-row > span,
#stamp-library-palette label.is-inline.compact-toggle-row > span,
#object-actions-panel label.is-inline.compact-toggle-row > span {
  flex: 0 0 auto;
}

#continent-generator .accordion-content label.is-inline.compact-toggle-row input[type="checkbox"],
#stamp-library-palette label.is-inline.compact-toggle-row input[type="checkbox"],
#object-actions-panel label.is-inline.compact-toggle-row input[type="checkbox"] {
  margin: 0;
  flex: 0 0 auto;
}

.drawing-tool-section-title,
.stamp-library-tool-section summary,
.panel-dropdown-section summary,
#object-actions-panel .object-actions-tool-section summary {
  justify-content: flex-start;
  gap: 8px;
  padding-right: 18px;
}

.drawing-tool-section-title-text {
  flex: 0 1 auto;
}

.drawing-tool-section--with-controls > .drawing-tool-section-title,
.panel-dropdown-section:has(.panel-dropdown-section__check) > summary {
  padding-right: 74px;
}

.drawing-tool-section-controls {
  position: static;
  top: auto;
  right: auto;
  left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 0 8px;
  line-height: 0;
  flex: 0 0 auto;
  transform: none;
  z-index: auto;
}

.drawing-tool-section-controls .panel-heading-toggle__check,
.drawing-tool-section-controls .panel-heading-toggle__action {
  margin: 0 !important;
  flex: 0 0 auto;
}

.panel-dropdown-section__check {
  position: absolute;
  top: 50%;
  right: 38px;
  display: inline-flex;
  align-items: center;
  line-height: 0;
  margin: 0 !important;
  transform: translateY(-50%);
  z-index: 2;
}

.panel-heading-toggle__action--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  min-width: 24px;
  height: 24px;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
}

.stamp-library-palette-title-group,
.object-actions-title-group {
  flex-wrap: nowrap;
  white-space: nowrap;
}

#object-actions-panel .object-actions-toggle-grid {
  gap: 6px 12px;
}

#object-actions-panel .object-actions-toggle-chip {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
}

#continent-generator .accordion-content label.is-inline.compact-toggle-row.compact-toggle-row--spread {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  gap: 12px !important;
}

.panel-heading-toggle__action--text {
  min-width: 0;
  width: auto;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #f5eedb;
  font-size: var(--panel-label-size);
  font-weight: 700;
  line-height: 1;
  margin-left: 6px !important;
}

.texture-next-inline-btn {
  width: 100%;
  justify-content: center;
  margin: 0 !important;
}

#textures-border-panel .drawing-tool-section-body > .texture-next-inline-btn + label.is-stacked {
  margin-top: 16px;
}

#grid-panel fieldset > label.is-stacked:has(> input[type="range"]) + label.is-stacked:has(> input[type="range"]) {
  margin-top: 12px;
}

.panel-heading-toggle__action--text:hover,
.panel-heading-toggle__action--text:focus {
  background: transparent;
  color: #DDC39A;
}

.panel-section-divider {
  width: 100%;
  margin: 10px 0;
  border: 0;
  border-top: 1px solid rgba(220, 154, 29, 0.28);
}

.panel-section-divider--tight {
  margin: 1em 0;
}

.panel-section-divider--wide {
  margin: 1.5em 0;
}

.panel-section-divider--wide-top {
  margin: 1.5em 0 1em;
}

.panel-subsection-title {
  margin: 0 0 8px;
  font-size: var(--panel-label-size);
  font-weight: 700;
  line-height: var(--panel-label-line);
  color: #f5eedb;
}

.title-block-inline-toggle-row {
  align-self: flex-start;
  min-height: 0;
  padding-bottom: 0;
}

.title-block-slider-stack {
  gap: 12px;
}

.text-box-border-toggle-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 24px;
  align-items: center;
  margin: 10px 0 8px;
}

.text-box-border-toggle-row .text-box-border-toggle {
  display: inline-flex !important;
  align-items: center !important;
  flex: 0 0 auto;
  margin-bottom: 0 !important;
  width: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  justify-content: flex-start !important;
  gap: 8px !important;
}

.paint-layer-mode-buttons {
  margin: 20px 0 24px;
}

#ray-lines-panel .panel-heading-toggle__check,
#grid-panel .panel-heading-toggle__check {
  align-self: center;
  transform: none;
}

.paint-layer-mode-buttons > button,
#paint-layer-clear-btn {
  min-height: 42px;
  height: 42px;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.paint-layer-clear-row {
  margin: 20px 0 22px;
}

#paint-layer-controls > .map-color-control + .paint-layer-mode-buttons {
  margin-top: 20px;
}

#paint-layer-controls > .paint-layer-mode-buttons + .slider-grid-two {
  margin-top: 18px;
}

#paint-layer-controls > .slider-grid-two + .slider-grid-two {
  margin-top: 14px;
}

#paint-layer-controls > .slider-grid-two + label.is-inline.compact-toggle-row {
  margin-top: 18px;
}

#paint-layer-controls > label.is-inline.compact-toggle-row + .paint-layer-clear-row {
  margin-top: 18px;
}
