/* ─────────────────────────────────────────────────────────────────────────────
   Boxi Tracker — Design System
   Material Design 3 inspired · Dark · Minimal
───────────────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');
/* Material Symbols Rounded is loaded via a <link> in each page's <head>
   instead of @import here — @import inside CSS is deferred and was
   visibly painting the literal ligature names ("shield_person") before
   the font arrived. */

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { display: block; }

/* ── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
    /* Surfaces — layered dark (zinc scale) */
    --bg:   #09090b;         /* app shell */
    --bg2:  #18181b;         /* cards / panels */
    --bg3:  #27272a;         /* inputs / chips / elevated surfaces */
    --bg4:  #3f3f46;         /* active hover bg, solid border */

    /* Borders */
    --border: rgba(255,255,255,.08);

    /* Typography */
    --text:       #fafafa;
    --text-muted: #a1a1aa;

    /* Primary — indigo */
    --primary:      #6366f1;
    --primary-h:    #4f46e5;
    --primary-dim:  rgba(99,102,241,.13);
    --primary-ring: rgba(99,102,241,.35);

    /* Semantic */
    --green:  #4ade80;
    --yellow: #fbbf24;
    --red:    #f87171;

    /* Shape */
    --r-xs:   6px;
    --r-sm:   10px;
    --radius: 16px;
    --r-full: 9999px;

    /* Elevation */
    --shadow-sm: 0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.3);
    --shadow:    0 4px 20px rgba(0,0,0,.45), 0 1px 4px rgba(0,0,0,.3);
    --shadow-lg: 0 12px 48px rgba(0,0,0,.65), 0 4px 16px rgba(0,0,0,.4);

    /* Motion */
    --ease:        cubic-bezier(.4, 0, .2, 1);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);   /* gentle overshoot for delight */
    --dur:         .18s;
    --dur-spring:  .32s;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
html {
    font-size: 15px;
    scroll-behavior: smooth;
}
body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--dur) var(--ease);
}
a:hover { color: var(--primary-h); text-decoration: underline; }

h1 {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.2;
}
h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -.015em;
    margin-bottom: .75rem;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar              { width: 7px; height: 7px; }
::-webkit-scrollbar-track        { background: var(--bg2); }
::-webkit-scrollbar-thumb        { background: var(--bg4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover  { background: #52525b; }

/* ── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
    background: rgba(9,9,11,.88);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    /* iOS standalone: the page draws under the status bar (status-bar-style
       black-translucent), so add the safe-area inset on top. Sides use the
       inset too so landscape iPhones with a notch don't clip the brand. */
    padding:
        max(.55rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right))
        .55rem                                max(1.5rem, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    /* Above Leaflet's panes (≤700) and default control bar (~1000) so the
       mobile dropdown menu never gets covered by the map on the dashboard. */
    z-index: 1100;
    gap: 1rem;
}
.nav-brand {
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -.025em;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    transition: opacity var(--dur);
}
.nav-brand:hover { text-decoration: none; opacity: .75; }

.nav-links {
    display: flex;
    gap: .15rem;
    align-items: center;
    font-size: .875rem;
    flex-wrap: wrap;
}
.nav-links a {
    color: var(--text-muted);
    padding: .35rem .7rem;
    border-radius: var(--r-sm);
    transition: color var(--dur), background var(--dur);
    font-weight: 500;
}
.nav-links a:hover {
    color: var(--text);
    background: rgba(255,255,255,.07);
    text-decoration: none;
}
.nav-links a.active {
    background: var(--primary-dim);
    color: #a5b4fc;
}
.nav-logout {
    color: var(--text-muted) !important;
    margin-left: .4rem;
    padding-left: .85rem !important;
    border-left: 1px solid var(--border);
}
.nav-logout:hover {
    color: var(--red) !important;
    background: rgba(248,113,113,.08) !important;
}

/* Hamburger toggle — mobile-only, hidden by default. The mobile media
   query flips display:flex and the open/close icon swap is driven by the
   .navbar.is-open class added by app.js. */
.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: var(--r-sm);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background var(--dur), border-color var(--dur);
}
.nav-toggle:hover     { background: rgba(255,255,255,.07); }
.nav-toggle:active    { background: rgba(255,255,255,.12); }
.nav-toggle .ms       { font-size: 1.5rem; line-height: 1; }
.nav-toggle-close     { display: none; }
.navbar.is-open .nav-toggle             { background: rgba(99,102,241,.12); border-color: var(--primary-ring); }
.navbar.is-open .nav-toggle-open        { display: none; }
.navbar.is-open .nav-toggle-close       { display: inline-block; }

/* ── Container ─────────────────────────────────────────────────────────────── */
.container {
    max-width: 1120px;
    margin: 0 auto;
    padding:
        2rem max(1.5rem, env(safe-area-inset-right))
        max(2rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}

/* ── Login Page ─────────────────────────────────────────────────────────────── */
.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    /* iOS standalone needs dvh to avoid the URL-bar-collapse jump. */
    min-height: 100dvh;
    padding:
        max(1.5rem, env(safe-area-inset-top))    max(1.5rem, env(safe-area-inset-right))
        max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 180px;
    background: radial-gradient(ellipse at 50% -10%, rgba(99,102,241,.2) 0%, transparent 70%);
    pointer-events: none;
}
.login-card h1 {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}
.login-card label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    margin-bottom: .3rem;
    margin-top: 1.1rem;
}
.login-card input {
    width: 100%;
    padding: .6rem .85rem;
    background: var(--bg3);
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: .95rem;
    font-family: inherit;
    transition: border-color var(--dur), box-shadow var(--dur);
    outline: none;
}
.login-card input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
/* "Angemeldet bleiben" row — overrides the .login-card label defaults so the
   checkbox sits inline with normal sentence-case text instead of uppercase
   field captions. */
.login-card .login-remember {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin-top: 1.1rem;
    margin-bottom: 0;
    font-size: .9rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}
.login-card .login-remember input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .5rem 1rem;
    border-radius: var(--r-sm);
    font-size: .875rem;
    font-weight: 500;
    font-family: inherit;
    letter-spacing: -.01em;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--bg3);
    color: var(--text);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    transition:
        background var(--dur) var(--ease),
        border-color var(--dur) var(--ease),
        box-shadow var(--dur) var(--ease),
        transform .1s var(--ease);
}
.btn:hover {
    background: var(--bg4);
    border-color: rgba(255,255,255,.15);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn:active { transform: translateY(0); box-shadow: none; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-h);
    border-color: var(--primary-h);
    box-shadow: 0 4px 18px var(--primary-ring);
}
.btn-danger {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}
.btn-danger:hover {
    opacity: .9;
    box-shadow: 0 4px 14px rgba(248,113,113,.35);
}
.btn-full {
    width: 100%;
    margin-top: 1.25rem;
    padding: .65rem;
    font-size: .95rem;
    font-weight: 600;
}
.btn-sm  { padding: .38rem .75rem; font-size: .8rem; }
.btn-xs  { padding: .22rem .55rem; font-size: .75rem; border-radius: var(--r-xs); }

.btn-share-on {
    background: rgba(74,222,128,.1);
    border-color: rgba(74,222,128,.28);
    color: var(--green);
}
.btn-share-on:hover {
    background: rgba(74,222,128,.18);
    border-color: var(--green);
}

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
    padding: .85rem 1.1rem;
    border-radius: var(--r-sm);
    margin-bottom: 1.1rem;
    font-size: .9rem;
    font-weight: 500;
    border: 1.5px solid;
}
.alert-error {
    background: rgba(248,113,113,.08);
    border-color: rgba(248,113,113,.3);
    color: #fca5a5;
}
.alert-alarm {
    background: rgba(248,113,113,.12);
    border-color: var(--red);
    color: #fca5a5;
    font-weight: 700;
    font-size: 1rem;
}
.alert-info {
    background: rgba(99,102,241,.1);
    border-color: rgba(99,102,241,.3);
    color: #c7d2fe;
}
.alert-success {
    background: rgba(74,222,128,.08);
    border-color: rgba(74,222,128,.28);
    color: #bbf7d0;
}
.alert-warning {
    background: rgba(245,158,11,.10);
    border-color: rgba(245,158,11,.35);
    color: #fcd34d;
}

/* ── Dashboard Grid ─────────────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.25rem;
    align-items: start;
}
@media (max-width: 760px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

/* Share card spans the full width below the map + status row. */
.card-share { grid-column: 1 / -1; }
.share-url-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-top: .5rem;
}
.share-url {
    flex: 1 1 auto;
    min-width: 0;
    padding: .4rem .6rem;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--r-sm);
    background: rgba(255,255,255,.04);
    color: inherit;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .85rem;
}

/* ── Map ─────────────────────────────────────────────────────────────────────── */
#map       { height: 480px; border-radius: var(--r-sm); }
.tour-map  { height: 420px; border-radius: var(--r-sm); }

/* ── Status Table ────────────────────────────────────────────────────────────── */
.status-table { width: 100%; border-collapse: collapse; }
.status-table th,
.status-table td { padding: .45rem .5rem; vertical-align: top; }
.status-table th {
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    text-align: left;
    white-space: nowrap;
    width: 42%;
}
.status-table td { font-weight: 600; font-size: .9rem; }

/* ── Battery colours ─────────────────────────────────────────────────────────── */
.battery  { font-weight: 700; }
.bat-ok   { color: var(--green); }
.bat-warn { color: var(--yellow); }
.bat-low  { color: var(--red); }

/* ── Stat boxes ──────────────────────────────────────────────────────────────── */
.stat-row { display: flex; gap: 1rem; margin-top: 1.25rem; }
.stat-box {
    flex: 1;
    background: var(--bg3);
    border-radius: var(--r-sm);
    padding: 1rem .85rem;
    text-align: center;
    border: 1px solid var(--border);
    transition: border-color var(--dur);
}
.stat-box:hover { border-color: var(--primary-dim); }
.stat-value {
    display: block;
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -.05em;
    line-height: 1;
    margin-bottom: .25rem;
}
.stat-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
}

/* ── Charts Grid ─────────────────────────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}
@media (max-width: 640px) {
    .charts-grid { grid-template-columns: 1fr; }
}

/* ── Data Tables ─────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

/* Collapsible details/summary (z.B. "Alle Punkte"-Tabelle auf tour.php).
   Native <details><summary>, styled to look like a heading + caret toggle. */
.points-details > .points-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    user-select: none;
}
.points-details > .points-summary::-webkit-details-marker { display: none; }
.points-chevron {
    font-size: 1.4rem;
    transition: transform .18s var(--ease);
}
.points-details[open] > .points-summary > .points-chevron {
    transform: rotate(90deg);
}
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
    text-align: left;
    padding: .6rem .85rem;
    background: var(--bg3);
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.data-table th:first-child { border-radius: var(--r-xs) 0 0 0; }
.data-table th:last-child  { border-radius: 0 var(--r-xs) 0 0; }
.data-table td {
    padding: .55rem .85rem;
    border-bottom: 1px solid rgba(255,255,255,.04);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td      { background: rgba(255,255,255,.03); }
.data-table-sm td,
.data-table-sm th { padding: .35rem .6rem; font-size: .8rem; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .18rem .6rem;
    border-radius: var(--r-full);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-green { background: rgba(74,222,128,.12);  color: #86efac; border-color: rgba(74,222,128,.22); }
.badge-gray  { background: var(--bg3);            color: var(--text-muted); border-color: var(--border); }
.badge-blue  { background: rgba(99,102,241,.12);  color: #a5b4fc; border-color: rgba(99,102,241,.22); }
.badge-amber { background: rgba(251,191,36,.1);   color: #fcd34d; border-color: rgba(251,191,36,.22); }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-inline { display: inline-flex; align-items: center; gap: .25rem; }

.input-label {
    background: var(--bg3);
    border: 1.5px solid var(--border);
    color: var(--text);
    border-radius: var(--r-xs);
    padding: .25rem .5rem;
    font-size: .8rem;
    font-family: inherit;
    width: 160px;
    outline: none;
    transition: border-color var(--dur), box-shadow var(--dur);
}
.input-label:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: .75rem;
    align-items: end;
}
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
}
.form-grid input,
.form-grid select {
    background: var(--bg3);
    border: 1.5px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    padding: .48rem .7rem;
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--dur), box-shadow var(--dur);
}
.form-grid input:focus,
.form-grid select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
}

/* ── Tour Header ─────────────────────────────────────────────────────────────── */
.tour-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.meta {
    color: var(--text-muted);
    font-size: .85rem;
    margin-top: .35rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem .8rem;
}
.meta > span { white-space: nowrap; }

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.nowrap { white-space: nowrap; }
.muted  { color: var(--text-muted); }
.center { text-align: center; }

/* ── Map Fullscreen ──────────────────────────────────────────────────────────── */
.map-wrap { position: relative; }

.map-fs-btn {
    position: absolute;
    top: 10px; right: 10px;
    z-index: 1000;
    width: 34px; height: 34px;
    background: #fff;
    border: 2px solid rgba(0,0,0,.2);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    padding: 0;
    transition: background var(--dur);
}
.map-fs-btn:hover { background: #f0f0f0; }

.map-wrap:fullscreen,
.map-wrap:-webkit-full-screen {
    width: 100vw; height: 100vh;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}
.map-wrap:fullscreen #map,
.map-wrap:-webkit-full-screen #map {
    flex: 1;
    width: 100vw !important;
    height: auto !important;
    min-height: 0;
    border-radius: 0 !important;
}
.map-wrap:fullscreen .tour-slider-wrap,
.map-wrap:-webkit-full-screen .tour-slider-wrap {
    width: 100%;
    background: rgba(9,9,11,.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(255,255,255,.08);
    padding: .65rem 1.5rem .9rem;
}

/* ── Tour admin controls ─────────────────────────────────────────────────────── */
.tour-actions { display: flex; gap: .5rem; align-items: flex-start; flex-wrap: wrap; }

/* ── Tour Time Slider ────────────────────────────────────────────────────────── */
.tour-slider-wrap {
    padding: .9rem 1.5rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg2);
}
.slider-info-bar {
    display: flex;
    gap: .6rem;
    align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: .6rem;
    font-size: .875rem;
    min-height: 1.4em;
}
.slider-ts {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.time-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--bg3);
    cursor: pointer;
    outline: none;
    border: none;
    display: block;
    transition: height .12s var(--ease);
}
.time-slider:hover { height: 6px; }
.time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 2.5px solid var(--bg2);
    cursor: pointer;
    box-shadow: 0 0 0 3px var(--primary-ring), var(--shadow-sm);
    transition: transform .1s;
}
.time-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.time-slider::-moz-range-thumb {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 2.5px solid var(--bg2);
    cursor: pointer;
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.slider-ends {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: .4rem;
}

/* ── Journal Panel (inside tour card) ───────────────────────────────────────── */
.journal-panel {
    padding: 1.25rem 1.5rem 1.5rem;
    border-top: 1px solid var(--border);
}
.journal-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.journal-nav-btns {
    display: flex;
    align-items: center;
    gap: .4rem;
}
.journal-date-label {
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: -.01em;
    min-width: 160px;
    text-align: center;
}
.journal-body {
    font-size: .9rem;
    line-height: 1.8;
    color: var(--text);
    margin-bottom: .75rem;
}
.journal-body p             { margin-bottom: .55rem; }
.journal-body p:last-child  { margin-bottom: 0; }
.journal-photos {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-top: .75rem;
}
.journal-photo {
    width: 130px;
    height: 96px;
    object-fit: cover;
    border-radius: var(--r-sm);
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: border-color var(--dur), transform .2s var(--ease), box-shadow .2s var(--ease);
    display: block;
}
.journal-photo:hover {
    border-color: var(--primary);
    transform: scale(1.04) translateY(-2px);
    box-shadow: var(--shadow);
}

/* ── Journal List (journal.php) ─────────────────────────────────────────────── */
.journal-list { display: flex; flex-direction: column; gap: 0; }
.journal-card {
    margin-bottom: 1rem;
    transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.journal-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.journal-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: .6rem;
    flex-wrap: wrap;
}
.journal-card-date {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -.025em;
    margin-right: .45rem;
}
.journal-card-tour {
    font-size: .85rem;
    color: var(--primary);
    font-weight: 500;
}
.journal-card-tour:hover { color: var(--primary-h); }
.journal-card-meta {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.journal-card-body {
    font-size: .875rem;
    color: var(--text-muted);
    line-height: 1.7;
}

/* ── Journal card expand / collapse ─────────────────────────────────────────── */
.jc-preview { }

.jc-chevron {
    display: inline-block;
    font-size: .9em;
    transition: transform .2s var(--ease);
    line-height: 1;
}

.jc-full {
    display: none;
    border-top: 1px solid var(--border);
    margin-top: .85rem;
    padding-top: .85rem;
}
.jc-full.is-open {
    display: block;
    animation: jc-in .22s var(--ease);
}
@keyframes jc-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Journal Edit form (journal_edit.php) ───────────────────────────────────── */
.je-form-row {
    display: grid;
    grid-template-columns: 1fr 180px;
    gap: .85rem;
    align-items: end;
    margin-bottom: 1rem;
}
@media (max-width: 520px) { .je-form-row { grid-template-columns: 1fr; } }

.je-label {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}
.je-select,
.je-input {
    background: var(--bg3);
    border: 1.5px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    padding: .5rem .75rem;
    font-size: .9rem;
    font-family: inherit;
    width: 100%;
    outline: none;
    transition: border-color var(--dur), box-shadow var(--dur);
}
.je-select:focus,
.je-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.je-textarea {
    background: var(--bg3);
    border: 1.5px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    padding: .65rem .75rem;
    font-size: .9rem;
    font-family: inherit;
    width: 100%;
    resize: vertical;
    line-height: 1.75;
    min-height: 260px;
    outline: none;
    transition: border-color var(--dur), box-shadow var(--dur);
}
.je-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.je-file {
    background: var(--bg3);
    border: 1.5px dashed rgba(255,255,255,.15);
    color: var(--text-muted);
    border-radius: var(--r-sm);
    padding: .6rem .75rem;
    font-size: .875rem;
    width: 100%;
    cursor: pointer;
    transition: border-color var(--dur), background var(--dur);
}
.je-file:hover {
    border-color: var(--primary);
    background: var(--primary-dim);
}
.je-photos-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .85rem;
}
.je-photo-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
}
.je-photo-thumb {
    width: 140px;
    height: 105px;
    object-fit: cover;
    border-radius: var(--r-sm);
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: border-color var(--dur), transform .2s var(--ease);
    display: block;
}
.je-photo-thumb:hover {
    border-color: var(--primary);
    transform: scale(1.03);
}
.je-photo-del { position: absolute; top: 4px; right: 4px; }
.je-photo-caption {
    font-size: .75rem;
    color: var(--text-muted);
    max-width: 140px;
    text-align: center;
    word-break: break-word;
}

/* ── Lightbox ────────────────────────────────────────────────────────────────── */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.lightbox img {
    max-width: 94vw;
    max-height: 94vh;
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-lg);
}

/* ── Journal overlay (dot click) ─────────────────────────────────────────────── */
.journal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 6000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1rem 1rem;
    overflow-y: auto;
}
.journal-overlay.is-open { display: flex; }
.journal-overlay-box {
    background: var(--bg2);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--radius);
    padding: 1.75rem;
    max-width: 620px;
    width: 100%;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: overlay-in .22s var(--ease);
}
@keyframes overlay-in {
    from { opacity: 0; transform: translateY(14px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);   }
}
.journal-overlay-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding-bottom: 1rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.journal-overlay-head span {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.02em;
}
.journal-overlay #jov-body {
    white-space: pre-wrap;
    line-height: 1.8;
    font-size: .9rem;
    margin-bottom: 1rem;
}
.journal-overlay #jov-photos {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-top: .85rem;
}
.journal-overlay #jov-photos img {
    width: 100px;
    height: 75px;
    object-fit: cover;
    border-radius: var(--r-sm);
    cursor: zoom-in;
    border: 1.5px solid var(--border);
    transition: border-color var(--dur), transform .2s var(--ease);
}
.journal-overlay #jov-photos img:hover {
    border-color: var(--primary);
    transform: scale(1.06);
}

/* ── Mobile ─────────────────────────────────────────────────────────────────── */
/* Hamburger menu — slightly wider breakpoint (768px) so small tablets and
   landscape phones also get a tap-friendly dropdown instead of a cramped
   icon row. The dropdown floats below the bar via position: absolute. */
@media (max-width: 768px) {
    .navbar    {
        padding:
            max(.5rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
            .5rem                                max(1rem, env(safe-area-inset-left));
    }
    .nav-brand   { flex-shrink: 0; }
    .nav-toggle  { display: inline-flex; }
    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        display: none;          /* hidden until .is-open */
        flex-direction: column;
        align-items: stretch;
        gap: .3rem;
        margin: 0;
        padding: .65rem max(.85rem, env(safe-area-inset-left)) max(.65rem, env(safe-area-inset-bottom)) max(.85rem, env(safe-area-inset-right));
        background: rgba(9,9,11,.96);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 8px 24px rgba(0,0,0,.45);
        max-height: calc(100vh - 100%);
        overflow-y: auto;
        font-size: 1rem;
    }
    .navbar.is-open .nav-links { display: flex; }
    .nav-links a {
        padding: .95rem 1rem;   /* generous tap target — ~52px tall */
        border-radius: var(--r-sm);
        display: flex;
        align-items: center;
        gap: 1rem;
        font-size: 1.05rem;
        font-weight: 500;
        line-height: 1.2;
    }
    .nav-links a .ms {
        font-size: 1.75rem;
        margin: 0;
        width: 2rem;            /* fixed icon column → labels line up */
        text-align: center;
        vertical-align: middle;
    }
    .nav-links a .nav-text  { font-size: 1.05rem; }
    .nav-user               { opacity: .65; font-weight: 400; font-size: .9rem; margin-left: .35rem; }
    .nav-logout             {
        border-left: none;
        border-top: 1px solid var(--border);
        margin-left: 0;
        margin-top: .35rem;
        padding-top: 1rem !important;
        padding-left: 1rem !important;
        border-radius: 0 0 var(--r-sm) var(--r-sm);
    }
}

@media (max-width: 600px) {
    /* Layout */
    .container { padding: 1.25rem .85rem; }
    .card      { padding: 1.1rem; }
    h1         { font-size: 1.35rem; }

    /* Maps */
    .tour-map, #map, #day-map { height: 300px; }

    /* Stat boxes — 2-up wrap */
    .stat-row  { flex-wrap: wrap; gap: .6rem; }
    .stat-box  { flex: 1 1 calc(50% - .35rem); min-width: 0; }
    .stat-value { font-size: 1.5rem; }

    /* Touch targets — minimum comfortable tap size */
    .btn-xs { padding: .38rem .65rem; font-size: .78rem; }

    /* Journal */
    .journal-date-label { min-width: 0; font-size: .88rem; }
    .journal-panel      { padding: 1rem; }
    .journal-panel-head { gap: .5rem; }
    .journal-nav-btns   { gap: .25rem; }
    .journal-photo      { width: 100px; height: 74px; }
    .je-photo-thumb     { width: 110px; height: 82px; }

    /* Slider bar */
    .tour-slider-wrap { padding: .6rem .85rem .7rem; }
    .slider-info-bar  { font-size: .8rem; }

    /* Data table */
    .data-table, .data-table-sm    { font-size: .78rem; }
    .data-table th, .data-table td { padding: .38rem .45rem; }

    /* Login card */
    .login-card { padding: 2rem 1.25rem; }

    /* ── Tours table → stacked cards ─────────────────────────────────────── */
    .tours-table thead       { display: none; }
    .tours-table,
    .tours-table tbody       { display: block; }
    .tours-table tr {
        display: block;
        background: var(--bg2);
        border: 1px solid var(--border);
        border-radius: var(--r-sm);
        margin-bottom: .75rem;
        overflow: hidden;
    }
    .tours-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: .5rem;
        padding: .55rem .85rem;
        border-bottom: 1px solid rgba(255,255,255,.04);
        font-size: .875rem;
        width: 100%;
    }
    .tours-table td:last-child { border-bottom: none; }
    .tours-table td::before {
        content: attr(data-label);
        font-size: .72rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: var(--text-muted);
        white-space: nowrap;
        flex-shrink: 0;
    }
    /* "Aktion" row: buttons only, no label */
    .tours-table td[data-label="Aktion"]::before { display: none; }
    .tours-table td[data-label="Aktion"] {
        justify-content: flex-end;
        gap: .4rem;
        background: rgba(255,255,255,.02);
    }
    /* Rename input stretches into remaining space */
    .tours-table .input-label { width: auto; flex: 1; min-width: 0; }
    .tours-table .form-inline { flex: 1; justify-content: flex-end; gap: .35rem; }
}

/* ── Material Symbols ────────────────────────────────────────────────────────── */
/* The font is loaded via @import at the top of this file. Variable axes
   (opsz, wght, FILL, GRAD) let us keep one font but render multiple weights
   and a filled/unfilled toggle. */
.ms {
    font-family: 'Material Symbols Rounded';
    font-weight: 400;
    font-style: normal;
    font-size: 1.15em;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    vertical-align: -.18em;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    user-select: none;
}
.ms-fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.ms-sm   { font-size: 1em; }
.ms-lg   { font-size: 1.6em; vertical-align: -.3em; }
.ms-xl   { font-size: 2.4em; vertical-align: -.4em; }

/* Slightly nudge the optical alignment inside buttons */
.btn .ms { font-size: 1.1em; margin-right: .05rem; }
.btn-xs .ms { font-size: 1em; }

/* ── Ripple ──────────────────────────────────────────────────────────────────── */
/* JS (app.js) injects a <span class="ripple"> on click; CSS animates it.
   Container needs position: relative + overflow: hidden — added per element. */
.btn,
.fab,
.nav-links a,
.stat-box {
    position: relative;
    overflow: hidden;
    isolation: isolate;          /* keep the ripple under the content */
}
.ripple {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background: currentColor;
    opacity: .28;
    transform: scale(0);
    animation: ripple-out .55s var(--ease) forwards;
    z-index: -1;
}
@keyframes ripple-out {
    to { transform: scale(2.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .ripple { animation: none; opacity: 0; }
}

/* Buttons get a touch more "press" with the ripple. */
.btn:active,
.fab:active { transform: translateY(1px) scale(.985); transition: transform .08s var(--ease); }

/* ── Floating Action Button ──────────────────────────────────────────────────── */
.fab {
    position: fixed;
    right: max(1.25rem, env(safe-area-inset-right));
    bottom: max(1.25rem, env(safe-area-inset-bottom));
    z-index: 150;
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    padding: 0 1.15rem;
    height: 56px;
    border-radius: 18px;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 600;
    letter-spacing: -.01em;
    border: none;
    cursor: pointer;
    text-decoration: none;
    box-shadow:
        0 10px 28px rgba(99,102,241,.45),
        0 4px 10px rgba(0,0,0,.35);
    transition:
        transform .28s var(--ease-spring),
        box-shadow .25s var(--ease),
        background .2s var(--ease);
}
.fab:hover {
    background: var(--primary-h);
    text-decoration: none;
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 16px 36px rgba(99,102,241,.55),
        0 6px 14px rgba(0,0,0,.4);
    color: #fff;
}
.fab .ms { font-size: 1.5em; vertical-align: middle; }
.fab .fab-text { display: inline; }
@media (max-width: 480px) {
    /* Mobile: collapse to a round icon-only FAB so it doesn't overlap content. */
    .fab          { padding: 0; width: 56px; height: 56px; border-radius: 50%; justify-content: center; gap: 0; }
    .fab .fab-text { display: none; }
    .fab .ms      { font-size: 1.7em; }
}

/* FAB peek-on-scroll: starts hidden, slides up after scrolling.
   app.js toggles .fab--shown. */
.fab--auto         { transform: translateY(120%); opacity: 0; pointer-events: none; }
.fab--auto.fab--shown {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}


/* ── Card hover spring (lift) ────────────────────────────────────────────────── */
.card {
    transition:
        transform .28s var(--ease-spring),
        box-shadow .25s var(--ease),
        border-color .2s var(--ease);
}
.card.card-hover:hover,
.card-lift:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: rgba(255,255,255,.12);
}

/* Suppress the spring on map / share / journal cards where the lift would
   shift the embedded interactive surface (Leaflet, share input, slider). */
.card-map,
.card-share,
.card-status,
.card-no-lift {
    transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.card-map:hover,
.card-share:hover,
.card-status:hover,
.card-no-lift:hover { transform: none; }

/* ── Stat box delight ────────────────────────────────────────────────────────── */
.stat-box {
    transition:
        transform .28s var(--ease-spring),
        border-color .25s var(--ease),
        background .25s var(--ease);
    cursor: default;
}
.stat-box:hover {
    transform: translateY(-2px);
    border-color: var(--primary-ring);
    background: rgba(99,102,241,.06);
}
.stat-value {
    font-variant-numeric: tabular-nums;
    background: linear-gradient(180deg, #a5b4fc 0%, var(--primary) 100%);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
    color: var(--text-muted);
    animation: empty-in .35s var(--ease-spring);
}
/* Direct-child only: the icon inside any nested button keeps its normal size. */
.empty-state > .ms {
    font-size: 4.2rem;
    color: var(--primary);
    opacity: .55;
    margin-bottom: .85rem;
    display: inline-block;
    animation: empty-bob 3.5s ease-in-out infinite;
}
.empty-state h3 {
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -.01em;
    margin-bottom: .4rem;
}
.empty-state p { font-size: .9rem; max-width: 32rem; margin: 0 auto .9rem; }
.empty-state .btn { margin-top: .5rem; }
@keyframes empty-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes empty-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}
@media (prefers-reduced-motion: reduce) {
    .empty-state, .empty-state > .ms { animation: none; }
}

/* ── Nav icon support ────────────────────────────────────────────────────────── */
.nav-links a .ms {
    font-size: 1.05rem;
    vertical-align: -.2em;
    margin-right: .25rem;
}

