/* US Interactive Map – Styles */

/* ── Reset / base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #eef1f6;
    color: #1c2333;
    height: 100%;
    overflow: hidden;
}

/* ── Two-column layout ───────────────────────────────────────────────────── */
.app-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: 1fr;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    gap: 0;
}

/* ── Map area ────────────────────────────────────────────────────────────── */
.map-area {
    display: flex;
    flex-direction: column;
    padding: 28px 24px 20px;
    overflow: hidden;
    min-width: 0;
}

.map-area h1 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -.3px;
    color: #1c2333;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.map-hint {
    font-size: 0.82rem;
    color: #6b7a99;
    margin-bottom: 16px;
    flex-shrink: 0;
}

/* Map wrapper fills remaining height */
.usim-map-wrapper {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,.09);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* ── Zoom layer ──────────────────────────────────────────────────────────── */
.usim-zoom-layer {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
    will-change: transform;
}
.usim-zoom-layer svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ── Zoom controls ───────────────────────────────────────────────────────── */
.zoom-controls {
    position: absolute;
    bottom: 14px;
    left: 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 10;
}
.zoom-btn {
    width: 32px;
    height: 32px;
    background: rgba(28,35,51,.82);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 7px;
    color: #e0e6f0;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .13s, color .13s;
    backdrop-filter: blur(4px);
}
.zoom-btn:hover:not(:disabled) {
    background: rgba(74,144,217,.85);
    color: #fff;
    border-color: rgba(255,255,255,.35);
}
.zoom-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/* ── State search bar ────────────────────────────────────────────────────── */
.search-bar-wrap {
    position: relative;
    flex-shrink: 0;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.state-search-input {
    flex: 1;
    min-width: 0;
    background: #fff;
    border: 1.5px solid #d0d8e8;
    border-radius: 8px;
    color: #1c2333;
    font-size: 0.85rem;
    padding: 8px 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.state-search-input:focus {
    border-color: #4a90d9;
    box-shadow: 0 0 0 3px rgba(74,144,217,.18);
}
.search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid #d0d8e8;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,.14);
    list-style: none;
    z-index: 200;
    overflow: hidden;
    margin: 0;
    padding: 4px 0;
}
.search-result {
    padding: 8px 14px;
    font-size: 0.83rem;
    color: #1c2333;
    cursor: pointer;
    transition: background .1s;
}
.search-result:hover,
.search-result--focused {
    background: #eef3fb;
    color: #1565c0;
}

/* ── Map toolbar buttons (undo/redo + preview) ───────────────────────────── */
.map-toolbar-btns {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.btn-toolbar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    min-width: 34px;
    padding: 0 8px;
    background: #f0f4f8;
    border: 1.5px solid #d0d8e8;
    border-radius: 7px;
    color: #3a4a60;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .13s, border-color .13s, color .13s;
    white-space: nowrap;
}
.btn-toolbar:hover:not(:disabled) {
    background: #dce8f7;
    border-color: #4a90d9;
    color: #1565c0;
}
.btn-toolbar:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}
.btn-toolbar--preview {
    padding: 0 13px;
    background: #1a3a6b;
    border-color: #2a5298;
    color: #9ec8f5;
    font-size: 0.8rem;
    letter-spacing: .3px;
}
.btn-toolbar--preview:hover:not(:disabled) {
    background: #2a5298;
    border-color: #4a90d9;
    color: #fff;
}
.btn-toolbar--reset {
    padding: 0 11px;
    background: #3a1a1a;
    border-color: #7a2a2a;
    color: #f5a0a0;
    font-size: 0.8rem;
}
.btn-toolbar--reset:hover:not(:disabled) {
    background: #7a2a2a;
    border-color: #c0392b;
    color: #fff;
}

/* ── State selection highlight — marching ants handled by JS overlay ── */
/* The .usim-selected class is used for logic; visual animation is via
   the #usim-sel-layer SVG group created by updateSelectionLayer() in map.js */
.usim-map-wrapper svg .usim-selected {
    outline: none;
}

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
.usim-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    line-height: 1.45;
    max-width: 280px;
    width: max-content;
    overflow-wrap: break-word;
    word-break: break-word;
    box-shadow: 0 3px 10px rgba(0,0,0,.28);
    border: 1px solid transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity .11s ease;
}
.usim-tooltip.usim-tooltip--visible {
    opacity: 1;
    visibility: visible;
}

/* Loading / error */
.usim-map-loading,
.usim-map-error {
    font-size: 0.9rem;
    color: #6b7a99;
    padding: 32px;
    text-align: center;
}
.usim-map-error { color: #c0392b; }

/* ── Colour Panel (sidebar) ──────────────────────────────────────────────── */
.color-panel {
    background: #1c2333;
    color: #e0e6f0;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 14px 28px;
    border-left: 1px solid #2a3348;
    min-height: 0;   /* allows grid child to shrink and scroll */
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: .4px;
    color: #ffffff;
    margin-bottom: 14px;
    flex-shrink: 0;
    text-transform: uppercase;
}

/* Selected state box */
.selected-state-box {
    background: #253047;
    border-radius: 8px;
    padding: 11px 13px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 50px;
    justify-content: center;
}
.selected-state-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
}
.selected-state-hint {
    font-size: 0.75rem;
    color: #7a8daa;
}

/* ── Accordion ───────────────────────────────────────────────────────────── */
.accordion {
    border-radius: 8px;
    overflow: visible;
    margin-bottom: 7px;
    background: #202c3e;
    border: 1px solid #2a3a52;
}
.accordion > .accordion-btn {
    border-radius: 8px 8px 0 0;
}
.accordion > .accordion-body {
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.accordion-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 13px;
    background: none;
    border: none;
    color: #c8d6ea;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    cursor: pointer;
    text-align: left;
    transition: background .13s, color .13s;
    position: relative;
}
.accordion-btn:hover {
    background: #263347;
    color: #fff;
}
.accordion-btn[aria-expanded="true"] {
    color: #fff;
    background: #253047;
    border-bottom: 1px solid #2a3a52;
}

.accordion-icon {
    font-size: 0.6rem;
    line-height: 1;
    flex-shrink: 0;
    transition: transform .2s ease;
    display: inline-block;
    margin-top: 1px;
}

.accordion-body {
    padding: 13px 13px 24px;
    display: block;
}
.accordion-body[hidden] {
    display: none;
}

/* Sub-labels inside accordion bodies */
.acc-sub-label {
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: #4a6080;
    margin-bottom: 8px;
}

/* Palette grid */
.palette-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}
.palette-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 5px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform .1s, border-color .1s;
    outline: none;
}
.palette-swatch:hover,
.palette-swatch:focus {
    transform: scale(1.18);
    border-color: #fff;
}
.palette-swatch.active {
    border-color: #fff;
    transform: scale(1.12);
    box-shadow: 0 0 0 2px #4a90d9;
}

/* Picker row */
.picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
#colorWheelInput {
    width: 42px;
    height: 36px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
    background: #253047;
    flex-shrink: 0;
}
#colorHexInput {
    width: 90px;
    flex: none;
    background: #253047;
    border: 1px solid #3a4a60;
    border-radius: 6px;
    color: #e0e6f0;
    font-size: 0.82rem;
    padding: 7px 10px;
    font-family: 'Courier New', monospace;
    outline: none;
    transition: border-color .15s;
}
#colorHexInput:focus { border-color: #4a90d9; }

/* Buttons */
.btn-apply {
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 13px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}
.btn-apply:hover { background: #357abd; }

.global-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.btn-global {
    background: #253047;
    color: #c8d6ea;
    border: 1px solid #3a4a60;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
    transition: background .15s, color .15s;
}
.btn-global:hover { background: #2e3d58; color: #fff; }
.btn-reset { color: #e07070; border-color: #4a2e2e; }
.btn-reset:hover { background: #3d2020; color: #ff9a9a; }

/* Legend */
.btn-clear-legend {
    background: none;
    border: none;
    color: #5c7094;
    font-size: 0.7rem;
    cursor: pointer;
    text-transform: lowercase;
    letter-spacing: .3px;
    padding: 0;
}
.btn-clear-legend:hover { color: #e07070; }

.legend-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.8rem;
    color: #c8d6ea;
}
.legend-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,.15);
}
/* ── State Info panel ───────────────────────────────────────────────────────── */
.info-saves-hint {
    font-size: 0.65rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #3d5a40;
    background: #1e3320;
    border-radius: 3px;
    padding: 1px 6px;
    margin-left: 6px;
}

.info-field-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.info-field-label {
    font-size: 0.73rem;
    color: #7a8daa;
    width: 72px;
    flex-shrink: 0;
}
.info-field-input {
    flex: 1;
    background: #253047;
    border: 1px solid #3a4a60;
    border-radius: 6px;
    color: #e0e6f0;
    font-size: 0.8rem;
    padding: 5px 9px;
    outline: none;
    transition: border-color .15s;
    min-width: 0;
}
.info-field-input:focus { border-color: #4a90d9; }
.info-field-input::placeholder { color: #6a84a8; opacity: 1; }

/* Custom field rows (label + value + delete) */
.custom-field-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 6px;
}
.custom-field-row .cf-label {
    width: 38%;
    flex-shrink: 0;
}
.custom-field-row .cf-value {
    flex: 1;
}
.btn-delete-field {
    background: none;
    border: 1px solid #4a2e2e;
    border-radius: 5px;
    color: #e07070;
    font-size: 0.9rem;
    width: 24px;
    height: 24px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .12s, color .12s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-delete-field:hover { background: #3d2020; color: #ff9a9a; }

.btn-add-field {
    margin-top: 4px;
    background: none;
    border: 1px dashed #3a4a60;
    border-radius: 6px;
    color: #5c7094;
    font-size: 0.78rem;
    padding: 6px 10px;
    width: 100%;
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, color .15s;
}
.btn-add-field:hover { border-color: #4a90d9; color: #c8d6ea; }

/* Tooltip data rows */
.tt-row {
    display: flex;
    gap: 6px;
    font-size: 0.78rem;
    margin-top: 3px;
    line-height: 1.35;
}
.tt-lbl {
    opacity: 0.6;
    flex-shrink: 0;
    min-width: 72px;
    white-space: nowrap;
}
.tt-val {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}
.tt-img {
    display: block;
    width: auto;
    max-width: 80px;
    max-height: 46px;
    height: auto;
    object-fit: contain;
    border-radius: 3px;
    margin-bottom: 5px;
    border: 1px solid rgba(255,255,255,.15);
}
/* ── Stroke controls ────────────────────────────────────────────────────── */
.stroke-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.stroke-label {
    font-size: 0.75rem;
    color: #7a8daa;
    width: 44px;
    flex-shrink: 0;
}
#strokeColorInput {
    width: 36px;
    height: 30px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    padding: 2px;
    background: #253047;
    flex-shrink: 0;
}
#strokeColorHex {
    flex: 1;
    background: #253047;
    border: 1px solid #3a4a60;
    border-radius: 6px;
    color: #e0e6f0;
    font-size: 0.82rem;
    padding: 5px 9px;
    font-family: 'Courier New', monospace;
    outline: none;
    transition: border-color .15s;
}
#strokeColorHex:focus { border-color: #4a90d9; }
#strokeWidthRange {
    flex: 1;
    accent-color: #4a90d9;
    cursor: pointer;
}
.stroke-width-val {
    font-size: 0.78rem;
    color: #c8d6ea;
    min-width: 26px;
    text-align: right;
    font-family: 'Courier New', monospace;
}

/* ── Data Input & Choropleth ───────────────────────────────────────────── */
.import-textarea {
    width: 100%;
    background: #253047;
    border: 1px solid #3a4a60;
    border-radius: 6px;
    color: #e0e6f0;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    padding: 7px 10px;
    resize: vertical;
    outline: none;
    transition: border-color .15s;
    line-height: 1.5;
    min-height: 80px;
    margin-bottom: 8px;
}
.import-textarea:focus { border-color: #4a90d9; }
.import-textarea::placeholder { color: #4a6080; }

.import-file-row {
    display: flex;
    gap: 7px;
    margin-bottom: 7px;
}
.import-file-row .btn-global {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    padding: 6px 8px;
}
.import-status {
    font-size: 0.72rem;
    min-height: 18px;
    line-height: 1.4;
    padding: 2px 0;
}
.import-status--ok    { color: #4caf88; }
.import-status--error { color: #e07070; }

.scale-row {
    display: flex;
    align-items: center;
    gap: 7px;
}
.scale-label {
    font-size: 0.72rem;
    color: #7a8daa;
    width: 42px;
    flex-shrink: 0;
}
.scale-label--mid {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.scale-label--mid input[type="checkbox"] {
    accent-color: #4a90d9;
    cursor: pointer;
    width: 13px;
    height: 13px;
}
.scale-color-wheel {
    width: 34px;
    height: 28px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    padding: 2px;
    background: #253047;
    flex-shrink: 0;
}
.scale-color-hex {
    flex: 1;
    background: #253047;
    border: 1px solid #3a4a60;
    border-radius: 6px;
    color: #e0e6f0;
    font-size: 0.78rem;
    padding: 5px 8px;
    font-family: 'Courier New', monospace;
    outline: none;
    transition: border-color .15s;
    min-width: 0;
}
.scale-color-hex:focus { border-color: #4a90d9; }

.scale-range-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.scale-range-input {
    flex: 1;
    background: #253047;
    border: 1px solid #3a4a60;
    border-radius: 6px;
    color: #e0e6f0;
    font-size: 0.78rem;
    padding: 5px 8px;
    outline: none;
    transition: border-color .15s;
    min-width: 0;
    -moz-appearance: textfield;
}
.scale-range-input:focus { border-color: #4a90d9; }
.scale-range-input::-webkit-outer-spin-button,
.scale-range-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.scale-range-sep {
    font-size: 0.8rem;
    color: #4a6080;
    flex-shrink: 0;
}
.scale-preview {
    height: 18px;
    border-radius: 5px;
    margin-top: 10px;
    background: linear-gradient(to right, #eff3ff, #08306b);
    border: 1px solid #2a3a52;
}

/* ── Responsive: stack on narrow screens ─────────────────────────────────── */
@media (max-width: 700px) {
    body { overflow: auto; }
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto;
    }
    .map-area {
        height: 70vw;
        min-height: 300px;
        overflow: hidden;
    }
    .color-panel {
        height: auto;
    }
}

/* ── Info panel extra fields ────────────────────────────────────────────────────── */
.info-field-textarea {
    resize: vertical;
    min-height: 60px;
    line-height: 1.5;
    font-family: inherit;
    padding: 6px 9px;
}

.btn-view-details {
    margin-top: 10px;
    margin-bottom: 6px;
    width: 100%;
    background: #2a4a72;
    border: 1px solid #3a6090;
    border-radius: 7px;
    color: #a8c8f0;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 8px 12px;
    cursor: pointer;
    text-align: center;
    transition: background .15s, color .15s, border-color .15s;
    letter-spacing: .3px;
}
.btn-view-details:hover {
    background: #4a90d9;
    color: #fff;
    border-color: #4a90d9;
}

/* ── Iframe snippet ─────────────────────────────────────────────────────── */
.btn-iframe {
    width: 100%;
    margin-top: 8px;
    background: #1a3a5c;
    border: 1px solid #2a5a8c;
    border-radius: 7px;
    color: #90caf9;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 8px 12px;
    cursor: pointer;
    text-align: center;
    transition: background .15s, color .15s;
}
.btn-iframe:hover { background: #1565c0; color: #fff; }
.btn-iframe.copied { background: #1b5e20; color: #a5d6a7; border-color: #2e7d32; }

/* ── Click action radio group ───────────────────────────────────────────────── */
.click-action-group {
    display: flex;
    gap: 14px;
    padding: 4px 0;
}
.click-action-opt {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    color: #b0c4d8;
    cursor: pointer;
}
.click-action-opt input[type="radio"] { accent-color: #4a90d9; cursor: pointer; }

/* ── Publish & Export section ───────────────────────────────────────────────── */
.btn-publish {
    width: 100%;
    background: #1b5e20;
    border: 1px solid #2e7d32;
    border-radius: 7px;
    color: #a5d6a7;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 10px 12px;
    cursor: pointer;
    text-align: center;
    transition: background .15s, color .15s;
    letter-spacing: .4px;
}
.btn-publish:hover { background: #2e7d32; color: #fff; }

.publish-hint {
    font-size: 0.75rem;
    color: #6b7a99;
    margin: 8px 0 0;
    line-height: 1.55;
}
.publish-hint code {
    font-family: monospace;
    background: #1e2635;
    border-radius: 3px;
    padding: 1px 4px;
    color: #90caf9;
}

.tt-link-hint {
    color: #90caf9;
    font-size: 0.78rem;
    margin-top: 4px;
}

/* ── State detail modal ─────────────────────────────────────────────────────── */
body.usim-modal-open { overflow: hidden; }

.usim-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14,20,32,.72);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(3px);
    animation: modalFadeIn .18s ease;
}
.usim-modal-overlay[hidden] { display: none; }

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.usim-modal-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 48px rgba(0,0,0,.35);
    max-width: 680px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlideIn .2s cubic-bezier(.25,.46,.45,.94);
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from { transform: translateY(18px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.usim-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #eef1f6;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
    flex-shrink: 0;
}
.usim-modal-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(0,0,0,.1);
}
.usim-modal-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1c2333;
    flex: 1;
}
.usim-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7a99;
    cursor: pointer;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background .12s, color .12s;
}
.usim-modal-close:hover { background: #f0f4f8; color: #1c2333; }

.usim-modal-img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
    background: #f8f9fb;
}
.usim-modal-img[hidden] { display: none; }

.usim-modal-body {
    padding: 16px 20px;
    flex: 1;
}
.modal-row {
    display: flex;
    gap: 10px;
    font-size: 0.9rem;
    color: #1c2333;
    margin-bottom: 8px;
    line-height: 1.45;
}
.modal-lbl {
    color: #6b7a99;
    flex-shrink: 0;
    min-width: 90px;
    font-size: 0.82rem;
    white-space: nowrap;
}
.modal-val {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}
.modal-desc {
    font-size: 0.88rem;
    color: #2d3a52;
    line-height: 1.6;
    margin: 10px 0;
    padding: 10px 12px;
    background: #f6f8fb;
    border-left: 3px solid #4a90d9;
    border-radius: 0 6px 6px 0;
}
.modal-empty {
    font-size: 0.85rem;
    color: #9aafc4;
    font-style: italic;
}

.usim-modal-footer {
    padding: 14px 20px 18px;
    border-top: 1px solid #eef1f6;
    flex-shrink: 0;
}
.usim-modal-footer[hidden] { display: none; }
.usim-modal-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #4a90d9;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background .15s;
}
.usim-modal-link::after { content: ' ↗'; }
.usim-modal-link:hover { background: #357abd; }
/* ── Quick Themes grid ──────────────────────────────────────────────────────── */
.themes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 14px;
}

.btn-theme {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 9px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 6px;
    color: #c8d4e0;
    font-size: 0.78rem;
    cursor: pointer;
    text-align: left;
    transition: background .14s, border-color .14s;
    white-space: nowrap;
    overflow: hidden;
}
.btn-theme:hover {
    background: rgba(255,255,255,.14);
    border-color: rgba(255,255,255,.22);
    color: #fff;
}

.theme-swatch {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.theme-swatch span {
    display: inline-block;
    width: 9px;
    height: 16px;
    border-radius: 2px;
}

/* ── Fill pattern buttons ────────────────────────────────────────────────── */

/* ── Themes popup ─────────────────────────────────────────────────────────── */
.btn-themes-open, .btn-example-data {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 4px;
    color: #a0bcd4;
    font-size: 0.72rem;
    padding: 2px 8px;
    cursor: pointer;
    line-height: 1.5;
}
.btn-themes-open:hover, .btn-example-data:hover { background: rgba(255,255,255,.18); color: #fff; }

#exampleDataOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
#exampleDataOverlay[hidden] { display: none; }
#exampleDataCard {
    background: #1c2b3a;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 12px;
    padding: 22px 26px 26px;
    width: 500px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(0,0,0,.6);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#exampleDataHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
#exampleDataTitle {
    font-size: 1rem;
    font-weight: 600;
    color: #e0ecf4;
}
#closeExampleDataBtn {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #8a9fbc;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
#closeExampleDataBtn:hover { color: #fff; }
.example-data-hint {
    color: #8aabb5;
    font-size: 0.78rem;
    margin: 0;
    line-height: 1.5;
}
.example-data-hint strong { color: #a0bcd4; }
.example-data-textarea {
    width: 100%;
    box-sizing: border-box;
    height: 280px;
    background: #0f1e2b;
    color: #c8dde8;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    resize: vertical;
}
.example-data-footer {
    display: flex;
    justify-content: flex-end;
}
.example-data-tabs {
    display: flex;
    gap: 6px;
}
.example-tab {
    flex: 1;
    padding: 6px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.06);
    color: #8aabb5;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.example-tab:hover { background: rgba(255,255,255,.14); color: #c8dde8; }
.example-tab.active { background: #1e5a8a; border-color: #2d7ec4; color: #e0ecf4; font-weight: 600; }

#themesPopupOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
#themesPopupOverlay[hidden] { display: none; }

#themesPopupCard {
    background: #1c2b3a;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 12px;
    padding: 22px 26px 26px;
    width: 480px;
    max-width: 92vw;
    max-height: 82vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(0,0,0,.6);
}
#themesPopupHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
#themesPopupTitle {
    font-size: 1rem;
    font-weight: 600;
    color: #e0ecf4;
}
#closeThemesPopupBtn {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #8a9fbc;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
#closeThemesPopupBtn:hover { color: #fff; }

.themes-popup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
/* ── Fill pattern buttons ────────────────────────────────────────────────── */
.pattern-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-bottom: 6px;
}
.btn-pattern {
    padding: 6px 4px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 5px;
    color: #c8d4e0;
    font-size: 0.75rem;
    cursor: pointer;
    text-align: center;
    transition: background .13s, border-color .13s, color .13s;
    white-space: nowrap;
    overflow: hidden;
}
.btn-pattern:hover {
    background: rgba(255,255,255,.14);
    border-color: rgba(255,255,255,.22);
    color: #fff;
}
.btn-pattern--active {
    background: rgba(74,144,217,.22);
    border-color: #4a90d9;
    color: #9ec8f5;
}

/* ── Map title overlay ──────────────────────────────────────────────────────── */
.map-title-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 14px 24px 10px;
    pointer-events: none;
}
.map-title-text {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: .3px;
    text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.map-subtitle-text {
    font-size: 0.82rem;
    opacity: 0.75;
    margin-top: 3px;
    text-shadow: 0 1px 3px rgba(0,0,0,.4);
}