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

:root {
    --bg:         #080d18;
    --surface:    rgba(15,23,42,0.85);
    --surface2:   rgba(30,41,59,0.6);
    --border:     rgba(255,255,255,0.09);
    --accent:     #6366f1;
    --accent-h:   #4f46e5;
    --success:    #10b981;
    --danger:     #ef4444;
    --warning:    #f59e0b;
    --text:       #f1f5f9;
    --muted:      #64748b;
    --soft:       #94a3b8;
    --r:          14px;
    --r-sm:       9px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ── GLOBAL BACKGROUND ─────────────────────────────────────── */
.global-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    filter: brightness(0.28) saturate(1.3) blur(1px);
    transition: background-image 1s ease;
}
.global-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: linear-gradient(135deg, rgba(8,13,24,0.55) 0%, rgba(8,13,24,0.35) 100%);
    pointer-events: none;
}

/* ── SCREENS ───────────────────────────────────────────────── */
.screen {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.screen.hidden { display: none; }

/* ── GLASS CARD ────────────────────────────────────────────── */
.glass-card {
    background: rgba(10,18,35,0.78);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 2.25rem;
    box-shadow: 0 32px 80px rgba(0,0,0,0.55);
    width: 100%;
    max-width: 440px;
}

/* ── BRAND ─────────────────────────────────────────────────── */
.brand-logo-wrap { display: flex; justify-content: center; margin-bottom: 1rem; }
.brand-logo { height: 110px; width: auto; object-fit: contain; }
.header-logo { height: 52px; width: auto; object-fit: contain; }
.brand-title,
.landing-title { font-size: 1.75rem; font-weight: 700; text-align: center; color: #fff; letter-spacing: -0.02em; margin-bottom: 0.35rem; }
.brand-sub    { text-align: center; color: var(--soft); font-size: 0.9rem; margin-bottom: 1.6rem; }

/* ── AUTH ──────────────────────────────────────────────────── */
.auth-card { /* inherits glass-card */ }

#googleBtnWrap { margin-bottom: 0; }
#googleBtnWrap > div:first-child { display: flex; justify-content: center; }

.divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.1rem 0;
    color: var(--muted);
    font-size: 0.82rem;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-tabs {
    display: flex;
    background: rgba(255,255,255,0.05);
    border-radius: var(--r-sm);
    padding: 3px;
    margin-bottom: 1.1rem;
}
.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--soft);
    padding: 0.45rem;
    border-radius: calc(var(--r-sm) - 2px);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
    font-family: inherit;
}
.auth-tab.active { background: var(--accent); color: #fff; }

.auth-error {
    color: #f87171;
    font-size: 0.83rem;
    text-align: center;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(239,68,68,0.1);
    border-radius: var(--r-sm);
}
.auth-error.hidden { display: none; }

/* ── LANDING ───────────────────────────────────────────────── */
.landing-card { /* inherits glass-card */ }

.landing-search-wrap {
    position: relative;
    margin-bottom: 0;
}
.search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
    font-size: 0.95rem;
}
.landing-search-wrap input {
    padding-left: 2.5rem !important;
    margin-bottom: 0;
}

.destination-picked {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    animation: fadeUp 0.3s ease;
}
.destination-picked.hidden { display: none; }
.picked-name {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(99,102,241,0.12);
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: var(--r-sm);
    padding: 0.6rem 1rem;
    font-weight: 600;
    color: #a5b4fc;
    font-size: 0.92rem;
}
.picked-dot {
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px var(--accent);
}

.landing-date-row { display: flex; flex-direction: column; gap: 0.3rem; }
.landing-date-label { font-size: 0.8rem; color: var(--muted); }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn-start {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--accent);
    border: none;
    border-radius: var(--r-sm);
    color: #fff;
    padding: 0.85rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    font-family: inherit;
    letter-spacing: 0.01em;
}
.btn-start:hover { background: var(--accent-h); transform: translateY(-1px); }

.btn-primary {
    background: var(--accent);
    border: none;
    border-radius: var(--r-sm);
    color: #fff;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.15s;
    white-space: nowrap;
    font-family: inherit;
}
.btn-primary:hover { background: var(--accent-h); }

.btn-secondary {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--soft);
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}
.btn-secondary:hover { border-color: rgba(255,255,255,0.2); color: var(--text); }

.btn-danger {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: var(--r-sm);
    color: #f87171;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s;
    font-family: inherit;
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: background 0.15s;
    font-family: inherit;
}
.btn-ghost:hover { background: rgba(99,102,241,0.1); }

.btn-full { width: 100%; }

.delete-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.95rem;
    transition: color 0.15s, background 0.15s;
    font-family: inherit;
}
.delete-btn:hover { color: var(--danger); background: rgba(239,68,68,0.08); }

/* ── HEADER ────────────────────────────────────────────────── */
#app { position: relative; z-index: 10; }

header {
    background: rgba(8,13,24,0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 200;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 0.7rem 0;
    flex-wrap: wrap;
}
.header-brand { display: flex; align-items: center; gap: 0.65rem; font-size: 1.3rem; }
.header-title { font-size: 0.95rem; font-weight: 700; line-height: 1.2; }
.header-destination { font-size: 0.75rem; color: var(--accent); font-weight: 500; }

.header-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--soft);
}
.header-user img {
    width: 28px; height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    display: block;
}
.header-avatar-wrap {
    width: 28px; height: 28px; border-radius: 50%;
    flex-shrink: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.header-avatar-init {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.68rem; font-weight: 700;
    border: 1px solid rgba(99,102,241,0.4);
}
.header-user button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: var(--r-sm);
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: inherit;
    transition: all 0.15s;
}
.header-user button:hover { border-color: rgba(255,255,255,0.2); color: var(--text); }

nav { display: flex; gap: 0.3rem; }
.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
    padding: 0.38rem 1rem;
    border-radius: 99px;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 500;
    transition: all 0.15s;
    font-family: inherit;
}
.tab-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── MAIN ──────────────────────────────────────────────────── */
main {
    max-width: 1200px;
    margin: 1.75rem auto;
    padding: 0 1.5rem;
}
.tab { display: none; }
.tab.active { display: block; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
    background: rgba(10,18,35,0.72);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 1.4rem;
    margin-bottom: 1.1rem;
}
.card h2 { font-size: 0.97rem; font-weight: 600; margin-bottom: 1rem; letter-spacing: -0.01em; }

/* ── TWO COLUMN ────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }

/* ── INPUTS ────────────────────────────────────────────────── */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
select, textarea {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    padding: 0.62rem 0.85rem;
    font-size: 0.9rem;
    margin-bottom: 0.7rem;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    background: rgba(255,255,255,0.07);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
select option { background: #1a2436; }

.row { display: flex; gap: 0.6rem; }
.row input { flex: 1; }

/* ── SUGGESTIONS DROPDOWN ──────────────────────────────────── */
.suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: rgba(15,25,45,0.97);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    list-style: none;
    padding: 0.3rem 0;
    z-index: 9999;
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    max-height: 230px;
    overflow-y: auto;
}
.suggestions.hidden { display: none; }
.suggestions li {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.55rem 0.85rem;
    cursor: pointer;
    font-size: 0.84rem;
    color: var(--soft);
    transition: background 0.12s, color 0.12s;
    line-height: 1.4;
}
.suggestions li:hover { background: rgba(99,102,241,0.12); color: var(--text); }

/* ── PEOPLE ────────────────────────────────────────────────── */
.add-form { display: flex; gap: 0.55rem; align-items: flex-start; margin-bottom: 0.75rem; }
.add-form input { margin-bottom: 0; flex: 1; }
.item-list { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; }
.item-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
}

/* ── TRIP MEMBERS ──────────────────────────────────────────── */
.members-list { display: flex; flex-direction: column; gap: 0.4rem; }
.member-item {
    display: flex; align-items: center; gap: 0.65rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.55rem 0.75rem;
}
.member-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82rem; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 0.9rem; font-weight: 500; }
.member-role { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }
.member-role.owner { color: var(--warning); }

/* ── INVITE PANEL ──────────────────────────────────────────── */
.invite-panel { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.invite-panel.hidden { display: none; }
.invite-link-row { display: flex; gap: 0.4rem; }
.invite-link-row input { flex: 1; margin-bottom: 0; font-size: 0.8rem; }
.qr-box {
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
    background: #f8fafc; border-radius: var(--r-sm);
    padding: 1.25rem; margin-top: 0.25rem;
}
.qr-box.hidden { display: none; }
.qr-hint { font-size: 0.78rem; color: #475569; font-weight: 500; }

/* ── EMOJI PICKER ──────────────────────────────────────────── */
.exp-title-wrap { margin-bottom: 0.7rem; }
.exp-title-row { display: flex; gap: 0.4rem; align-items: center; }
.exp-title-row input { margin-bottom: 0; flex: 1; }
.emoji-toggle-btn {
    flex-shrink: 0;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    width: 38px; height: 38px;
    cursor: pointer; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.emoji-toggle-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.emoji-picker {
    background: rgba(10,18,40,0.97);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.75rem;
    margin-top: 0.3rem;
    max-height: 240px;
    overflow-y: auto;
}
.emoji-picker.hidden { display: none; }
.emoji-cat { margin-bottom: 0.65rem; }
.emoji-cat:last-child { margin-bottom: 0; }
.emoji-cat-label {
    font-size: 0.7rem; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 0.35rem; font-weight: 600;
}
.emoji-grid { display: flex; flex-wrap: wrap; gap: 0.15rem; }
.emoji-btn {
    background: transparent; border: none; cursor: pointer;
    font-size: 1.3rem; padding: 0.22rem;
    border-radius: 6px; line-height: 1;
    transition: background 0.1s, transform 0.1s;
}
.emoji-btn:hover { background: rgba(255,255,255,0.08); transform: scale(1.25); }

/* ── EXPENSES ──────────────────────────────────────────────── */
.split-section { margin-bottom: 0.7rem; }
.split-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.45rem; flex-wrap: wrap; gap: 0.35rem; }

.split-mode-toggle { display: flex; background: rgba(255,255,255,0.05); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.split-mode-btn {
    background: transparent; border: none; color: var(--muted);
    padding: 0.22rem 0.6rem; border-radius: calc(var(--r-sm) - 2px);
    cursor: pointer; font-size: 0.78rem; font-weight: 500;
    transition: all 0.15s; font-family: inherit;
}
.split-mode-btn.active { background: var(--accent); color: #fff; }

.custom-split-row {
    display: flex; align-items: center; gap: 0.5rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.3rem;
}
.custom-split-label { display: flex; align-items: center; gap: 0.4rem; flex: 1; font-size: 0.88rem; cursor: pointer; }
.custom-split-label input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); }
.custom-amount-input { width: 80px !important; margin-bottom: 0 !important; padding: 0.35rem 0.5rem !important; font-size: 0.84rem !important; text-align: right; flex-shrink: 0; }

.custom-split-total {
    font-size: 0.8rem; padding: 0.35rem 0.65rem;
    border-radius: var(--r-sm); margin-top: 0.3rem; font-weight: 500;
}
.custom-split-total.ok   { background: rgba(16,185,129,0.1); color: #34d399; border: 1px solid rgba(16,185,129,0.25); }
.custom-split-total.warn { background: rgba(245,158,11,0.1); color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); }
.custom-split-total.hidden { display: none; }
.field-label { font-size: 0.8rem; color: var(--muted); }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.checkbox-group label {
    display: flex; align-items: center; gap: 0.35rem;
    background: rgba(255,255,255,0.04); border: 1px solid var(--border);
    border-radius: 99px; padding: 0.28rem 0.7rem;
    cursor: pointer; font-size: 0.83rem; transition: all 0.15s;
}
.checkbox-group label:hover { border-color: var(--accent); }
.checkbox-group input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); }

.expense-item {
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    border-radius: var(--r-sm); padding: 0.8rem 0.9rem; margin-bottom: 0.5rem;
    display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem;
}
.expense-info .title { font-weight: 600; font-size: 0.9rem; }
.expense-info .meta  { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.expense-info .note  { font-size: 0.78rem; color: var(--soft); font-style: italic; margin-top: 0.15rem; }
.expense-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; }
.expense-amount { font-size: 1.05rem; font-weight: 700; color: var(--success); white-space: nowrap; }

/* ── BALANCES ──────────────────────────────────────────────── */
.balance-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.65rem 0.85rem; background: rgba(255,255,255,0.03);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    margin-bottom: 0.4rem; font-size: 0.9rem;
}
.balance-amount { font-weight: 700; }
.balance-pos  { color: var(--success); }
.balance-neg  { color: #f87171; }
.balance-zero { color: var(--muted); }

.settlement-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 0.85rem; background: rgba(255,255,255,0.03);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    margin-bottom: 0.4rem; font-size: 0.88rem;
}
.settlement-item .arrow  { color: var(--muted); }
.settlement-item .amount { font-weight: 700; color: var(--warning); margin-left: auto; }

/* ── ROUTES ────────────────────────────────────────────────── */
.route-layout {
    display: grid; grid-template-columns: 290px 1fr;
    gap: 1.1rem; margin-bottom: 1.1rem; align-items: start;
}
.route-map-wrap { position: sticky; top: 68px; }
#map { height: 560px; border-radius: var(--r); border: 1px solid var(--border); z-index: 1; }

.place-search-wrap { position: relative; margin-bottom: 0.7rem; }
.place-search-wrap input { margin-bottom: 0; }
.route-actions { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }

.hint { font-size: 0.79rem; color: var(--muted); margin-top: 0.65rem; }
#drawBtn.active { background: var(--success); }
#drawBtn.active:hover { background: #059669; }

.waypoint-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.7rem;
}
.waypoint-header h2 { margin-bottom: 0; }

.badge {
    background: var(--accent); color: #fff;
    border-radius: 99px; font-size: 0.7rem;
    padding: 0.1rem 0.45rem; font-weight: 600; margin-left: 0.3rem;
}
.route-distance {
    background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.25);
    color: #a5b4fc; border-radius: var(--r-sm);
    padding: 0.32rem 0.65rem; font-size: 0.8rem; font-weight: 600;
}
.route-distance.hidden { display: none; }

.waypoint-list {
    list-style: none; display: flex; flex-direction: column;
    gap: 0.3rem; max-height: 270px; overflow-y: auto;
}
.waypoint-list li {
    display: flex; align-items: flex-start; gap: 0.45rem;
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    border-radius: var(--r-sm); padding: 0.45rem 0.6rem; font-size: 0.82rem;
}
.wp-number {
    background: var(--accent); color: #fff; border-radius: 50%;
    width: 20px; height: 20px; min-width: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.66rem; font-weight: 700; margin-top: 1px;
}
.wp-address { flex: 1; color: var(--soft); line-height: 1.4; }
.wp-loading  { color: var(--muted); font-style: italic; }

.route-item {
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    border-radius: var(--r-sm); padding: 0.85rem 0.95rem; margin-bottom: 0.5rem;
    transition: border-color 0.15s;
}
.route-item:hover { border-color: rgba(255,255,255,0.15); }
.route-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.route-name   { font-weight: 600; font-size: 0.92rem; }
.route-desc   { font-size: 0.8rem; color: var(--soft); margin-bottom: 0.3rem; }
.route-meta   { font-size: 0.76rem; color: var(--muted); }
.route-btns   { display: flex; gap: 0.35rem; }

@media (max-width: 800px) {
    .route-layout { grid-template-columns: 1fr; }
    .route-map-wrap { position: static; }
    #map { height: 350px; }
}

/* ── MODAL ─────────────────────────────────────────────────── */
.modal {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(6px);
}
.modal.hidden { display: none; }
.modal-box { max-width: 340px; width: 90%; text-align: center; }
.modal-box p { margin-bottom: 1.25rem; line-height: 1.6; }

/* ── TRIP SELECTOR ─────────────────────────────────────────── */
.trip-selector-card { max-width: 520px; }
.trip-selector-list {
    display: flex; flex-direction: column; gap: 0.5rem;
    margin-bottom: 1rem; max-height: 340px; overflow-y: auto;
}
.trip-item {
    display: flex; align-items: center; gap: 0.75rem;
    background: rgba(255,255,255,0.04); border: 1px solid var(--border);
    border-radius: var(--r-sm); padding: 0.85rem 1rem; transition: border-color 0.15s;
}
.trip-item:hover { border-color: rgba(99,102,241,0.4); }
.trip-item-info  { flex: 1; min-width: 0; }
.trip-item-name  { font-weight: 600; font-size: 0.92rem; }
.trip-item-dest  { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.trip-item-btns  { display: flex; gap: 0.35rem; flex-shrink: 0; }

/* ── HEADER TRIP SWITCHER ───────────────────────────────────── */
.header-trip-wrap { position: relative; display: flex; align-items: center; gap: 0.5rem; }
.header-trip-btn {
    display: flex; align-items: center; gap: 0.4rem;
    background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.3);
    border-radius: var(--r-sm); color: #a5b4fc;
    padding: 0.35rem 0.75rem; cursor: pointer;
    font-size: 0.83rem; font-weight: 500; transition: all 0.15s; font-family: inherit;
    max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-trip-btn:hover { background: rgba(99,102,241,0.2); border-color: rgba(99,102,241,0.5); }
.trip-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 220px; background: rgba(10,20,40,0.97);
    backdrop-filter: blur(20px); border: 1px solid var(--border);
    border-radius: var(--r-sm); box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    z-index: 300; overflow: hidden;
}
.trip-dropdown.hidden { display: none; }
.trip-dropdown-item {
    display: flex; align-items: center; padding: 0.6rem 0.85rem;
    cursor: pointer; font-size: 0.84rem; color: var(--soft);
    transition: background 0.12s; gap: 0.5rem;
}
.trip-dropdown-item:hover { background: rgba(99,102,241,0.1); color: var(--text); }
.trip-dropdown-item.active { color: #a5b4fc; font-weight: 600; }
.trip-dd-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-dropdown-divider { height: 1px; background: var(--border); margin: 0.25rem 0; }
.trip-dropdown-new {
    padding: 0.6rem 0.85rem; color: var(--accent);
    font-size: 0.84rem; font-weight: 500; cursor: pointer;
}
.trip-dropdown-new:hover { background: rgba(99,102,241,0.1); }

/* Countdown chip in header */
.trip-countdown {
    font-size: 0.78rem; font-weight: 600;
    padding: 0.28rem 0.65rem; border-radius: 99px; white-space: nowrap;
}
.trip-countdown.hidden { display: none; }
.countdown-future { background: rgba(99,102,241,0.13); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.3); }
.countdown-soon   { background: rgba(245,158,11,0.13); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.countdown-today  { background: rgba(16,185,129,0.13); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.countdown-past   { background: rgba(255,255,255,0.05); color: var(--muted); border: 1px solid var(--border); }
.cd-num  { font-variant-numeric: tabular-nums; font-weight: 700; }
.cd-unit { font-weight: 400; opacity: 0.7; margin-right: 0.2rem; font-size: 0.72em; }

/* Date row inside trip dropdown */
.trip-dd-date-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.85rem; border-top: 1px solid var(--border);
}
.trip-dd-date-input {
    flex: 1; background: rgba(255,255,255,0.05);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    color: var(--text); padding: 0.3rem 0.5rem;
    font-size: 0.8rem; margin-bottom: 0; font-family: inherit; cursor: pointer;
}
.trip-dd-date-input:focus { border-color: var(--accent); outline: none; }
.trip-dd-del {
    background: transparent; border: none; color: var(--muted);
    cursor: pointer; font-size: 0.8rem; padding: 0.15rem 0.35rem;
    border-radius: 4px; line-height: 1; transition: color 0.15s, background 0.15s;
    font-family: inherit; flex-shrink: 0;
}
.trip-dd-del:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

/* ── MEDIA ────────────────────────────────────────────────── */
.media-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.media-header-row h2 { margin-bottom: 0; }
.storage-bar-wrap { margin-bottom: 0.9rem; }
.storage-bar-label { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.35rem; }
.storage-pct { color: var(--soft); margin-left: 0.25rem; }
.storage-bar-track {
    height: 6px; background: rgba(255,255,255,0.07);
    border-radius: 99px; overflow: hidden;
}
.storage-bar-fill {
    height: 100%; width: 0%; background: var(--accent);
    border-radius: 99px; transition: width 0.4s ease, background 0.3s;
}

.upload-drop-area {
    border: 2px dashed var(--border); border-radius: var(--r);
    padding: 1.75rem 1rem; text-align: center; cursor: pointer;
    transition: border-color 0.2s, background 0.2s; margin-bottom: 0.75rem;
}
.upload-drop-area:hover, .upload-drop-area.drag-over {
    border-color: var(--accent); background: rgba(99,102,241,0.06);
}
.drop-icon { font-size: 2rem; margin-bottom: 0.45rem; }
.drop-text { font-size: 0.9rem; font-weight: 500; margin-bottom: 0.25rem; }
.drop-sub  { font-size: 0.77rem; color: var(--muted); }

.file-preview {
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    border-radius: var(--r-sm); padding: 0.6rem; margin-bottom: 0.7rem; text-align: center;
}
.file-preview.hidden { display: none; }
.file-preview-media {
    max-width: 100%; max-height: 160px; border-radius: calc(var(--r-sm) - 2px);
    display: block; margin: 0 auto 0.4rem; object-fit: contain;
}
.file-preview-name { font-size: 0.78rem; color: var(--muted); word-break: break-all; }
.multi-preview-grid { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; margin-bottom: 0.45rem; }
.multi-thumb {
    width: 58px; height: 58px; border-radius: 6px; overflow: hidden;
    background: rgba(255,255,255,0.06); border: 1px solid var(--border);
    position: relative; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.multi-thumb img, .multi-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.multi-thumb span { position: absolute; font-size: 1.1rem; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.7); }
.multi-thumb-more { font-size: 0.82rem; font-weight: 700; color: var(--soft); border-style: dashed; }

.upload-progress { margin-bottom: 0.7rem; }
.upload-progress.hidden { display: none; }
.progress-track {
    height: 6px; background: rgba(255,255,255,0.07);
    border-radius: 99px; overflow: hidden; margin-bottom: 0.35rem;
}
.progress-fill {
    height: 100%; width: 0%; background: var(--accent);
    border-radius: 99px; transition: width 0.15s linear;
}
.progress-text { font-size: 0.78rem; color: var(--muted); text-align: center; }

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.65rem;
}
.media-item {
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    border-radius: var(--r-sm); overflow: hidden; cursor: pointer;
    transition: border-color 0.15s, transform 0.15s; position: relative;
}
.media-item:hover { border-color: rgba(99,102,241,0.5); transform: translateY(-2px); }
.media-thumb {
    width: 100%; aspect-ratio: 1; background: rgba(255,255,255,0.04);
    overflow: hidden; position: relative;
    display: flex; align-items: center; justify-content: center;
}
.media-thumb img,
.media-thumb-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb.thumb-error::after { content: '🖼️'; font-size: 2rem; position: absolute; }
.media-play-icon {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.35); color: #fff; font-size: 1.75rem; pointer-events: none;
}
.media-caption-label {
    font-size: 0.78rem; color: var(--soft); padding: 0.3rem 0.5rem 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-meta-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.2rem 0.5rem 0.35rem; font-size: 0.72rem; color: var(--muted);
}
.media-del-btn {
    background: transparent; border: none; color: var(--muted);
    cursor: pointer; font-size: 0.85rem; padding: 0.1rem 0.2rem;
    border-radius: 3px; transition: color 0.15s; font-family: inherit;
}
.media-del-btn:hover { color: var(--danger); }

/* Lightbox */
.media-lightbox {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(8px); padding: 1.5rem;
}
.media-lightbox.hidden { display: none; }
.lightbox-inner {
    position: relative; max-width: 90vw; max-height: 90vh;
    display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
}
.lightbox-content img {
    max-width: 85vw; max-height: 80vh; border-radius: var(--r-sm); display: block;
}
.lightbox-content iframe {
    width: 80vw; max-width: 960px; height: 54vw; max-height: 540px;
    border: none; border-radius: var(--r-sm);
}
.lightbox-close {
    position: absolute; top: -2.5rem; right: 0;
    background: rgba(255,255,255,0.12); border: none; color: #fff;
    width: 36px; height: 36px; border-radius: 50%;
    cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s; font-family: inherit;
}
.lightbox-close:hover { background: rgba(255,255,255,0.22); }
.lightbox-caption { color: var(--soft); font-size: 0.88rem; text-align: center; }

/* ── MISC ──────────────────────────────────────────────────── */
.empty { color: var(--muted); font-style: italic; text-align: center; padding: 2rem 0; font-size: 0.88rem; }
.hidden { display: none !important; }

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

/* ── LIGHT THEME ───────────────────────────────────────────── */
body.light-theme {
    --bg:       #eef2f7;
    --surface:  rgba(255,255,255,0.88);
    --surface2: rgba(240,244,250,0.75);
    --border:   rgba(0,0,0,0.10);
    --text:     #1e293b;
    --muted:    #64748b;
    --soft:     #475569;
}
body.light-theme { background: var(--bg); color: var(--text); }

body.light-theme .global-bg {
    filter: brightness(0.55) saturate(1.2) blur(2px);
}
body.light-theme .global-overlay {
    background: linear-gradient(135deg, rgba(238,242,247,0.62) 0%, rgba(238,242,247,0.40) 100%);
}
body.light-theme .glass-card {
    background: rgba(255,255,255,0.86);
    border-color: rgba(0,0,0,0.10);
    box-shadow: 0 24px 60px rgba(0,0,0,0.12);
}
body.light-theme header {
    background: rgba(255,255,255,0.88);
    border-color: rgba(0,0,0,0.10);
}
body.light-theme .card {
    background: rgba(255,255,255,0.82);
    border-color: rgba(0,0,0,0.09);
}
body.light-theme input,
body.light-theme select,
body.light-theme textarea {
    background: rgba(0,0,0,0.04);
    color: var(--text);
    border-color: rgba(0,0,0,0.14);
}
body.light-theme input::placeholder,
body.light-theme textarea::placeholder { color: var(--muted); }
body.light-theme .tab-btn { color: var(--soft); }
body.light-theme .tab-btn.active { background: var(--accent); color: #fff; }
body.light-theme .trip-dropdown {
    background: rgba(255,255,255,0.96);
    border-color: rgba(0,0,0,0.12);
}
body.light-theme .trip-dd-item:hover { background: rgba(0,0,0,0.05); }
body.light-theme .header-user button { color: var(--soft); border-color: rgba(0,0,0,0.14); }
body.light-theme .header-user button:hover { color: var(--text); border-color: rgba(0,0,0,0.25); }
body.light-theme .member-chip { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.10); color: var(--text); }
body.light-theme .modal { background: rgba(0,0,0,0.4); }

/* ── SETTINGS MODAL ────────────────────────────────────────── */
.settings-modal-box {
    max-width: 420px; width: 94%; text-align: left;
    max-height: 90vh; overflow-y: auto;
}
.settings-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem;
}
.settings-header h2 { font-size: 1.1rem; font-weight: 700; margin: 0; }
.settings-close-btn {
    background: rgba(255,255,255,0.08); border: 1px solid var(--border);
    color: var(--soft); width: 30px; height: 30px; border-radius: 50%;
    cursor: pointer; font-size: 0.85rem; display: flex; align-items: center;
    justify-content: center; transition: all 0.15s; font-family: inherit;
}
.settings-close-btn:hover { background: rgba(255,255,255,0.14); color: var(--text); }

.settings-section { margin-bottom: 1.4rem; }
.settings-section-title {
    font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.65rem;
}
.settings-select { width: 100%; margin-bottom: 0; }

/* Theme toggle */
.theme-toggle-row { display: flex; gap: 0.5rem; }
.theme-btn {
    flex: 1; padding: 0.55rem 0.5rem; border-radius: var(--r-sm);
    border: 1px solid var(--border); background: rgba(255,255,255,0.05);
    color: var(--soft); cursor: pointer; font-size: 0.88rem; font-weight: 500;
    transition: all 0.18s; font-family: inherit;
}
.theme-btn:hover { border-color: var(--accent); color: var(--text); }
.theme-btn.active {
    background: var(--accent); border-color: var(--accent);
    color: #fff; font-weight: 600;
}

/* Community averages */
.avg-settings {
    background: rgba(255,255,255,0.04); border: 1px solid var(--border);
    border-radius: var(--r-sm); overflow: hidden;
}
.avg-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.55rem 0.85rem; font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}
.avg-row:last-child { border-bottom: none; }
.avg-label { color: var(--muted); }
.avg-value { font-weight: 600; color: var(--text); }

/* Settings gear button in header */
.settings-gear-btn {
    background: transparent; border: 1px solid var(--border);
    color: var(--muted); width: 28px; height: 28px; border-radius: 50%;
    cursor: pointer; font-size: 0.9rem; display: flex; align-items: center;
    justify-content: center; transition: all 0.15s; padding: 0; font-family: inherit;
}
.settings-gear-btn:hover { border-color: var(--accent); color: var(--accent); }

body.light-theme .settings-modal-box { background: rgba(255,255,255,0.95); }
body.light-theme .theme-btn { background: rgba(0,0,0,0.04); }
body.light-theme .avg-settings { background: rgba(0,0,0,0.03); }

@media (max-width: 600px) {
    .header-inner { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    main { padding: 0 1rem; margin: 1.25rem auto; }
    .glass-card { padding: 1.5rem; }
    .landing-title, .brand-title { font-size: 1.45rem; }
    nav { flex-wrap: wrap; }
    .media-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ── TRANSPORT MODE ────────────────────────────────────────── */
.transport-mode-row {
    display: flex; gap: 0.4rem; margin-bottom: 0.75rem;
}
.mode-btn {
    flex: 1; padding: 0.45rem 0.25rem; border-radius: var(--r-sm);
    border: 1px solid var(--border); background: rgba(255,255,255,0.05);
    color: var(--soft); cursor: pointer; font-size: 0.82rem; font-weight: 500;
    transition: all 0.18s; font-family: inherit;
}
.mode-btn:hover { border-color: var(--accent); color: var(--text); }
.mode-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ── MAP OVERLAY CONTROLS ──────────────────────────────────── */
.route-map-wrap { position: relative; }
.map-controls-overlay {
    position: absolute; top: 10px; left: 10px; z-index: 500;
    display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.map-layer-btns {
    display: flex; flex-direction: column; gap: 2px;
    background: rgba(10,18,35,0.85); border: 1px solid var(--border);
    border-radius: var(--r-sm); overflow: hidden; pointer-events: all;
    backdrop-filter: blur(10px);
}
.layer-btn {
    background: transparent; border: none; color: var(--soft);
    padding: 0.4rem 0.55rem; cursor: pointer; font-size: 1rem; line-height: 1;
    transition: background 0.15s, color 0.15s; font-family: inherit;
    display: flex; align-items: center; justify-content: center;
}
.layer-btn:hover  { background: rgba(255,255,255,0.08); color: var(--text); }
.layer-btn.active { background: var(--accent); color: #fff; }
.map-fullscreen-btn {
    background: rgba(10,18,35,0.85); border: 1px solid var(--border);
    color: var(--soft); width: 34px; height: 34px; border-radius: var(--r-sm);
    cursor: pointer; font-size: 1rem; display: flex; align-items: center;
    justify-content: center; transition: all 0.15s; pointer-events: all;
    backdrop-filter: blur(10px); font-family: inherit;
}
.map-fullscreen-btn:hover { border-color: var(--accent); color: var(--accent); }
.map-fullscreen {
    position: fixed !important; inset: 0 !important; z-index: 1000 !important;
    top: 0 !important; left: 0 !important; width: 100vw !important; height: 100vh !important;
}
.map-fullscreen #map { height: 100vh !important; border-radius: 0 !important; }

/* ── DIRECTIONS ─────────────────────────────────────────────── */
.directions-list {
    list-style: none; display: flex; flex-direction: column;
    gap: 0.2rem; max-height: 280px; overflow-y: auto;
}
.direction-step {
    display: flex; align-items: flex-start; gap: 0.5rem;
    padding: 0.4rem 0.5rem; border-radius: 6px;
    transition: background 0.12s; font-size: 0.82rem;
}
.direction-step:hover { background: rgba(255,255,255,0.04); }
.dir-icon  { flex-shrink: 0; font-size: 1rem; width: 20px; text-align: center; }
.dir-text  { flex: 1; color: var(--text); line-height: 1.4; }
.dir-dist  { flex-shrink: 0; font-size: 0.75rem; color: var(--muted); white-space: nowrap; align-self: center; }


/* ── ELEVATION ──────────────────────────────────────────────── */
.elevation-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.65rem;
}
.elevation-header h2 { margin-bottom: 0; }
.elevation-stats { font-size: 0.78rem; color: var(--muted); }
.elevation-canvas { width: 100%; display: block; border-radius: var(--r-sm); }

/* ── ROUTE COLOR DOT ────────────────────────────────────────── */
.route-color-dot {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; margin-right: 0.4rem; flex-shrink: 0;
    vertical-align: middle;
}

/* Light theme overrides for new elements */
body.light-theme .map-layer-btns,
body.light-theme .map-fullscreen-btn { background: rgba(255,255,255,0.92); }
body.light-theme .layer-btn { color: var(--muted); }
body.light-theme .mode-btn  { background: rgba(0,0,0,0.04); }
