/* ============================================================
   REALM CARTOGRAPHER — Fantasy D&D Map Overlay
   Premium dark-parchment theme
   ============================================================ */

/* ---------- Custom Properties ---------- */
:root {
    --parchment:       #f4e4c1;
    --parchment-dark:  #e0cfa0;
    --ink:             #2c1810;
    --ink-light:       #5c3a1e;
    --gold:            #c9a961;
    --gold-dim:        #a08640;
    --panel-bg:        rgba(22, 14, 10, 0.92);
    --panel-border:    rgba(201, 169, 97, 0.25);
    --input-bg:        rgba(244, 228, 193, 0.08);
    --input-border:    rgba(201, 169, 97, 0.3);
    --btn-gradient:    linear-gradient(135deg, #8B4513 0%, #A0522D 60%, #b8683a 100%);
    --btn-hover:       linear-gradient(135deg, #a0522d 0%, #c47a4a 60%, #d49060 100%);
    --shadow-glow:     0 0 20px rgba(201, 169, 97, 0.15);
    --radius:          8px;
    --transition:      0.25s ease;

    --font-heading:    'Cinzel', serif;
    --font-fantasy:    'MedievalSharp', cursive;
    --font-body:       'Lora', serif;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    background: #0d0a08;
    color: var(--parchment);
}

/* ---------- Header ---------- */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 20px;
    background: linear-gradient(180deg, rgba(13, 10, 8, 0.95) 0%, rgba(13, 10, 8, 0.7) 100%);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--panel-border);
}

.header-brand {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-shrink: 0;
}

.header-brand h1 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.header-brand .subtitle {
    font-family: var(--font-fantasy);
    font-size: 0.8rem;
    color: var(--parchment-dark);
    opacity: 0.7;
    white-space: nowrap;
}

/* ---------- Search ---------- */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 540px;
}

.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 150px;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--gold-dim);
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 8px 14px 8px 38px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--parchment);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

#search-input::placeholder {
    color: rgba(228, 212, 180, 0.4);
}

#search-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(201, 169, 97, 0.2);
}

.quick-jump-select {
    padding: 7px 10px;
    font-family: var(--font-heading);
    font-size: 0.78rem;
    color: var(--parchment);
    background: rgba(26, 18, 12, 0.94);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
    cursor: pointer;
    white-space: nowrap;
    max-width: 215px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.quick-jump-select:hover,
.quick-jump-select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(201, 169, 97, 0.25);
}

.quick-jump-select optgroup {
    background: #140d09;
    color: var(--gold);
    font-family: var(--font-heading);
    font-weight: bold;
}

.quick-jump-select option {
    background: #1c130d;
    color: var(--parchment);
    font-family: var(--font-body);
}

#search-results {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    list-style: none;
    background: rgba(22, 14, 10, 0.96);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1100;
}

#search-results li.bookmark-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(201, 169, 97, 0.08);
    border-left: 3px solid var(--gold);
}

#search-results li.bookmark-result:hover {
    background: rgba(201, 169, 97, 0.22);
}

#search-results li.bookmark-result .bookmark-tag {
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(201, 169, 97, 0.2);
    color: var(--gold);
    font-family: var(--font-heading);
    white-space: nowrap;
    margin-left: 8px;
}

#search-results li {
    padding: 10px 14px;
    font-size: 0.85rem;
    color: var(--parchment-dark);
    cursor: pointer;
    border-bottom: 1px solid rgba(201, 169, 97, 0.1);
    transition: background var(--transition), color var(--transition);
}

#search-results li:last-child {
    border-bottom: none;
}

#search-results li:hover {
    background: rgba(201, 169, 97, 0.12);
    color: var(--parchment);
}

/* ---------- Map ---------- */
#map {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ---------- Parchment texture overlay ---------- */
#parchment-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 350;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    mix-blend-mode: multiply;
    background:
        radial-gradient(ellipse at 15% 20%, rgba(120, 90, 50, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 75%, rgba(100, 70, 30, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 50%, rgba(140, 110, 60, 0.06) 0%, transparent 70%);
}

#parchment-overlay.active {
    opacity: 1;
}

/* ---------- Tile Layer Filters ---------- */
.parchment-tiles {
    filter: sepia(0.55) saturate(0.5) brightness(0.88) contrast(1.12) hue-rotate(8deg);
}

.dark-tiles {
    filter: invert(0.92) hue-rotate(180deg) brightness(0.55) contrast(1.4) sepia(0.35);
}

/* ---------- Control Panel ---------- */
#control-panel {
    position: fixed;
    top: 52px;
    right: 0;
    bottom: 0;
    z-index: 800;
    width: 288px;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--panel-border);
    transform: translateX(0);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#control-panel.collapsed {
    transform: translateX(100%);
}

/* ---------- Sidebar Tab Bar ---------- */
.sidebar-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(18, 12, 8, 0.94);
    border-bottom: 1px solid var(--panel-border);
    padding: 6px 8px;
    gap: 3px;
}

.tab-btn {
    flex: 1;
    height: 32px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 1.05rem;
    color: var(--parchment-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    position: relative;
}

.tab-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold-light);
    transform: translateY(-1px);
}

.tab-btn.active {
    background: rgba(212, 175, 55, 0.22);
    border-color: var(--gold);
    color: var(--gold-light);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.25);
}

.tab-collapse-btn {
    width: 26px;
    height: 30px;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: var(--radius);
    color: var(--gold-dim);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    margin-left: 2px;
}

.tab-collapse-btn:hover {
    background: rgba(212, 175, 55, 0.25);
    color: var(--gold-light);
    border-color: var(--gold);
}

/* Floating Expand button shown when panel is collapsed */
#panel-expand-btn {
    position: fixed;
    top: 60px;
    right: 14px;
    z-index: 900;
    width: 36px;
    height: 36px;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    color: var(--gold);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

#panel-expand-btn:hover {
    background: rgba(44, 30, 18, 0.95);
    color: var(--gold-light);
    transform: scale(1.05);
}

.tab-pane {
    display: none;
    animation: fadeInTab 0.18s ease-in-out;
}

.tab-pane.active {
    display: block;
}

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

.panel-inner {
    flex: 1;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 12px 14px 60px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(201, 169, 97, 0.45) rgba(0, 0, 0, 0.25);
}

.panel-inner::-webkit-scrollbar {
    width: 8px;
}

.panel-inner::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 4px;
}

.panel-inner::-webkit-scrollbar-thumb {
    background: rgba(201, 169, 97, 0.45);
    border-radius: 4px;
}

.panel-inner::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 169, 97, 0.75);
}

/* ---------- Buttons ---------- */
.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--parchment);
    background: var(--btn-gradient);
    border: 1px solid rgba(201, 169, 97, 0.3);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), transform 0.15s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.primary-btn:hover {
    background: var(--btn-hover);
    box-shadow: var(--shadow-glow), 0 4px 16px rgba(139, 69, 19, 0.4);
    transform: translateY(-1px);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn .btn-icon {
    font-size: 1.1rem;
}

.secondary-btn {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--gold);
    background: transparent;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.secondary-btn:hover {
    background: rgba(201, 169, 97, 0.1);
    border-color: var(--gold);
}

.small-btn {
    padding: 6px 14px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--parchment);
    background: var(--btn-gradient);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
}

.small-btn:hover {
    background: var(--btn-hover);
}

/* ---------- Feature Count ---------- */
.feature-count {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--parchment-dark);
    opacity: 0.8;
}

.feature-count span {
    white-space: nowrap;
}

/* ---------- Control Sections ---------- */
.control-section {
    margin-top: 14px;
    border: 1px solid rgba(201, 169, 97, 0.12);
    border-radius: var(--radius);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--gold);
    background: rgba(201, 169, 97, 0.06);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.section-header::after {
    content: '▾';
    margin-left: auto;
    font-size: 0.7rem;
    opacity: 0.5;
    transition: transform var(--transition);
}

.section-header.collapsed::after {
    transform: rotate(-90deg);
}

.section-header:hover {
    background: rgba(201, 169, 97, 0.1);
}

.section-content {
    padding: 10px 12px 12px;
    max-height: 2500px;
    transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.25s ease;
    opacity: 1;
}

.section-content.collapsed {
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

/* ---------- Form Controls ---------- */
.slider-label {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: 8px;
    margin-bottom: 4px;
    font-size: 0.8rem;
    color: var(--parchment-dark);
}

.slider-label:first-child {
    margin-top: 0;
}

.slider-val {
    margin-left: auto;
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--gold);
    font-size: 0.8rem;
}

/* Range slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(201, 169, 97, 0.15);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid var(--ink);
    cursor: pointer;
    transition: box-shadow var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 8px rgba(201, 169, 97, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--gold);
    border: 2px solid var(--ink);
    cursor: pointer;
}

/* Select */
select {
    width: 100%;
    padding: 7px 10px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--parchment);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
}

select:focus {
    border-color: var(--gold);
}

select option {
    background: #1a0f0a;
    color: var(--parchment);
}

/* Toggle Checkboxes */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 0.82rem;
    color: var(--parchment-dark);
    cursor: pointer;
    transition: color var(--transition);
}

.toggle-label:hover {
    color: var(--parchment);
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-check {
    position: relative;
    width: 32px;
    height: 18px;
    background: rgba(201, 169, 97, 0.15);
    border-radius: 9px;
    flex-shrink: 0;
    transition: background var(--transition);
}

.toggle-check::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--parchment-dark);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

.toggle-label input:checked + .toggle-check {
    background: rgba(201, 169, 97, 0.4);
}

.toggle-label input:checked + .toggle-check::after {
    transform: translateX(14px);
    background: var(--gold);
}

/* API Key input group */
.api-key-group {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.api-key-group input {
    flex: 1;
    padding: 6px 10px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--parchment);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    outline: none;
}

.api-key-group input::placeholder {
    color: rgba(228, 212, 180, 0.35);
}

/* Hint text */
.hint {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--parchment-dark);
    opacity: 0.5;
    font-style: italic;
    line-height: 1.4;
}

/* ---------- Loading Overlay (Granular Progress Tracker) ---------- */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(13, 10, 8, 0.78);
    backdrop-filter: blur(8px);
    transition: opacity 0.25s ease;
}

#loading-overlay.active {
    display: flex;
}

.loading-content.loading-card {
    text-align: center;
    animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    background: radial-gradient(ellipse at center, rgba(32, 24, 18, 0.97) 0%, rgba(16, 12, 9, 0.98) 100%);
    border: 1px solid var(--border);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(201, 169, 97, 0.25);
    border-radius: 8px;
    padding: 24px 28px;
    width: 90%;
    max-width: 480px;
    box-sizing: border-box;
    position: relative;
}

.loading-spinner {
    width: 46px;
    height: 46px;
    margin: 0 auto 14px;
    border: 3px solid rgba(201, 169, 97, 0.2);
    border-top-color: var(--gold);
    border-right-color: rgba(201, 169, 97, 0.6);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

.loading-message {
    font-family: var(--font-fantasy);
    font-size: 1.15rem;
    color: var(--gold);
    letter-spacing: 0.03em;
    margin: 0 0 8px 0;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

/* Progress bar container */
.loading-progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0 6px 0;
}

.loading-progress-bar-wrap {
    flex: 1;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(201, 169, 97, 0.28);
    border-radius: 6px;
    padding: 3px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

.loading-progress-bar {
    height: 10px;
    background: linear-gradient(90deg, #7c4e20 0%, #c49a6c 60%, #ffe1a6 100%);
    border-radius: 4px;
    transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 0 10px rgba(201, 169, 97, 0.5);
}

.loading-progress-pct {
    font-family: 'Cinzel', serif;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--gold);
    min-width: 42px;
    text-align: right;
}

.loading-subtext {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.82rem;
    color: #c4b99e;
    margin: 4px 0 12px 0;
    line-height: 1.35;
    min-height: 18px;
}

/* Granular Steps Checklist */
.loading-steps-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 12px 0;
    max-height: 220px;
    overflow-y: auto;
    text-align: left;
}

.loading-step-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(201, 169, 97, 0.12);
    border-radius: 5px;
    font-size: 0.82rem;
    transition: all 0.2s ease;
}

.loading-step-row.active {
    background: rgba(201, 169, 97, 0.09);
    border-color: rgba(201, 169, 97, 0.4);
    box-shadow: 0 0 8px rgba(201, 169, 97, 0.15);
}

.loading-step-row.completed {
    border-color: rgba(80, 160, 80, 0.25);
    background: rgba(50, 120, 50, 0.06);
}

.loading-step-left {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading-step-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
}

.loading-step-label {
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    color: var(--parchment);
    letter-spacing: 0.02em;
}

.loading-step-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.loading-step-detail {
    font-size: 0.72rem;
    color: #9e917d;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading-step-badge {
    font-size: 0.72rem;
    padding: 2px 7px;
    border-radius: 3px;
    font-weight: 500;
}

.loading-step-badge.badge-pending {
    background: rgba(255, 255, 255, 0.05);
    color: #7a7263;
}

.loading-step-badge.badge-active {
    background: rgba(201, 169, 97, 0.22);
    color: var(--gold);
    animation: pulse 1.4s infinite ease-in-out;
}

.loading-step-badge.badge-done {
    background: rgba(70, 150, 70, 0.22);
    color: #7ee07e;
}

.loading-step-badge.badge-skipped {
    background: rgba(120, 120, 120, 0.15);
    color: #8c8578;
}

.loading-step-badge.badge-warning {
    background: rgba(210, 140, 40, 0.22);
    color: #f7be6d;
}

.loading-actions {
    margin-top: 14px;
    display: flex;
    justify-content: center;
}

#loading-cancel-btn {
    background: rgba(201, 169, 97, 0.1);
    border: 1px solid rgba(201, 169, 97, 0.3);
    color: var(--parchment);
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

#loading-cancel-btn:hover {
    background: rgba(201, 169, 97, 0.25);
    border-color: var(--gold);
    color: #fff;
    box-shadow: 0 0 10px rgba(201, 169, 97, 0.3);
}

/* ---------- Compass Rose ---------- */
.compass-rose {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.compass-rose:hover {
    opacity: 1;
}

/* ---------- Leaflet Overrides ---------- */
.leaflet-control-zoom a {
    background: var(--panel-bg) !important;
    backdrop-filter: blur(8px);
    color: var(--gold) !important;
    border-color: var(--panel-border) !important;
    font-family: var(--font-body) !important;
    transition: background var(--transition);
}

.leaflet-control-zoom a:hover {
    background: rgba(44, 30, 18, 0.95) !important;
}

.leaflet-control-scale-line {
    background: rgba(22, 14, 10, 0.8) !important;
    border-color: var(--gold-dim) !important;
    color: var(--parchment-dark) !important;
    font-family: var(--font-body) !important;
    font-size: 10px !important;
    backdrop-filter: blur(6px);
}

.leaflet-control-attribution {
    background: rgba(22, 14, 10, 0.7) !important;
    color: rgba(228, 212, 180, 0.4) !important;
    font-size: 9px !important;
}

.leaflet-control-attribution a {
    color: rgba(201, 169, 97, 0.5) !important;
}

/* ---------- Grid Zoom Hint ---------- */
.grid-zoom-hint {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 600;
    padding: 6px 16px;
    font-family: var(--font-fantasy);
    font-size: 0.85rem;
    color: var(--parchment);
    background: rgba(22, 14, 10, 0.85);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    pointer-events: none;
    animation: fadeInUp 0.3s ease;
}

/* ---------- Canvas Overlays ---------- */
.fantasy-overlay,
.grid-overlay {
    image-rendering: auto;
}

/* ---------- Animations ---------- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

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

/* ---------- Custom Inscribe Modal ---------- */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 6, 4, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-modal-content {
    background: rgba(22, 14, 10, 0.98);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 20px;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(201, 169, 97, 0.15);
}

.custom-modal-content input[type="text"] {
    background: rgba(10, 6, 4, 0.8);
    border: 1px solid var(--panel-border);
    color: var(--parchment);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    box-sizing: border-box;
}

.custom-modal-content input[type="text"]:focus {
    border-color: var(--gold);
    box-shadow: 0 0 8px rgba(201, 169, 97, 0.25);
}

/* ---------- Stamp Tools (Cartographer's Quill) ---------- */
.stamp-tools {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.tool-btn {
    padding: 7px 6px;
    font-size: 0.78rem;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--parchment-dark);
    background: rgba(201, 169, 97, 0.08);
    border: 1px solid rgba(201, 169, 97, 0.2);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
}

.tool-btn:hover {
    background: rgba(201, 169, 97, 0.18);
    color: var(--parchment);
    border-color: var(--gold);
}

.tool-btn.active {
    background: linear-gradient(135deg, rgba(201, 169, 97, 0.3), rgba(139, 69, 19, 0.4));
    color: var(--gold);
    border-color: var(--gold);
    font-weight: 600;
    box-shadow: 0 0 8px rgba(201, 169, 97, 0.25);
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(201, 169, 97, 0.2); }
    50%      { box-shadow: 0 0 20px rgba(201, 169, 97, 0.4); }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .header-brand .subtitle {
        display: none;
    }

    .header-brand h1 {
        font-size: 1rem;
    }

    #control-panel {
        width: 260px;
    }

    .search-container {
        max-width: 220px;
    }
}

@media (max-width: 480px) {
    #app-header {
        padding: 6px 12px;
    }

    .header-brand h1 {
        font-size: 0.9rem;
    }

    #control-panel {
        width: 100%;
        top: 48px;
    }

    .search-container {
        max-width: 180px;
    }
}

/* ---------- Chronological Era & Time-Slider HUD ---------- */
.timeline-floating-hud {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 90%;
    max-width: 580px;
    background: rgba(22, 16, 11, 0.94);
    border: 1px solid #c9a961;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.75), inset 0 0 16px rgba(201, 169, 97, 0.15);
    backdrop-filter: blur(8px);
    color: #f7e7c8;
    font-family: 'Cinzel', Georgia, serif;
    user-select: none;
    transition: all 0.3s ease;
}

.timeline-hud-inner {
    padding: 8px 14px;
}

.timeline-hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(201, 169, 97, 0.25);
}

.timeline-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.timeline-icon {
    font-size: 1rem;
}

.timeline-title {
    color: #c9a961;
}

.timeline-year-badge {
    background: rgba(201, 169, 97, 0.2);
    border: 1px solid #c9a961;
    border-radius: 4px;
    padding: 1px 8px;
    font-weight: bold;
    color: #f7e7c8;
    font-family: monospace;
    font-size: 0.9rem;
}

.timeline-minimize-btn {
    background: transparent;
    border: 1px solid rgba(201, 169, 97, 0.4);
    color: #c9a961;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timeline-minimize-btn:hover {
    background: rgba(201, 169, 97, 0.2);
}

.timeline-controls {
    margin-top: 8px;
}

.timeline-era-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
    justify-content: center;
}

.era-pill {
    background: rgba(36, 24, 16, 0.8);
    border: 1px solid rgba(201, 169, 97, 0.35);
    border-radius: 12px;
    color: #d8c29d;
    padding: 3px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: 'Cinzel', Georgia, serif;
    transition: all 0.2s ease;
}

.era-pill:hover {
    background: rgba(201, 169, 97, 0.25);
    border-color: #c9a961;
    color: #fff;
}

.era-pill.active {
    background: #c9a961;
    border-color: #f7e7c8;
    color: #1a120b;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(201, 169, 97, 0.5);
}

.timeline-slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px;
}

.timeline-bound {
    font-size: 0.72rem;
    color: #a88d5e;
    font-family: monospace;
    white-space: nowrap;
}

#timeline-year-slider {
    flex: 1;
    accent-color: #c9a961;
    cursor: pointer;
    height: 5px;
}

/* ---------- Landmark Dossier & Inspector Popup ---------- */

/* Custom dossier pane sits directly on the map container above the canvas overlay (z-index: 400).
   This ensures popups render above roads, trees, canopy, and all canvas-drawn features. */
.leaflet-fantasyDossierPane-pane {
    z-index: 850 !important;
    pointer-events: none;
}

.leaflet-fantasyDossierPane-pane .leaflet-popup {
    pointer-events: auto !important;
}

.leaflet-popup-pane {
    z-index: 800 !important;
}

.fantasy-dossier-popup,
.cave-site-leaflet-popup {
    z-index: 99999 !important;
    pointer-events: auto !important;
}

.fantasy-dossier-popup .leaflet-popup-content-wrapper {
    background: rgba(22, 15, 10, 0.96) !important;
    border: 1px solid #c9a961 !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.85), inset 0 0 18px rgba(201, 169, 97, 0.12) !important;
    backdrop-filter: blur(8px) !important;
    color: #f7e7c8 !important;
    padding: 0 !important;
    font-family: 'Cinzel', Georgia, serif !important;
}

.fantasy-dossier-popup .leaflet-popup-tip {
    background: rgba(22, 15, 10, 0.96) !important;
    border: 1px solid #c9a961 !important;
}

.fantasy-dossier-popup .leaflet-popup-content {
    margin: 0 !important;
    padding: 12px 14px !important;
    line-height: 1.4 !important;
    max-height: 480px !important;
    overflow-y: auto !important;
}

.landmark-dossier-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dossier-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(201, 169, 97, 0.3);
    padding-bottom: 5px;
}

.dossier-archetype {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dossier-icon {
    font-size: 1.1rem;
}

.dossier-badge {
    font-size: 0.75rem;
    font-weight: bold;
    color: #c9a961;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.dossier-close-btn {
    background: transparent;
    border: 1px solid rgba(201, 169, 97, 0.4);
    color: #c9a961;
    border-radius: 4px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.dossier-close-btn:hover {
    background: rgba(201, 169, 97, 0.25);
    color: #fff;
}

.dossier-title {
    margin: 0;
    font-size: 1.05rem;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.25;
}

.dossier-section {
    background: rgba(36, 25, 17, 0.7);
    border: 1px solid rgba(201, 169, 97, 0.25);
    border-radius: 6px;
    padding: 8px 10px;
}

.dossier-section-title {
    font-size: 0.68rem;
    font-weight: bold;
    color: #c9a961;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    border-bottom: 1px dashed rgba(201, 169, 97, 0.2);
    padding-bottom: 3px;
}

.dossier-loading {
    font-size: 0.78rem;
    color: #d8c29d;
    font-style: italic;
    padding: 6px 0;
}

.wiki-thumb-wrapper {
    float: right;
    margin: 0 0 6px 8px;
    border: 1px solid #c9a961;
    border-radius: 4px;
    padding: 2px;
    background: #110c08;
}

.wiki-thumb-img {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 2px;
}

.wiki-extract {
    margin: 0;
    font-size: 0.78rem;
    color: #ecd8b8;
    line-height: 1.35;
    font-family: Georgia, serif;
}

.wiki-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 0.7rem;
    clear: both;
}

.wiki-desc {
    color: #9e855a;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.wiki-link {
    color: #c9a961;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.7rem;
}

.wiki-link:hover {
    text-decoration: underline;
    color: #fff;
}

.osm-attributes-row {
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px dotted rgba(201, 169, 97, 0.25);
    font-size: 0.7rem;
    color: #bfa57b;
    font-family: sans-serif;
}

/* Fantasy Lore Section */
.fantasy-unconjured {
    text-align: center;
    padding: 4px 0;
}

.conjure-lore-btn {
    background: rgba(85, 40, 105, 0.45);
    border: 1px solid #b779db;
    color: #ecd6fb;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.conjure-lore-btn:hover {
    background: rgba(115, 55, 145, 0.65);
    color: #fff;
    box-shadow: 0 0 10px rgba(183, 121, 219, 0.4);
}

.lore-hint {
    font-size: 0.68rem;
    color: #a48e75;
    font-style: italic;
    margin-top: 4px;
}

.fantasy-lore-scroll {
    background: rgba(28, 18, 30, 0.6);
    border: 1px solid rgba(183, 121, 219, 0.35);
    border-radius: 4px;
    padding: 6px 8px;
}

.lore-fiction-badge {
    font-size: 0.62rem;
    color: #d19ff5;
    font-weight: bold;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    text-align: center;
}

.lore-field-label {
    display: block;
    font-size: 0.68rem;
    color: #c9a961;
    font-weight: 600;
    margin-top: 4px;
    margin-bottom: 2px;
}

.dossier-input, .dossier-textarea {
    width: 100%;
    background: rgba(14, 10, 7, 0.85);
    border: 1px solid rgba(201, 169, 97, 0.35);
    border-radius: 4px;
    color: #f7e7c8;
    padding: 4px 6px;
    font-family: Georgia, serif;
    font-size: 0.76rem;
    box-sizing: border-box;
}

.dossier-input:focus, .dossier-textarea:focus {
    border-color: #c9a961;
    outline: none;
    background: rgba(14, 10, 7, 0.95);
}

.dossier-textarea {
    resize: vertical;
    min-height: 46px;
    line-height: 1.3;
}

.dm-notes-input {
    min-height: 52px;
    color: #e5b872;
}

.notes-status {
    font-size: 0.68rem;
    color: #4a7c59;
    font-weight: bold;
    text-align: right;
    height: 12px;
    transition: opacity 0.3s ease;
}

.lore-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.reroll-lore-btn {
    background: rgba(201, 169, 97, 0.15);
    border: 1px solid rgba(201, 169, 97, 0.4);
    color: #dfc89d;
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    font-family: 'Cinzel', serif;
}

.reroll-lore-btn:hover {
    background: rgba(201, 169, 97, 0.3);
    color: #fff;
}

.lore-saved-indicator {
    font-size: 0.68rem;
    color: #8fa382;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.reroll-confirm-bar {
    margin-top: 6px;
    background: rgba(70, 20, 20, 0.85);
    border: 1px solid #e07a5f;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.confirm-yes-btn {
    background: #e07a5f;
    border: none;
    color: #fff;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 0.68rem;
    font-weight: bold;
    cursor: pointer;
}

.confirm-no-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 0.68rem;
    cursor: pointer;
}

/* Atmosphere & Soundscape Section */
.atmosphere-section {
    background: rgba(22, 32, 42, 0.75);
    border: 1px solid rgba(100, 180, 220, 0.35);
}

.soundscape-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.soundscape-select {
    background: #141d26;
    color: #9cdcfe;
    border: 1px solid rgba(100, 180, 220, 0.45);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.72rem;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    cursor: pointer;
    max-width: 220px;
    outline: none;
    transition: all 0.2s ease;
}

.soundscape-select:hover, .soundscape-select:focus {
    border-color: #9cdcfe;
    background: #1a2532;
    box-shadow: 0 0 6px rgba(100, 180, 220, 0.3);
}

.soundscape-select option {
    background: #161f28;
    color: #e2e8f0;
    font-family: sans-serif;
    font-weight: normal;
}

.soundscape-badge {
    font-size: 0.74rem;
    font-weight: bold;
    color: #9cdcfe;
    display: flex;
    align-items: center;
    gap: 4px;
}

.soundscape-meta {
    font-size: 0.65rem;
    color: #a0aec0;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    padding: 1px 5px;
}

.soundscape-sensory {
    margin: 0;
    font-size: 0.74rem;
    color: #e2e8f0;
    font-style: italic;
    line-height: 1.35;
    font-family: Georgia, serif;
}

.soundscape-volume-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 3px 0;
    font-size: 0.70rem;
    color: #a0aec0;
}

.soundscape-vol-label {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: #cce7f8;
    white-space: nowrap;
}

.soundscape-vol-slider {
    flex: 1;
    height: 4px;
    background: #1a2634;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    accent-color: #38bdf8;
}

.soundscape-vol-value {
    font-size: 0.68rem;
    color: #38bdf8;
    min-width: 28px;
    text-align: right;
    font-family: monospace;
}

.soundscape-attr-badge {
    font-size: 0.62rem;
    color: #4ade80;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(74, 222, 128, 0.35);
    border-radius: 3px;
    padding: 1px 5px;
    white-space: nowrap;
    font-family: 'Cinzel', serif;
    font-weight: 600;
}

.soundscape-tools {
    display: flex;
    gap: 6px;
    margin-top: 2px;
}

.soundscape-synth-btn {
    flex: 1;
    background: rgba(40, 90, 130, 0.35);
    border: 1px solid rgba(120, 200, 240, 0.4);
    color: #cce7f8;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.70rem;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.soundscape-synth-btn:hover {
    background: rgba(60, 120, 180, 0.55);
    color: #fff;
    box-shadow: 0 0 8px rgba(120, 200, 240, 0.3);
}

.soundscape-synth-btn.playing {
    background: rgba(180, 60, 60, 0.65);
    border-color: #ff9988;
    color: #fff;
    animation: soundPulse 1.5s infinite ease-in-out;
}

@keyframes soundPulse {
    0%, 100% { box-shadow: 0 0 4px rgba(255, 100, 100, 0.4); }
    50% { box-shadow: 0 0 12px rgba(255, 100, 100, 0.8); }
}

.soundscape-copy-btn {
    flex: 1;
    background: rgba(30, 40, 30, 0.45);
    border: 1px solid rgba(140, 200, 140, 0.35);
    color: #c8e6c9;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.68rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
}

.soundscape-copy-btn:hover {
    background: rgba(40, 70, 40, 0.65);
    color: #fff;
    border-color: rgba(160, 230, 160, 0.6);
}

.dossier-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.dossier-action-btn {
    flex: 1;
    min-width: 90px;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.72rem;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
}

.dossier-action-btn.primary-action {
    background: #c9a961;
    border: 1px solid #f7e7c8;
    color: #1a120b;
}

.dossier-action-btn.primary-action:hover {
    background: #e0be75;
    box-shadow: 0 0 8px rgba(201, 169, 97, 0.5);
}

.dossier-action-btn.secondary-action {
    background: rgba(36, 24, 16, 0.8);
    border: 1px solid rgba(201, 169, 97, 0.4);
    color: #dfc89d;
}

.dossier-action-btn.secondary-action:hover {
    background: rgba(201, 169, 97, 0.2);
    color: #fff;
}

.dossier-action-btn.close-action {
    background: transparent;
    border: 1px solid rgba(201, 169, 97, 0.3);
    color: #a88d5e;
    flex: 0 0 auto;
    min-width: 60px;
}

.dossier-action-btn.close-action:hover {
    color: #fff;
    border-color: #c9a961;
}

/* On-Site Cave Inspection Popup */
.cave-site-leaflet-popup {
    z-index: 99999 !important;
}

.cave-site-leaflet-popup .leaflet-popup-content-wrapper {
    background: rgba(20, 14, 10, 0.95) !important;
    border: 1px solid #a87848 !important;
    border-radius: 6px !important;
    color: #dfc89d !important;
    padding: 0 !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8) !important;
    font-family: 'Cinzel', Georgia, serif !important;
}

.cave-site-leaflet-popup .leaflet-popup-tip {
    background: rgba(20, 14, 10, 0.95) !important;
    border: 1px solid #a87848 !important;
}

.cave-site-leaflet-popup .leaflet-popup-content {
    margin: 0 !important;
    padding: 8px 10px !important;
}

.cave-site-popup-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.cave-site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(168, 120, 72, 0.35);
    padding-bottom: 4px;
}

.cave-site-title {
    font-size: 0.75rem;
    font-weight: bold;
    color: #f5e2bf;
    max-width: 170px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cave-site-close-btn {
    background: transparent;
    border: 1px solid rgba(168, 120, 72, 0.4);
    color: #c5a47e;
    border-radius: 3px;
    width: 18px;
    height: 18px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cave-site-close-btn:hover {
    background: rgba(168, 120, 72, 0.3);
    color: #fff;
}

.cave-site-sub {
    font-size: 0.7rem;
    color: #c2a482;
    text-align: center;
}

.cave-site-actions {
    display: flex;
    gap: 4px;
    margin-top: 2px;
}

.cave-site-btn {
    flex: 1;
    background: rgba(168, 120, 72, 0.2);
    border: 1px solid #8a6442;
    color: #f0ddb8;
    border-radius: 3px;
    padding: 3px 5px;
    font-size: 0.68rem;
    font-family: 'Cinzel', serif;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
}

.cave-site-btn:hover {
    background: rgba(168, 120, 72, 0.35);
    color: #fff;
}

.cave-site-btn.exit-btn {
    background: rgba(139, 38, 62, 0.3);
    border-color: #8b263e;
    color: #f5c2c7;
}

/* ---------- URL Deep-Linking & Share System ---------- */

.header-actions {
    display: flex;
    align-items: center;
    margin-left: 12px;
}

.header-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(46, 30, 18, 0.95), rgba(30, 20, 12, 0.95));
    border: 1px solid #c9a961;
    color: #f7e7c8;
    padding: 6px 14px;
    border-radius: 6px;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 8px rgba(201, 169, 97, 0.1);
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.header-share-btn:hover {
    background: linear-gradient(135deg, rgba(62, 42, 26, 0.95), rgba(46, 30, 18, 0.95));
    border-color: #ffd700;
    color: #fff;
    box-shadow: 0 4px 14px rgba(201, 169, 97, 0.35);
    transform: translateY(-1px);
}

.header-share-btn.active,
.header-share-btn.advanced-mode-btn.active {
    background: linear-gradient(135deg, rgba(120, 75, 20, 0.95), rgba(70, 45, 15, 0.95));
    border-color: #ffd700;
    color: #fff4d0;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.45);
}

/* ---------- Sidebar Mode Bar (Standard vs Advanced) ---------- */
.sidebar-mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(15, 10, 6, 0.88);
    border-bottom: 1px solid rgba(201, 169, 97, 0.16);
    font-size: 0.72rem;
    font-family: var(--font-heading);
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.sidebar-mode-label {
    color: var(--gold-dim);
    font-weight: 600;
    font-size: 0.72rem;
}

.mode-pill-group {
    display: flex;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(201, 169, 97, 0.22);
    border-radius: 14px;
    padding: 2px;
    gap: 2px;
}

.mode-pill-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--parchment-dark);
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.mode-pill-btn:hover {
    color: var(--gold-light);
}

.mode-pill-btn.active {
    background: linear-gradient(135deg, rgba(201, 169, 97, 0.35), rgba(160, 134, 64, 0.45));
    color: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 215, 0, 0.4);
}

/* ---------- Advanced Mode Gating ---------- */
body:not(.advanced-mode) .advanced-only {
    display: none !important;
}

body.advanced-mode .advanced-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-family: var(--font-heading);
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(201, 169, 97, 0.2);
    border: 1px solid rgba(201, 169, 97, 0.45);
    color: #ffe6a3;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    vertical-align: middle;
}

.advanced-badge {
    display: none;
}

/* Subtle accent for advanced sections in advanced mode */
body.advanced-mode .advanced-only.control-section {
    border-color: rgba(201, 169, 97, 0.28);
}

/* Advanced Notice Banner in tabs */
.advanced-gate-notice {
    margin-top: 14px;
    padding: 8px 10px;
    background: rgba(30, 20, 12, 0.45);
    border: 1px dashed rgba(201, 169, 97, 0.25);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--parchment-dark);
}

body.advanced-mode .advanced-gate-notice {
    display: none !important;
}

.enable-advanced-link {
    background: rgba(201, 169, 97, 0.15);
    border: 1px solid rgba(201, 169, 97, 0.35);
    color: var(--gold-light);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.68rem;
    font-family: var(--font-heading);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.enable-advanced-link:hover {
    background: rgba(201, 169, 97, 0.3);
    border-color: var(--gold);
    color: #fff;
}

.share-link-box {
    margin-top: 6px;
}

.share-link-input {
    width: 100%;
    box-sizing: border-box;
    background: rgba(18, 12, 8, 0.85);
    border: 1px solid #8a6442;
    border-radius: 4px;
    color: #dfc89d;
    font-family: monospace;
    font-size: 0.76rem;
    padding: 6px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: text;
}

.share-link-input:focus {
    outline: none;
    border-color: #c9a961;
    background: rgba(26, 18, 12, 0.95);
    color: #fff;
}

.realm-share-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(22, 14, 8, 0.96);
    border: 1px solid #c9a961;
    color: #f7e7c8;
    padding: 10px 22px;
    border-radius: 8px;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75), 0 0 16px rgba(201, 169, 97, 0.3);
    backdrop-filter: blur(8px);
    z-index: 999999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    text-align: center;
    letter-spacing: 0.5px;
}

.realm-share-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- Notification Toast Stack & Activity Log ---------- */
.realm-toast-stack {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 999999;
    max-width: 420px;
    pointer-events: none;
}

.realm-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 6px;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.82rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
    opacity: 0;
    transform: translateX(35px);
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    cursor: pointer;
    user-select: none;
}

.realm-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.realm-toast.hide {
    opacity: 0;
    transform: translateX(35px);
}

.realm-toast.toast-info {
    background: rgba(22, 16, 11, 0.96);
    border: 1px solid #c9a961;
    color: #f7e7c8;
}

.realm-toast.toast-success {
    background: rgba(14, 26, 16, 0.96);
    border: 1px solid #50fa7b;
    color: #e8fced;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 12px rgba(80, 250, 123, 0.2);
}

.realm-toast.toast-warning {
    background: rgba(28, 20, 10, 0.96);
    border: 1px solid #ffb86c;
    color: #fff2e0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 12px rgba(255, 184, 108, 0.2);
}

.realm-toast.toast-error {
    background: rgba(30, 12, 14, 0.96);
    border: 1px solid #ff5555;
    color: #ffe6e6;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 14px rgba(255, 85, 85, 0.25);
}

.toast-icon {
    font-size: 1.15rem;
    line-height: 1.2;
    flex-shrink: 0;
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-source {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.8;
    font-family: sans-serif;
    margin-bottom: 2px;
    font-weight: 700;
}

.toast-message {
    line-height: 1.35;
    word-break: break-word;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.15rem;
    opacity: 0.6;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: opacity 0.15s ease;
}

.toast-close:hover {
    opacity: 1;
}

/* Activity Log Modal */
.activity-log-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-log-backdrop {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
}

.activity-log-card {
    position: relative;
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    background: #150f0a;
    border: 1px solid #c9a961;
    border-radius: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85), inset 0 0 16px rgba(201, 169, 97, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #f7e7c8;
}

.activity-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(201, 169, 97, 0.25);
    background: rgba(30, 20, 12, 0.5);
    font-family: 'Cinzel', serif;
}

.activity-log-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #c9a961;
}

.activity-log-close {
    background: none;
    border: none;
    color: #c9a961;
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
}

.activity-log-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.activity-log-filters {
    display: flex;
    gap: 4px;
}

.log-filter-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(201, 169, 97, 0.25);
    color: #d4c5a9;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.72rem;
    cursor: pointer;
}

.log-filter-btn.active {
    background: rgba(201, 169, 97, 0.25);
    border-color: #c9a961;
    color: #fff;
    font-weight: bold;
}

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

.activity-log-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.activity-log-empty {
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.8rem;
    margin: 30px 0;
}

.activity-log-item {
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid #c9a961;
    border-radius: 0 4px 4px 0;
    padding: 6px 10px;
    font-size: 0.78rem;
}

.activity-log-item.log-item-error {
    border-left-color: #ff5555;
    background: rgba(40, 15, 15, 0.35);
}

.activity-log-item.log-item-warning {
    border-left-color: #ffb86c;
    background: rgba(40, 25, 10, 0.3);
}

.activity-log-item.log-item-success {
    border-left-color: #50fa7b;
    background: rgba(15, 35, 18, 0.3);
}

.log-item-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #a89f91;
    margin-bottom: 2px;
}

.log-item-source {
    font-weight: bold;
    color: #c9a961;
}

.log-item-msg {
    color: #f0e6d2;
    line-height: 1.3;
}


.cave-site-btn.exit-btn:hover {
    background: rgba(139, 38, 62, 0.6);
    color: #fff;
}

/* ---------- Fog of War & Party Token ---------- */
.fog-control-card {
    background: rgba(16, 12, 22, 0.75);
    border: 1px solid rgba(150, 130, 180, 0.3);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 0 10px rgba(70, 50, 90, 0.2);
    border-radius: 6px;
    padding: 10px;
}

.party-token-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
}

.party-token-marker:active {
    cursor: grabbing;
}

.party-token-inner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle, #3d2b1f 0%, #1a120c 100%);
    border: 2px solid #c9a961;
    box-shadow: 0 0 12px rgba(201, 169, 97, 0.7), inset 0 0 6px rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    line-height: 1;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.party-token-inner:hover {
    transform: scale(1.12);
    box-shadow: 0 0 16px rgba(201, 169, 97, 0.95), inset 0 0 6px rgba(0, 0, 0, 0.9);
}

.fog-brush-active #map,
.fog-brush-active .leaflet-container {
    cursor: crosshair !important;
}

/* ============================================================
   ENDPOINTS & SERVER MIRRORS MANAGEMENT PANEL
   ============================================================ */
.endpoints-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0;
    font-size: 0.8rem;
}

.endpoints-action-bar {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(201, 169, 97, 0.2);
}

.endpoints-action-bar .small-btn {
    padding: 4px 8px;
    font-size: 0.72rem;
    flex: 1;
    text-align: center;
}

.endpoints-action-bar .reset-btn {
    border-color: rgba(220, 100, 100, 0.35);
    color: #ffcccc;
}

.endpoints-action-bar .reset-btn:hover {
    background: rgba(180, 40, 40, 0.3);
    border-color: #ff6666;
}

.endpoints-nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 2px 0;
}

.endpoints-nav-btn {
    background: rgba(26, 18, 11, 0.7);
    border: 1px solid rgba(138, 100, 66, 0.4);
    color: #a89270;
    font-family: 'Cinzel', serif;
    font-size: 0.68rem;
    padding: 3px 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.endpoints-nav-btn:hover {
    background: rgba(201, 169, 97, 0.15);
    color: #dfc89d;
    border-color: #c9a961;
}

.endpoints-nav-btn.active {
    background: #3d2b1f;
    color: #ffd987;
    border-color: #c9a961;
    box-shadow: 0 0 6px rgba(201, 169, 97, 0.4);
    font-weight: bold;
}

.endpoint-svc-header {
    background: rgba(0, 0, 0, 0.25);
    border-left: 3px solid #c9a961;
    padding: 6px 8px;
    border-radius: 0 4px 4px 0;
}

.endpoint-svc-title {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: bold;
    color: #e5cf9f;
}

.endpoint-svc-desc {
    font-size: 0.7rem;
    color: #9d8c76;
    margin-top: 2px;
    line-height: 1.3;
}

.endpoints-mirrors-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.endpoints-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    color: #bfa57b;
    margin-top: 4px;
}

.endpoint-mirror-row {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(28, 18, 11, 0.85);
    border: 1px solid rgba(138, 100, 66, 0.4);
    border-radius: 4px;
    padding: 6px 8px;
    transition: all 0.2s ease;
}

.endpoint-mirror-row:hover {
    border-color: #c9a961;
    background: rgba(45, 28, 18, 0.9);
}

.endpoint-mirror-row.disabled {
    opacity: 0.45;
    filter: grayscale(0.5);
}

.mirror-order-controls {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mirror-order-btn {
    background: transparent;
    border: none;
    color: #a89270;
    font-size: 0.6rem;
    line-height: 1;
    padding: 1px 3px;
    cursor: pointer;
    border-radius: 2px;
}

.mirror-order-btn:hover:not(:disabled) {
    background: rgba(201, 169, 97, 0.25);
    color: #fff;
}

.mirror-order-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.mirror-enable-toggle {
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.mirror-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mirror-url {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.72rem;
    color: #e5cf9f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mirror-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.66rem;
}

.mirror-tag {
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.mirror-tag.default {
    background: rgba(100, 140, 180, 0.25);
    border: 1px solid rgba(100, 140, 180, 0.5);
    color: #9ac2e8;
}

.mirror-tag.custom {
    background: rgba(180, 120, 40, 0.3);
    border: 1px solid rgba(220, 150, 50, 0.6);
    color: #ffcf73;
}

.endpoint-test-btn, .endpoint-ping-btn {
    background: rgba(201, 169, 97, 0.15);
    border: 1px solid rgba(201, 169, 97, 0.35);
    color: #dfc89d;
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 3px;
    cursor: pointer;
}

.endpoint-test-btn:hover, .endpoint-ping-btn:hover {
    background: rgba(201, 169, 97, 0.3);
    color: #fff;
}

.endpoint-latency-badge {
    font-size: 0.65rem;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
}

.endpoint-latency-badge.fast {
    background: rgba(40, 160, 60, 0.25);
    border: 1px solid #3eb858;
    color: #85e89d;
}

.endpoint-latency-badge.moderate {
    background: rgba(200, 160, 40, 0.25);
    border: 1px solid #e0af30;
    color: #ffe07a;
}

.endpoint-latency-badge.slow {
    background: rgba(220, 110, 40, 0.25);
    border: 1px solid #d97724;
    color: #ffab70;
}

.endpoint-latency-badge.fail {
    background: rgba(200, 40, 40, 0.25);
    border: 1px solid #d94040;
    color: #ff8585;
}

.endpoint-latency-badge.testing {
    background: rgba(50, 120, 200, 0.25);
    border: 1px solid #4a90e2;
    color: #92c0fc;
}

.mirror-row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.endpoint-remove-btn {
    background: transparent;
    border: none;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0.7;
    padding: 2px 4px;
    border-radius: 3px;
}

.endpoint-remove-btn:hover {
    opacity: 1;
    background: rgba(220, 40, 40, 0.25);
}

.add-mirror-box {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed rgba(201, 169, 97, 0.3);
    border-radius: 4px;
}

.add-mirror-label {
    display: block;
    font-size: 0.7rem;
    color: #bfa57b;
    margin-bottom: 4px;
}

.add-mirror-input-group {
    display: flex;
    gap: 6px;
}

.add-mirror-input-group input {
    flex: 1;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.72rem;
    background: rgba(15, 10, 6, 0.8);
    border: 1px solid #8a6442;
    color: #dfc89d;
    padding: 4px 6px;
    border-radius: 3px;
}

.add-mirror-input-group input:focus {
    outline: none;
    border-color: #c9a961;
}

.endpoints-single-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(28, 18, 11, 0.85);
    border: 1px solid rgba(138, 100, 66, 0.4);
    border-radius: 4px;
    padding: 10px;
}

.single-url-label {
    font-size: 0.72rem;
    color: #bfa57b;
}

.single-url-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.single-url-input-group input {
    flex: 1;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.75rem;
    background: rgba(15, 10, 6, 0.8);
    border: 1px solid #8a6442;
    color: #dfc89d;
    padding: 5px 8px;
    border-radius: 3px;
}

.single-url-input-group input:focus {
    outline: none;
    border-color: #c9a961;
}

.single-url-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
}

.single-url-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

/* ==========================================================================
   Issue #51: 5e SRD Monster Stat Block Modal & Parchment Card
   ========================================================================== */
.monster-statblock-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 12000;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'Book Antiqua', 'Palatino Linotype', 'Georgia', serif;
}

.monster-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 8, 7, 0.82);
    backdrop-filter: blur(8px);
}

.monster-modal-window {
    position: relative;
    width: 680px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 48px);
    background: #1a1410;
    border: 2px solid #c9a961;
    border-radius: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.9), 0 0 24px rgba(201, 169, 97, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}

.monster-modal-header {
    background: linear-gradient(180deg, #2c1a12 0%, #1a120c 100%);
    border-bottom: 2px solid #c9a961;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.monster-modal-header .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.monster-modal-header .header-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 6px rgba(230, 80, 50, 0.5));
}

.monster-modal-header .header-main-title {
    margin: 0;
    font-size: 1.15rem;
    letter-spacing: 1px;
    color: #ffd899;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    font-family: 'Cinzel', 'Times New Roman', serif;
}

.monster-modal-header .header-sub-title {
    font-size: 0.72rem;
    color: #a89270;
    display: block;
}

.modal-close-icon {
    background: transparent;
    border: none;
    color: #c9a961;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.15s ease, color 0.15s ease;
}

.modal-close-icon:hover {
    color: #ff5544;
    transform: scale(1.15);
}

.monster-search-ribbon {
    background: rgba(26, 18, 12, 0.95);
    border-bottom: 1px solid rgba(201, 169, 97, 0.3);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-input-wrapper {
    display: flex;
    gap: 8px;
}

.monster-search-input {
    flex: 1;
    background: #0d0a08;
    border: 1px solid #7d6540;
    border-radius: 4px;
    padding: 8px 12px;
    color: #f7e6c4;
    font-size: 0.9rem;
    font-family: inherit;
}

.monster-search-input:focus {
    outline: none;
    border-color: #ffd899;
    box-shadow: 0 0 8px rgba(201, 169, 97, 0.4);
}

.monster-search-btn {
    background: linear-gradient(180deg, #7d2a1c 0%, #52180e 100%);
    border: 1px solid #d45d47;
    color: #fff;
    padding: 0 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-family: inherit;
    font-size: 0.85rem;
    transition: background 0.15s ease;
}

.monster-search-btn:hover {
    background: linear-gradient(180deg, #963322 0%, #681f13 100%);
}

.quick-monsters-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.quick-label {
    font-size: 0.72rem;
    color: #a89270;
    font-weight: bold;
    text-transform: uppercase;
}

.quick-btn {
    background: rgba(45, 30, 20, 0.8);
    border: 1px solid rgba(201, 169, 97, 0.35);
    color: #dfc89d;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 3px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quick-btn:hover {
    background: rgba(201, 169, 97, 0.25);
    border-color: #ffd899;
    color: #fff;
}

.monster-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #140f0c;
}

.statblock-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #c9a961;
    gap: 12px;
}

/* Authentic 5e Parchment Card */
.statblock-card {
    background: #fbf3e4;
    color: #2c2014;
    border: 1px solid #bda884;
    border-top: 6px solid #58180D;
    border-radius: 4px;
    padding: 18px 22px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    line-height: 1.45;
}

.statblock-header {
    margin-bottom: 6px;
}

.statblock-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.statblock-name {
    margin: 0;
    font-family: 'Cinzel', 'Palatino', 'Georgia', serif;
    font-size: 1.7rem;
    color: #58180D;
    letter-spacing: 0.5px;
    font-weight: bold;
}

.statblock-cr-badge {
    background: #58180D;
    color: #f7e6c4;
    font-size: 0.85rem;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.statblock-meta {
    font-style: italic;
    font-size: 0.9rem;
    color: #554433;
    margin-top: 2px;
}

.statblock-rule {
    height: 3px;
    background: linear-gradient(to right, transparent, #922610, transparent);
    margin: 10px 0;
}

.statblock-line {
    font-size: 0.92rem;
    margin-bottom: 3px;
    color: #2b1f14;
}

.statblock-line strong {
    color: #58180D;
    font-weight: 700;
}

.statblock-abilities {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    text-align: center;
    margin: 8px 0;
}

.ability-box {
    background: rgba(189, 168, 132, 0.22);
    border: 1px solid rgba(88, 24, 13, 0.25);
    border-radius: 3px;
    padding: 5px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ab-label {
    font-size: 0.72rem;
    font-weight: bold;
    color: #58180D;
    text-transform: uppercase;
}

.ab-score {
    font-size: 1.05rem;
    font-weight: bold;
    color: #2b1f14;
}

.ab-mod {
    font-size: 0.8rem;
    color: #664422;
}

.statblock-section {
    margin-top: 10px;
}

.statblock-section-title {
    font-size: 1.15rem;
    color: #58180D;
    border-bottom: 1px solid #bda884;
    padding-bottom: 2px;
    margin: 12px 0 8px 0;
    font-family: 'Cinzel', 'Palatino', serif;
    letter-spacing: 0.5px;
}

.statblock-entry {
    font-size: 0.9rem;
    margin-bottom: 8px;
    text-align: justify;
}

.statblock-entry .entry-name {
    font-style: italic;
    font-weight: bold;
    color: #2b1f14;
}

.legendary-intro {
    font-size: 0.86rem;
    font-style: italic;
    color: #554433;
    margin-bottom: 8px;
}

.statblock-actions-bar {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    padding-top: 8px;
}

.statblock-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.88rem;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.statblock-btn.dndbeyond-btn {
    background: #6a1a10;
    border: 1px solid #942d20;
    color: #fff;
}

.statblock-btn.dndbeyond-btn:hover {
    background: #8b2316;
}

.statblock-btn.copy-btn {
    background: #73592c;
    border: 1px solid #99783f;
    color: #fff;
}

.statblock-btn.copy-btn:hover {
    background: #8f6e37;
}

.statblock-btn.close-btn {
    background: #3d342c;
    border: 1px solid #574b40;
    color: #ded1be;
    flex: 0 0 90px;
}

.statblock-btn.close-btn:hover {
    background: #4f4339;
    color: #fff;
}

.statblock-footer-source {
    font-size: 0.72rem;
    color: #776655;
    text-align: center;
    margin-top: 12px;
}


/* ============================================================
   NATURE & ECOLOGY TAB — Issues #58 & #59
   iNaturalist regional fauna/flora panels
   ============================================================ */

/* Scan Buttons */
.nature-scan-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.82rem;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(40, 80, 40, 0.6), rgba(60, 100, 50, 0.4));
    border: 1px solid rgba(100, 180, 80, 0.35);
    transition: all var(--transition);
}
.nature-scan-btn:hover {
    background: linear-gradient(135deg, rgba(50, 100, 50, 0.7), rgba(80, 130, 60, 0.5));
    border-color: rgba(120, 200, 100, 0.5);
    box-shadow: 0 0 12px rgba(100, 180, 80, 0.2);
}
.nature-scan-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

/* Category Filter Pills */
.nature-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}
.nature-pill {
    font-family: var(--font-body);
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    background: rgba(244, 228, 193, 0.06);
    color: rgba(244, 228, 193, 0.7);
    cursor: pointer;
    transition: all var(--transition);
}
.nature-pill:hover {
    background: rgba(201, 169, 97, 0.15);
    color: var(--parchment);
}
.nature-pill.active {
    background: rgba(201, 169, 97, 0.25);
    border-color: var(--gold-dim);
    color: var(--gold);
    font-weight: 600;
}

/* Results List */
.nature-results-list {
    max-height: 380px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(201, 169, 97, 0.3) transparent;
}

/* Species Card */
.nature-species-card {
    display: flex;
    gap: 8px;
    padding: 8px;
    margin-bottom: 6px;
    border-radius: var(--radius);
    border: 1px solid rgba(201, 169, 97, 0.15);
    background: rgba(244, 228, 193, 0.04);
    transition: all var(--transition);
}
.nature-species-card:hover {
    background: rgba(244, 228, 193, 0.08);
    border-color: rgba(201, 169, 97, 0.3);
}

/* Species Photo Thumbnail */
.nature-species-photo {
    width: 52px;
    height: 52px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid rgba(201, 169, 97, 0.2);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
}

/* Species Info */
.nature-species-info {
    flex: 1;
    min-width: 0;
}
.nature-species-name {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--parchment);
    margin: 0 0 2px;
    line-height: 1.2;
}
.nature-species-sci {
    font-style: italic;
    font-size: 0.7rem;
    color: rgba(244, 228, 193, 0.5);
    margin: 0 0 4px;
}
.nature-species-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

/* Provenance Badges */
.nature-provenance-badge {
    font-family: var(--font-body);
    font-size: 0.62rem;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.nature-badge-real {
    background: rgba(38, 166, 154, 0.2);
    border: 1px solid rgba(38, 166, 154, 0.4);
    color: #4db6ac;
}
.nature-badge-ttrpg {
    background: rgba(255, 179, 71, 0.15);
    border: 1px solid rgba(255, 179, 71, 0.35);
    color: #ffb347;
}
.nature-badge-mythic {
    background: rgba(171, 71, 188, 0.15);
    border: 1px solid rgba(171, 71, 188, 0.35);
    color: #ce93d8;
}

/* Observation Count Badge */
.nature-count-badge {
    font-size: 0.62rem;
    padding: 1px 5px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(201, 169, 97, 0.2);
    color: rgba(244, 228, 193, 0.6);
}

/* 5e Stat Suggestion */
.nature-stat-suggestion {
    margin-top: 5px;
    padding: 5px 8px;
    border-radius: 5px;
    background: rgba(139, 69, 19, 0.12);
    border: 1px solid rgba(139, 69, 19, 0.25);
    font-size: 0.72rem;
    color: rgba(244, 228, 193, 0.8);
}
.nature-stat-suggestion .stat-name {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--gold);
}
.nature-stat-suggestion .stat-cr {
    font-size: 0.66rem;
    color: rgba(244, 228, 193, 0.5);
    margin-left: 6px;
}
.nature-stat-suggestion .stat-note {
    display: block;
    font-size: 0.66rem;
    color: rgba(244, 228, 193, 0.45);
    font-style: italic;
    margin-top: 2px;
}
.nature-stat-suggestion .stat-view-btn {
    font-family: var(--font-body);
    font-size: 0.66rem;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(201, 169, 97, 0.3);
    background: rgba(201, 169, 97, 0.1);
    color: var(--gold);
    cursor: pointer;
    margin-left: 8px;
    transition: all var(--transition);
}
.nature-stat-suggestion .stat-view-btn:hover {
    background: rgba(201, 169, 97, 0.25);
}

/* Mythic escalation cards */
.nature-mythic-list {
    margin-top: 4px;
    padding-left: 8px;
    border-left: 2px solid rgba(171, 71, 188, 0.3);
}
.nature-mythic-item {
    font-size: 0.7rem;
    color: #ce93d8;
    padding: 2px 0;
}

/* Biome Calibration Panel */
.nature-biome-panel {
    padding: 8px 10px;
    border-radius: var(--radius);
    border: 1px solid rgba(100, 180, 80, 0.25);
    background: rgba(40, 80, 40, 0.12);
    margin-bottom: 8px;
}
.biome-detected {
    font-size: 0.75rem;
    color: rgba(244, 228, 193, 0.75);
    line-height: 1.4;
}
.biome-detected .biome-style-name {
    font-family: var(--font-heading);
    color: var(--gold);
    font-weight: 600;
}
.biome-detected .biome-confidence {
    font-size: 0.66rem;
    padding: 1px 6px;
    border-radius: 6px;
    margin-left: 4px;
}
.biome-confidence-high {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
}
.biome-confidence-medium {
    background: rgba(255, 179, 71, 0.2);
    color: #ffb347;
}
.biome-confidence-low {
    background: rgba(244, 67, 54, 0.15);
    color: #ef9a9a;
}

/* Wildflower Palette Swatches */
.nature-palette-swatches {
    display: flex;
    gap: 3px;
    margin-top: 4px;
}
.nature-palette-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Herbalism Table */
.nature-herbalism-section {
    border-top: 1px dashed rgba(201, 169, 97, 0.2);
    padding-top: 4px;
}
.nature-herbalism-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
}
.nature-herbalism-table th {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    color: var(--gold);
    text-align: left;
    padding: 4px 6px;
    border-bottom: 1px solid rgba(201, 169, 97, 0.25);
    white-space: nowrap;
}
.nature-herbalism-table td {
    padding: 3px 6px;
    color: rgba(244, 228, 193, 0.75);
    border-bottom: 1px solid rgba(201, 169, 97, 0.08);
    vertical-align: top;
}
.nature-herbalism-table tr:hover td {
    background: rgba(244, 228, 193, 0.04);
}
.herbalism-cat-medicinal { color: #4db6ac; }
.herbalism-cat-toxin { color: #ef5350; }
.herbalism-cat-fungi { color: #ab47bc; }
.herbalism-cat-hazard { color: #ffa726; }

/* Summary Bar */
.nature-summary {
    font-size: 0.72rem;
    color: rgba(244, 228, 193, 0.55);
    padding: 6px 0 2px;
    border-top: 1px dashed rgba(201, 169, 97, 0.15);
    margin-top: 6px;
    text-align: center;
}

/* Loading Indicator */
.nature-loading {
    text-align: center;
    padding: 16px;
    color: var(--gold-dim);
    font-style: italic;
    font-size: 0.78rem;
}
.nature-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(201, 169, 97, 0.3);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: nature-spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}
@keyframes nature-spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.nature-empty {
    text-align: center;
    padding: 12px;
    color: rgba(244, 228, 193, 0.4);
    font-size: 0.75rem;
    font-style: italic;
}

/* ============================================================
   ROYAL MENAGERIE & BEAST ENCLOSURES — Issue #62
   ============================================================ */

.menagerie-unleash-btn {
    background: linear-gradient(135deg, rgba(140, 30, 30, 0.5), rgba(100, 20, 20, 0.3));
    border: 1px solid rgba(220, 50, 50, 0.4);
    color: #fca5a5;
    transition: all var(--transition);
}
.menagerie-unleash-btn:hover {
    background: linear-gradient(135deg, rgba(180, 40, 40, 0.7), rgba(140, 30, 30, 0.5));
    border-color: rgba(239, 68, 68, 0.8);
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.35);
    color: #ffffff;
}
.menagerie-unleash-btn.active {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.8), rgba(185, 28, 28, 0.6));
    border-color: #f87171;
    color: #ffffff;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
    animation: menagerie-pulse 1.8s ease-in-out infinite;
}

@keyframes menagerie-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.8); }
}

.menagerie-roster-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 5px;
    border-radius: var(--radius);
    border: 1px solid rgba(201, 169, 97, 0.15);
    background: rgba(244, 228, 193, 0.04);
    transition: all var(--transition);
}
.menagerie-roster-item:hover {
    background: rgba(244, 228, 193, 0.08);
    border-color: rgba(201, 169, 97, 0.3);
}

.menagerie-badge-contained {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.35);
    color: #86efac;
}
.menagerie-badge-breached {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fca5a5;
    font-weight: 700;
}

/* Menagerie Beast On-Map Popup */
.menagerie-beast-leaflet-popup .leaflet-popup-content-wrapper {
    background: rgba(22, 16, 11, 0.95);
    border: 1px solid var(--gold);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.75), 0 0 12px rgba(201, 169, 97, 0.25);
    backdrop-filter: blur(8px);
    padding: 10px;
}
.menagerie-beast-leaflet-popup .leaflet-popup-tip {
    background: rgba(22, 16, 11, 0.95);
    border: 1px solid var(--gold);
}
.menagerie-beast-popup-card {
    display: flex;
    flex-direction: column;
    color: var(--parchment);
    font-family: 'Inter', sans-serif;
}

/* ==========================================================================
   About Modal Dialog & Data Sources Table
   ========================================================================== */
.about-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 12500;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'Book Antiqua', 'Palatino Linotype', 'Georgia', serif;
}

.about-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 8, 7, 0.85);
    backdrop-filter: blur(8px);
}

.about-modal-window {
    position: relative;
    width: 860px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 48px);
    background: #1a1410;
    border: 2px solid #c9a961;
    border-radius: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.95), 0 0 28px rgba(201, 169, 97, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}

.about-modal-header {
    background: linear-gradient(180deg, #2c1a12 0%, #1a120c 100%);
    border-bottom: 2px solid #c9a961;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.about-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.about-header-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px rgba(201, 169, 97, 0.6));
}

.about-header-titles {
    display: flex;
    flex-direction: column;
}

.about-main-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #ffd899;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    font-family: 'Cinzel', 'Times New Roman', serif;
}

.about-sub-title {
    font-size: 0.78rem;
    color: #c9a961;
    opacity: 0.9;
    margin-top: 2px;
    font-family: 'Lora', Georgia, serif;
}

.about-modal-close-icon {
    background: transparent;
    border: none;
    color: #c9a961;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.15s ease, color 0.15s ease;
}

.about-modal-close-icon:hover {
    color: #ff5544;
    transform: scale(1.15);
}

.about-modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    color: var(--parchment);
}

.about-hero-card {
    background: rgba(30, 20, 14, 0.85);
    border: 1px solid rgba(201, 169, 97, 0.35);
    border-radius: 6px;
    padding: 14px 18px;
    box-shadow: inset 0 0 16px rgba(0,0,0,0.5);
}

.about-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.92rem;
    flex-wrap: wrap;
}

.about-meta-row:last-child {
    margin-bottom: 0;
}

.about-meta-label {
    color: #c9a961;
    font-weight: 600;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    min-width: 90px;
}

.about-meta-value {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.about-link {
    color: #ffd899;
    text-decoration: none;
    border-bottom: 1px dashed #c9a961;
    transition: color 0.2s, border-color 0.2s;
    font-weight: 600;
}

.about-link:hover {
    color: #fff;
    border-bottom-style: solid;
}

.about-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: 'Cinzel', serif;
}

.about-badge.version-badge {
    background: linear-gradient(135deg, #7d5218 0%, #4a2e0a 100%);
    border: 1px solid #ffd700;
    color: #fff8e0;
}

.about-commit-wrap {
    font-size: 0.85rem;
    color: #a89270;
    margin-left: 8px;
}

.about-commit-code {
    background: #0d0a08;
    border: 1px solid #5a4228;
    padding: 2px 6px;
    border-radius: 4px;
    color: #73d0ff;
    font-family: monospace;
    font-size: 0.85rem;
    text-decoration: none;
    transition: border-color 0.2s;
}

.about-commit-code:hover {
    border-color: #73d0ff;
    text-decoration: underline;
}

.about-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.about-section-title {
    font-family: 'Cinzel', serif;
    font-size: 1.05rem;
    color: #ffd899;
    margin: 0;
    border-bottom: 1px solid rgba(201, 169, 97, 0.25);
    padding-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.about-section-subtitle {
    font-size: 0.82rem;
    color: #a89270;
    margin: 0 0 6px 0;
    font-style: italic;
}

.about-description {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.5;
    color: #e6dac6;
}

.about-table-container {
    overflow-x: auto;
    border: 1px solid rgba(201, 169, 97, 0.35);
    border-radius: 6px;
    background: #120d09;
    box-shadow: inset 0 0 12px rgba(0,0,0,0.6);
    max-height: 380px;
    overflow-y: auto;
}

.about-sources-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
    text-align: left;
}

.about-sources-table th {
    background: #25170f;
    color: #ffd899;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 2px solid #c9a961;
    position: sticky;
    top: 0;
    z-index: 2;
}

.about-sources-table td {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(201, 169, 97, 0.15);
    vertical-align: top;
    line-height: 1.42;
    color: #dcd0bf;
}

.about-sources-table tr:hover td {
    background: rgba(201, 169, 97, 0.08);
}

.about-sources-table .source-name {
    font-weight: 700;
    color: #ffd899;
    font-size: 0.86rem;
    margin-bottom: 2px;
}

.about-sources-table .source-provider {
    font-size: 0.72rem;
    color: #a89270;
}

.about-footer-note {
    text-align: center;
    font-size: 0.76rem;
    color: #8e785a;
    font-style: italic;
    border-top: 1px solid rgba(201, 169, 97, 0.2);
    padding-top: 12px;
    margin-top: 4px;
}


