:root {
    color-scheme: dark;
    --bg: #111418;
    --panel: rgba(26, 31, 38, 0.88);
    --panel-2: #20262f;
    --panel-3: rgba(32, 38, 47, 0.98);
    --text: #e8edf2;
    --muted: #a4b0bd;
    --border: rgba(255, 255, 255, 0.12);
    --link: #8fc7ff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}


/* Auth pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
}

.auth-card {
    background: var(--panel-3);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px;
    width: min(380px, 100%);
    box-shadow: var(--shadow);
}

.auth-title {
    margin: 0 0 4px;
    font-size: 1.5rem;
}

.auth-subtitle {
    color: var(--muted);
    margin: 0 0 24px;
    font-size: 0.9rem;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-label {
    display: grid;
    gap: 4px;
    font-size: 0.88rem;
    color: var(--muted);
}

.auth-label input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 120ms;
}

.auth-label input:focus {
    border-color: var(--link);
}

.auth-btn {
    margin-top: 8px;
    padding: 12px;
    background: var(--link);
    color: #111;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 120ms;
}

.auth-btn:hover { opacity: 0.9; }

.auth-flash {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 16px;
}

.auth-flash--success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

/* Admin panel */
.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.admin-action-btn {
    padding: 8px 16px;
    background: var(--link);
    color: #111;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}

.admin-action-btn:hover { opacity: 0.9; }
.admin-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-code-cell {
    font-family: monospace;
    font-size: 0.88rem;
}

.admin-muted {
    color: var(--muted);
    font-size: 0.84rem;
}

.admin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
}

.admin-badge--available {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
}

.admin-badge--used {
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
}

.admin-badge--admin {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

.admin-delete-btn {
    background: none;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
}

.admin-delete-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

.auth-flash--error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.auth-footer {
    text-align: center;
    margin: 20px 0 0;
    font-size: 0.86rem;
    color: var(--muted);
}

.auth-footer a {
    color: var(--link);
    text-decoration: none;
}

.auth-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

.storage-usage {
    margin: 8px 0 4px;
}

.storage-bar-track {
    height: 8px;
    border-radius: 4px;
    background: var(--panel-2);
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--link);
    transition: width 300ms ease;
}

.storage-label {
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 6px;
}

.invite-hint {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 0 0 10px;
}

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

.invite-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--panel-2);
}

.invite-code {
    font-size: 0.82rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    color: var(--text);
}

.invite-status {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 4px;
}

.invite-status--available {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.12);
}

.invite-status--used {
    color: var(--muted);
    background: rgba(164, 176, 189, 0.1);
}

.auth-section-title {
    font-size: 1rem;
    margin: 0 0 12px;
}

/* Sharing page */
.share-url-hint {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 16px;
}

.share-url-hint code {
    color: var(--text);
}

.share-add-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.share-add-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    font-size: 0.9rem;
}

.share-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.share-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.02);
}

.share-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.share-delete-btn {
    font-size: 1rem;
}

.share-perms {
    display: grid;
    gap: 4px;
}

.share-perm-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    cursor: pointer;
    padding: 3px 0;
}

.share-perm-row input[disabled] + span {
    opacity: 0.4;
}

/* Friends page */
.friends-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.friend-card {
    display: block;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.02);
    text-decoration: none;
    color: var(--text);
    transition: background 120ms, border-color 120ms;
}

.friend-card:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.18);
}

.friend-card-name {
    font-weight: 600;
    font-size: 0.95rem;
}

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

.user-logout-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: inherit;
    padding: 0;
    text-decoration: none;
}

.user-logout-btn:hover {
    color: var(--text);
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, sans-serif;
}

body {
    min-height: 100vh;
}

body.map-screen {
    overflow: hidden;
    /* Prevent iOS Safari from leaving the page scrolled after keyboard dismiss */
    position: fixed;
    width: 100%;
    height: 100%;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.shell {
    width: min(1400px, calc(100vw - 32px));
    margin: 0 auto;
}

.site-header {
    border-bottom: 1px solid var(--border);
    background: #0d1014;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 0;
}

.site-title {
    margin: 0;
    font-size: 1.25rem;
}

.site-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.site-nav {
    display: flex;
    gap: 16px;
}

/* Hamburger button — hidden on desktop */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-direction: column;
    gap: 5px;
}

.hamburger-line {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.25s, opacity 0.25s;
}

.hamburger-btn.is-active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.is-active .hamburger-line:nth-child(2) {
    opacity: 0;
}
.hamburger-btn.is-active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 600px) {
    .hamburger-btn {
        display: flex;
    }

    .site-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #0d1014;
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 12px 16px;
        gap: 8px;
        z-index: 100;
    }

    .site-nav.is-open {
        display: flex;
    }

    .header-inner {
        position: relative;
    }
}

main.shell {
    padding: 20px 0 28px;
}

.card {
    background: rgba(26, 31, 38, 0.95);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
}

.muted {
    margin: 0;
    color: var(--muted);
}

.is-hidden {
    display: none !important;
}

.map-shell {
    position: relative;
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    /* Fallback for browsers without dvh support */
    height: 100vh;
    height: 100dvh;
}

#map,
.maplibregl-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left {
    bottom: env(safe-area-inset-bottom, 0px);
}

.floating-menu-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 20;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-3);
    color: var(--text);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.floating-near-me-btn {
    position: absolute;
    bottom: calc(32px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    z-index: 20;
    width: 48px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--panel-3);
    color: var(--text);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 120ms, border-color 120ms;
}

.floating-near-me-btn:hover,
.floating-near-me-btn:active {
    background: rgba(40, 50, 65, 0.98);
    border-color: rgba(255, 255, 255, 0.25);
}

.menu-version {
    text-align: center;
    font-size: 0.7rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    color: var(--muted);
    opacity: 0.5;
    padding-top: 12px;
}

.near-me-panel {
    position: absolute;
    bottom: 92px;
    left: 16px;
    z-index: 22;
    width: min(340px, calc(100vw - 32px));
    max-height: calc(100dvh - 120px);
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
}

.near-me-panel-inner {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    overflow-y: auto;
    max-height: calc(100dvh - 120px);
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
    -webkit-overflow-scrolling: touch;
}

.near-me-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.near-me-header h3 {
    margin: 0;
    font-size: 1rem;
}

.near-me-status {
    color: var(--muted);
    font-size: 0.86rem;
    margin-bottom: 8px;
}

.near-me-results {
    display: grid;
    gap: 4px;
}

.near-me-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 80ms;
}

.near-me-item:hover,
.near-me-item:active {
    background: rgba(255, 255, 255, 0.06);
}

.near-me-item-body {
    min-width: 0;
    flex: 1;
}

.near-me-item-name {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.near-me-item-meta {
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.near-me-item-dist {
    color: var(--muted);
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.map-menu-panel {
    position: absolute;
    top: 68px;
    left: 16px;
    z-index: 21;
    width: min(360px, calc(100vw - 32px));
    max-height: calc(100dvh - 84px);
    max-height: calc(100vh - 84px);
    max-height: calc(100dvh - 84px);
}

.menu-panel-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    overflow-y: auto;
    max-height: calc(100dvh - 84px);
    max-height: calc(100vh - 84px);
    max-height: calc(100dvh - 84px);
}

.menu-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.menu-panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.menu-section + .menu-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.menu-section-first {
    padding-top: 0;
    border-top: 0;
    margin-top: 0;
}

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

.section-header-inline h3 {
    margin: 0;
    font-size: 0.98rem;
}

.section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: 0.98rem;
    text-align: left;
}

.collapsible-body {
    margin-top: 12px;
}

.menu-subsection + .menu-subsection {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.menu-subsection-title {
    margin: 0 0 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.inline-actions {
    display: flex;
    gap: 8px;
}

.type-filter-actions {
    margin-bottom: 10px;
}

.mini-btn {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.type-filter-list {
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.type-filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 0.94rem;
}

.type-filter-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.compact-field {
    margin-top: 12px;
}

.range-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.range-value {
    min-width: 2.5rem;
    text-align: right;
    color: var(--muted);
    font-size: 0.92rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.type-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.12);
}

.stat-label {
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
}

.ghost-btn {
    min-width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: transparent;
    color: var(--text);
}

.legend-wrap {
    margin-top: 0;
}

.legend-label-row {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.legend-gradient {
    height: 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: linear-gradient(
        90deg,
        hsl(240 85% 60%),
        hsl(180 85% 50%),
        hsl(120 70% 48%),
        hsl(60 85% 52%),
        hsl(0 85% 58%)
    );
}

.legend-unknown-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

.legend-unknown-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #d1d5db;
    border: 1px solid rgba(0, 0, 0, 0.25);
}

.menu-links {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.place-drawer {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 25;
    width: min(360px, 92vw);
    height: 100dvh;
    height: 100%;
    height: 100dvh;
    transform: translateX(100%);
    transition: transform 180ms ease;
    pointer-events: none;
}

.place-drawer.is-open {
    transform: translateX(0);
    pointer-events: auto;
}

.place-drawer-inner {
    height: 100%;
    background: var(--panel-3);
    border-left: 1px solid var(--border);
    box-shadow: -12px 0 28px rgba(0, 0, 0, 0.22);
    padding: 18px 16px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.drawer-header h2 {
    margin: 0 0 6px;
    font-size: 1.15rem;
}

.drawer-empty {
    margin-top: 8px;
}

.place-form {
    display: grid;
    gap: 14px;
}

.form-field {
    display: grid;
    gap: 6px;
}

.form-field > span {
    font-size: 0.92rem;
    color: var(--muted);
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #13181f;
    color: var(--text);
    padding: 10px 12px;
}

.form-field textarea {
    resize: vertical;
    min-height: 120px;
}

.drawer-meta {
    display: grid;
    gap: 8px;
    padding: 10px 0 2px;
    border-top: 1px solid var(--border);
}

.drawer-meta p {
    margin: 0;
    font-size: 0.92rem;
}

.drawer-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.drawer-actions button {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #1f6feb;
    color: white;
    padding: 10px 14px;
    font-weight: 600;
}

.drawer-actions button:disabled {
    opacity: 0.7;
    cursor: default;
}

.save-status {
    min-height: 1.2em;
    color: #9dd38c;
    font-size: 0.9rem;
}

.save-status.is-error {
    color: #ff9a9a;
}

@media (max-width: 800px) {
    .place-drawer {
        width: min(100vw, 100vw);
    }

    .floating-menu-btn {
        top: 12px;
        left: 12px;
    }

    .map-menu-panel {
        top: 62px;
        left: 12px;
        width: min(360px, calc(100vw - 24px));
    }

    .stats-grid,
    .type-stats-grid {
        grid-template-columns: 1fr;
    }
}

.add-place-btn {
    width: 100%;
}

.add-place-hint {
    margin-top: 8px;
    font-size: 0.9rem;
}

.map-context-menu {
    position: absolute;
    z-index: 40;
    min-width: 180px;
    background: var(--panel-3);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 6px;
    backdrop-filter: blur(10px);
}

.map-context-menu button {
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--text);
    border: 0;
    border-radius: 8px;
    padding: 10px 12px;
}

.map-context-menu button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.drawer-actions-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.danger-btn {
    border: 1px solid rgba(255, 120, 120, 0.35);
    border-radius: 10px;
    background: rgba(140, 30, 30, 0.22);
    color: #ffb4b4;
    padding: 10px 14px;
    font-weight: 600;
}

.danger-btn:hover {
    background: rgba(160, 36, 36, 0.3);
}

.place-media-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.place-cover-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: #111827;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.place-cover-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1rem;
  color: #cbd5e1;
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.95));
}

.place-cover-empty-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.place-cover-empty-subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
}

.place-cover-image,
.place-cover-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.place-media-strip {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.place-media-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 92px;
  height: 92px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #e5e7eb;
  padding: 0;
  cursor: pointer;
}

.place-media-thumb:hover {
  border-color: #94a3b8;
}

.place-media-thumb.is-selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.place-media-thumb img,
.place-media-thumb-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: #e5e7eb;
  background: linear-gradient(180deg, #334155, #0f172a);
}

.place-media-thumb-badge {
  position: absolute;
  left: 0.45rem;
  bottom: 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
}

.place-media-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.place-media-editor {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem;
  border-radius: 14px;
  background: #1f2937;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.place-media-editor-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.is-hidden {
  display: none !important;
}



.flight-mode-banner {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
  max-width: calc(100vw - 2rem);
  white-space: nowrap;
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  .flight-mode-banner {
    border-radius: 12px;
    white-space: normal;
    text-align: center;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
  }
}

.flight-drawer {
  right: 26rem;
}

.flight-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.flight-list-item,
.flight-popup-action {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  background: #111827;
  color: #f8fafc;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
}

.flight-list-item:hover,
.flight-popup-action:hover {
  border-color: rgba(96, 165, 250, 0.6);
}

.flight-list-item.is-selected {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.18);
}

.flight-list-item-title {
  display: block;
  font-weight: 700;
}

.flight-list-item-meta {
  display: block;
  margin-top: 0.2rem;
  color: #94a3b8;
  font-size: 0.85rem;
}

.flight-route-labels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.flight-route-chip {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: #111827;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.flight-popup {
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flight-popup-title {
  font-weight: 700;
}

.inline-actions .mini-btn.is-active {
  background: #2563eb;
  color: #fff;
}

@media (max-width: 1400px) {
  .flight-drawer {
    right: 0;
  }
}

.maplibregl-popup-content {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #374151;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.maplibregl-popup-tip {
  border-top-color: #111827 !important;
  border-bottom-color: #111827 !important;
}

.flight-popup-title {
  color: #f9fafb;
}

.flight-popup-choice {
  background: #1f2937;
  color: #e5e7eb;
  border: 1px solid #374151;
}

.flight-popup-choice:hover {
  background: #374151;
}

.flight-popup-choice strong {
  color: #f9fafb;
}

.flight-popup-simple {
  min-width: 220px;
}

.flight-popup-choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
}

.flight-popup-choice-simple {
  display: block;
  width: 100%;
  text-align: left;
  background: #1f2937;
  color: #e5e7eb;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  padding: 0.65rem 0.8rem;
  cursor: pointer;
}

.flight-popup-choice-simple:hover {
  background: #374151;
}

.menu-links {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

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

.form-field {
    display: grid;
    gap: 6px;
}

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

.form-field input,
.form-field textarea,
.form-field select,
.flight-grid-input,
.flight-grid-select {
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #151922;
    color: var(--text);
}

.flights-page-shell {
    padding-top: 20px;
    padding-bottom: 28px;
}

.flights-stats-card,
.flights-toolbar-card,
.flights-grid-card {
    margin-bottom: 16px;
}

.flights-stats-card .section-toggle {
    width: 100%;
    text-align: left;
}

.flight-stats-loading {
    color: var(--text-muted);
    font-size: 0.88rem;
    padding: 8px 0;
}

.flight-stats-grid {
    display: grid;
    gap: 16px;
    padding: 4px 0;
}

.flight-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.flight-stats-section h4 {
    margin: 0 0 6px;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.flight-stats-list {
    display: grid;
    gap: 2px;
}

.flight-stats-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.flight-stats-list-item:last-child {
    border-bottom: none;
}

.flight-stats-count {
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.flights-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.flights-toolbar-left {
    flex: 1 1 420px;
}

.flights-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.flights-filter-field {
    margin: 0;
}

.flights-grid-wrap {
    overflow-x: auto;
}

.flights-grid-table {
    width: 100%;
    min-width: 1400px;
    border-collapse: collapse;
}

.flights-grid-table th,
.flights-grid-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.flights-grid-table th {
    position: sticky;
    top: 0;
    background: #171c24;
    z-index: 1;
    font-size: 0.9rem;
    color: var(--muted);
    white-space: nowrap;
}

.flights-grid-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

.flight-grid-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.flights-empty-cell {
    color: var(--muted);
    text-align: center;
    padding: 24px 12px !important;
}

.is-new-row {
    background: rgba(143, 199, 255, 0.05);
}

@media (max-width: 900px) {
    .flights-toolbar {
        align-items: stretch;
    }

    .flights-toolbar-right {
        width: 100%;
    }
}

.flights-wide-shell {
    width: min(98vw, 2200px);
    max-width: min(98vw, 2200px);
}

.flights-page-shell {
    padding-top: 20px;
    padding-bottom: 28px;
}

.flights-grid-wrap {
    overflow-x: auto;
}

.flights-grid-table {
    width: 100%;
    min-width: 1760px;
    border-collapse: collapse;
    table-layout: fixed;
}

.flights-grid-table th,
.flights-grid-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.flights-grid-table th {
    position: sticky;
    top: 0;
    background: #171c24;
    z-index: 1;
    font-size: 0.9rem;
    color: var(--muted);
    white-space: nowrap;
}

.flights-grid-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.025);
}

.col-conf {
    width: 120px;
}

.col-flight-number {
    width: 140px;
}

.col-airline {
    width: 220px;
}

.col-aircraft {
    width: 140px;
}

.col-airport {
    width: 150px;
}

.col-datetime {
    width: 190px;
}

.col-seat {
    width: 110px;
}

.col-note {
    width: 420px;
}

.col-actions {
    width: 150px;
}

.flight-grid-input,
.flight-grid-select {
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #151922;
    color: var(--text);
    box-sizing: border-box;
}

.conf-input {
    min-width: 100px;
}

.flight-number-input {
    min-width: 120px;
}

.airline-input {
    min-width: 180px;
}

.airport-select {
    min-width: 130px;
}

.datetime-input {
    min-width: 175px;
}

.seat-input {
    min-width: 90px;
}

.note-input {
    min-width: 380px;
}

.flight-grid-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.flights-empty-cell {
    color: var(--muted);
    text-align: center;
    padding: 24px 12px !important;
}

.is-new-row {
    background: rgba(143, 199, 255, 0.05);
}

@media (max-width: 1200px) {
    .flights-wide-shell {
        width: min(99vw, 2200px);
        max-width: min(99vw, 2200px);
    }

    .flights-grid-table {
        min-width: 1500px;
    }
}

.col-conf {
    width: 120px;
}

.col-flight-number {
    width: 118px;
}

.col-airline {
    width: 110px;
}

.col-aircraft {
    width: 110px;
}

.col-airport {
    width: 150px;
}

.col-datetime {
    width: 215px;
}

.col-seat {
    width: 110px;
}

.col-note {
    width: 420px;
}

.col-actions {
    width: 170px;
}

.conf-input {
    min-width: 100px;
}

.flight-number-input {
    min-width: 98px;
}

.airline-input {
    min-width: 90px;
}

.airport-select {
    min-width: 130px;
}

.datetime-input {
    min-width: 200px;
}

.seat-input {
    min-width: 90px;
}

.note-input {
    min-width: 380px;
}

.flight-grid-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
}

.flight-save-btn,
.flight-delete-btn {
    white-space: nowrap;
}

.danger-btn {
    background: #7f1d1d;
    border-color: #b91c1c;
    color: #fee2e2;
}

.danger-btn:hover {
    background: #991b1b;
    border-color: #dc2626;
}

.col-conf {
    width: 120px;
}

.col-flight-number {
    width: 104px;
}

.col-airline {
    width: 95px;
}

.col-aircraft {
    width: 95px;
}

.col-airport {
    width: 112px;
}

.col-datetime {
    width: 245px;
}

.col-seat {
    width: 82px;
}

.col-note {
    width: 420px;
}

.col-actions {
    width: 158px;
}

.conf-input {
    min-width: 100px;
}

.flight-number-input {
    min-width: 86px;
}

.airline-input {
    min-width: 78px;
}

.airport-select {
    min-width: 92px;
}

.datetime-input {
    min-width: 228px;
}

.seat-input {
    min-width: 64px;
}

.note-input {
    min-width: 380px;
}

.flight-grid-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: stretch;
}

.flight-save-btn,
.flight-delete-btn {
    white-space: nowrap;
    height: 40px;
    min-height: 40px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.flight-delete-btn {
    padding-left: 10px;
    padding-right: 10px;
}

.danger-btn {
    background: #7f1d1d;
    border-color: #b91c1c;
    color: #fee2e2;
}

.danger-btn:hover {
    background: #991b1b;
    border-color: #dc2626;
}

.is-dirty-row td {
    background: rgba(250, 204, 21, 0.08);
}

.is-dirty-row:hover td {
    background: rgba(250, 204, 21, 0.11);
}

/* Fix flight drawer closed/open positioning */
.flight-drawer {
    right: 26rem;
    transform: translateX(calc(100% + 26rem));
}

.flight-drawer.is-open {
    transform: translateX(0);
}

@media (max-width: 1400px) {
    .flight-drawer {
        right: 0;
        transform: translateX(100%);
    }

    .flight-drawer.is-open {
        transform: translateX(0);
    }
}

.flight-route-panel {
  display: grid;
  gap: 0.85rem;
}

.flight-route-cards {
  display: grid;
  gap: 0.75rem;
}

.flight-route-card {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: #111827;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  cursor: pointer;
  display: grid;
  gap: 0.3rem;
}

.flight-route-card:hover {
  background: #1f2937;
  border-color: #475569;
}

.flight-route-card-title {
  font-weight: 700;
  color: #f9fafb;
}

.flight-route-card-subtitle {
  color: #94a3b8;
  font-size: 0.92rem;
}

.danger-btn {
    background: #7f1d1d !important;
    border: 1px solid #b91c1c;
    color: #fee2e2;
}

.danger-btn:hover {
    background: #991b1b;
    border-color: #dc2626;
    color: #ffffff;
}

.flight-route-card {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: #111827;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  cursor: pointer;
  display: grid;
  gap: 0.45rem;
  min-height: 152px;
  align-content: start;
}

.flight-route-card:hover {
  background: #1f2937;
  border-color: #475569;
}

.flight-route-card-line {
  min-width: 0;
}

.flight-route-card-header {
  font-weight: 700;
  color: #f9fafb;
  font-size: 1rem;
  line-height: 1.3;
}

.flight-route-card-times,
.flight-route-card-meta {
  color: #cbd5e1;
  font-size: 0.8rem;
  line-height: 1.3;
}

.flight-route-card-notes {
  color: #94a3b8;
  font-size: 0.92rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

/* app/static/css/app.css */
.flight-drawer {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  height: 100vh;
  transform: translateX(100%);
}

.flight-drawer.is-open {
  transform: translateX(0);
}

/* -------------------------------------------------------------------------
 * Trip drawer + trip UI
 * ---------------------------------------------------------------------- */

.trip-drawer {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  height: 100vh;
  transform: translateX(100%);
  z-index: 24; /* between place (25) and flight (24) drawers */
}

.trip-drawer.is-open {
  transform: translateX(0);
}

/* Stops list */

.trip-stops-list {
  display: grid;
  gap: 6px;
  margin-top: 2px;
}

.trip-stop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  cursor: default;
  user-select: none;
  transition: background 100ms;
}

.trip-stop-item.is-dragging {
  opacity: 0.45;
}

.trip-stop-item.drag-over {
  border-color: rgba(143, 199, 255, 0.55);
  background: rgba(143, 199, 255, 0.06);
}

.trip-stop-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 1.1rem;
  flex: 0 0 auto;
  line-height: 1;
}

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

.trip-stop-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trip-stop-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.trip-stop-new-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(143, 199, 255, 0.18);
  color: var(--link);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
}

.trip-stop-remove {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 6px;
  font-size: 0.75rem;
  padding: 0;
  opacity: 0.55;
  transition: opacity 120ms;
}

.trip-stop-remove:hover {
  opacity: 1;
}

/* Visit picker popup (rendered inside MapLibre popup) */

.trip-visit-popup {
  font-family: Inter, system-ui, sans-serif;
  min-width: 220px;
  display: grid;
  gap: 8px;
}

.trip-visit-popup-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #f9fafb;
}

.trip-visit-popup-section {
  font-size: 0.78rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.trip-visit-popup-list {
  display: grid;
  gap: 5px;
}

.trip-visit-popup-item {
  width: 100%;
  text-align: left;
  background: #1f2937;
  color: #e5e7eb;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  display: grid;
  gap: 2px;
}

.trip-visit-popup-item:hover {
  background: #374151;
  border-color: #6b7280;
}

.trip-visit-date {
  font-weight: 600;
  font-size: 0.88rem;
}

.trip-visit-note {
  font-size: 0.8rem;
  color: #94a3b8;
  display: block;
}

/* =========================================================
   Home page
   ========================================================= */

.home-main {
    padding: 28px 0 48px;
    display: grid;
    gap: 36px;
}

.home-flash {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.home-flash--error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ff9a9a;
}

.home-flash--success {
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.25);
    color: #4ade80;
}

.home-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.home-stat-card {
    background: rgba(26, 31, 38, 0.95);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.home-stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}

.home-stat-label {
    color: var(--muted);
    font-size: 0.88rem;
}

.home-stat-card--clickable {
    cursor: pointer;
    transition: border-color 120ms, background 120ms;
}

.home-stat-card--clickable:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(30, 38, 50, 0.95);
}

.home-stat-card--clickable .home-stat-label::after {
    content: ' \203A';
    opacity: 0.5;
}

/* Region detail panel */
.home-region-detail {
    background: rgba(26, 31, 38, 0.95);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 22px;
    margin-bottom: 6px;
}

.region-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.region-detail-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0;
}

.region-detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 80ms;
}

.region-detail-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.region-detail-name {
    font-weight: 500;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    margin-right: 12px;
}

.region-detail-count {
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.home-search-wrap {
    margin-bottom: 4px;
}

.home-search-input {
    width: 100%;
    background: rgba(26, 31, 38, 0.95);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 120ms;
}

.home-search-input:focus {
    border-color: var(--link);
}

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

.home-section-title {
    margin: 0 0 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

/* Recently visited grid */

.recent-places-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.recent-place-skeleton {
    height: 68px;
    background: rgba(26, 31, 38, 0.6);
    border: 1px solid var(--border);
    border-radius: 12px;
    animation: home-pulse 1.4s ease-in-out infinite;
}

@keyframes home-pulse {
    0%, 100% { opacity: 0.5; }
    50%       { opacity: 1; }
}

.recent-place-card {
    background: rgba(26, 31, 38, 0.95);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    gap: 12px;
    align-items: center;
    position: relative;
    overflow: hidden;
    transition: border-color 120ms, background 120ms;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.recent-place-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(30, 38, 50, 0.95);
}

.recent-place-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--place-color, var(--muted));
    border-radius: 12px 0 0 12px;
}

/* Variant B: cover photo as card background */
.recent-place-card--has-bg {
    position: relative;
    border: none;
    overflow: hidden;
    /* Use a pseudo-element for the background image so the overlay sits between */
}

.recent-place-card--has-bg .recent-place-card-bg {
    position: absolute;
    inset: 0;
    background-image: var(--cover-url);
    background-size: cover;
    background-position: center;
    z-index: 0;
}

.recent-place-card--has-bg .recent-place-card-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to right,
        rgba(17, 20, 24, 0.92) 0%,
        rgba(17, 20, 24, 0.78) 40%,
        rgba(17, 20, 24, 0.50) 100%
    );
}

/* Color bar and content sit above the background */
.recent-place-card--has-bg::before {
    z-index: 2;
}

.recent-place-card--has-bg > :not(.recent-place-card-bg) {
    position: relative;
    z-index: 1;
}

.recent-place-icon-wrap {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--place-color, #a4b0bd) 18%, transparent);
    display: grid;
    place-items: center;
}

.recent-place-icon {
    width: 18px;
    height: 18px;
    filter: invert(1);
    opacity: 0.8;
}

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

.recent-place-name {
    font-weight: 600;
    font-size: 0.93rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-place-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 0.8rem;
    flex-wrap: nowrap;
    overflow: hidden;
}

.recent-place-type {
    color: var(--place-color, var(--muted));
    font-weight: 500;
    white-space: nowrap;
}

.recent-place-dot {
    color: var(--muted);
    opacity: 0.5;
    flex: 0 0 auto;
}

.recent-place-date {
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Explore nav cards */

.home-nav-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.home-nav-card {
    background: rgba(26, 31, 38, 0.95);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 20px;
    display: flex;
    gap: 18px;
    align-items: center;
    color: var(--text);
    text-decoration: none;
    transition: border-color 120ms, background 120ms;
}

.home-nav-card:hover {
    border-color: rgba(143, 199, 255, 0.35);
    background: rgba(30, 38, 50, 0.95);
    text-decoration: none;
}

.home-nav-icon {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(143, 199, 255, 0.08);
    border: 1px solid rgba(143, 199, 255, 0.12);
    display: grid;
    place-items: center;
    color: var(--link);
}

.home-nav-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.home-nav-desc {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 3px;
}

@media (max-width: 900px) {
    .recent-places-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .home-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .home-stat-card {
        padding: 14px 16px;
    }

    .home-stat-value {
        font-size: 1.6rem;
    }

    .region-detail-list {
        grid-template-columns: 1fr;
    }

    .recent-places-grid {
        grid-template-columns: 1fr;
    }

    .home-nav-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   Visits section in place drawer
   ========================================================= */

.visits-section {
  margin-top: 1.25rem;
  border-top: 1px solid #334155;
  padding-top: 1rem;
}

.visits-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.visits-section-header h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #94a3b8;
  text-transform: uppercase;
}

.add-visit-btn {
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
}

.visits-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.visits-loading,
.no-visits-msg {
  font-size: 0.82rem;
  color: #64748b;
}

.visit-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
}

.visit-card--editing {
  border-color: #3b82f6;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.visit-edit-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.visit-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.visit-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
  flex: 1 1 auto;
}

.visit-stars {
  display: flex;
  gap: 1px;
}

.star-display {
  font-size: 0.85rem;
  color: #475569;
}

.star-display.active {
  color: #f59e0b;
}

.visit-trip-badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #1d4ed8;
  color: #bfdbfe;
  font-weight: 600;
}

.visit-card-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.visit-card-actions button {
  font-size: 0.78rem;
  padding: 0.1rem 0.4rem;
  opacity: 0.6;
}

.visit-card-actions button:hover {
  opacity: 1;
}

.visit-note {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: #94a3b8;
  white-space: pre-wrap;
}

/* Visit add/edit form */

.visit-form {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.75rem;
}

.visit-form-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.visit-date-input {
  flex: 1;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 4px;
  color: #e2e8f0;
}

.visit-date-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.star-rating {
  display: flex;
  gap: 2px;
}

.star-rating button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: #475569;
  padding: 0;
  line-height: 1;
  transition: color 0.1s;
}

.star-rating button.active {
  color: #f59e0b;
}

.star-rating button:hover {
  color: #fbbf24;
}

.visit-note-input {
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 4px;
  color: #e2e8f0;
  resize: vertical;
  font-family: inherit;
}

.visit-note-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.visit-form-actions {
  display: flex;
  gap: 0.5rem;
}

.muted-btn {
  color: #64748b;
}

/* =========================================================
   Pending imports review panel
   ========================================================= */

.pending-count-badge {
  display: inline-block;
  background: #f59e0b;
  color: #000;
  border-radius: 9px;
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.5;
  vertical-align: middle;
  margin-left: 4px;
}

.pending-review-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.pending-review-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.15);
  cursor: pointer;
  transition: background 100ms;
}

.pending-review-row:hover {
  background: rgba(245, 158, 11, 0.12);
}

.pending-review-row.is-highlighted {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(245, 158, 11, 0.5);
}

.pending-check {
  margin-top: 2px;
  flex: 0 0 auto;
  accent-color: #f59e0b;
}

.pending-row-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pending-row-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.danger-mini-btn {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.danger-mini-btn:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* =========================================================
   Import page
   ========================================================= */

.import-main {
    padding: 28px 0 60px;
    display: grid;
    gap: 24px;
    max-width: 680px;
}

.import-step {
    background: rgba(26, 31, 38, 0.95);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px 26px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.import-step-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.import-step-num {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(143, 199, 255, 0.15);
    border: 1px solid rgba(143, 199, 255, 0.3);
    color: var(--link);
    font-size: 0.82rem;
    font-weight: 700;
    display: grid;
    place-items: center;
}

.import-step h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.import-step-desc {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
}

/* Drop zone */

.csv-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 120ms, background 120ms;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.csv-drop-zone.is-drag-over,
.csv-drop-zone:hover {
    border-color: rgba(143, 199, 255, 0.5);
    background: rgba(143, 199, 255, 0.04);
}

.csv-drop-icon {
    color: var(--muted);
    opacity: 0.6;
}

.csv-drop-label {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.csv-drop-filename {
    font-size: 0.85rem;
}

.inline-link-btn {
    background: none;
    border: none;
    color: var(--link);
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
}

/* Import row (label + button inline) */

.import-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.import-source-label {
    flex: 1 1 200px;
    min-width: 0;
}

.import-source-input {
    width: 100%;
    background: var(--input-bg, rgba(255,255,255,0.06));
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 6px 10px;
    font-size: 0.9rem;
}

/* Primary button */

.primary-btn {
    background: rgba(143, 199, 255, 0.12);
    border: 1px solid rgba(143, 199, 255, 0.3);
    border-radius: 7px;
    color: var(--link);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 16px;
    white-space: nowrap;
    transition: background 120ms, border-color 120ms;
}

.primary-btn:hover:not(:disabled) {
    background: rgba(143, 199, 255, 0.2);
    border-color: rgba(143, 199, 255, 0.5);
}

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

/* Import result box */

.import-result {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    font-size: 0.88rem;
}

.import-result--error {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* Stats grid */

.import-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
}

.import-stat {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.import-stat.success { border-color: rgba(74, 222, 128, 0.3); }
.import-stat.warn    { border-color: rgba(251, 191, 36, 0.3); }
.import-stat.danger  { border-color: rgba(239, 68, 68, 0.3); }

.import-stat-val {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}

.import-stat.success .import-stat-val { color: #4ade80; }
.import-stat.warn    .import-stat-val { color: #fbbf24; }
.import-stat.danger  .import-stat-val { color: #f87171; }

.import-stat-lbl {
    font-size: 0.72rem;
    color: var(--muted);
}

/* Progress bar */

.resolve-progress-bar-wrap {
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.resolve-progress-bar {
    height: 100%;
    background: var(--link);
    border-radius: 4px;
    transition: width 400ms ease;
}

.resolve-progress-text {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 0;
}

/* Notice box */

.import-notice {
    background: rgba(251, 191, 36, 0.07);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.85rem;
    line-height: 1.6;
}

.import-notice code {
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.82rem;
}

.pending-select-btns {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

/* Rejected places list on import page */
.rejected-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.rejected-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.15);
  font-size: 0.85rem;
}

.rejected-row-title {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unreject-btn {
  flex: 0 0 auto;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 5px;
  color: #4ade80;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 3px 8px;
}

.unreject-btn:hover:not(:disabled) {
  background: rgba(74, 222, 128, 0.2);
}

/* =========================================================
   Shared view mode — hide all edit controls
   ========================================================= */
.shared-view-banner {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
    font-size: 0.88rem;
    max-width: calc(100vw - 2rem);
    box-sizing: border-box;
}

.shared-view-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 8px;
    background: rgba(99, 150, 255, 0.18);
    border: 1px solid rgba(99, 150, 255, 0.35);
    color: #93bbff;
    font-size: 0.82rem;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

.shared-view-back-btn:hover {
    background: rgba(99, 150, 255, 0.28);
}

@media (max-width: 600px) {
    .shared-view-banner {
        flex-direction: column;
        font-size: 0.82rem;
        padding: 0.5rem 0.75rem;
        text-align: center;
        gap: 0.4rem;
    }

    .shared-view-back-btn {
        width: 100%;
    }
}

.shared-view #placeSaveBtn,
.shared-view #placeDeleteBtn,
.shared-view #addVisitBtn,
.shared-view .visit-edit-btn,
.shared-view .visit-delete-btn,
.shared-view .place-form-actions,
.shared-view .floating-near-me-btn,
.shared-view #nearMePanel,
.shared-view #newTripMenuBtn,
.shared-view #placeTypeLockNotice,
.shared-view #addFlightFromPlaceBtn,
.shared-view .place-media-actions,
.shared-view .place-media-editor {
    display: none !important;
}

/* Make form fields read-only in shared view */
.shared-view #placeForm input,
.shared-view #placeForm select,
.shared-view #placeForm textarea {
    pointer-events: none;
    opacity: 0.7;
    -webkit-user-select: none;
    user-select: none;
}

.shared-view #placeNote {
    resize: none;
}

.shared-hide-stars .visit-stars,
.shared-hide-stars .star-rating {
    display: none !important;
}
