    :root {
      --bg: #FDFCFB;
      --bg-surface: #FFFFFF;
      --bg-hover: #F8FAF9;
      --text: #2D3748;
      --text-muted: #718096;
      --border: #E2E8F0;
      --accent: #4A9C8D;
      --accent-soft: #E6F3EF;
      --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
      --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
      --radius: 12px;
      --font-stack: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }

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

    .hidden {
      display: none !important;
    }

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

    #loginOverlay {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.45);
      z-index: 2000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 24px;
    }

    #loginOverlay.hidden {
      display: none !important;
    }

    .login-box {
      background: var(--bg-surface);
      padding: 28px 32px;
      border-radius: var(--radius);
      min-width: min(360px, 100%);
      box-shadow: var(--shadow);
      border: 1px solid var(--border);
    }

    .login-box h2 {
      font-size: 18px;
      font-weight: 600;
      margin-bottom: 16px;
    }

    .login-box input {
      width: 100%;
      padding: 10px 12px;
      margin-bottom: 10px;
      border-radius: 8px;
      border: 1px solid var(--border);
      font-size: 14px;
    }

    .login-box .btn {
      width: 100%;
      margin: 12px 0 0 0;
      padding: 10px;
    }

    #loginError {
      color: #c53030;
      font-size: 13px;
      margin-top: 10px;
    }

    html,
    body {
      overflow-y: auto;
      height: auto;
    }

    body {
      font-family: var(--font-stack);
      background-color: var(--bg);
      color: var(--text);
      line-height: 1.5;
      min-height: 100vh;
    }

    /* Elegant Header */
    header {
      padding: 20px 40px;
      background-color: var(--bg-surface);
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid rgba(0, 0, 0, 0.03);
      position: sticky;
      top: 0;
      z-index: 10;
      padding-right: 20px;
    }

    .brand {
      font-size: 18px;
      font-weight: 500;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .brand svg {
      width: 18px;
      height: 18px;
      color: var(--accent);
    }

    .meta-info {
      font-size: 13px;
      color: var(--text-muted);
      background: var(--bg);
      padding: 6px 14px;
      border-radius: 20px;
      border: 1px solid var(--border);
      display: flex;
      align-items: center;
    }

    .btn {
      background: var(--accent);
      color: white;
      border: none;
      padding: 6px 14px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 13px;
      margin-left: 10px;
      font-weight: 500;
    }

    .btn-secondary {
      background: var(--bg-hover);
      color: var(--text);
      border: 1px solid var(--border);
    }

    .btn:hover {
      opacity: 0.9;
    }

    main {
      padding: 40px;
      max-width: 1600px;
      margin: 0 auto;
    }

    .dropzone {
      border: 2px dashed #CBD5E0;
      border-radius: 20px;
      padding: 80px 40px;
      text-align: center;
      background-color: var(--bg-surface);
      cursor: pointer;
      margin-top: 40px;
    }

    .dropzone.hidden {
      display: none;
    }

    .controls {
      display: none;
      flex-direction: column;
      align-items: stretch;
      gap: 0;
      margin-bottom: 24px;
    }

    .gallery-filters-panel {
      display: flex;
      flex-direction: column;
      gap: 10px;
      margin-top: 12px;
    }

    .gallery-filters-toolbar {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-end;
      justify-content: space-between;
      gap: 12px 20px;
    }

    .gallery-filters-group {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px 12px;
      min-width: 0;
    }

    .gallery-filters-heading {
      font-size: 15px;
      font-weight: 600;
      color: var(--text);
      letter-spacing: -0.01em;
      line-height: 1.2;
    }

    .gallery-filters-kicker {
      font-size: 11px;
      font-weight: 700;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.04em;
      line-height: 1.2;
    }

    .gallery-filters-group--difficulty {
      align-items: center;
    }

    .gallery-filters-search-row {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px 14px;
    }

    .gallery-filters-search-input {
      flex: 1 1 280px;
      min-width: min(100%, 220px);
      max-width: 100%;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--bg);
      color: var(--text);
      box-sizing: border-box;
    }

    .gallery-filters-result-count {
      font-size: 12px;
      color: var(--text-muted);
      flex: 0 0 auto;
      margin-left: auto;
      white-space: nowrap;
    }

    @media (max-width: 520px) {
      .gallery-filters-result-count {
        margin-left: 0;
        width: 100%;
      }
    }

    .controls select {
      padding: 8px 16px;
      border-radius: 8px;
      border: 1px solid var(--border);
      font-size: 13px;
      outline: none;
    }

    /* Dual-View Grid */
    .grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
      gap: 12px;
    }

    .card {
      display: flex;
      flex-direction: column;
      background: var(--bg-surface);
      border-radius: var(--radius);
      border: 1px solid rgba(0, 0, 0, 0.06);
      overflow: hidden;
      box-shadow: var(--shadow-sm);
      cursor: pointer;
    }

    .card:hover {
      box-shadow: var(--shadow);
    }

    /* Gallery: right-click classification thumbnail → GeoTIFF download menu */
    .gallery-context-menu {
      position: fixed;
      z-index: 10050;
      min-width: 260px;
      max-width: min(320px, 92vw);
      padding: 8px 0 10px;
      border-radius: 10px;
      border: 1px solid rgba(15, 23, 42, 0.12);
      background: rgba(255, 255, 255, 0.98);
      box-shadow: 0 10px 32px rgba(15, 23, 42, 0.18);
      font-size: 12px;
      color: var(--text);
      box-sizing: border-box;
    }

    .gallery-context-menu.hidden {
      display: none !important;
    }

    .gallery-context-menu-title {
      padding: 2px 12px 8px;
      font-weight: 700;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--text-muted);
    }

    .gallery-context-menu-item {
      display: block;
      width: 100%;
      text-align: left;
      padding: 8px 12px;
      border: none;
      background: transparent;
      cursor: pointer;
      font: inherit;
      color: var(--text);
    }

    .gallery-context-menu-item:hover {
      background: var(--bg-hover);
    }

    .gallery-context-menu-hint {
      margin: 8px 12px 0;
      font-size: 10px;
      color: var(--text-muted);
      line-height: 1.35;
    }

    .card-images {
      display: flex;
      align-items: stretch;
      justify-content: center;
      min-height: 200px;
      height: 200px;
      width: 100%;
      background: #000;
    }

    /* Gallery: same square on every card (full card width); map fills it — cover crops edges, no letterbox bands. */
    .card-images.card-images--fill {
      width: 100%;
      margin: 0;
      padding: 0 0 4px;
      display: block;
      flex: 0 0 auto;
      height: auto;
      min-height: 0;
      background: var(--bg-surface);
      position: relative;
      z-index: 1;
    }

    .card-media-viewport {
      width: 100%;
      max-width: 100%;
      margin-inline: 0;
      aspect-ratio: auto;
      height: 175px;
      position: relative;
      background: #1a1f26;
      box-sizing: border-box;
      border-radius: 8px;
      overflow: hidden;
      border: 1px solid var(--border);
      /* Discourage iOS long-press “Save Image” on the preview; use right-click → GeoTIFF menu instead. */
      -webkit-touch-callout: none;
    }

    .card-gallery-save-badge {
      position: absolute;
      top: 6px;
      right: 6px;
      z-index: 4;
      font-size: 10px;
      font-weight: 700;
      padding: 3px 8px;
      border-radius: 6px;
      pointer-events: none;
      letter-spacing: 0.02em;
      line-height: 1.2;
    }

    .card-gallery-save-badge--my {
      background: rgba(72, 187, 120, 0.94);
      color: #fff;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    }

    .card-gallery-save-badge--base {
      background: rgba(255, 255, 255, 0.9);
      color: var(--text-muted);
      border: 1px solid var(--border);
      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    }

    .card-img-half {
      width: 50%;
      position: relative;
      overflow: hidden;
    }

    .card-img-half+.card-img-half {
      border-left: 1px solid rgba(0, 0, 0, 0.5);
    }

    .card-img-full {
      position: relative;
      overflow: hidden;
      box-sizing: border-box;
      max-height: 100%;
      max-width: 100%;
      width: auto;
      height: 100%;
      min-width: 0;
      flex-shrink: 1;
    }

    .group-container .grid .card-img-full {
      margin: 0;
      position: relative;
      overflow: hidden;
    }

    /* Wins over .group-container .grid .card-img-full (position) and generic object-fit: contain on thumbs. */
    .group-container .grid .card .card-images.card-images--fill .card-img-full {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      margin: 0;
      overflow: hidden;
      box-sizing: border-box;
    }

    .group-container .grid .card .card-media-viewport .card-img-full .map-thumb,
    .group-container .grid .card .card-media-viewport .card-img-full .card-bg-sat,
    .group-container .grid .card .card-media-viewport .card-bg-sat-host canvas.card-bg-sat {
      object-fit: cover;
      object-position: center;
    }

    .card-bg-sat-host {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 0;
      display: block;
      pointer-events: none;
    }

    .card-bg-sat-host canvas.card-bg-sat {
      width: 100%;
      height: 100%;
      display: block;
      object-fit: contain;
    }

    .card-img-full .card-bg-sat {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      object-fit: contain;
      object-position: center;
      z-index: 0;
      image-rendering: pixelated;
    }

    .card-img-half img,
    .card-img-half canvas,
    .card-img-full .map-thumb,
    .card-img-full canvas {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      object-fit: contain;
      object-position: center;
      z-index: 1;
    }

    .card-label {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: 2;
      text-align: left;
      font-size: 8px;
      font-weight: 700;
      letter-spacing: 1.5px;
      text-transform: uppercase;
      color: #FFF;
      background: rgba(0, 0, 0, 0.4);
      padding: 4px 8px;
      pointer-events: none;
    }

    .composition-bar {
      height: 6px;
      width: 100%;
      display: flex;
      background: #E2E8F0;
      position: relative;
      z-index: 2;
    }

    .comp-segment {
      height: 100%;
    }

    .card-body {
      padding: 14px;
      position: relative;
      z-index: 2;
      background: var(--bg-surface);
    }

    .card-title {
      font-weight: 600;
      font-size: 13px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      margin-bottom: 6px;
    }

    .card-title>span:first-child {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .card-title .flag {
      margin-right: 4px;
    }

    .card-workflow-strip {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 5px 6px;
      margin-bottom: 8px;
    }

    .card-wf-chip {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-height: 22px;
      min-width: 22px;
      padding: 0 6px;
      border-radius: 6px;
      font-size: 10px;
      font-weight: 700;
      line-height: 1;
      letter-spacing: 0.02em;
      background: var(--bg-hover, rgba(0, 0, 0, 0.06));
      color: var(--text-muted);
      border: 1px solid rgba(0, 0, 0, 0.08);
      cursor: default;
      user-select: none;
    }

    .card-wf-ws {
      font-variant-numeric: tabular-nums;
      color: var(--accent);
      border-color: color-mix(in srgb, var(--accent) 35%, transparent);
      background: color-mix(in srgb, var(--accent) 12%, transparent);
    }

    .card-wf-rev--pass {
      color: #047857;
      border-color: rgba(4, 120, 87, 0.35);
      background: rgba(4, 120, 87, 0.1);
    }

    .card-wf-rev--passed {
      color: #0d7a3a;
      border-color: rgba(13, 122, 58, 0.35);
      background: rgba(13, 122, 58, 0.12);
    }

    .card-wf-rev--revised {
      color: #1d4ed8;
      border-color: rgba(29, 78, 216, 0.35);
      background: rgba(29, 78, 216, 0.1);
    }

    .card-wf-rev--unrevised {
      color: #6d28d9;
      border-color: rgba(109, 40, 217, 0.32);
      background: rgba(109, 40, 217, 0.1);
    }

    .card-wf-rev--revise {
      color: #b45309;
      border-color: rgba(180, 83, 9, 0.35);
      background: rgba(180, 83, 9, 0.12);
    }

    .card-wf-rev--none {
      color: var(--text-muted);
      opacity: 0.85;
    }

    .card-wf-diff--high {
      color: #b91c1c;
      border-color: rgba(185, 28, 28, 0.3);
      background: rgba(185, 28, 28, 0.08);
    }

    .card-wf-diff--med {
      color: #92400e;
    }

    .card-wf-diff--low,
    .card-wf-diff--simple {
      color: #1d4ed8;
      border-color: rgba(29, 78, 216, 0.25);
      background: rgba(29, 78, 216, 0.08);
    }

    .card-wf-ann {
      gap: 4px;
      min-width: auto;
      padding-left: 5px;
      padding-right: 7px;
      font-weight: 600;
    }

    .card-wf-ann-ic {
      font-size: 11px;
      line-height: 1;
      opacity: 0.75;
    }

    .card-wf-ann-txt {
      font-size: 9px;
      letter-spacing: 0.04em;
    }

    .card-stats {
      margin-top: 2px;
    }

    .card-stats-block {
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--bg-hover);
      padding: 8px 9px;
    }

    .card-stats-head {
      margin: 0 0 6px;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.03em;
      text-transform: uppercase;
      color: var(--accent);
    }

    .card-stats-empty {
      margin: 0;
      font-size: 10px;
      color: var(--text-muted);
      line-height: 1.35;
    }

    .card-stats-grid {
      display: flex;
      flex-direction: column;
      gap: 5px;
    }

    .card-stat-row {
      display: grid;
      grid-template-columns: 12px minmax(0, 1fr) auto auto;
      align-items: center;
      gap: 6px;
      font-size: 10px;
      line-height: 1.25;
    }

    .card-stats .stat-dot {
      width: 10px;
      height: 10px;
      border-radius: 3px;
      border: 1px solid rgba(15, 23, 42, 0.12);
      display: block;
      margin: 0;
    }

    .card-stat-label {
      color: var(--text);
      font-weight: 500;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .card-stat-pct {
      font-variant-numeric: tabular-nums;
      font-weight: 600;
      color: var(--text);
      white-space: nowrap;
    }

    .card-stat-px {
      font-size: 9px;
      font-variant-numeric: tabular-nums;
      color: var(--text-muted);
      white-space: nowrap;
    }

    .card-version-row {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin-top: 8px;
    }

    .card-version-chip {
      font-size: 10px;
      line-height: 1;
      padding: 4px 7px;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--bg-hover);
      color: var(--text-muted);
      font-weight: 600;
      cursor: pointer;
      transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
    }

    .card-version-chip.is-active {
      color: var(--accent);
      border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
      background: color-mix(in srgb, var(--accent) 14%, var(--bg-hover));
    }

    /* Full Screen Editor Modal */
    .modal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: var(--bg);
      z-index: 1000;
      display: none;
      flex-direction: row;
    }

    .modal.active {
      display: flex;
      align-items: stretch;
    }

    /* Tools sidebar (collapsible) */
    .sidebar {
      flex: 0 0 330px;
      width: 330px;
      max-width: 330px;
      background: var(--bg-surface);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      overflow-y: auto;
      overflow-x: hidden;
      font-size: 12px;
      scrollbar-width: none;
      -ms-overflow-style: none;
      transition: flex-basis 0.22s ease, width 0.22s ease, max-width 0.22s ease, opacity 0.18s ease,
        border-color 0.2s ease;
    }

    .modal.sidebar-collapsed .sidebar {
      flex: 0 0 0;
      width: 0;
      max-width: 0;
      min-width: 0;
      padding-left: 0;
      padding-right: 0;
      overflow: hidden;
      border-right-color: transparent;
      opacity: 0;
      pointer-events: none;
    }

    .editor-sidebar-toggle {
      flex: 0 0 32px;
      width: 32px;
      min-width: 32px;
      align-self: stretch;
      border: none;
      border-right: 1px solid var(--border);
      background: var(--bg-surface);
      color: var(--text-muted);
      cursor: pointer;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;
      padding: 8px 0;
      z-index: 11;
      transition: background 0.15s ease, color 0.15s ease;
    }

    .editor-sidebar-toggle:hover {
      background: var(--bg-hover);
      color: var(--text);
    }

    .editor-sidebar-toggle:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: -2px;
    }

    .editor-sidebar-toggle-icon {
      font-size: 14px;
      line-height: 1;
      user-select: none;
    }

    .sidebar::-webkit-scrollbar {
      display: none;
    }

    .sidebar-header {
      position: sticky;
      top: 0;
      background: var(--bg-surface);
      padding: 20px 20px 12px 20px;
      border-bottom: 1px solid var(--border);
      z-index: 10;
      margin-bottom: 16px;
    }

    .sidebar-content {
      padding: 0 20px 20px 20px;
    }

    .close-btn {
      cursor: pointer;
      font-size: 18px;
      color: var(--text-muted);
    }

    .panel-section {
      margin-bottom: 20px;
    }

    .class-btn {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 6px 12px;
      border-radius: 6px;
      border: 1px solid var(--border);
      margin-bottom: 6px;
      cursor: pointer;
      background: var(--bg-surface);
    }

    .class-btn.active {
      border-color: var(--accent);
      box-shadow: 0 0 0 1px var(--accent);
    }

    .class-color {
      width: 14px;
      height: 14px;
      border-radius: 3px;
      display: inline-block;
      margin-right: 8px;
      vertical-align: middle;
    }

    .tool-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin-bottom: 12px;
    }

    .tool-btn {
      padding: 6px;
      text-align: center;
      border: 1px solid var(--border);
      border-radius: 6px;
      cursor: pointer;
      background: var(--bg-hover);
    }

    .tool-btn.active {
      background: var(--accent);
      color: white;
      border-color: var(--accent);
    }

    /* Poly fill "Apply" stacks .btn + .tool-btn; force dark text on light surface for readability. */
    #btnPolyFillApply.btn.tool-btn {
      color: var(--text);
      background: var(--bg-surface);
      border: 1px solid var(--border);
      margin-left: 0;
    }

    #btnPolyFillApply.btn.tool-btn:not(:disabled):hover {
      background: var(--bg-hover);
      border-color: var(--accent);
    }

    #btnPolyFillApply.btn.tool-btn:disabled {
      color: var(--text-muted);
      cursor: not-allowed;
      opacity: 0.92;
    }

    .slider-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
    }

    .slider-row input {
      flex: 1;
      margin: 0 10px;
    }

    /* Editor: 1×1 + 3×3 grid toggles — column alignment (checkbox / title / footprint). */
    .editor-grid-toggles {
      display: grid;
      grid-template-columns: auto 20px minmax(0, 1fr) max-content;
      grid-template-rows: auto auto;
      column-gap: 10px;
      row-gap: 8px;
      align-items: center;
      margin-bottom: 10px;
      font-size: 11px;
    }

    .editor-grid-toggles .editor-grid-side-label {
      grid-column: 1;
      grid-row: 1 / 3;
      align-self: center;
    }

    .editor-grid-toggles .editor-grid-cb {
      justify-self: center;
      margin: 0;
      width: 14px;
      height: 14px;
      flex: none;
    }

    .editor-grid-toggles .editor-grid-title {
      grid-column: 3;
      min-width: 0;
    }

    .editor-grid-toggles .editor-grid-dim {
      grid-column: 4;
      justify-self: end;
      font-size: 10px;
      color: var(--text-muted);
      white-space: nowrap;
      font-variant-numeric: tabular-nums;
    }

    .editor-hex-outline-toggles {
      grid-template-columns: auto 20px minmax(0, 1fr);
      grid-template-rows: auto;
      margin-top: -2px;
    }

    .editor-hex-outline-toggles .editor-grid-side-label {
      grid-row: 1;
    }

    .stats-section {
      margin-bottom: 16px;
    }

    .stats-section-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 8px;
    }

    .stats-section-title {
      font-size: 13px;
      font-weight: 600;
      letter-spacing: -0.01em;
      color: var(--text);
    }

    .stats-csv-btn {
      flex-shrink: 0;
      padding: 4px 10px !important;
      font-size: 11px;
      font-weight: 600;
      line-height: 1.2;
      border-radius: 6px;
    }

    .stats-section-hint {
      font-size: 10px;
      color: var(--text-muted);
      margin: 0 0 10px;
      line-height: 1.45;
    }

    .stats-section-keys {
      font-size: 10px;
      color: var(--text-muted);
      margin: 12px 0 0;
      text-align: center;
      letter-spacing: 0.02em;
    }

    .stats-table-wrap {
      overflow-x: auto;
      overflow-y: visible;
      max-width: 100%;
      margin-bottom: 0;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--bg-surface);
      box-shadow: var(--shadow-sm);
      -webkit-overflow-scrolling: touch;
      scrollbar-width: thin;
      scrollbar-color: rgba(15, 23, 42, 0.28) transparent;
    }

    .stats-table-wrap:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }

    .stats-table-wrap::-webkit-scrollbar {
      height: 6px;
    }

    .stats-table-wrap::-webkit-scrollbar-thumb {
      background: rgba(15, 23, 42, 0.22);
      border-radius: 3px;
    }

    .stats-table {
      width: max-content;
      min-width: 100%;
      border-collapse: separate;
      border-spacing: 0;
      font-size: 11px;
      margin-bottom: 0;
    }

    .stats-table thead th {
      background: var(--bg-hover);
      color: var(--text-muted);
      font-size: 10px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      border-bottom: 1px solid var(--border);
    }

    .stats-table thead th {
      padding-top: 7px;
      padding-bottom: 7px;
      white-space: nowrap;
    }

    .stats-table th.stats-col-head {
      text-align: right;
      color: var(--text-muted);
      font-size: 9px;
      letter-spacing: 0.05em;
      font-weight: 600;
    }

    .stats-table th.stats-col-head--group {
      border-left: 1px solid var(--border);
    }

    .stats-table th.stats-col-head .stats-col-ver {
      display: block;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0;
      text-transform: none;
      color: var(--text);
      margin-bottom: 1px;
    }

    .stats-table th.stats-col-head.stats-ver--active {
      background: var(--accent-soft);
    }

    .stats-table th.stats-col-head.stats-ver--active .stats-col-ver {
      color: var(--accent);
    }

    .stats-table th.stats-col-head.stats-ver--active,
    .stats-table td.stats-cell.stats-ver--active {
      background: rgba(74, 156, 141, 0.07);
    }

    .stats-table th.stats-class-head {
      text-align: left;
      text-transform: uppercase;
    }

    .stats-table th,
    .stats-table td {
      padding: 6px 8px;
      text-align: left;
      border-bottom: 1px solid var(--border);
      vertical-align: middle;
    }

    .stats-table th:not(:first-child),
    .stats-table td:not(:first-child) {
      text-align: right;
      min-width: 58px;
    }

    .stats-table tbody tr:last-child td {
      border-bottom: none;
    }

    .stats-table th:first-child,
    .stats-table td:first-child {
      position: sticky;
      left: 0;
      z-index: 2;
      min-width: 140px;
      max-width: 180px;
      white-space: normal;
      background: var(--bg-surface);
      box-shadow: 4px 0 8px -6px rgba(15, 23, 42, 0.14);
    }

    .stats-table thead th:first-child {
      z-index: 3;
      background: var(--bg-hover);
    }

    .stats-table tbody tr:hover td {
      background: rgba(248, 250, 249, 0.92);
    }

    .stats-table tbody tr:hover td:first-child {
      background: #f8faf9;
    }

    .stats-table tbody tr.stats-row--inactive td {
      color: var(--text-muted);
    }

    .stats-table tbody tr.stats-row--inactive .stats-class-label {
      opacity: 0.72;
    }

    .stats-table tbody tr.stats-row--total td {
      background: var(--bg-hover);
      border-top: 1px solid var(--border);
      font-weight: 600;
    }

    .stats-table tbody tr.stats-row--total td:first-child {
      background: var(--bg-hover);
    }

    .stats-class-cell {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      line-height: 1.35;
    }

    .stats-table .stats-class-swatch {
      width: 12px;
      height: 12px;
      margin: 2px 0 0;
      border-radius: 3px;
      border: 1px solid rgba(15, 23, 42, 0.14);
      flex-shrink: 0;
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    }

    .stats-class-label {
      font-weight: 500;
      color: var(--text);
    }

    .stats-cell--pct .stats-val,
    .stats-cell--px .stats-val {
      font-variant-numeric: tabular-nums;
    }

    .stats-cell--px .stats-val {
      font-weight: 600;
      color: var(--text);
    }

    .stats-cell--empty {
      color: var(--text-muted);
    }

    .stats-delta {
      display: block;
      margin-top: 2px;
      font-size: 9px;
      font-weight: 500;
      line-height: 1.2;
      color: var(--text-muted);
      font-variant-numeric: tabular-nums;
    }

    .stats-delta--pos {
      color: #2f855a;
    }

    .stats-delta--neg {
      color: #c05621;
    }

    .stats-delta--zero {
      opacity: 0.55;
    }

    /* Editor: reference column + working canvas (shown only when editing or view-only) */
    .editor-panels {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      min-height: 0;
      min-width: 0;
      background: var(--bg);
    }

    .editor-panels > .editor-unified-inner {
      flex: 1 1 auto;
      min-height: 0;
      min-width: 0;
      width: 100%;
    }

    .editor-unified-inner {
      display: flex;
      flex-direction: row;
      align-items: stretch;
      gap: 0;
      padding: 18px 20px 20px;
      min-height: 0;
      overflow-x: hidden;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      scrollbar-gutter: stable;
      margin: 8px 10px 10px;
      border-radius: 14px;
      background: var(--bg-surface);
      border: 1px solid rgba(15, 23, 42, 0.07);
      box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.75) inset,
        0 10px 28px rgba(15, 23, 42, 0.05);
      height: calc(100vh - 36px);
    }

    /* Bound to layout: keep wheel/overscroll inside this column; maps refit when this box resizes (ResizeObserver). */
    .editor-unified-inner.layout-bound {
      overscroll-behavior: contain;
    }

    /* With main canvas on wide layouts: avoid a duplicate scrollbar on this shell (scroll stays in
       #editorReferenceControlsCol / notes). Narrow screens keep outer scroll as a fallback. */
    .editor-unified-inner.editor-unified--with-main {
      scrollbar-gutter: auto;
    }

    @media (min-width: 960px) {
      .editor-unified-inner.editor-unified--with-main {
        height: auto;
        max-height: none;
        flex: 1 1 auto;
        min-height: 0;
        align-self: stretch;
        overflow-x: hidden;
        overflow-y: hidden;
      }
    }

    .editor-layout-reference-only {
      flex-direction: column;
      gap: 16px;
    }

    /* Reference on top, working viewport below — one column, no extra “card” sections. */
    .editor-unified--with-main {
      flex-direction: column;
      align-items: stretch;
      gap: 0;
    }

    /* Contributions strip full width; badge on the row below (centered). */
    .editor-unified-chrome {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 10px;
      width: 100%;
      flex: 0 0 auto;
      padding: 2px 0 14px 0;
      box-sizing: border-box;
      border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    }

    .editor-chrome-contrib {
      width: 100%;
      min-width: 0;
    }

    .editor-chrome-contrib .editor-contrib-strip {
      width: 100%;
      max-width: none;
    }

    .editor-chrome-contrib .contrib-table-region {
      width: 100%;
      max-width: none;
    }

    .editor-chrome-center {
      display: flex;
      justify-content: center;
      width: 100%;
      min-width: 0;
    }

    .editor-version-row {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;
      gap: 10px;
      flex-wrap: wrap;
      min-width: 0;
      max-width: min(860px, 92vw);
    }

    .editor-version-preview-buttons {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
      justify-content: center;
      min-width: 0;
    }

    .editor-restore-my-draft-btn {
      flex-shrink: 0;
      font-size: 12px;
      font-weight: 600;
      padding: 6px 12px;
      white-space: nowrap;
    }

    .editor-unified-inner:not(.editor-unified--with-main) .editor-chrome-center {
      display: none;
    }

    .editor-unified-body {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      flex: 1 1 auto;
      min-height: 0;
      min-width: 0;
      width: 100%;
      position: relative;
    }

    .editor-layout-reference-only .editor-unified-body {
      flex: 1 1 auto;
      min-height: 0;
    }

    .editor-chrome-center .editor-version-badge {
      position: relative;
      top: auto;
      left: auto;
      max-width: min(360px, 42vw);
    }

    .editor-chrome-contrib .editor-context-strip {
      width: 100%;
      box-sizing: border-box;
      border: 1px solid rgba(15, 23, 42, 0.08);
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.72);
      padding: 12px 14px;
    }

    .editor-top-version-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      justify-content: flex-end;
      margin: 0 0 8px;
    }

    .editor-version-nav-btn {
      margin-left: 0;
      font-size: 12px;
      padding: 5px 12px;
      white-space: nowrap;
    }

    .editor-current-version-label {
      color: var(--text-muted);
      font-size: 12px;
      white-space: nowrap;
    }

    @media (max-width: 720px) {
      .editor-chrome-center .editor-version-badge {
        max-width: none;
        text-align: center;
      }

      .editor-version-row {
        flex-direction: column;
        max-width: none;
      }
    }

    /* Read-only (viewers / anonymous): only main map — no reference column, notes, or contributions strip */
    .editor-unified-inner.editor-viewer-map-only .editor-reference {
      display: none !important;
    }

    .editor-unified-inner.editor-viewer-map-only #editorMain {
      flex: 1 1 auto;
      width: 100%;
      max-width: none;
      min-width: 0;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }

    /* Annotate-only mode (new-tab edit): hide step flow and keep only editable map + tools. */
    .editor-unified-inner.editor-annotate-only .editor-unified-chrome,
    .editor-unified-inner.editor-annotate-only .editor-reference {
      display: none !important;
    }

    .editor-unified-inner.editor-annotate-only #editorMain {
      flex: 1 1 auto;
      width: 100%;
      max-width: none;
      min-width: 0;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }

    .editor-viewer-notes-banner {
      flex: 0 0 auto;
      padding: 10px 14px;
      margin-bottom: 8px;
      border-radius: 10px;
      border: 1px solid rgba(15, 23, 42, 0.08);
      background: rgba(255, 255, 255, 0.92);
      font-size: 12px;
      line-height: 1.45;
      max-height: 36vh;
      overflow-y: auto;
    }

    .editor-viewer-notes-banner.hidden {
      display: none !important;
    }

    .editor-viewer-notes-block + .editor-viewer-notes-block {
      margin-top: 12px;
      padding-top: 12px;
      border-top: 1px solid rgba(15, 23, 42, 0.08);
    }

    .editor-viewer-notes-heading {
      font-weight: 600;
      margin: 0 0 6px 0;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.03em;
      color: var(--text-muted);
    }

    .editor-viewer-notes-body {
      white-space: pre-wrap;
      word-break: break-word;
      margin: 0;
      color: var(--text);
    }

    .editor-viewer-map-only .editor-working-viewport {
      flex: 1 1 auto;
      min-height: 0;
    }

    .editor-layout-reference-only .editor-reference {
      flex: 1 1 0;
      max-width: none;
      width: 100%;
      min-height: 0;
    }

    /* Reference column: flex stack — preview grows, other blocks size to content */
    .editor-reference {
      flex: 0 0 auto;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 14px;
      max-width: min(720px, 58vw);
      min-width: 0;
      min-height: 0;
      cursor: default;
    }

    .editor-reference-top-row {
      display: grid;
      grid-template-columns: minmax(340px, 1fr) minmax(420px, 1.35fr);
      gap: 12px;
      align-items: stretch;
      width: 100%;
      min-height: 0;
    }

    .editor-contrib-strip {
      width: 100%;
    }

    .editor-contrib-strip .contrib-table-region {
      max-height: min(32vh, 300px);
      overflow: auto;
    }

    .editor-reference-main-row {
      display: grid;
      grid-template-columns: minmax(300px, 0.85fr) 32px minmax(420px, 1.35fr);
      gap: 12px;
      width: 100%;
      align-items: stretch;
      min-height: 0;
    }

    .editor-reference-controls-col {
      display: flex;
      flex-direction: column;
      gap: 12px;
      min-width: 0;
      align-self: stretch;
      height: 100%;
      max-height: none;
      overflow: visible;
    }

    .editor-section-toggle {
      width: 32px;
      min-width: 32px;
      align-self: stretch;
      border: 1px solid var(--border);
      border-radius: 10px;
      background: var(--bg-surface);
      color: var(--text-muted);
      cursor: pointer;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;
      padding: 8px 0;
      transition: background 0.15s ease, color 0.15s ease;
    }

    .editor-section-toggle:hover {
      background: var(--bg-hover);
      color: var(--text);
    }

    .editor-section-toggle:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: -2px;
    }

    .editor-section-toggle-icon {
      font-size: 14px;
      line-height: 1;
      user-select: none;
    }

    /* Two tracks only: with #editorReferenceControlsCol display:none it is not a grid item — a 3-track
       template would auto-place the map into the 32px column. */
    .editor-reference-main-row.ref-map-collapsed {
      grid-template-columns: 32px minmax(0, 1fr);
    }

    .editor-reference-main-row.ref-map-collapsed #editorReferenceControlsCol {
      display: none;
    }

    .editor-unified--with-main .editor-reference {
      flex: 0 0 auto;
      width: 100%;
      max-width: none;
      min-width: 0;
      align-self: stretch;
      max-height: none;
      overflow-x: hidden;
      overflow-y: visible;
      scrollbar-gutter: stable;
      padding-right: 0;
      padding-bottom: 0;
      margin-right: 0;
      border-right: none;
      border-bottom: none;
      gap: 12px;
    }

    .editor-unified--with-main .editor-reference-top-row {
      grid-template-columns: minmax(360px, 0.95fr) minmax(520px, 1.45fr);
      min-height: min(66vh, 840px);
    }

    /* One surface: map + actions + notes read as a single block beside the canvas (Step 1 lives in chrome). */
    .editor-unified--with-main .editor-reference-preview-block,
    .editor-unified--with-main .editor-action-group,
    .editor-unified--with-main .editor-reference-notes {
      border: none;
      background: transparent;
      box-shadow: none;
      border-radius: 0;
    }

    .editor-unified--with-main .editor-reference-preview-block,
    .editor-unified--with-main .editor-action-group,
    .editor-unified--with-main .editor-reference-notes {
      padding-left: 0;
      padding-right: 0;
    }

    .editor-unified--with-main .editor-reference-notes {
      padding-top: 0;
      padding-bottom: 0;
    }

    .editor-unified--with-main .contrib-table-region {
      border-color: rgba(15, 23, 42, 0.06);
      background: rgba(255, 255, 255, 0.4);
    }

    .editor-unified--with-main .editor-reference-notes {
      max-height: min(30vh, 300px);
      overflow-y: auto;
    }

    /* Step 2 workflow: full form — do not shrink or clip into a scrollbar-only strip (see editor-reference-notes above). */
    .editor-unified--with-main #panelHexWorkflow.editor-reference-notes {
      max-height: none;
      overflow: visible;
      flex: 0 0 auto;
      flex-shrink: 0;
      min-height: 0;
    }

    .editor-context-strip {
      width: 100%;
      padding: 12px 14px;
      border-radius: 10px;
      border: 1px solid rgba(15, 23, 42, 0.08);
      background: rgba(255, 255, 255, 0.72);
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 10px;
      min-height: 0;
      flex: 0 1 auto;
    }

    .editor-signed-in-banner {
      font-size: 11px;
      line-height: 1.4;
      color: var(--text);
      margin: 0;
      padding: 6px 8px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--bg-hover);
      word-break: break-word;
    }

    .editor-signed-in-banner strong {
      font-weight: 600;
      color: var(--text-muted);
      margin-right: 4px;
    }

    .editor-reference-top-row .editor-context-strip,
    .editor-reference-top-row .editor-reference-preview-block {
      height: 100%;
      min-height: 0;
    }

    .editor-layout-reference-only .editor-context-strip {
      max-height: min(56vh, 560px);
      overflow: auto;
    }

    .editor-unified--with-main .editor-context-strip {
      max-height: none;
      overflow: visible;
      flex: 0 0 auto;
    }

    .editor-reference-title {
      font-size: 11px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.09em;
      align-self: flex-start;
      margin: 0;
    }

    .editor-step-title {
      width: 100%;
      margin: 2px 0 2px;
      letter-spacing: 0.06em;
    }

    .contrib-details {
      margin: 0;
      min-width: 0;
      width: 100%;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      min-height: 0;
      flex: 0 0 auto;
    }

    .contrib-details > summary {
      list-style: none;
      cursor: pointer;
      font-size: 13px;
      font-weight: 600;
      color: var(--text);
      padding: 0 0 6px 0;
      letter-spacing: -0.01em;
      flex-shrink: 0;
    }

    .contrib-details > summary::-webkit-details-marker {
      display: none;
    }

    /* Dropdown chevron (replaces green dot). */
    .contrib-details > summary::before {
      content: '';
      display: inline-block;
      width: 6px;
      height: 6px;
      margin-right: 10px;
      margin-bottom: 1px;
      border: solid var(--text-muted);
      border-width: 0 2px 2px 0;
      vertical-align: middle;
      transform: translateY(-2px) rotate(45deg);
      transition: transform 0.15s ease, border-color 0.15s ease;
      background: none;
      border-radius: 0;
      opacity: 0.9;
    }

    .contrib-details[open] > summary::before {
      transform: translateY(0) rotate(-135deg);
      border-color: var(--text);
    }

    .contrib-details .editor-contrib-hint {
      font-size: 12px;
      color: var(--text-muted);
      margin: 0 0 8px 0;
      line-height: 1.5;
      flex-shrink: 0;
    }

    .editor-combined-block {
      margin-top: 12px;
    }

    .editor-combined-block:first-of-type {
      margin-top: 0;
    }

    .editor-review-subheading {
      font-size: 11px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      margin: 0 0 6px 0;
    }

    .contrib-table-region {
      width: 100%;
      box-sizing: border-box;
      flex: 1 1 auto;
      min-height: 0;
      border: 1px solid rgba(15, 23, 42, 0.08);
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.5);
    }

    .editor-layout-reference-only .contrib-table-region {
      max-height: min(180px, 26vh);
      overflow: auto;
    }

    .editor-unified--with-main .contrib-table-region {
      max-height: none;
      overflow-x: auto;
      overflow-y: visible;
    }

    .editor-contrib-table {
      table-layout: fixed;
      width: 100%;
      margin: 0;
    }

    .editor-contrib-table th:nth-child(1),
    .editor-contrib-table td:nth-child(1) {
      width: 24%;
      word-break: break-word;
    }

    .editor-contrib-table th:nth-child(2),
    .editor-contrib-table td:nth-child(2) {
      width: 12%;
      text-align: center;
      vertical-align: middle;
    }

    .editor-contrib-table th:nth-child(3),
    .editor-contrib-table td:nth-child(3) {
      width: 18%;
    }

    .editor-contrib-table th:nth-child(4),
    .editor-contrib-table td:nth-child(4) {
      width: 10%;
    }

    .editor-contrib-table th:nth-child(5),
    .editor-contrib-table td:nth-child(5) {
      width: 14%;
    }

    .editor-contrib-table th:nth-child(6),
    .editor-contrib-table td:nth-child(6) {
      width: 14%;
    }

    .editor-contrib-table th:nth-child(7),
    .editor-contrib-table td:nth-child(7) {
      width: 8%;
      text-align: center;
      vertical-align: middle;
    }

    .editor-workflow-table {
      table-layout: fixed;
      width: 100%;
      margin: 0;
    }

    .editor-workflow-draft-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      align-items: center;
      justify-content: flex-start;
    }

    .editor-workflow-table th:nth-child(1),
    .editor-workflow-table td:nth-child(1) {
      width: 7%;
    }

    .editor-workflow-table th:nth-child(2),
    .editor-workflow-table td:nth-child(2) {
      width: 10%;
      text-align: center;
      vertical-align: middle;
    }

    .editor-workflow-table th:nth-child(3),
    .editor-workflow-table td:nth-child(3) {
      width: 22%;
      word-break: break-word;
    }

    .editor-workflow-table th:nth-child(4),
    .editor-workflow-table td:nth-child(4) {
      width: 10%;
    }

    .editor-workflow-table th:nth-child(5),
    .editor-workflow-table td:nth-child(5) {
      width: 8%;
    }

    .editor-workflow-table th:nth-child(6),
    .editor-workflow-table td:nth-child(6) {
      width: 14%;
      word-break: break-word;
    }

    .editor-workflow-table th:nth-child(7),
    .editor-workflow-table td:nth-child(7) {
      width: 12%;
      word-break: break-word;
    }

    .editor-workflow-table th:nth-child(8),
    .editor-workflow-table td:nth-child(8) {
      width: 10%;
      word-break: break-word;
    }

    .editor-workflow-table th:nth-child(9),
    .editor-workflow-table td:nth-child(9) {
      width: 12%;
      text-align: center;
      vertical-align: middle;
    }

    .contrib-preview-cell {
      vertical-align: middle;
      padding: 4px 6px;
    }

    .contrib-activity-cell {
      color: var(--text-muted);
      vertical-align: middle;
    }

    .contrib-note-cell {
      vertical-align: middle;
      word-break: break-word;
    }

    .contrib-action-cell {
      vertical-align: middle;
      text-align: center;
    }

    .editor-reference-preview-block {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 8px;
      width: 100%;
      min-height: 0;
      padding: 12px 14px;
      border-radius: 10px;
      border: 1px solid rgba(15, 23, 42, 0.08);
      background: rgba(255, 255, 255, 0.72);
      box-sizing: border-box;
      /* visible so position:sticky on .editor-reference-stage works vs #editorUnifiedInner scroll */
      overflow: visible;
    }

    .editor-draft-full-preview {
      position: absolute;
      inset: 0;
      z-index: 40;
      display: flex;
      flex-direction: column;
      padding: 10px 12px 12px;
      box-sizing: border-box;
      border-radius: 10px;
      background: var(--bg-surface);
      box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
    }

    .editor-draft-full-preview.hidden {
      display: none !important;
    }

    .editor-draft-full-preview-head {
      display: flex;
      flex-wrap: nowrap;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      flex-shrink: 0;
      margin-bottom: 8px;
      padding-bottom: 8px;
      border-bottom: 1px solid var(--border);
    }

    .editor-draft-full-preview-body {
      flex: 1 1 auto;
      min-height: 0;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .editor-draft-full-preview-img {
      display: block;
      width: 100%;
      height: 100%;
      max-width: none;
      max-height: none;
      object-fit: contain;
      image-rendering: pixelated;
      image-rendering: crisp-edges;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: #000;
    }

    .editor-draft-full-preview-close {
      flex-shrink: 0;
      width: 32px;
      height: 32px;
      border: none;
      border-radius: 8px;
      background: var(--bg-hover);
      color: var(--text);
      font-size: 20px;
      line-height: 1;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .editor-draft-full-preview-close:hover {
      background: var(--border);
    }

    .editor-layout-reference-only .editor-reference-preview-block {
      flex: 1 1 0;
      min-height: min(82vh, 1080px);
    }

    .editor-ref-preview-head {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      width: 100%;
    }

    .editor-ref-preview-label {
      font-size: 11px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.08em;
      margin: 0;
    }

    .editor-ref-map-toolbar {
      display: flex;
      align-items: center;
      gap: 4px;
      flex-shrink: 0;
    }

    .editor-ref-zoombtn {
      margin-left: 0 !important;
      padding: 4px 10px !important;
      min-width: 2rem;
      font-size: 13px;
      line-height: 1.2;
    }

    .editor-ref-map-hint {
      font-size: 10px;
      color: var(--text-muted);
      margin: 0 0 6px 0;
      line-height: 1.35;
    }

    /* Block + top-left wrapper: pan/zoom math assumes the scaled wrapper is positioned from (0,0).
       Flex centering used the pre-transform size, so scale(from top-left) pulled the map off-center. */
    .editor-reference-stage {
      display: block;
      width: 100%;
      max-width: 100%;
      flex: 1 1 auto;
      min-height: 0;
      /* No inner scrollbars: pan/zoom are clamped in applyReferencePreviewTransform (same idea as #editorWorkingViewport). */
      overflow: hidden;
      box-sizing: border-box;
      border-radius: 8px;
      background: rgba(255, 255, 255, 0.96);
      box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
      /* Stay in view while scrolling the editor column (context / main canvas scroll underneath). */
      position: sticky;
      top: 0;
      z-index: 4;
      align-self: stretch;
      max-height: min(78vh, 1000px);
    }

    .editor-reference-stage .editor-hud-reference {
      z-index: 8;
      bottom: 10px;
      right: 10px;
      min-width: 200px;
      max-width: min(280px, calc(100% - 20px));
      font-size: 11px;
      padding: 8px 10px;
      cursor: grab;
      touch-action: none;
      user-select: none;
    }

    .editor-reference-stage .editor-hud-reference.editor-hud--dragging {
      cursor: grabbing;
    }

    /* Editable / classification map: same shell as reference (title + hint + stage + HUD). */
    .editor-main-map-block {
      flex: 1 1 auto;
      min-height: 0;
      min-width: 0;
    }

    .editor-main-map-stage.editor-reference-stage {
      position: relative;
      top: auto;
      z-index: 1;
      max-height: none;
      flex: 1 1 auto;
      min-height: min(52vh, 680px);
      display: flex;
      flex-direction: column;
    }

    .editor-main-map-block .editor-working-viewport {
      flex: 1 1 auto;
      min-height: 0;
    }

    .editor-layout-reference-only .editor-reference-stage {
      flex: 1 1 auto;
      min-height: min(78vh, 1000px);
      max-height: min(78vh, 1000px);
    }

    /* Same map panel min-size as reference-only; do not shrink when Edit map opens. */
    .editor-unified--with-main .editor-reference .editor-reference-preview-block {
      flex: 0 0 auto;
      min-height: min(72vh, 960px);
    }

    .editor-unified--with-main .editor-reference-stage {
      flex: 1 1 auto;
      min-height: min(68vh, 900px);
      max-height: min(68vh, 900px);
      overflow: hidden;
      border-radius: 8px;
    }

    .editor-action-group {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
      padding: 12px 14px;
      border-radius: 10px;
      border: 1px solid rgba(15, 23, 42, 0.08);
      background: rgba(255, 255, 255, 0.72);
      box-sizing: border-box;
    }

    .editor-primary-actions,
    .editor-secondary-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      width: 100%;
    }

    .editor-primary-actions {
      align-items: center;
    }

    .editor-secondary-actions {
      padding-top: 2px;
      border-top: 1px dashed rgba(15, 23, 42, 0.08);
    }

    .editor-workspace-hint {
      font-size: 12px;
      line-height: 1.45;
      color: var(--text-muted);
      margin: 0;
      padding: 8px 10px;
      border-radius: 8px;
      background: rgba(102, 223, 182, 0.08);
      border: 1px solid rgba(102, 223, 182, 0.2);
    }

    .canvas-wrapper-preview {
      pointer-events: auto;
      flex-shrink: 0;
      transform-origin: top left;
      box-shadow: none;
      background: transparent;
    }

    #btnEditImage,
    #btnSaveDraftImage,
    #btnDiscardDraftImage {
      width: auto;
      max-width: none;
      font-size: 13px;
      font-weight: 500;
      padding: 10px 14px;
      border-radius: 8px;
      letter-spacing: -0.01em;
    }

    #btnDiscardDraftImage:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    #btnSaveDraftImage:disabled,
    #btnSaveDraftImage.btn-save-draft--inactive {
      opacity: 0.4;
      cursor: not-allowed;
      pointer-events: none;
      background: transparent;
      border-color: var(--border);
      color: var(--text-muted);
      box-shadow: none;
    }

    #btnSaveDraftImage:disabled:hover,
    #btnSaveDraftImage.btn-save-draft--inactive:hover {
      background: transparent;
      filter: none;
    }

    img.draft-thumb-js {
      display: block;
      max-height: 32px;
      max-width: 48px;
      width: auto;
      height: auto;
      object-fit: contain;
      border-radius: 4px;
      border: 1px solid rgba(15, 23, 42, 0.1);
      background: var(--bg-hover);
      cursor: zoom-in;
      transition: box-shadow 0.15s ease, transform 0.15s ease;
    }

    img.draft-thumb-js:hover {
      box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
      transform: scale(1.02);
    }

    /* Full-size draft preview (contributions + admin activity) */
    .draft-preview-lightbox {
      position: fixed;
      inset: 0;
      z-index: 5001;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: max(16px, 3vw);
      box-sizing: border-box;
    }

    .draft-preview-lightbox.hidden {
      display: none !important;
    }

    .draft-preview-lightbox-backdrop {
      position: absolute;
      inset: 0;
      background: rgba(15, 23, 42, 0.58);
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      cursor: zoom-out;
    }

    .draft-preview-lightbox-dialog {
      position: relative;
      z-index: 1;
      max-width: min(96vw, 1280px);
      max-height: min(92vh, 960px);
      margin: auto;
    }

    .draft-preview-lightbox-img {
      display: block;
      max-width: min(92vw, 1200px);
      max-height: min(88vh, 900px);
      width: auto;
      height: auto;
      object-fit: contain;
      image-rendering: pixelated;
      image-rendering: crisp-edges;
      border-radius: 12px;
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
      background: #fff;
    }

    .draft-preview-lightbox-close {
      position: absolute;
      top: -6px;
      right: -6px;
      width: 36px;
      height: 36px;
      border: none;
      border-radius: 50%;
      background: var(--bg-surface);
      color: var(--text);
      font-size: 22px;
      line-height: 1;
      cursor: pointer;
      box-shadow: 0 4px 16px rgba(15, 23, 42, 0.2);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 2;
    }

    .draft-preview-lightbox-close:hover {
      background: var(--bg-hover);
    }

    .editor-reference-notes {
      width: 100%;
      max-width: 100%;
      align-self: stretch;
      margin-top: 0;
      padding: 14px 14px 12px;
      border-radius: 10px;
      border: 1px solid rgba(15, 23, 42, 0.08);
      background: rgba(255, 255, 255, 0.55);
      box-sizing: border-box;
    }

    .editor-reference-notes-row {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      width: 100%;
    }

    .editor-reference-notes-row > .editor-step-title {
      margin-top: 4px;
      margin-bottom: -2px;
    }

    .editor-reference-notes-row .editor-reference-notes {
      flex: 1 1 320px;
      min-width: 0;
      padding: 10px 10px 8px;
    }

    .editor-workflow-grid {
      display: grid;
      gap: 10px;
      grid-template-columns: repeat(2, minmax(180px, 1fr));
      width: 100%;
    }

    .editor-workflow-grid label {
      min-width: 0;
    }

    .editor-workflow-grid select {
      width: 100%;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--bg-surface);
      color: var(--text);
      font-size: 12px;
    }

    .editor-workflow-finalization-controls {
      display: flex;
      align-items: center;
      gap: 14px;
      min-height: 40px;
      flex-wrap: wrap;
    }

    /* Step 2 panel: one column so Difficulty / Finalization / hint use full sidebar width
       (two columns squeezed “Final” and clipped the orange guidance in narrow layouts). */
    #panelHexWorkflow .editor-workflow-grid {
      grid-template-columns: minmax(0, 1fr);
    }

    .editor-workflow-final-hint {
      grid-column: 1 / -1;
      margin: 0;
      font-size: 11px;
      color: #b45309;
      line-height: 1.45;
      padding: 2px 0 4px;
      max-width: 100%;
      overflow-wrap: anywhere;
      word-break: break-word;
    }

    .editor-workflow-last-edited-wrap {
      grid-column: 1 / -1;
      min-width: 0;
    }

    .editor-workflow-last-edited-value {
      margin: 0;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--bg-muted, rgba(0, 0, 0, 0.04));
      color: var(--text);
      font-size: 12px;
      line-height: 1.35;
      word-break: break-word;
    }

    .editor-workflow-save-row {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
      margin-top: 10px;
    }

    .editor-field-label {
      display: block;
      font-size: 11px;
      font-weight: 600;
      opacity: 0.78;
      margin-bottom: 4px;
    }

    .editor-reference-notes .editor-reference-notes-title {
      font-size: 13px;
      font-weight: 600;
      color: var(--text);
      margin: 0 0 6px 0;
      letter-spacing: -0.02em;
      line-height: 1.3;
    }

    .editor-reference-notes-row .editor-reference-notes .editor-reference-notes-title {
      font-size: 12px;
      margin-bottom: 4px;
    }

    .editor-reference-notes textarea {
      width: 100%;
      padding: 10px 12px;
      border-radius: 8px;
      border: 1px solid rgba(15, 23, 42, 0.1);
      font-size: 13px;
      font-family: var(--font-stack);
      resize: vertical;
      min-height: 88px;
      box-sizing: border-box;
      line-height: 1.45;
    }

    .editor-reference-notes-row .editor-reference-notes textarea {
      padding: 6px 8px;
      font-size: 12px;
      line-height: 1.4;
      min-height: 52px;
    }

    .editor-workflow-previous-notes {
      margin-top: 4px;
    }

    .editor-workflow-previous-notes.hidden {
      display: none !important;
    }

    .editor-previous-notes-picker {
      width: 100%;
      margin-top: 4px;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid rgba(15, 23, 42, 0.1);
      font-size: 13px;
      font-family: var(--font-stack);
      background: #fff;
      box-sizing: border-box;
    }

    .editor-previous-notes-body {
      margin-top: 8px;
      padding: 10px 12px;
      border-radius: 8px;
      border: 1px solid rgba(15, 23, 42, 0.08);
      background: rgba(15, 23, 42, 0.03);
      font-size: 12px;
      line-height: 1.5;
      color: var(--text);
      white-space: pre-wrap;
      word-break: break-word;
      max-height: 160px;
      overflow-y: auto;
    }

    .editor-previous-notes-body.hidden {
      display: none;
    }

    .editor-previous-notes-meta {
      font-size: 11px;
      color: var(--text-muted);
      margin-bottom: 6px;
    }

    .editor-reference-notes .editor-reference-notes-hint {
      font-size: 12px;
      color: var(--text-muted);
      margin-bottom: 8px;
      line-height: 1.45;
    }

    .editor-reference-notes-row .editor-reference-notes .editor-reference-notes-hint {
      font-size: 11px;
      margin-bottom: 4px;
      line-height: 1.35;
    }

    #panelEditorContributions .stats-table {
      font-size: 12px;
    }

    #panelEditorContributions .stats-table th,
    #panelEditorContributions .stats-table td {
      padding: 5px 7px;
    }

    #panelEditorContributions .editor-contrib-copy-btn,
    #panelEditorContributions .editor-contrib-edit-image-btn,
    #panelEditorContributions .editor-workflow-draft-action-btn {
      font-size: 12px;
      padding: 5px 10px;
      white-space: nowrap;
      border-radius: 6px;
    }

    .editor-contrib-hex-id {
      font-size: 12px;
      color: var(--text-muted);
      font-weight: 400;
    }

    #saveDraftImageStatus.editor-ref-save-status,
    .save-draft-status {
      display: block;
      color: var(--text-muted);
      font-size: 12px;
      min-height: 14px;
    }

    .editor-ref-note-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 8px;
    }

    .editor-reference-notes-row .editor-ref-note-actions {
      margin-top: 5px;
      gap: 6px;
    }

    #btnSaveAnnotationNote.editor-ref-note-save {
      font-size: 13px;
      padding: 8px 14px;
      border-radius: 8px;
    }

    .editor-reference-notes-row #btnSaveAnnotationNote.editor-ref-note-save {
      font-size: 12px;
      padding: 5px 10px;
      border-radius: 6px;
    }

    #annotationNoteStatus.editor-ref-note-status,
    .editor-ref-note-status {
      font-size: 12px;
      color: var(--text-muted);
    }

    #btnPromoteHexNext.promote-disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .editor-promote-row {
      position: relative;
    }

    .editor-promote-hint {
      position: absolute;
      left: 160px;
      top: calc(100% + 4px);
      z-index: 4;
      padding: 6px 8px;
      border-radius: 4px;
      font-size: 11px;
      line-height: 1.35;
      color: #2d3748;
      background: #fff;
      border: 1px solid #a0aec0;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
      max-width: min(420px, 90vw);
      pointer-events: none;
      white-space: nowrap;
    }

    .editor-unified--with-main .editor-working-area {
      flex: 1 1 auto;
      width: 100%;
      min-width: 0;
      min-height: min(58vh, 760px);
      margin-top: 14px;
      padding-top: 14px;
      border-top: 1px solid rgba(15, 23, 42, 0.07);
    }

    .editor-unified--with-main .editor-working-viewport {
      flex: 1 1 auto;
      min-height: 0;
    }

    .editor-unified--with-main .editor-main-map-stage {
      min-height: min(50vh, 620px);
    }

    @media (min-width: 960px) {
      .editor-unified-inner.editor-unified--with-main .editor-unified-body {
        flex-direction: row;
        align-items: stretch;
        gap: 14px;
      }

      .editor-unified--with-main .editor-reference {
        flex: 0 0 42%;
        width: 42%;
        min-width: 360px;
        max-width: none;
        height: 100%;
        overflow-x: hidden;
        overflow-y: visible;
        padding-right: 8px;
        border-right: 1px solid rgba(15, 23, 42, 0.07);
      }

      .editor-unified--with-main .editor-reference .editor-reference-preview-block {
        min-height: calc(100vh - 250px);
      }

      .editor-unified--with-main .editor-reference-stage {
        min-height: calc(100vh - 320px);
        max-height: calc(100vh - 320px);
      }

      .editor-unified--with-main .editor-working-area {
        flex: 1 1 auto;
        width: auto;
        min-height: 0;
        height: 100%;
        margin-top: 0;
        padding-top: 0;
        padding-left: 6px;
        border-top: none;
      }

      .editor-unified--with-main .editor-working-viewport {
        min-height: 0;
        flex: 1 1 auto;
      }

      .editor-unified--with-main .editor-main-map-stage {
        min-height: calc(100vh - 320px);
        max-height: calc(100vh - 220px);
      }

      /* Section 2 hidden: shrink reference column so #editorMain / edPolyCanvas uses the freed width. */
      .editor-unified--with-main.ref-pane-section2-collapsed .editor-reference {
        flex: 0 0 auto;
        /* Narrow strip: Step 1 + toggle + reference map only — main canvas takes the rest. */
        width: clamp(200px, 18vw, 320px);
        min-width: 200px;
        max-width: min(320px, 26vw);
      }

      .editor-unified--with-main.ref-pane-section2-collapsed .editor-working-area {
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
      }

      /* Reference map hidden while editing: reclaim the empty left gutter for #editorMain. */
      .editor-unified-inner.editor-unified--with-main .editor-reference.editor-ref-map-hidden {
        flex: 0 0 auto;
        width: min(400px, 42vw);
        min-width: min(280px, 88vw);
        max-width: min(420px, 48vw);
      }

      .editor-unified-inner.editor-unified--with-main.ref-pane-section2-collapsed .editor-reference.editor-ref-map-hidden {
        flex: 0 0 48px;
        width: 48px;
        min-width: 48px;
        max-width: 48px;
        padding-right: 8px;
        overflow: visible;
      }

      .editor-unified-inner.editor-unified--with-main.ref-pane-section2-collapsed .editor-reference.editor-ref-map-hidden .editor-reference-main-row {
        grid-template-columns: 32px;
        gap: 0;
        width: 100%;
        min-width: 0;
      }
    }

    /* Two-column row when preview is hidden but section 2 is open (no empty third track). */
    @media (min-width: 1201px) {
      .editor-reference.editor-ref-map-hidden .editor-reference-main-row:not(.ref-map-collapsed) {
        grid-template-columns: minmax(0, 1fr) 32px;
      }
    }

    @media (max-width: 1200px) {
      .editor-reference-main-row {
        grid-template-columns: 1fr;
      }

      /* Collapsed: two tracks so toggle + map don’t stack as full-width rows; controls stay display:none from base rule. */
      .editor-reference-main-row.ref-map-collapsed {
        grid-template-columns: 32px minmax(0, 1fr);
      }

      /* Hide strip toggle only when there is no main editor (reference-only); with-main needs collapse on all widths. */
      .editor-unified-inner:not(.editor-unified--with-main) .editor-section-toggle {
        display: none;
      }

      .editor-reference-top-row {
        grid-template-columns: 1fr;
      }

      .editor-unified--with-main .editor-reference-top-row {
        min-height: 0;
      }
    }

    .editor-working-area {
      flex: 1;
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      position: relative;
    }

    .editor-working-area.classified {
      cursor: auto;
    }

    .editor-working-header {
      flex: 0 0 auto;
      padding: 0 0 8px 2px;
    }

    .editor-working-title {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.07em;
    }

    .editor-working-viewport {
      flex: 1;
      min-height: 0;
      position: relative;
      overflow: hidden;
      z-index: 0;
      /* Let the app handle pan/draw on touch and stylus without the browser stealing gestures. */
      touch-action: none;
    }

    #editorReferencePreview {
      touch-action: none;
    }

    .editor-version-badge {
      position: absolute;
      top: 12px;
      left: 12px;
      z-index: 7;
      padding: 6px 10px;
      border-radius: 8px;
      border: 1px solid rgba(15, 23, 42, 0.12);
      background: rgba(255, 255, 255, 0.92);
      color: var(--text);
      font-size: 12px;
      font-weight: 600;
      line-height: 1.2;
      max-width: min(58%, 460px);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
      pointer-events: none;
    }

    .editor-main-zoombtn {
      margin-left: 0 !important;
      padding: 4px 10px !important;
      min-width: 2rem;
      font-size: 13px;
      line-height: 1.2;
    }

    .brush-shape-toggle {
      display: inline-flex;
      border: 1px solid var(--border);
      border-radius: 8px;
      overflow: hidden;
    }

    .brush-shape-btn {
      margin: 0;
      padding: 4px 10px;
      font-size: 14px;
      line-height: 1;
      border: none;
      background: var(--bg-hover);
      color: var(--text);
      cursor: pointer;
    }

    .brush-shape-btn + .brush-shape-btn {
      border-left: 1px solid var(--border);
    }

    .brush-shape-btn.active {
      background: var(--accent);
      color: var(--bg);
    }

    .brush-meter-btn {
      margin: 0;
      padding: 4px 8px;
      font-size: 10px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: var(--bg-hover);
      color: var(--text);
      cursor: pointer;
    }

    .brush-meter-btn.active {
      background: var(--accent-soft);
      border-color: var(--accent);
      color: var(--text);
      box-shadow: 0 0 0 1px var(--accent);
    }

    .editor-brush-cursor {
      position: absolute;
      pointer-events: none;
      box-sizing: border-box;
      border: 2px solid rgba(255, 255, 255, 0.92);
      box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
      z-index: 18;
      visibility: hidden;
      top: 0;
      left: 0;
      margin: 0;
      padding: 0;
    }

    .editor-brush-cursor.is-visible {
      visibility: visible;
    }

    .editor-brush-cursor.shape-circle {
      border-radius: 50%;
    }

    .editor-brush-cursor.shape-square {
      border-radius: 2px;
    }

    .canvas-wrapper {
      position: absolute;
      top: 0;
      left: 0;
      box-shadow: var(--shadow);
      background: white;
      transform-origin: top left;
    }

    #edGridSvg,
    #edGridSvgPreview {
      position: absolute;
      top: 0;
      left: 0;
      z-index: 4;
      pointer-events: none;
      overflow: visible;
      transform-origin: 0 0;
    }

    .canvas-wrapper .editor-sat-bg {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      object-fit: fill;
      z-index: 1;
      pointer-events: none;
      image-rendering: pixelated;
      transition: opacity 0.12s ease, filter 0.18s ease;
    }

    .canvas-wrapper .editor-hi-res-bg {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      image-rendering: pixelated;
      image-rendering: crisp-edges;
      pointer-events: none;
      z-index: 0;
      transition: filter 0.18s ease;
    }

    /* Enhance cycle — applied on the wrapper, filters both basemap and hi-res layers together. */
    .canvas-wrapper.enhance-mode-1 .editor-sat-bg,
    .canvas-wrapper.enhance-mode-1 .editor-hi-res-bg {
      filter: contrast(1.25) saturate(1.35) brightness(1.04);
    }
    .canvas-wrapper.enhance-mode-2 .editor-sat-bg,
    .canvas-wrapper.enhance-mode-2 .editor-hi-res-bg {
      filter: contrast(1.55) saturate(1.8) brightness(1.08);
    }
    .canvas-wrapper.enhance-mode-3 .editor-sat-bg,
    .canvas-wrapper.enhance-mode-3 .editor-hi-res-bg {
      filter: contrast(1.15) saturate(0) brightness(1.12);
    }

    .canvas-wrapper canvas {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      image-rendering: pixelated;
      z-index: 2;
    }

    .canvas-wrapper canvas.editor-sat-canvas {
      z-index: 1;
      image-rendering: auto;
      pointer-events: none;
    }

    .canvas-wrapper canvas.editor-hi-res-bg {
      image-rendering: auto;
      image-rendering: -webkit-optimize-contrast;
    }

    /* Classification map under the grid so 10 m lines stay visible; grid ignores clicks (poly + map coords use wrapper). */
    .canvas-wrapper #edMapCanvas,
    .canvas-wrapper #edMapCanvasPreview {
      z-index: 3;
    }

    .canvas-wrapper #edPolyCanvas,
    .canvas-wrapper #edPolyCanvasPreview {
      z-index: 5;
    }

    .canvas-wrapper #edMapCanvasPreview {
      border: none;
      outline: none;
      box-shadow: none;
    }

    .editor-hud {
      position: absolute;
      bottom: 14px;
      right: 14px;
      cursor: grab;
      touch-action: none;
      user-select: none;
      display: grid;
      grid-template-columns: auto minmax(7.5em, 1fr);
      column-gap: 10px;
      row-gap: 4px;
      align-items: baseline;
      background: rgba(255, 255, 255, 0.94);
      padding: 10px 12px;
      border-radius: 10px;
      font-size: 12px;
      line-height: 1.45;
      border: 1px solid rgba(15, 23, 42, 0.08);
      box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
      z-index: 10;
      margin: 0;
      min-width: 220px;
      max-width: min(340px, 92vw);
    }

    .editor-hud-label {
      font-weight: 500;
      color: var(--text-muted);
    }

    .editor-hud-value {
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
      text-align: right;
      margin: 0;
      padding: 0;
    }

    .editor-hud-hint {
      grid-column: 1 / -1;
      font-size: 11px;
      color: var(--text-muted);
      margin: 4px 0 0 0;
    }

    .editor-hud.editor-hud--dragging {
      cursor: grabbing;
    }

    .editor-hud.editor-hud--drag-float {
      position: fixed;
      z-index: 1200;
      margin: 0;
    }

    #editorModal > .editor-hud-floating {
      position: fixed;
      z-index: 1105;
      pointer-events: auto;
      bottom: auto;
      right: auto;
    }

    /* Summary Table */
    .view-toggle {
      display: flex;
      flex-wrap: wrap;
      align-items: flex-end;
      gap: 6px;
    }

    .view-toggle .btn {
      font-size: 12px;
      padding: 5px 14px;
    }

    .view-toggle .btn.active-tab {
      background: var(--accent);
      color: white;
    }

    .view-toggle .btn:not(.active-tab) {
      background: var(--bg-hover);
      color: var(--text);
      border: 1px solid var(--border);
    }

    .export-actions {
      display: inline-flex;
      flex-wrap: wrap;
      align-items: flex-end;
      gap: 10px 14px;
      margin-left: 4px;
    }

    .export-item {
      display: inline-flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 3px;
      max-width: 168px;
    }

    .export-item--inline {
      flex-direction: row;
      align-items: center;
      gap: 8px;
      max-width: none;
    }

    .export-hint {
      font-size: 10px;
      line-height: 1.3;
      color: var(--text-muted);
    }

    .export-status {
      font-size: 12px;
      color: var(--text-muted);
      min-width: 130px;
      align-self: center;
    }

    .summary-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 12px;
      font-family: var(--font-stack);
    }

    .summary-table th {
      position: sticky;
      top: 0;
      background: var(--bg-surface);
      text-align: left;
      padding: 10px 12px;
      font-weight: 600;
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--text-muted);
      border-bottom: 2px solid var(--border);
    }

    .summary-table th.sortable {
      cursor: pointer;
      user-select: none;
    }

    .summary-table th.sortable:hover {
      color: var(--text);
    }

    .summary-table td {
      padding: 7px 12px;
      border-bottom: 1px solid var(--border);
      white-space: nowrap;
    }

    .summary-table tr {
      cursor: pointer;
    }

    .summary-table tr:hover td {
      background: var(--bg-hover);
    }

    .summary-table .pct-bar {
      display: inline-block;
      height: 12px;
      border-radius: 2px;
      margin-right: 6px;
      vertical-align: middle;
      min-width: 2px;
    }

    .summary-table .pct-val {
      font-family: monospace;
      font-size: 11px;
    }

    .summary-table .flag-cell {
      font-size: 13px;
    }

    .summary-table .check-cell {
      color: var(--accent);
      font-weight: bold;
    }

    .summary-table .summary-diff-cell {
      font-size: 11px;
      text-transform: capitalize;
      color: var(--text);
    }

    /* Ruler (Google Earth–style): compact table, no on-map labels */
    .ruler-panel {
      margin-top: 8px;
      padding: 10px 10px 8px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--bg-surface);
      box-shadow: var(--shadow-sm);
    }

    .ruler-panel-head {
      margin-bottom: 6px;
    }

    .ruler-panel-title {
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.02em;
      color: var(--text);
    }

    .ruler-tabs {
      display: flex;
      gap: 4px;
      margin-bottom: 8px;
    }

    .ruler-tab {
      flex: 1;
      font-size: 10px;
      padding: 5px 6px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: var(--bg-hover);
      color: var(--text-muted);
      cursor: pointer;
    }

    .ruler-tab.active {
      background: var(--accent-soft);
      border-color: var(--accent);
      color: var(--text);
      font-weight: 600;
    }

    .ruler-instruction {
      font-size: 10px;
      color: var(--text-muted);
      line-height: 1.35;
      margin: 0 0 8px;
    }

    .ruler-kv-wrap {
      display: flex;
      flex-direction: column;
      gap: 4px;
      margin-bottom: 6px;
    }

    .ruler-kv-row {
      display: grid;
      grid-template-columns: minmax(72px, auto) 1fr minmax(52px, auto);
      gap: 6px 8px;
      align-items: center;
      font-size: 11px;
    }

    .ruler-k {
      color: var(--text-muted);
      font-variant-numeric: tabular-nums;
    }

    .ruler-v {
      font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
      font-size: 11px;
      text-align: right;
      color: var(--text);
    }

    .ruler-unit {
      font-size: 10px;
      padding: 2px 4px;
      border-radius: 4px;
      border: 1px solid var(--border);
      background: var(--bg);
      color: var(--text);
      max-width: 72px;
    }

    .ruler-footnote {
      font-size: 9px;
      color: var(--text-muted);
      margin: 0 0 8px;
      line-height: 1.35;
    }

    .ruler-actions {
      display: flex;
      gap: 6px;
    }

    .ruler-actions .tool-btn {
      flex: 1;
      font-size: 10px;
      padding: 6px 4px;
    }

    .ruler-tabs-multi {
      flex-wrap: wrap;
      gap: 4px;
    }

    .ruler-tabs-multi .ruler-tab {
      flex: 1 1 calc(33.33% - 4px);
      min-width: 56px;
      font-size: 9px;
      padding: 4px 4px;
    }

    .ruler-path-meta {
      font-size: 9px;
      color: var(--text-muted);
      margin: 2px 0 0;
    }

    /* Floating measurement callout (Google Earth–style info bubble) */
    .ruler-map-callout {
      position: fixed;
      z-index: 60;
      min-width: 120px;
      max-width: 220px;
      padding: 8px 22px 10px 8px;
      border-radius: 6px;
      border: 1px solid rgba(0, 0, 0, 0.12);
      background: rgba(255, 255, 255, 0.96);
      box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
      font-size: 10px;
      line-height: 1.35;
      pointer-events: none;
    }

    .ruler-callout-close {
      position: absolute;
      top: 2px;
      right: 4px;
      border: none;
      background: transparent;
      color: var(--text-muted);
      font-size: 14px;
      line-height: 1;
      cursor: pointer;
      padding: 2px 4px;
      pointer-events: auto;
    }

    .ruler-callout-close:hover {
      color: var(--text);
    }

    .ruler-callout-kv {
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 2px 10px;
      align-items: baseline;
    }

    .ruler-callout-kv dt {
      color: var(--text-muted);
      font-size: 9px;
    }

    .ruler-callout-kv dd {
      margin: 0;
      font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
      font-size: 10px;
      text-align: right;
      word-break: break-all;
    }

    .ruler-callout-tail {
      position: absolute;
      left: 50%;
      bottom: -6px;
      margin-left: -6px;
      width: 0;
      height: 0;
      border-left: 6px solid transparent;
      border-right: 6px solid transparent;
      border-top: 6px solid rgba(255, 255, 255, 0.96);
      filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.08));
    }
