/* ── Migration Map – Page Styles ──────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #f3efe4;
    --surface:      #fffdf7;
    --surface2:     #f6f1e6;
    --border:       #d8c9ad;
    --text:         #3a2f1f;
    --text-muted:   #7b6a4e;
    --accent:       #8b5e34;
    --accent-dim:   #6f4a29;
    --btn-bg:       #8b5e34;
    --btn-hover:    #6f4a29;
    --btn-sec:      #efe4d2;
    --btn-sec-hov:  #e1d2ba;
    --danger:       #e05050;

    /* Event colours */
    --c-birth:      #4ccd70;
    --c-marriage:   #f0c040;
    --c-death:      #e05050;
    --c-internment: #b07bd0;
    --c-military:   #4aadee;
    --c-home:       #9b7a52;
    --c-education:  #d8a126;
    --c-travel:     #2f88c5;
    --c-posting:    #3f6bd8;
    --c-war:        #c23a3a;
    --c-journey:    #00d4ff;
}

html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Segoe UI', Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Layout ──────────────────────────────────────────────────────────────── */

#mm-page { display: flex; flex-direction: column; height: 100vh; }

/* Geocode progress bar */
#mm-geocode-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
#mm-geocode-bar {
    width: 120px;
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
}
#mm-geocode-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width .3s ease;
    border-radius: 3px;
}

/* ── Main layout ──────────────────────────────────────────────────────────── */

#mm-layout { position: relative; flex: 1; overflow: hidden; }

#mm-sidebar {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 336px;
    min-width: 336px;
    max-width: 336px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.24);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1110;
    max-height: calc(100vh - 40px);
}

#mm-sidebar.collapsed {
    width: 336px;
    min-width: 336px;
    max-width: 336px;
}

#mm-sidebar.collapsed #mm-geocode-status,
#mm-sidebar.collapsed .mm-section {
    display: none;
}

#mm-map {
    width: 100%;
    height: 100%;
    background: #d9d2c4;
}

.mm-panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 12px 12px 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
}

.mm-panel-title-row:active {
    cursor: grabbing;
}

.mm-panel-title-text {
    margin: 0;
    color: var(--accent);
    font-size: 16px;
    font-family: 'Playfair Display', 'Palatino Linotype', serif;
    text-transform: none;
    letter-spacing: 0;
}

.mm-panel-title-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#mm-sidebar-toggle-btn {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 11px;
    min-width: 70px;
    margin: 0;
}

#mm-sidebar-close-btn {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 14px;
    line-height: 26px;
    min-width: 28px;
    border-radius: 6px;
    margin: 0;
}

.secondary {
    background: var(--btn-sec);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.secondary:hover {
    background: var(--btn-sec-hov);
    color: var(--text);
}

#mm-sidebar button {
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
}

#mm-geocode-status {
    margin: 10px 12px 0;
}

/* ── Sidebar sections ─────────────────────────────────────────────────────── */

.mm-section {
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
}

.mm-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Search input */
#mm-search {
    width: 100%;
    padding: 7px 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    margin-bottom: 8px;
}
#mm-search:focus { border-color: var(--accent); }

.mm-search-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

#mm-search-btn {
    flex: 1;
    padding: 7px 8px;
    background: var(--btn-bg);
    color: #fff;
    border: none;
    font-size: 12px;
    font-weight: 600;
    transition: background .15s;
}

#mm-search-btn:hover {
    background: var(--btn-hover);
}

#mm-search-status {
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-muted);
    min-height: 16px;
}

/* Event filters */
.mm-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    cursor: pointer;
    font-size: 13px;
}

.mm-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 10px;
}

.mm-filter-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.mm-filter-actions button {
    flex: 1;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 600;
    background: var(--btn-bg);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 6px;
}

.mm-filter-actions button.secondary {
    background: var(--btn-sec);
    color: var(--text);
    border-color: var(--border);
}

.mm-filter input[type="checkbox"] {
    width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer;
}

/* Coloured event type dots */
.mm-dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.mm-dot.birth      { background: var(--c-birth); }
.mm-dot.marriage   { background: var(--c-marriage); }
.mm-dot.death      { background: var(--c-death); }
.mm-dot.internment { background: var(--c-internment); }
.mm-dot.military   { background: var(--c-military); }
.mm-dot.home       { background: var(--c-home); }
.mm-dot.education  { background: var(--c-education); }
.mm-dot.travel     { background: var(--c-travel); }
.mm-dot.militaryPosting { background: var(--c-posting); }
.mm-dot.warService { background: var(--c-war); }

/* ── Journey panel ──────────────────────────────────────────────────────── */

.mm-journey-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.mm-collapse-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    padding: 2px 4px;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.18s ease;
    flex-shrink: 0;
}

.mm-collapse-toggle:hover {
    color: var(--accent);
}

.mm-collapse-toggle[aria-expanded="false"] {
    transform: rotate(-90deg);
}

#mm-journey-body.mm-journey-collapsed {
    display: none;
}

#mm-journey-name {
    font-size: 12px !important;
    color: var(--accent) !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-family: 'Playfair Display', serif;
    font-size: 15px !important;
    margin-bottom: 10px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mm-journey-events {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.mm-journey-event {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    line-height: 1.4;
}
.mm-journey-event .mm-dot {
    margin-top: 3px;
    flex-shrink: 0;
}
.mm-journey-event-info { color: var(--text); }
.mm-journey-event-info .date { color: var(--text-muted); font-size: 11px; }
.mm-journey-event-info .place { color: var(--text); }
.mm-journey-event-info .extra { color: var(--text-muted); font-style: italic; }
.mm-event-narrative {
    margin-top: 5px;
    font-size: 11px;
    color: var(--text);
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 4px 6px;
    line-height: 1.5;
    white-space: pre-wrap;
}
.mm-event-narrative-label {
    font-weight: 700;
    color: var(--accent, #c23a3a);
}

.mm-event-narrative-diary {
    color: #0d2150;
    border: 1px solid rgba(48, 94, 156, 0.28);
    background: linear-gradient(180deg, rgba(240, 247, 255, 0.92), rgba(230, 242, 255, 0.86));
    font-family: 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', cursive;
    font-size: 12px;
    line-height: 1.58;
}

.mm-event-narrative-diary .mm-event-narrative-label {
    color: #091840;
}

.mm-war-step-card {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 1400;
    background: linear-gradient(180deg, rgba(247, 241, 229, 0.98), rgba(241, 233, 218, 0.97));
    color: #4b3e2f;
    border: 3px solid #4f2f1c;
    border-radius: 12px;
    background-clip: padding-box;
    overflow: hidden;
    padding: 14px 24px;
    font-size: 13px;
    max-width: min(90vw, 680px);
    min-width: 340px;
    line-height: 1.5;
    box-shadow: 0 24px 46px rgba(51, 36, 20, 0.4), 0 10px 22px rgba(25, 18, 10, 0.26);
    backdrop-filter: blur(6px);
    pointer-events: none;
    display: none;
    text-align: center;
}

.mm-war-step-place {
    font-weight: 700;
    font-size: 28px;
    color: #4a3b2d;
    line-height: 1.2;
}

.mm-war-step-title {
    color: #6d5a45;
    margin-top: 7px;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.35;
}

.mm-war-step-meta {
    color: #8d7558;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.mm-war-step-text {
    margin-top: 10px;
    text-align: left;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(75, 62, 47, 0.15);
    border-radius: 6px;
    padding: 10px 12px;
    white-space: pre-wrap;
    font-size: 17.5px;
    color: #5e4c38;
}

.mm-war-step-label {
    font-weight: 700;
    color: #886c4f;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 11px;
}

.mm-war-step-section-title {
    margin-top: 8px;
    margin-bottom: 2px;
    text-align: left;
}

.mm-war-step-note {
    background: rgba(75, 62, 47, 0.04);
    border: 1px solid rgba(75, 62, 47, 0.16);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 16px;
    line-height: 1.58;
}

.mm-war-step-diary {
    color: #132f66;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    padding: 9px 11px;
    font-family: 'Segoe Script', 'Lucida Handwriting', 'Bradley Hand', 'Segoe Print', 'Snell Roundhand', cursive;
    font-size: 20px;
    letter-spacing: 0.01em;
    line-height: 1.65;
}

.mm-war-step-diary .mm-war-step-label {
    color: #0f2756;
}

.mm-journey-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mm-journey-primary-btns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.mm-journey-action-btn {
    width: 100%;
    padding: 7px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 2px 0 rgba(0,0,0,.18), 0 4px 10px rgba(0,0,0,.12);
    transition: background .15s, box-shadow .15s, transform .08s;
}

#mm-storyboard-open-btn {
    width: min(72%, 220px);
    display: block;
    margin: 8px auto 0;
}

#mm-diary-layout-open-btn {
    width: min(72%, 220px);
    display: block;
    margin: 8px auto 0;
}

#mm-animate-btn,
#mm-war-service-btn {
    background: linear-gradient(180deg, #9a6b3d 0%, var(--btn-bg) 100%);
    color: #fff;
    border-color: #6f4a29;
}
#mm-animate-btn:hover,
#mm-war-service-btn:hover {
    background: linear-gradient(180deg, #885b32 0%, var(--btn-hover) 100%);
}
#mm-animate-btn:disabled,
#mm-war-service-btn:disabled {
    opacity: .5;
    cursor: default;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 0 rgba(0,0,0,.14);
}

#mm-clear-btn {
    background: linear-gradient(180deg, #f6ecdd 0%, var(--btn-sec) 100%);
    color: var(--text-muted);
    border-color: var(--border);
}
#mm-clear-btn:hover { background: linear-gradient(180deg, #f0e2cd 0%, var(--btn-sec-hov) 100%); color: var(--text); }

.mm-journey-action-btn:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 0 rgba(0,0,0,.16), 0 2px 6px rgba(0,0,0,.14);
}

#mm-war-story-mode-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}

#mm-war-story-mode-row label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
}

#mm-war-story-mode {
    min-width: 138px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 6px 8px;
    font-size: 12px;
}

/* Stats footer */
#mm-footer-section {
    margin-top: auto;
}

#mm-stats {
    padding: 0;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 10px;
}

#mm-back-btn {
    width: 100%;
    background: var(--btn-sec);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s;
}

#mm-back-btn:hover {
    background: var(--btn-sec-hov);
}

/* ── Loading overlay ─────────────────────────────────────────────────────── */

#mm-loading-overlay {
    position: fixed; inset: 0;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    z-index: 9998;
    transition: opacity .3s ease;
}
#mm-loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}
#mm-loading-overlay.hidden { display: none; }

#mm-loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    color: var(--text-muted);
    font-size: 14px;
}

.mm-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: mmSpin .8s linear infinite;
}
@keyframes mmSpin { to { transform: rotate(360deg); } }

/* ── Auth overlay ─────────────────────────────────────────────────────────── */

#mm-auth-overlay {
    position: fixed; inset: 0;
    background: rgba(10,12,20,.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
#mm-auth-overlay.hidden { display: none; }
#mm-auth-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 30px 36px;
    text-align: center;
    max-width: 320px;
}
#mm-auth-box p { margin-bottom: 16px; color: var(--text); }
#mm-auth-box button {
    background: var(--btn-bg);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 9px 20px;
    cursor: pointer;
    font-size: 14px;
}
#mm-auth-box button:hover { background: var(--btn-hover); }

/* ── Leaflet popup overrides ──────────────────────────────────────────────── */

.leaflet-popup-content-wrapper {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.leaflet-popup-tip { background: var(--surface2); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.5; }
.mm-popup-name { font-weight: 700; font-size: 14px; color: var(--accent); margin-bottom: 4px; }
.mm-popup-type { font-size: 12px; color: var(--text-muted); text-transform: capitalize; margin-bottom: 2px; }
.mm-popup-date { font-size: 12px; color: var(--text-muted); }
.mm-popup-place { font-size: 12px; color: var(--text); }
.mm-popup-extra { font-size: 11px; color: var(--text-muted); font-style: italic; margin-top: 2px; }
.mm-popup-journey-link {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 10px;
    background: var(--btn-bg);
    color: #fff;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    border: none;
}
.mm-popup-journey-link:hover { background: var(--btn-hover); }

/* Marker cluster override – dark theme */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
    background-color: rgba(139, 94, 52, 0.28) !important;
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
    background-color: rgba(139, 94, 52, 0.78) !important;
    color: #ffffff !important;
    font-weight: 600;
    font-size: 12px;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    #mm-sidebar {
        top: 12px;
        right: 12px;
        width: 254px;
        min-width: 254px;
        max-width: 254px;
        max-height: calc(100vh - 24px);
    }

    #mm-sidebar.collapsed {
        width: 254px;
        min-width: 254px;
        max-width: 254px;
    }
}
@media (max-width: 480px) {
    #mm-sidebar {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        min-width: 0;
        max-width: none;
        max-height: calc(100vh - 20px);
    }

    #mm-sidebar.collapsed {
        left: 10px;
        right: 10px;
        width: auto;
        min-width: 0;
        max-width: none;
    }
}

/* ── Year range filter ───────────────────────────────────────────────────── */

.mm-year-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.mm-year-filter label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
}
.mm-year-filter input {
    width: 68px;
    padding: 5px 7px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-size: 12px;
}
.mm-year-filter input:focus { border-color: var(--accent); outline: none; }

#mm-war-pause-btn {
    margin-top: 6px;
}

#mm-war-playback-controls {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 10px;
    z-index: 9601;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(6px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
}

#mm-war-playback-controls.hidden {
    display: none;
}

#mm-playback-block-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 12, 20, 0.72);
    padding: 18px;
}

#mm-playback-block-modal.hidden {
    display: none;
}

.mm-playback-block-modal-box {
    width: min(520px, 96vw);
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.mm-playback-block-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
    font-size: 16px;
    font-weight: 700;
}

#mm-playback-block-close {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--btn-sec);
    color: var(--text);
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 15px;
}

#mm-playback-block-close:hover {
    background: var(--btn-sec-hov);
}

.mm-playback-block-modal-body {
    padding: 14px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

.mm-playback-block-modal-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 14px 14px;
}

#mm-playback-block-ok {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--btn-bg);
    color: #fff;
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
}

#mm-playback-block-ok:hover {
    background: var(--btn-hover);
}

#mm-war-playback-toggle,
#mm-war-playback-stop {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.94);
    color: #222;
    font-family: "Segoe UI Symbol", "Segoe UI", Arial, sans-serif;
    font-size: 20px;
    line-height: 1;
    font-weight: 700;
    width: 40px;
    height: 40px;
    cursor: pointer;
}

#mm-war-playback-toggle:hover,
#mm-war-playback-stop:hover {
    background: #fff;
}

#mm-war-playback-times {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: 48px 1fr 48px 56px;
    align-items: center;
    gap: 8px;
    color: #0f1115;
    font-size: 12px;
    font-weight: 700;
}

#mm-war-playback-progress {
    width: 100%;
    accent-color: #8b1a1a;
}

#mm-war-playback-music-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

#mm-war-playback-music-toggle,
#mm-war-playback-music-track {
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.94);
    color: #222;
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

#mm-war-playback-music-toggle:hover,
#mm-war-playback-music-track:hover {
    background: #fff;
}

#mm-war-playback-music-controls label,
#mm-war-playback-music-label {
    font-size: 12px;
    font-weight: 700;
    color: #0f1115;
}

#mm-war-playback-music-volume {
    width: 110px;
    accent-color: #6a7f2b;
}

#mm-sidebar.mm-playback-hidden {
    display: none !important;
}

@media (max-width: 700px) {
    #mm-war-playback-controls {
        left: 10px;
        right: 10px;
        bottom: 8px;
        padding: 8px 10px;
        gap: 8px;
    }

    #mm-war-playback-times {
        grid-template-columns: 42px 1fr 42px 48px;
        gap: 6px;
        font-size: 11px;
    }

    #mm-war-playback-music-controls {
        gap: 6px;
    }

    #mm-war-playback-music-toggle,
    #mm-war-playback-music-track {
        height: 28px;
        padding: 0 8px;
        font-size: 11px;
    }

    #mm-war-playback-music-volume {
        width: 86px;
    }

    #mm-war-playback-music-controls label,
    #mm-war-playback-music-label {
        font-size: 11px;
    }
}

#mm-war-route-controls {
    margin-top: 8px;
    padding: 8px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface2);
}

.mm-war-route-title {
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.mm-war-route-opt {
    display: block;
    font-size: 12px;
    color: var(--text);
    margin: 3px 0;
}

#mm-war-route-build-btn {
    background: #1f5f46;
    color: #f5f7f8;
}

#mm-war-route-build-btn:hover {
    background: #174b37;
}

#mm-war-route-status {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}

#mm-war-route-clear-btn {
    margin-top: 6px;
    width: 100%;
}

#mm-admin-overlay-toggle {
    margin-top: 6px;
    width: 100%;
    font-weight: 700;
}

#mm-admin-tools {
    margin-top: 8px;
    padding: 8px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface2);
}

#mm-admin-tools h4 {
    font-size: 11px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 6px;
}

.mm-admin-group {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

.mm-admin-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.mm-admin-grid2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-top: 6px;
}

#mm-admin-tools input,
#mm-admin-tools select {
    width: 100%;
    margin-top: 2px;
    padding: 5px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
    font-size: 12px;
}

#mm-admin-tools button {
    font-size: 11px;
    padding: 7px 6px;
}

#mm-admin-timeline {
    margin-top: 8px;
    max-height: 165px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
}

.mm-admin-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.mm-admin-entry:last-child {
    border-bottom: none;
}

.mm-admin-entry.selected {
    background: rgba(139, 94, 52, 0.12);
}

.mm-admin-entry-main {
    min-width: 0;
}

.mm-admin-entry-title {
    font-size: 11px;
    color: var(--text);
    font-weight: 700;
}

.mm-admin-entry-meta {
    font-size: 10px;
    color: var(--text-muted);
}

.mm-admin-entry-load {
    flex: 0 0 auto;
    min-width: 56px;
}

.mm-admin-empty {
    font-size: 11px;
    color: var(--text-muted);
    padding: 8px;
}

#mm-admin-script {
    width: 100%;
    margin-top: 6px;
    padding: 7px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #101620;
    color: #d5dde8;
    font-size: 11px;
    line-height: 1.4;
    resize: vertical;
    min-height: 100px;
}

#mm-admin-status {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}

#mm-admin-grid-overlay {
    position: absolute;
    inset: 0;
    z-index: 520;
    pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(255, 223, 156, 0.34) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 223, 156, 0.34) 1px, transparent 1px),
        linear-gradient(to right, rgba(92, 164, 230, 0.22) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(92, 164, 230, 0.22) 1px, transparent 1px);
    background-size: 64px 64px;
    background-position: 0 0, 0 0, 32px 32px, 32px 32px;
}

#mm-admin-hud {
    position: absolute;
    z-index: 530;
    left: 16px;
    bottom: 16px;
    min-width: 250px;
    max-width: 360px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(8, 12, 20, 0.8);
    color: #dbe7f6;
    font-size: 11px;
    line-height: 1.45;
    letter-spacing: .01em;
    pointer-events: none;
    white-space: pre-line;
}

#mm-storyboard-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    pointer-events: none;
}

#mm-storyboard-modal.hidden {
    display: none;
}

#mm-sb-dock-modal {
    position: fixed;
    inset: 0;
    z-index: 2800;
    display: block;
    pointer-events: none;
}

#mm-sb-dock-modal.hidden {
    display: none;
}

#mm-sb-dock-box {
    position: fixed;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: min(860px, calc(100vw - 200px));
    max-width: calc(100vw - 16px);
    min-width: 400px;
    height: min(34vh, 320px);
    max-height: 86vh;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    background: color-mix(in srgb, var(--surface) 90%, #000 10%);
    padding: 5px 6px 6px;
    pointer-events: auto;
}

#mm-sb-dock-header {
    margin-bottom: 3px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

#mm-sb-dock-header-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

#mm-sb-dock-drag-handle {
    font-size: 14px;
    color: var(--text-muted);
    cursor: grab;
    user-select: none;
    touch-action: none;
    letter-spacing: -2px;
    flex: 0 0 auto;
    padding: 0 4px;
}

#mm-sb-dock-drag-handle:hover {
    color: var(--accent);
}

#mm-sb-dock-drag-handle:active {
    cursor: grabbing;
}

#mm-sb-dock-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    flex: 1 1 auto;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

#mm-sb-dock-scale-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
}

.mm-sb-dock-ctrl-label {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

#mm-sb-dock-scale {
    width: 84px;
    cursor: pointer;
    accent-color: var(--accent);
}

#mm-sb-snap-ms {
    height: 24px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--btn-sec);
    color: var(--text);
    font-size: 11px;
    padding: 0 4px;
}

#mm-sb-dock-scale-val {
    font-size: 11px;
    color: var(--text-muted);
    width: 32px;
    text-align: right;
}

#mm-sb-dock-infobar {
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 16px;
}

#mm-sb-dock-total {
    font-weight: 600;
    color: var(--text);
}

#mm-sb-dock-sel-info {
    color: var(--text-muted);
}

#mm-sb-dock-save-info {
    color: var(--text-muted);
    font-weight: 600;
}

/* ── Layout Preview Mode ─────────────────────────────────────────────────── */
#mm-sb-layout-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    padding: 4px 6px 2px;
    border-top: 1px solid var(--border);
    font-size: 11px;
}

#mm-sb-layout-row input[type="number"] {
    width: 80px;
    font-size: 11px;
    padding: 1px 4px;
}

/* Ghost wrapper — absolute in #mm-layout, draggable */
.mm-sb-layout-ghost {
    position: absolute;
    z-index: 2500;
    cursor: grab;
    touch-action: none;
    user-select: none;
    outline: none;
    border-radius: 6px;
    box-shadow: none;
    overflow: visible;
}

.mm-sb-layout-ghost:hover {
    outline: none;
    box-shadow: none;
}

.mm-sb-layout-ghost.mm-sb-layout-dragging {
    cursor: grabbing;
    z-index: 2600;
    outline: 3px solid #f5c842;
    box-shadow: 0 8px 30px rgba(0,0,0,.55);
}

/* Handle label — sits above the ghost, shows type + time range */
.mm-sb-layout-handle {
    position: absolute;
    top: -22px;
    left: 0;
    background: var(--accent, #e87c1e);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px 4px 0 0;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    letter-spacing: 0.03em;
}

/* Inner content must not steal pointer events during a drag */
.mm-sb-layout-ghost > :not(.mm-sb-layout-handle) {
    pointer-events: none;
    position: static !important;
    display: block;
}

/* Keep inner card/town/image in normal flow inside wrapper */
.mm-sb-layout-ghost .mm-war-step-card,
.mm-sb-layout-ghost .mm-town-label-card,
.mm-sb-layout-ghost .mm-sb-image-overlay {
    position: static;
    display: block;
    opacity: 1;
}

/* Active state: highlight dock border */
body.mm-layout-mode-active #mm-sb-dock-modal {
    outline: 3px solid var(--accent, #e87c1e);
    outline-offset: 2px;
}
/* ────────────────────────────────────────────────────────────────────────── */

.mm-sb-dock-info-sep {
    color: var(--border);
    user-select: none;
}

#mm-sb-dock-close {
    border: 1px solid var(--border);
    background: var(--btn-sec);
    color: var(--text);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
}

#mm-sb-dock-resize-handle {
    position: absolute;
    right: 2px;
    top: 36px;
    bottom: 22px;
    width: 9px;
    cursor: ew-resize;
    touch-action: none;
    user-select: none;
    border-right: 2px dotted rgba(0, 0, 0, 0.18);
    opacity: 0.55;
}

#mm-sb-dock-resize-handle:hover {
    opacity: 0.9;
    border-right-color: color-mix(in srgb, var(--accent) 45%, #000 55%);
}

#mm-sb-dock-resize-bottom {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 2px;
    width: 120px;
    height: 12px;
    cursor: ns-resize;
    touch-action: none;
    user-select: none;
    border-bottom: 2px dotted rgba(0, 0, 0, 0.18);
    border-radius: 6px;
    opacity: 0.55;
}

#mm-sb-dock-resize-bottom:hover {
    opacity: 0.9;
    border-bottom-color: color-mix(in srgb, var(--accent) 45%, #000 55%);
}

#mm-sb-graphic-dock {
    flex: 1 1 auto;
    min-height: 92px;
}

#mm-storyboard-modal-box {
    width: fit-content;
    max-width: calc(100vw - 36px);
    max-height: 92vh;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    padding: 12px;
    pointer-events: auto;
}

#mm-storyboard-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 7px;
    cursor: move;
    user-select: none;
}

#mm-storyboard-modal-title {
    font-size: 16px;
    color: var(--accent);
    font-weight: 700;
}

.mm-storyboard-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

#mm-storyboard-modal-hide,
#mm-storyboard-modal-close {
    height: 30px;
    border-radius: 6px;
}

#mm-storyboard-modal-hide {
    padding: 2px 10px;
    height: 30px;
    font-size: 13px;
}

#mm-storyboard-modal-close {
    width: 30px;
    padding: 0;
}

#mm-storyboard-modal-box.mm-minimized {
    width: 320px;
    max-width: min(320px, calc(100vw - 20px));
    max-height: 58px;
    overflow: hidden;
    padding: 8px 10px;
}

#mm-storyboard-modal-box.mm-minimized > :not(#mm-storyboard-modal-header) {
    display: none !important;
}

#mm-storyboard-modal-box.mm-minimized #mm-storyboard-modal-header {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

#mm-storyboard-runtime {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

#mm-sb-track-tabs {
    display: grid;
    grid-template-columns: repeat(4, max-content);
    gap: 4px 6px;
    margin-bottom: 8px;
}

.mm-sb-track-tab {
    border: 1px solid var(--border);
    background: var(--btn-sec);
    color: var(--text);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.mm-sb-track-tab.active {
    background: var(--btn-bg);
    border-color: transparent;
    color: #fff;
}

.mm-storyboard-grid {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: fit-content;
}

.mm-sb-track-panel.hidden {
    display: none;
}

.mm-storyboard-panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    padding: 8px;
    width: 100%;
    min-width: 0;
    max-width: 360px;
}

.mm-storyboard-panel h4 {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 6px;
}

.mm-storyboard-panel label {
    display: block;
    font-size: 12px;
    color: var(--text);
    width: fit-content;
    max-width: 100%;
}

.mm-storyboard-panel input,
.mm-storyboard-panel select {
    width: auto;
    min-width: 90px;
    max-width: 210px;
    margin-top: 2px;
    margin-bottom: 6px;
    padding: 5px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text);
}

.mm-storyboard-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 6px;
    margin-bottom: 6px;
    width: 100%;
}

.mm-storyboard-row label {
    flex: 0 0 auto;
}

#mm-sb-route-from,
#mm-sb-route-to {
    width: 150px;
}

#mm-sb-route-speed {
    width: 120px;
}

#mm-sb-route-speed-val {
    display: inline-block;
    min-width: 44px;
    align-self: end;
    font-size: 12px;
    color: var(--text-muted);
}

#mm-sb-zoom-center-mode,
#mm-sb-zoom-center-step,
#mm-sb-town-step {
    min-width: 160px;
}

.mm-storyboard-panel button {
    width: auto;
    margin-bottom: 6px;
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: var(--btn-bg);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.mm-storyboard-panel .mm-storyboard-row > button {
    flex: 0 0 auto;
}

#mm-sb-card-start,
#mm-sb-card-end,
#mm-sb-route-start,
#mm-sb-zoom-start,
#mm-sb-next-start {
    max-width: 65px;
}

#mm-sb-card-x,
#mm-sb-card-y,
#mm-sb-zoom-value,
#mm-sb-town-x,
#mm-sb-town-y {
    max-width: 86px;
}

#mm-sb-zoom-arc-number,
#mm-sb-zoom-arc-start,
#mm-sb-zoom-arc-end,
#mm-sb-zoom-arc-granularity,
#mm-sb-zoom-arc-from,
#mm-sb-zoom-arc-to {
    max-width: 96px;
}

#mm-sb-zoom-arc-center-mode {
    min-width: 180px;
}

#mm-sb-zoom-arc-centre-val {
    align-self: end;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

#mm-sb-card-fade-in,
#mm-sb-card-fade-out,
#mm-sb-town-fade-in,
#mm-sb-town-fade-out,
#mm-sb-image-fade-in,
#mm-sb-image-fade-out {
    max-width: 86px;
}

#mm-sb-town-start,
#mm-sb-town-end {
    max-width: 110px;
}

#mm-sb-card-step,
#mm-sb-route-from,
#mm-sb-route-to,
#mm-sb-town-step,
#mm-sb-zoom-center-step,
#mm-sb-zoom-from-step,
#mm-sb-zoom-to-step {
    min-width: 210px;
    max-width: 300px;
}

#mm-sb-timeline {
    width: 100%;
}

.mm-sb-graphic-target {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    margin-bottom: 0;
    overflow: hidden;
}

.mm-sbg-empty {
    font-size: 11px;
    color: var(--text-muted);
    padding: 8px;
}

.mm-sbg-scroll {
    width: 100%;
    overflow-x: scroll;
    overflow-y: hidden;
    padding-bottom: 0;
    scrollbar-gutter: stable both-edges;
}

#mm-sb-graphic-dock .mm-sbg-scroll {
    height: 100%;
    max-height: none;
    overflow-y: auto;
}

.mm-sbg-ruler {
    position: relative;
    height: 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.02));
}

.mm-sbg-ruler-tick {
    position: absolute;
    bottom: 0;
    width: 1px;
    background: rgba(0, 0, 0, 0.24);
}

.mm-sbg-ruler-tick.minor {
    height: 6px;
}

.mm-sbg-ruler-tick.major {
    height: 11px;
    background: rgba(0, 0, 0, 0.38);
}

.mm-sbg-ruler-label {
    position: absolute;
    top: 2px;
    transform: translateX(4px);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.mm-sbg-track-row {
    display: flex;
    align-items: stretch;
    min-height: 28px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.mm-sbg-track-row.collapsed {
    min-height: 20px;
}

.mm-sbg-track-row:last-child {
    border-bottom: none;
}

.mm-sbg-start-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px solid rgba(183, 62, 28, 0.92);
    pointer-events: none;
    z-index: 3;
}

.mm-sbg-stop-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px dashed rgba(195, 158, 20, 0.92);
    pointer-events: none;
    z-index: 3;
}

.mm-sbg-tag-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px solid rgba(187, 22, 37, 0.96);
    pointer-events: none;
    z-index: 3;
}

.mm-sbg-stop-marker-ruler {
    bottom: auto;
    height: 100%;
    pointer-events: auto;
}

.mm-sbg-stop-marker-lane {
    opacity: 0.8;
}

.mm-sbg-tag-marker-ruler {
    bottom: auto;
    height: 100%;
    pointer-events: auto;
}

.mm-sbg-tag-marker-lane {
    opacity: 0.9;
}

.mm-sbg-tag-handle {
    position: absolute;
    top: 2px;
    left: -6px;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: #bb1625;
    border: 2px solid rgba(255, 239, 241, 0.96);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    cursor: ew-resize;
}

.mm-sbg-tag-label {
    position: absolute;
    top: 0;
    left: 8px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(255, 239, 241, 0.98);
    border: 1px solid rgba(150, 18, 30, 0.45);
    color: #8e1820;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.mm-sbg-stop-handle {
    position: absolute;
    top: 2px;
    left: -6px;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: #c49e14;
    border: 2px solid rgba(255, 248, 230, 0.95);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
    cursor: ew-resize;
}

.mm-sbg-stop-label {
    position: absolute;
    top: 0;
    right: 8px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(255, 248, 230, 0.96);
    border: 1px solid rgba(128, 100, 20, 0.35);
    color: #7a5c10;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.mm-sbg-start-marker-ruler {
    bottom: auto;
    height: 100%;
    pointer-events: auto;
}

.mm-sbg-start-marker-lane {
    opacity: 0.8;
}

.mm-sbg-start-handle {
    position: absolute;
    top: 2px;
    left: -6px;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #b73e1c;
    border: 2px solid rgba(255, 248, 230, 0.95);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
    cursor: ew-resize;
}

.mm-sbg-start-label {
    position: absolute;
    top: 0;
    left: 8px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(255, 248, 230, 0.96);
    border: 1px solid rgba(128, 76, 36, 0.35);
    color: #6f4a29;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.mm-sbg-track-label {
    width: 88px;
    flex: 0 0 88px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.03);
    padding: 6px;
}

.mm-sbg-track-toggle {
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    padding: 0;
    cursor: pointer;
}

.mm-sbg-track-toggle:hover {
    color: #5c3f26;
}

.mm-sbg-lane {
    position: relative;
    height: 28px;
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(0, 0, 0, 0.06) 0,
            rgba(0, 0, 0, 0.06) 1px,
            transparent 1px,
            transparent var(--mm-sbg-minor-step, 32px)
        ),
        repeating-linear-gradient(
            to right,
            rgba(0, 0, 0, 0.12) 0,
            rgba(0, 0, 0, 0.12) 1px,
            transparent 1px,
            transparent var(--mm-sbg-major-step, 64px)
        );
}

.mm-sbg-bar {
    position: absolute;
    top: 5px;
    height: 18px;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    padding: 0 28px 0 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    color: #fff;
    background: #6f7b86;
    touch-action: none;
}

.mm-sbg-fade-region {
    position: absolute;
    top: 0;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.mm-sbg-fade-region-left {
    left: 0;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.08));
}

.mm-sbg-fade-region-right {
    right: 0;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.08));
}

.mm-sbg-fade-handle {
    position: absolute;
    top: 1px;
    width: 8px;
    height: calc(100% - 2px);
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(0, 0, 0, 0.22);
    opacity: 0;
    transition: opacity 120ms ease;
    z-index: 2;
}

.mm-sbg-fade-handle-left {
    cursor: ew-resize;
}

.mm-sbg-fade-handle-right {
    cursor: ew-resize;
}

.mm-sbg-bar:hover .mm-sbg-fade-handle,
.mm-sbg-bar.selected .mm-sbg-fade-handle {
    opacity: 1;
}

.mm-sbg-bar:hover {
    filter: brightness(1.06);
}

.mm-sbg-bar.selected {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 0 4px rgba(0, 0, 0, 0.45);
    z-index: 2;
}

.mm-sbg-handle {
    position: absolute;
    top: 0;
    width: 8px;
    height: 100%;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 120ms ease;
}

.mm-sbg-bar:hover .mm-sbg-handle,
.mm-sbg-bar.selected .mm-sbg-handle {
    opacity: 1;
}

.mm-sbg-handle-left {
    left: 1px;
    cursor: ew-resize;
}

.mm-sbg-handle-right {
    right: 1px;
    cursor: ew-resize;
}

.mm-sbg-delete-btn {
    position: absolute;
    top: 1px;
    right: 10px;
    width: 14px;
    height: 14px;
    line-height: 12px;
    text-align: center;
    font-size: 11px;
    font-weight: 900;
    color: #fff;
    background: rgba(124, 24, 24, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 999px;
    cursor: pointer;
    opacity: 0;
    z-index: 4;
}

.mm-sbg-bar:hover .mm-sbg-delete-btn,
.mm-sbg-bar.selected .mm-sbg-delete-btn {
    opacity: 1;
}

.mm-sbg-bar-type-zoom { background: #4d86d8; }
.mm-sbg-bar-type-route { background: #c23a3a; }
.mm-sbg-bar-type-card { background: #f2a43d; color: #2f1d05; }
.mm-sbg-bar-type-context { background: #4f7d95; }
.mm-sbg-bar-type-nextLocation { background: #8f6bd1; }
.mm-sbg-bar-type-town { background: #2f9e7b; }
.mm-sbg-bar-type-image { background: #7b8c3a; }
.mm-sbg-bar-type-intro { background: #8c6133; }
.mm-sbg-bar-type-epilogue { background: #5a4f8f; }

.mm-storyboard-panel button.secondary {
    background: var(--btn-sec);
    color: var(--text);
    border-color: var(--border);
}

#mm-sb-dock-save,
#mm-sb-play-from,
#mm-sb-start-reset,
#mm-sb-move-to-tag-toggle {
    margin-left: 4px;
}

#mm-sb-list-mode {
    min-width: 150px;
}

#mm-sb-timeline {
    max-height: 220px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    margin-bottom: 6px;
}

.mm-sb-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 6px 6px 8px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    border-left: 4px solid rgba(120, 120, 120, 0.5);
    cursor: pointer;
}

.mm-sb-row:last-child {
    border-bottom: none;
}

.mm-sb-row.selected {
    background: rgba(139, 94, 52, 0.14);
}

.mm-sb-row-type-zoom { border-left-color: #4d86d8; }
.mm-sb-row-type-route { border-left-color: #c23a3a; }
.mm-sb-row-type-card { border-left-color: #f2a43d; }
.mm-sb-row-type-context { border-left-color: #4f7d95; }
.mm-sb-row-type-town { border-left-color: #2f9e7b; }
.mm-sb-row-type-nextLocation { border-left-color: #8f6bd1; }
.mm-sb-row-type-image { border-left-color: #7b8c3a; }
.mm-sb-row-type-intro { border-left-color: #8c6133; }
.mm-sb-row-type-epilogue { border-left-color: #5a4f8f; }

.mm-sb-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.mm-sb-type-pill {
    display: inline-block;
    font-size: 10px;
    letter-spacing: .03em;
    font-weight: 700;
    color: #fff;
    background: #6f7b86;
    border-radius: 999px;
    padding: 2px 6px;
}

.mm-sb-row-type-zoom .mm-sb-type-pill { background: #4d86d8; }
.mm-sb-row-type-route .mm-sb-type-pill { background: #c23a3a; }
.mm-sb-row-type-card .mm-sb-type-pill { background: #f2a43d; color: #2f1d05; }
.mm-sb-row-type-context .mm-sb-type-pill { background: #4f7d95; }
.mm-sb-row-type-town .mm-sb-type-pill { background: #2f9e7b; }
.mm-sb-row-type-nextLocation .mm-sb-type-pill { background: #8f6bd1; }
.mm-sb-row-type-image .mm-sb-type-pill { background: #7b8c3a; }
.mm-sb-row-type-intro .mm-sb-type-pill { background: #8c6133; }
.mm-sb-row-type-epilogue .mm-sb-type-pill { background: #5a4f8f; }

/* Image overlay rendered over the map during playback / preview */
.mm-sb-image-overlay {
    position: absolute;
    z-index: 1150;
    display: none;
}

.mm-sb-image-card {
    background: linear-gradient(180deg, rgba(247, 241, 229, 0.98), rgba(241, 233, 218, 0.97));
    border: 2px solid #5a3822;
    border-radius: 10px;
    color: #4b3e2f;
    box-shadow: 0 16px 30px rgba(66, 50, 31, 0.34);
    backdrop-filter: blur(4px);
    padding: 8px;
    overflow: hidden;
}

.mm-sb-image-frame {
    background: #f7f5ee;
    border: none;
    border-radius: 8px;
    overflow: hidden;
}

.mm-sb-image-photo {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 0;
}

.mm-sb-image-frame-error {
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3ece7;
}

.mm-sb-image-error {
    font-size: 12px;
    font-weight: 700;
    color: #7c2525;
    letter-spacing: .02em;
    padding: 8px;
}

.mm-sb-image-overlay-caption {
    margin-top: 5px;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 700;
    color: #5e4c38;
    background: rgba(255, 248, 230, 0.86);
    border: 1px solid rgba(145, 124, 97, 0.32);
    border-radius: 8px;
    text-align: left;
}

.mm-sb-image-thumb-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.mm-sb-meta {
    font-size: 11px;
    color: var(--text-muted);
}

#mm-sb-status {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

#mm-sb-route-estimate {
    margin-top: 2px;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.mm-town-label-card {
    position: absolute;
    display: none;
    pointer-events: none;
    z-index: 1400;
    background: linear-gradient(180deg, #fafaf6 0%, #f1f1ea 100%);
    border: 2px solid #101010;
    border-radius: 5px;
    color: #101010;
    box-shadow: inset 0 0 0 1px rgba(16, 16, 16, 0.95), 0 8px 24px rgba(8, 10, 14, 0.46);
    backdrop-filter: blur(4px);
    padding: 6px 12px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    font-family: 'Franklin Gothic Medium', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.1;
    white-space: nowrap;
}

@media (max-width: 1600px) {
    .mm-war-step-card {
        max-width: min(94vw, 760px);
        min-width: min(520px, 70vw);
        padding: 16px 22px;
    }

    .mm-war-step-place {
        font-size: 30px;
    }

    .mm-town-label-card {
        font-size: 17px;
        padding: 7px 13px;
    }
}

@media (max-width: 1366px) {
    .mm-war-step-card {
        min-width: min(460px, 74vw);
        max-width: min(96vw, 800px);
        padding: 14px 18px;
    }

    .mm-war-step-place {
        font-size: 26px;
    }

    .mm-war-step-text {
        font-size: 16px;
    }

    .mm-town-label-card {
        font-size: 15px;
        letter-spacing: 0.09em;
    }
}

/* ── Search chooser ──────────────────────────────────────────────────────── */

#mm-search-chooser {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mm-chooser-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text);
    background: var(--surface2);
    border: 1px solid var(--border);
    text-align: left;
    transition: background .12s;
}

.mm-chooser-item:hover,
.mm-chooser-item:focus {
    background: var(--btn-bg);
    color: #fff;
    border-color: var(--accent-dim);
    outline: none;
}

.mm-chooser-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mm-chooser-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mm-chooser-meta {
    font-size: 11px;
    opacity: .72;
    flex-shrink: 0;
}

#mm-chooser-overflow {
    font-size: 11px;
    color: var(--text-muted);
    padding: 3px 2px;
    font-style: italic;
    text-align: center;
}

/* ── Journey summary in sidebar ──────────────────────────────────────────── */

#mm-journey-summary {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    line-height: 1.4;
}

#mm-journey-details-btn {
    width: 100%;
    background: var(--btn-sec);
    color: var(--text);
    border: 1px solid var(--border);
    margin-bottom: 0;
    transition: background .15s;
}

#mm-journey-details-btn:hover {
    background: var(--btn-sec-hov);
}

/* ── Journey detail modal ─────────────────────────────────────────────────── */

#mm-journey-modal {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1200;
}

#mm-journey-modal.hidden {
    display: none;
}

#mm-journey-modal-box {
    position: absolute;
    top: 50%;
    left: 24px;
    transform: translateY(-50%);
    pointer-events: all;
    width: 280px;
    max-height: min(75vh, 540px);
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,.32);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#mm-journey-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#mm-journey-modal-title {
    font-family: 'Playfair Display', 'Palatino Linotype', serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#mm-journey-modal-close {
    background: var(--btn-sec);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
}

#mm-journey-modal-close:hover {
    background: var(--btn-sec-hov);
    color: var(--text);
}

#mm-journey-modal-events {
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (max-width: 640px) {
    #mm-journey-modal-box {
        left: 12px;
        width: calc(100vw - 48px);
        max-width: 320px;
    }
}

/* ── Long-jump emphasis label ────────────────────────────────────────────── */

.mm-longjump-label {
    background: rgba(15,12,8,.82) !important;
    border: 1px solid #f5a623 !important;
    color: #f5a623 !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    white-space: nowrap !important;
    pointer-events: none !important;
}
