:root {
    color-scheme: dark;
    --bg: #0b0f14;
    --glass: rgba(18, 24, 33, 0.72);
    --glass-strong: rgba(18, 24, 33, 0.88);
    --border: rgba(255, 255, 255, 0.12);
    --text: #e8eef7;
    --muted: #9aa8b8;
    --accent: #6ea8fe;
    --danger: #ff6b7a;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    --drawer-width: 420px;
    --chrome-top: 100px;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --app-bar-base-height: 56px;
    --app-bar-outer-height: calc(var(--app-bar-base-height) + var(--safe-area-top));
    --bottom-nav-base-height: 64px;
    --bottom-nav-outer-height: calc(var(--bottom-nav-base-height) + var(--safe-area-bottom));
    --fab-size: 56px;
    --fab-gap: 16px;
    --radius: 14px;
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body, #app {
    margin: 0;
    height: 100%;
    height: 100dvh;
    width: 100%;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

/* FOUC: never flash wrapped desktop toolbar on phones before JS boots */
@media (max-width: 768px) {
    .top-bar {
        display: none !important;
    }
}

#map {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.glass {
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.top-bar {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    pointer-events: none;
    flex-wrap: wrap;
}

.top-bar > * { pointer-events: auto; }

.top-context {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1 1 220px;
}

.top-left-cluster {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1;
}

.top-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 320px;
    min-width: min(100%, 280px);
    max-width: 820px;
    margin: 0 auto;
}

.search-field-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--muted);
    font-size: 1.05rem;
    pointer-events: none;
    line-height: 1;
}

.search-input {
    width: 100%;
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(4, 5, 7, 0.55);
    color: var(--text);
    border-radius: 999px;
    padding: 10px 36px 10px 34px;
    font: inherit;
    font-size: 0.95rem;
    outline: none;
}

.search-input::placeholder {
    color: var(--muted);
}

.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.search-clear {
    position: absolute;
    right: 8px;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    z-index: 1;
}

.search-clear:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.search-submit {
    position: absolute;
    right: 36px;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    z-index: 1;
}

.search-submit:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.search-control.is-discover .search-input {
    padding-right: 68px;
}

.search-control {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
}

.search-scope {
    display: flex;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
}

.search-scope-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 7px 11px;
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
}

.search-scope-btn:hover {
    color: var(--text);
}

.search-scope-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.search-scope-btn.active {
    color: var(--text);
    background: rgba(110, 168, 254, 0.18);
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 1002;
    max-height: min(60vh, 480px);
    overflow: auto;
    border-radius: 12px;
    padding: 8px;
    background: rgba(4, 5, 7, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(22px) saturate(120%);
    -webkit-backdrop-filter: blur(22px) saturate(120%);
}

.search-group-label {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 8px 10px 4px;
}

.search-result {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    text-align: left;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text);
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
}

.search-result:hover,
.search-result.active {
    background: rgba(110, 168, 254, 0.14);
}

.search-result-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.search-result-sub {
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 2px;
}

.search-result-meta {
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

.search-result-match {
    color: rgba(110, 168, 254, 0.9);
    font-size: 0.76rem;
    margin-top: 4px;
}

.search-result-chevron {
    color: var(--muted);
    flex-shrink: 0;
    margin-top: 2px;
}

.search-empty,
.search-loading {
    padding: 16px 12px;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

.workspace-switcher { position: relative; min-width: 200px; }

.admin-switcher {
    position: relative;
}

.admin-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 38px;
    padding: 8px;
}

.admin-toggle svg {
    display: block;
    flex-shrink: 0;
}

.admin-toggle:hover,
.admin-toggle:focus-visible {
    color: var(--accent);
    border-color: rgba(110, 168, 254, 0.4);
}

.ws-toggle:focus-visible,
.glass-btn:focus-visible,
.glass-control:focus-visible {
    outline: 2px solid rgba(110, 168, 254, 0.55);
    outline-offset: 2px;
}

.view-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
}

.view-pill {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    border-radius: 999px;
    padding: 5px 11px;
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
}

.view-pill:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
}

.view-pill.active {
    color: var(--text);
    background: rgba(110, 168, 254, 0.18);
    border-color: rgba(110, 168, 254, 0.4);
}

.view-pill-lock {
    margin-left: 4px;
    opacity: 0.55;
    font-size: 0.95em;
}

.view-pill-add {
    color: var(--muted);
    border-style: dashed;
    background: transparent;
}

.view-pill-add:hover {
    color: var(--accent);
    border-color: rgba(110, 168, 254, 0.35);
}

.view-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.view-chip {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    border-radius: 999px;
    padding: 4px 10px;
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}

.view-chip:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.18);
}

.view-chip.on {
    color: var(--text);
    background: rgba(110, 168, 254, 0.16);
    border-color: rgba(110, 168, 254, 0.38);
}

.view-chip.locked {
    cursor: default;
}

.shell-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 12px;
    font-size: 0.9rem;
}

.shell-row-wrap-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ws-toggle, .glass-btn, .glass-control, .map-context button {
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 12px;
    font: inherit;
    cursor: pointer;
}

.ws-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-width: 220px;
}

.ws-menu,
.chrome-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 100%;
    border-radius: 12px;
    padding: 6px;
    z-index: 1001;
}

.chrome-menu {
    left: auto;
    right: 0;
    min-width: 200px;
}

.ws-menu button,
.chrome-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    color: var(--text);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
}

.ws-menu button:hover,
.ws-menu button.active,
.chrome-menu button:hover {
    background: rgba(110, 168, 254, 0.15);
}

.chrome-menu button:disabled {
    color: var(--muted);
    cursor: not-allowed;
    opacity: 0.65;
}

.chrome-menu button:disabled:hover {
    background: transparent;
}

.top-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.glass-btn.primary {
    background: rgba(110, 168, 254, 0.22);
    border-color: rgba(110, 168, 254, 0.45);
}

.glass-btn.danger {
    color: var(--danger);
    border-color: rgba(255, 107, 122, 0.35);
}

.drawer {
    position: absolute;
    top: var(--chrome-top);
    left: 16px;
    bottom: 16px;
    width: min(var(--drawer-width), calc(100vw - 32px));
    z-index: 900;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: rgba(4, 5, 7, 0.94);
    backdrop-filter: blur(24px) saturate(120%);
    -webkit-backdrop-filter: blur(24px) saturate(120%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.drawer-inner {
    overflow: auto;
    padding: 16px 18px 24px;
    height: 100%;
}

.shell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.shell-back,
.shell-close {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    border-radius: 8px;
    padding: 6px 10px;
    font: inherit;
    cursor: pointer;
}

.shell-back:hover,
.shell-close:hover {
    background: rgba(255, 255, 255, 0.08);
}

.shell-identity { margin-bottom: 14px; }

.shell-title {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    color: #f4f7fb;
}

.shell-type {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.85rem;
}

.shell-description {
    color: #c5d0dc;
    line-height: 1.45;
    white-space: pre-wrap;
    min-height: 1.2em;
}

.shell-muted { color: var(--muted); font-size: 0.9rem; }

.shell-section-label {
    margin: 18px 0 8px;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.shell-rows { display: flex; flex-direction: column; gap: 8px; }

.shell-row,
.shell-row-wrap-col {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.shell-row {
    width: 100%;
    text-align: left;
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
    border-radius: 10px;
    padding: 12px 14px;
    font: inherit;
    cursor: pointer;
}

.shell-row:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
}

.contact-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.08);
}
.contact-avatar-sm { width: 32px; height: 32px; }
.contact-avatar-lg { width: 72px; height: 72px; }
.contact-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
}
.contact-avatar-lg.contact-avatar-fallback { font-size: 1.25rem; }
.contact-profile-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
}
.shell-row .contact-avatar + div {
    flex: 1;
    min-width: 0;
}

.shell-row-label { font-weight: 500; }
.shell-row-kicker {
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 2px;
}
.shell-row-meta { color: var(--muted); white-space: nowrap; }

.shell-unlink {
    appearance: none;
    border: 1px solid rgba(255, 107, 122, 0.25);
    background: transparent;
    color: var(--danger);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
}

.shell-row-wrap {
    display: flex;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 6px;
}

.shell-row-wrap .shell-row {
    flex: 1;
    margin: 0;
}

.shell-hero {
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shell-hero img,
.shell-hero video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.shell-hero-empty {
    color: var(--muted);
    font-size: 0.9rem;
}

.shell-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.shell-actions .icon-btn {
    opacity: 0.85;
}

.shell-actions .icon-btn:hover {
    opacity: 1;
    border-color: rgba(110, 168, 254, 0.45);
}

.full { width: 100%; margin-top: 12px; }

.shell-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 12px;
}

.shell-filter-row .glass-btn {
    min-height: 44px;
}

.contact-method-row,
.contact-address-block {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
}

.shell-link {
    color: var(--accent, #6ea8fe);
    text-decoration: none;
}

.shell-link:hover {
    text-decoration: underline;
}

.rel-composer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.rel-results { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }

.module-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.module-row .row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.module-row .row-actions .glass-btn {
    padding: 6px 10px;
    font-size: 0.85rem;
}

.locale-block {
    margin-bottom: 14px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.locale-block:last-of-type {
    border-bottom: 0;
}

.delete-confirm-list {
    margin: 0 0 12px;
    padding-left: 1.2em;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

.drawer-media {
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.35);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drawer-media img,
.drawer-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drawer-media audio {
    width: 90%;
}

.field-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

.field-row h1 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.25;
}

.field-row .meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.field-row p {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.45;
}

.icon-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
}

.icon-btn:hover { color: var(--accent); }

.thumb-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-top: 8px;
}

.thumb-strip button,
.thumb-strip .thumb {
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.25);
    border-radius: 8px;
    width: 64px;
    height: 48px;
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.7rem;
}

.thumb-strip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drawer-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 800;
    padding: 24px 28px;
    border-radius: var(--radius);
    text-align: center;
    max-width: 360px;
}

.map-context {
    position: absolute;
    z-index: 850;
    border-radius: 10px;
    padding: 4px;
}

.modal {
    position: absolute;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal[hidden],
.drawer[hidden],
.empty-state[hidden],
.map-context[hidden],
.ws-menu[hidden],
.chrome-menu[hidden] {
    display: none !important;
}

.modal-card {
    width: min(480px, 100%);
    border-radius: var(--radius);
    padding: 18px;
    max-height: min(90vh, 720px);
    overflow: auto;
}

.modal-card h2 {
    margin: 0 0 14px;
    font-size: 1.1rem;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.85rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
}

.form-group textarea {
    min-height: 90px;
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.leaflet-container {
    background: #1a222d;
    font: inherit;
}

.leaflet-control-attribution {
    background: rgba(18, 24, 33, 0.55) !important;
    color: var(--muted) !important;
    border-radius: 4px 0 0 0;
    font-size: 10px !important;
    line-height: 1.2;
    padding: 2px 5px !important;
}

.leaflet-control-attribution a {
    font-size: inherit;
}

.leaflet-attribution-flag {
    width: 9px;
    height: 6px;
}

.leaflet-bar a,
.leaflet-draw-toolbar a {
    background: var(--glass-strong) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

.draft-hint {
    color: var(--accent);
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.placement-banner {
    position: absolute;
    top: var(--chrome-top);
    left: 50%;
    transform: translateX(-50%);
    z-index: 950;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: var(--radius);
    max-width: min(520px, calc(100vw - 32px));
}

.placement-banner[hidden] {
    display: none !important;
}

.placement-sub {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 2px;
}

.entity-pin-label {
    background: rgba(18, 24, 33, 0.82) !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    color: #e8eef7 !important;
    border-radius: 8px !important;
    padding: 3px 8px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none !important;
    white-space: nowrap;
}

.entity-pin-label::before {
    border-top-color: rgba(18, 24, 33, 0.82) !important;
}

.leaflet-tooltip-top.entity-pin-label::before {
    border-top-color: rgba(18, 24, 33, 0.82) !important;
}

.entity-focus-marker {
    filter: drop-shadow(0 0 6px rgba(110, 168, 254, 0.85));
}

.contains-section {
    margin: 16px 0;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.contains-heading {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.contains-list {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
}

.contains-list li {
    margin: 0;
}

.contains-link {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    color: var(--text);
    padding: 8px 0;
    cursor: pointer;
    font: inherit;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.contains-link:hover {
    color: var(--accent);
}

#btn-add-inside {
    margin-top: 4px;
    width: 100%;
}

/* —— Media Viewer —— */
body.media-viewer-open {
    overflow: hidden;
}

.media-viewer {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.media-viewer[hidden] {
    display: none;
}

.media-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
}

.media-viewer-panel {
    position: relative;
    z-index: 1;
    width: min(1100px, 100%);
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: rgba(8, 10, 14, 0.92);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
}

.media-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

.media-viewer-title {
    font-size: 1rem;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-viewer-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 0.9rem;
    flex: 0 0 auto;
}

.media-viewer-close {
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.media-viewer-close:hover {
    border-color: rgba(110, 168, 254, 0.45);
    color: var(--accent);
}

.media-viewer-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 56px;
    position: relative;
}

.media-viewer-main {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #000;
}

.media-viewer-empty {
    color: var(--muted);
}

.media-viewer-file-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 28px 32px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    max-width: 420px;
    text-align: center;
}

.media-viewer-file-name {
    font-weight: 600;
    word-break: break-word;
}

.media-viewer-file-kind {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.media-viewer-file-card audio {
    width: 100%;
}

.media-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    appearance: none;
    width: 44px;
    height: 64px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(18, 24, 33, 0.72);
    color: var(--text);
    font-size: 1.75rem;
    cursor: pointer;
    backdrop-filter: blur(12px);
}

.media-viewer-nav.prev { left: 10px; }
.media-viewer-nav.next { right: 10px; }

.media-viewer-nav:hover:not(:disabled) {
    border-color: rgba(110, 168, 254, 0.45);
    color: var(--accent);
}

.media-viewer-nav:disabled {
    opacity: 0.25;
    cursor: default;
}

.media-viewer-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 18px 16px;
    border-top: 1px solid var(--border);
    flex: 0 0 auto;
}

.media-viewer-thumb {
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    width: 72px;
    height: 54px;
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.65rem;
}

.media-viewer-thumb.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(110, 168, 254, 0.35);
}

.media-viewer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* —— Album / media library —— */
.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 10px 0 14px;
}

.media-grid-item {
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.35);
    border-radius: 10px;
    aspect-ratio: 1;
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.7rem;
    position: relative;
}

.media-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-grid-item.muted {
    opacity: 0.45;
}

.media-grid-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(110, 168, 254, 0.4);
}

.media-grid-item .media-check {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.7rem;
    line-height: 16px;
    text-align: center;
}

.media-grid-item.selected .media-check {
    background: var(--accent);
    border-color: var(--accent);
}

.album-card {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
    text-align: left;
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 10px;
    color: var(--text);
    cursor: pointer;
    margin-bottom: 8px;
}

.album-card:hover {
    border-color: rgba(110, 168, 254, 0.4);
}

.album-cover {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.4);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.7rem;
}

.album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.album-card-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.album-card-meta {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 2px;
}

.media-select-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 10px 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
}

.shell-row.event-media-selected {
    border-color: var(--accent, #5b9dff);
    background: rgba(91, 157, 255, 0.08);
}

/* V1.9 Calendar / Event shell */
.drawer.drawer-wide {
    width: min(720px, calc(100vw - 32px));
}

.drawer.drawer-cal-wide {
    width: min(960px, calc(100vw - 32px));
}

.drawer.drawer-cal-grid {
    display: flex;
    flex-direction: column;
}

.drawer.drawer-cal-grid .drawer-inner {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.drawer.drawer-cal-grid .cal-body.cal-view-timed {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.drawer.drawer-cal-grid .cal-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.drawer.drawer-cal-grid .cal-render-target {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.cal-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.cal-month-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 1.05rem;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.cal-grid-month {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cal-dow-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.cal-dow {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
    padding: 4px 0;
    font-weight: 600;
}

.cal-week {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cal-week-lanes {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 0;
}

.cal-week-lane {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    min-height: 18px;
}

.cal-week-view .cal-week-lane {
    grid-template-columns: repeat(7, minmax(var(--cal-day-min, 88px), 1fr));
    gap: 2px;
}

.cal-span {
    appearance: none;
    border: 0;
    border-radius: 4px;
    background: rgba(110, 168, 254, 0.28);
    color: var(--text);
    font-size: 0.68rem;
    line-height: 1.2;
    padding: 2px 6px;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    z-index: 1;
}

.cal-week-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.cal-cell {
    min-height: 72px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cal-cell:hover {
    border-color: rgba(110, 168, 254, 0.35);
}

.cal-cell.cal-muted {
    opacity: 0.45;
}

.cal-cell.cal-today {
    border-color: rgba(110, 168, 254, 0.55);
    background: rgba(110, 168, 254, 0.08);
}

.cal-cell.is-focused {
    border-color: rgba(180, 210, 255, 0.75);
    box-shadow: inset 0 0 0 1px rgba(110, 168, 254, 0.35);
}

.cal-cell-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.cal-day-num {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: left;
    padding: 0 2px;
    cursor: pointer;
}

.cal-add {
    appearance: none;
    border: 0;
    background: rgba(110, 168, 254, 0.25);
    color: var(--text);
    border-radius: 4px;
    width: 20px;
    height: 20px;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    flex-shrink: 0;
}

.cal-cell:hover .cal-add,
.cal-cell:focus-within .cal-add,
.cal-cell.is-focused .cal-add {
    opacity: 1;
    pointer-events: auto;
}

.cal-pills {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cal-pill {
    appearance: none;
    border: 0;
    border-radius: 4px;
    background: rgba(110, 168, 254, 0.22);
    color: var(--text);
    font-size: 0.68rem;
    line-height: 1.2;
    padding: 2px 4px;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.cal-pill-cont {
    background: rgba(110, 168, 254, 0.12);
    color: var(--muted);
}

.cal-more {
    appearance: none;
    border: 0;
    background: transparent;
    font-size: 0.65rem;
    color: var(--muted);
    padding: 0 2px;
    text-align: left;
    cursor: pointer;
}

.cal-more:hover {
    color: var(--text);
}

/* Week / Day timed views */
.cal-week-view,
.cal-day-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.cal-week-body {
    display: flex;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

.cal-hours-col {
    flex: 0 0 52px;
    display: flex;
    flex-direction: column;
    z-index: 2;
    background: rgba(4, 5, 7, 0.94);
    min-height: 0;
}

.cal-hours-spacer {
    min-height: 52px;
    flex-shrink: 0;
}

.cal-multiday-spacer {
    min-height: 48px;
    flex-shrink: 0;
}

.cal-hours-scroll {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.cal-week-hscroll {
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

.cal-week-main {
    min-width: calc(var(--cal-day-min, 88px) * 7);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.cal-week-head {
    display: grid;
    grid-template-columns: repeat(7, minmax(var(--cal-day-min, 88px), 1fr));
    gap: 2px;
    margin-bottom: 6px;
}

.cal-week-head-cell {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    color: var(--text);
    padding: 6px 4px;
    cursor: pointer;
    text-align: center;
}

.cal-week-head-cell.cal-today {
    border-color: rgba(110, 168, 254, 0.55);
    background: rgba(110, 168, 254, 0.08);
}

.cal-week-head-cell.is-focused {
    box-shadow: inset 0 0 0 1px rgba(110, 168, 254, 0.45);
}

.cal-week-dow {
    display: block;
    font-size: 0.7rem;
    color: var(--muted);
}

.cal-week-dom {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
}

.cal-multiday {
    margin-bottom: 8px;
}

.cal-multiday-label {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}

.cal-multiday-chips,
.cal-week-allday-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.cal-week-allday-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(var(--cal-day-min, 88px), 1fr));
    gap: 2px;
    margin-top: 4px;
}

.cal-week-allday-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 4px;
}

.cal-lane-chip {
    appearance: none;
    border: 0;
    border-radius: 4px;
    background: rgba(110, 168, 254, 0.22);
    color: var(--text);
    font-size: 0.72rem;
    padding: 4px 8px;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.cal-time-scroll {
    flex: 1;
    min-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.cal-day-view .cal-time-scroll {
    display: grid;
    grid-template-columns: 52px 1fr;
}

.cal-hours {
    background: rgba(4, 5, 7, 0.94);
}

.cal-hour-label {
    height: 48px;
    font-size: 0.68rem;
    color: var(--muted);
    padding: 0 6px;
    box-sizing: border-box;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.cal-day-cols {
    display: grid;
    grid-template-columns: repeat(7, minmax(var(--cal-day-min, 88px), 1fr));
    gap: 2px;
}

.cal-day-col {
    position: relative;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.cal-day-grid {
    position: relative;
}

.cal-hour-slot {
    height: 48px;
    box-sizing: border-box;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.cal-timed-block {
    appearance: none;
    border: 0;
    position: absolute;
    z-index: 1;
    margin: 0 1px;
    border-radius: 4px;
    background: rgba(110, 168, 254, 0.35);
    border-left: 3px solid rgba(110, 168, 254, 0.9);
    color: var(--text);
    font-size: 0.7rem;
    padding: 2px 4px;
    overflow: hidden;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
}

.cal-timed-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-now-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 2px solid #e85d5d;
    z-index: 3;
    pointer-events: none;
}

.cal-now-label {
    position: absolute;
    left: 0;
    top: -0.7em;
    transform: translateX(-100%);
    font-size: 0.62rem;
    color: #e85d5d;
    padding-right: 4px;
    white-space: nowrap;
}

.cal-day-view .cal-now-label {
    left: -52px;
    transform: none;
}

.cal-load-error {
    margin: 0 0 10px;
    color: #f0a0a0;
}

.cal-empty-day {
    margin: 0 0 8px;
}

#gc-ws-chips {
    max-height: 88px;
    overflow-y: auto;
}

@media (max-width: 640px) {
    .cal-cell {
        min-height: 56px;
    }
    .cal-pill {
        font-size: 0.6rem;
    }
    .cal-add {
        opacity: 0;
    }
    .cal-cell.is-focused .cal-add {
        opacity: 1;
        pointer-events: auto;
    }
}

.discover-bounded {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    white-space: nowrap;
    cursor: pointer;
}

.discover-bounded[hidden] {
    display: none !important;
}

.discover-attribution {
    padding: 10px 10px 4px;
    font-size: 0.72rem;
    color: var(--muted);
}

.discover-attribution a {
    color: inherit;
}

.discover-meta {
    font-size: 0.88rem;
    margin-bottom: 10px;
}

.discover-search-area {
    position: absolute;
    top: var(--chrome-top);
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    padding: 8px 14px;
    border-radius: 999px;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text);
}

.discovery-marker {
    background: transparent;
    border: 0;
}

.discovery-pin {
    display: block;
    width: 14px;
    height: 14px;
    margin: 2px auto 0;
    border-radius: 2px 2px 2px 0;
    transform: rotate(-45deg);
    background: rgba(126, 182, 255, 0.25);
    border: 1.5px dashed #7eb6ff;
    box-shadow: 0 0 0 1px rgba(4, 5, 7, 0.6);
}

.discovery-marker.is-active .discovery-pin {
    background: rgba(126, 182, 255, 0.7);
    border-style: solid;
}

/* GPS track media markers on Leaflet */
.track-media-marker {
    background: transparent;
    border: none;
}
.track-media-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(15, 22, 36, 0.85);
    border: 1px solid rgba(110, 168, 254, 0.7);
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.track-live .shell-row-label {
    color: #7eb6ff;
}
