:root {
    --bg: #f8fafc;
    --bg-soft: #ffffff;
    --fg: #0f172a;
    --muted: #64748b;
    --accent: #6366f1;
    --accent-2: #0891b2;
    --danger: #dc2626;
    --card: #ffffff;
    --card-fg: #0f172a;
    --border: #e2e8f0;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--fg);
    min-height: 100%;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.hero {
    min-height: 100vh;
    background: radial-gradient(1200px 600px at 80% -10%, rgba(99,102,241,0.18), transparent 60%),
                radial-gradient(900px 500px at -10% 20%, rgba(8,145,178,0.12), transparent 60%),
                var(--bg);
    display: flex;
    flex-direction: column;
}

.nav {
    display: flex;
    align-items: center;
    padding: 1.25rem 2rem;
}

.brand {
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: inherit;
    text-decoration: none;
}
.brand:hover {
    color: var(--accent);
    text-decoration: none;
}
.brand-icon {
    width: 22px;
    height: 22px;
    color: var(--accent);
    flex-shrink: 0;
}

.hero-inner {
    flex: 1;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 3rem;
    align-items: center;
    padding: 2rem 3rem 4rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

@media (max-width: 880px) {
    .hero-inner { grid-template-columns: 1fr; padding: 1rem 1.5rem 3rem; }
}

.badge {
    display: inline-block;
    background: rgba(99,102,241,0.1);
    color: #4338ca;
    border: 1px solid rgba(99,102,241,0.3);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.hero-copy h1 {
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    line-height: 1.05;
    margin: 0 0 1rem;
    background: linear-gradient(90deg, #0f172a, #4f46e5);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lede {
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1.55;
    max-width: 540px;
}

.features {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
    display: grid;
    gap: 0.55rem;
}

.features li {
    color: var(--fg);
    padding-left: 1.5rem;
    position: relative;
}

.features li::before {
    content: "✓";
    color: var(--accent-2);
    position: absolute;
    left: 0;
    font-weight: 700;
}

.login-card {
    background: var(--card);
    color: var(--card-fg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 40px -20px rgba(15,23,42,0.15);
}

.login-card h2 {
    margin: 0 0 1rem;
    font-size: 1.4rem;
}

.login-card label {
    display: block;
    margin-bottom: 0.9rem;
    font-size: 0.9rem;
    color: #475569;
}

.login-card label span {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.login-card input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    background: #f8fafc;
    color: var(--card-fg);
}

.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
    background: #fff;
}

.login-card button {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background 120ms ease;
}

.login-card button:hover { background: #4f46e5; }

.alert {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 0.7rem 0.85rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.foot {
    padding: 1rem 2rem;
    color: var(--muted);
    text-align: center;
}

/* Dashboard */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.topbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}
.topbar { position: relative; }
.topbar-center-link {
    color: var(--fg);
    font-weight: 600;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
}
.topbar-center-link:hover {
    background: rgba(15, 23, 42, 0.06);
    text-decoration: none;
}

.topbar-right .user {
    color: var(--muted);
    font-size: 0.9rem;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.topbar-nav .strava-sync-form {
    display: inline-flex;
}

.settings-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--muted);
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}
.settings-link:hover, .settings-link.is-active {
    background: rgba(15,23,42,0.06);
    color: var(--fg);
    text-decoration: none;
}
.settings-link svg {
    width: 20px;
    height: 20px;
}

.topbar-menu {
    position: relative;
}
.topbar-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    padding: 0.35rem;
    background: var(--bg, #fff);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12);
    z-index: 50;
}
.topbar-menu-dropdown[hidden] {
    display: none;
}
.topbar-menu-item-form {
    margin: 0;
    display: block;
}
.topbar-menu-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--fg);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.topbar-menu-item:hover {
    background: rgba(15, 23, 42, 0.06);
    text-decoration: none;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1rem;
}

.run-city {
    color: var(--muted);
}

.today-cheer {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    margin: 1.25rem 0 1rem;
    padding: 1.1rem 1.3rem;
    border-radius: 12px;
    background: linear-gradient(90deg, rgba(16,185,129,0.22), rgba(16,185,129,0.10));
    border: 2px solid rgba(16,185,129,0.55);
    color: var(--fg);
    text-decoration: none;
    transition: transform 120ms ease, box-shadow 120ms ease;
}
.today-cheer:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16,185,129,0.25);
    text-decoration: none;
}
.today-cheer-icon {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    color: #047857;
    display: flex;
    align-items: center;
    justify-content: center;
}
.today-cheer-icon svg {
    width: 40px;
    height: 40px;
}
.today-cheer-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}
.today-cheer-phrase {
    font-size: 2rem;
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.005em;
}
.today-cheer-sub {
    font-size: 0.95rem;
    color: var(--muted);
}

.weekplan-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
}
.weekplan-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    outline: none;
    min-width: 0;
}
.weekplan-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}
.weekplan-square {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 64px;
    border-radius: 8px;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 120ms ease, box-shadow 120ms ease;
    position: relative;
}
.weekplan-check {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #16a34a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--surface, #fff);
    pointer-events: none;
}
.weekplan-check svg {
    width: 14px;
    height: 14px;
}
.weekplan-day.is-done .weekplan-square {
    box-shadow: 0 0 0 1px rgba(22,163,74,0.45);
}
.weekplan-day.is-today .weekplan-square {
    border-color: #d4af37;
    box-shadow: 0 0 0 1px rgba(212,175,55,0.35);
}
.weekplan-day.is-training .weekplan-square {
    background-color: var(--accent);
}
.weekplan-day.is-rest .weekplan-square {
    background-color: rgba(15,23,42,0.08);
}
/* Past days and today: real data — blue if a run was logged, grey if not. */
.weekplan-day.is-ran .weekplan-square {
    background-color: var(--accent);
}
.weekplan-day.is-norun .weekplan-square {
    background-color: rgba(15,23,42,0.08);
}
.weekplan-day:hover .weekplan-square,
.weekplan-day:focus-visible .weekplan-square {
    transform: scale(1.06);
    box-shadow: 0 4px 12px rgba(99,102,241,0.25);
}
.weekplan-icon {
    width: 60%;
    height: 60%;
    pointer-events: none;
}
.weekplan-day.is-training .weekplan-icon { color: #fff; }
.weekplan-day.is-rest .weekplan-icon { color: rgba(15,23,42,0.08); }
.weekplan-day.is-ran .weekplan-icon { color: #fff; }
.weekplan-day.is-norun .weekplan-icon { color: rgba(15,23,42,0.08); }
.weekplan-date {
    font-size: 0.75rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.weekplan-detail {
    margin-top: 0.85rem;
    min-height: 1.25rem;
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 540px) {
    .card { padding: 1.25rem 1rem; }
    .weekplan-grid { gap: 0.3rem; }
    .weekplan-label,
    .weekplan-date { font-size: 0.7rem; }
}

.progress-track + .progress-track {
    margin-top: 1.6rem;
}
.progress-track-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    font-size: 0.85rem;
}
.progress-track-label {
    font-weight: 600;
}
.progress-track-meta {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.progress-track-meta strong { color: inherit; }
.progress-bar {
    margin: 1.55rem 0 1.4rem;
}
.progress-bar-track {
    position: relative;
    height: 10px;
    background: #e2e8f0;
    border-radius: 999px;
}
.progress-bar-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    background: var(--accent);
    border-radius: 999px;
    transition: width 240ms ease;
}
.progress-bar-goal-line {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: var(--accent);
    opacity: 0.45;
    border-radius: 1px;
    transform: translateX(-50%);
    pointer-events: none;
}
.progress-bar-goal-tick {
    position: absolute;
    top: 100%;
    margin-top: 0.4rem;
    transform: translateX(-50%);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}
.progress-bar-marker {
    position: absolute;
    top: -1.55rem;
    transform: translateX(-50%);
    pointer-events: none;
}
.progress-bar-value {
    position: relative;
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.progress-bar-value::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--accent);
}
.progress-note {
    margin: 0.6rem 0 0;
    font-size: 0.78rem;
    color: var(--muted);
}
.progress-delta {
    margin-left: 0.3rem;
    font-weight: 600;
}
.progress-delta-up { color: #16a34a; }
.progress-delta-down { color: #dc2626; }
.progress-delta-flat { color: var(--muted); }

/* Generic modal (used by import-complete summary) */
body.modal-open { overflow: hidden; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,0.55);
    cursor: pointer;
}
.modal-card {
    position: relative;
    z-index: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    box-shadow: 0 30px 80px -20px rgba(15,23,42,0.4);
    max-width: 520px;
    width: 100%;
}
.modal-card h2 {
    margin: 0 0 0.5rem;
    font-size: 1.2rem;
}

.import-summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
    font-size: 0.9rem;
}
.import-summary-table th,
.import-summary-table td {
    padding: 0.45rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.import-summary-table th {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.import-summary-table tr:last-child td { border-bottom: 0; }
.import-summary-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

.dashboard {
    padding: 1rem 2rem 3rem;
    max-width: 1100px;
    margin: 0 auto;
}
.dashboard > *:first-child {
    margin-top: 0;
}

.dashboard h1 {
    margin: 0;
    font-size: 1.8rem;
}

.card {
    background: var(--card);
    color: var(--card-fg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    box-shadow: 0 10px 30px -20px rgba(15,23,42,0.15);
    margin-top: 1.5rem;
}

.card h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

/* Tabbed overview card */
.tabs {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
}
.tab {
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    margin-bottom: -1px;
    padding: 0.55rem 1rem;
    font: inherit;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: color 120ms ease, background 120ms ease;
}
.tab:hover {
    color: var(--fg);
    background: #e9eef4;
}
.tab.is-active {
    background: var(--card);
    border-bottom-color: var(--card);
    color: var(--accent);
}
.tab-panel {
    display: none;
}
.tab-panel.is-active {
    display: block;
}

.map-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.map-card-head h2 {
    margin: 0;
}
.photo-toggle {
    font-size: 0.85rem;
    color: var(--accent-2);
    cursor: pointer;
}
.run-map--no-thumbs .photo-marker {
    display: none !important;
}

.run-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.run-form .field { flex: 1 1 160px; }
.run-form .duration { flex: 1 1 220px; }

.run-form label {
    display: block;
    font-size: 0.85rem;
    color: #475569;
}

.run-form > label > span,
.run-form fieldset legend {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    color: #475569;
    font-size: 0.85rem;
}

.run-form input[type="date"],
.run-form input[type="number"] {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    background: #f8fafc;
    color: var(--card-fg);
}

.run-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
    background: #fff;
}

.run-form fieldset.duration {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.45rem 0.7rem 0.6rem;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
}

.run-form fieldset.duration legend {
    padding: 0 0.35rem;
    margin-bottom: 0;
}

.run-form fieldset.duration label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.run-form fieldset.duration label span {
    text-align: center;
    font-weight: 500;
    color: var(--muted);
    font-size: 0.8rem;
    margin-bottom: 0.2rem;
}

.run-form fieldset.duration input {
    padding: 0.4rem 0.5rem;
    text-align: center;
}

.run-form button {
    padding: 0.7rem 1.1rem;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms ease;
}

.run-form button:hover { background: #4f46e5; }

.runs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
}

.runs-month-header {
    grid-column: 1 / -1;
    font-size: 1.25rem;
    color: var(--muted);
    font-weight: 600;
    margin-top: 0.6rem;
    text-align: center;
}

.runs-month-header:first-child { margin-top: 0; }

.run-tile {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background-color: #1f2937;
    color: #fff;
    text-decoration: none;
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.run-tile-cover {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.run-tile:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.run-tile--no-photo {
    background-image: linear-gradient(135deg, #334155, #1f2937);
}

.run-tile--outlier {
    opacity: 0.55;
    filter: grayscale(0.6);
}
.run-tile--outlier:hover {
    opacity: 0.85;
    filter: grayscale(0);
}

.run-tile-outlier-badge {
    position: absolute;
    top: 0.9rem;
    right: 1rem;
    z-index: 1;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.85);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.25rem;
    text-align: center;
}

.run-tile-day {
    position: absolute;
    top: 0.9rem;
    left: 1rem;
    background: rgba(0, 0, 0, 0.55);
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    z-index: 1;
}

.run-tile-route {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.85));
}

.run-tile-route polyline {
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.run-tile-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1rem 1.1rem 0.95rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.55) 70%, rgba(0, 0, 0, 0) 100%);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
}

.run-tile-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.run-tile-city {
    font-weight: 400;
    opacity: 0.85;
}

.run-tile-km-big {
    flex: 0 0 auto;
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 0.95;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.run-tile-speed {
    flex: 0 0 auto;
    margin-right: 1.25rem;
    font-size: 0.9rem;
    line-height: 1.25;
    opacity: 0.75;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.run-tile-name-mobile { display: none; }
.run-tile-name-desktop { display: inline; }
.run-tile-day-mobile { display: none; }

@media (max-width: 640px) {
    .topbar { flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.85rem 1.25rem; }
    .topbar-right { flex-wrap: wrap; gap: 0.5rem 1rem; }
    .topbar-nav { flex-wrap: wrap; gap: 0.5rem 1rem; }
    .topbar-menu-dropdown { min-width: 180px; }
    .topbar-center { position: static; transform: none; order: 3; flex-basis: 100%; justify-content: center; }
}

/* /show — full-screen run slideshow */
.show-stage {
    position: fixed;
    inset: 0;
    background: #000;
    overflow: hidden;
    z-index: 1000;
}
.show-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.4s ease;
    color: #fff;
}
.show-slide.is-active {
    opacity: 1;
    pointer-events: auto;
}
.show-photo {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.show-vignette {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.15) 45%, rgba(0,0,0,0) 70%),
        linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 30%);
    pointer-events: none;
}
.show-meta {
    position: absolute;
    left: 4vw;
    right: 4vw;
    bottom: 5vh;
    display: flex;
    flex-direction: column;
    gap: 1.5vh;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}
.show-title {
    font-size: clamp(2.5rem, 7vw, 6.5rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
    max-width: 80vw;
    color: #fff;
    text-decoration: none;
    pointer-events: auto;
}
.show-title:hover {
    text-decoration: underline;
    text-decoration-thickness: 0.05em;
    text-underline-offset: 0.1em;
}
.show-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4em 3vw;
    align-items: baseline;
    font-size: clamp(1.2rem, 2.4vw, 2.4rem);
}
.show-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25em;
}
.show-stat-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.show-stat-unit {
    opacity: 0.75;
    font-size: 0.65em;
}
.show-stat-date {
    opacity: 0.85;
}
.show-shape {
    position: absolute;
    top: 4vh;
    right: 4vw;
    width: clamp(220px, 32vw, 520px);
    height: clamp(220px, 32vw, 520px);
    color: #fff;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
    opacity: 0.92;
}
.show-close {
    position: absolute;
    top: 1.5vh;
    left: 1.5vw;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    background: rgba(0, 0, 0, 0.35);
    font-size: 1.8rem;
    line-height: 1;
    text-decoration: none;
    z-index: 10;
}
.show-close:hover {
    background: rgba(0, 0, 0, 0.6);
    text-decoration: none;
}
.show-empty {
    padding: 3rem 2rem;
}

.show-progress {
    position: absolute;
    bottom: 2vh;
    right: 2vw;
    width: 52px;
    height: 52px;
    transform: rotate(-90deg);
    z-index: 10;
    pointer-events: none;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.55));
}
.show-progress-track {
    stroke: rgba(255, 255, 255, 0.25);
    stroke-width: 3;
}
.show-progress-bar {
    stroke: #fff;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: show-progress-fill 10s linear forwards;
}
@keyframes show-progress-fill {
    from { stroke-dashoffset: 100; }
    to   { stroke-dashoffset: 0; }
}
    .runs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .run-tile-overlay { padding: 0.5rem 0.65rem 0.55rem; gap: 0.5rem; }
    .run-tile-day { display: none; }
    .run-tile-km-big { display: none; }
    .run-tile-speed { display: none; }
    .run-tile-name-mobile { display: inline; }
    .run-tile-name-desktop { display: none; }
    .run-tile-day-mobile {
        display: block;
        position: absolute;
        top: 0.45rem;
        right: 0.55rem;
        background: rgba(0, 0, 0, 0.55);
        padding: 0.1rem 0.4rem;
        border-radius: 4px;
        font-size: 0.75rem;
        font-weight: 600;
        line-height: 1.2;
        z-index: 1;
    }
}

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

.muted { color: var(--muted); margin: 0.25rem 0 0; font-size: 0.9rem; }
.muted code {
    background: #f1f5f9;
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}

.flash {
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    border: 1px solid transparent;
}
.flash-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}
.flash-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.strava-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.strava-head h2 { margin: 0; }

.strava-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.inline-form { display: inline; margin: 0; }

.btn {
    display: inline-block;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 0;
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: #4f46e5; text-decoration: none; }
.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: rgba(15,23,42,0.04);
    color: var(--fg);
    text-decoration: none;
}
.btn-danger-ghost {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--border);
}
.btn-danger-ghost:hover {
    background: rgba(220, 38, 38, 0.08);
    border-color: var(--danger);
    color: var(--danger);
    text-decoration: none;
}

.run-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* GitHub-style activity heatmap */
.heatmap-wrap {
    padding-bottom: 0.25rem;
}
.heatmap {
    display: block;
    width: 100%;
    height: auto;
    font-family: inherit;
}
.heatmap .hm-label {
    fill: var(--muted);
    font-size: 10px;
}
.heatmap rect {
    transition: stroke 120ms ease;
}
.heatmap rect:hover {
    stroke: var(--accent);
    stroke-width: 1.5;
}
.hm-legend {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.6rem;
    font-size: 0.75rem;
    color: var(--muted);
}
.hm-legend-cell {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* "Add run" toggle next to the page title */
.add-run-link,
.strava-sync-link {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.add-run-link:hover,
.strava-sync-link:hover {
    color: #4f46e5;
    text-decoration: underline;
}
.strava-sync-form {
    display: inline;
    margin: 0;
}
.strava-sync-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--accent);
}

.add-run { margin-top: 0; }
.add-run-card {
    position: relative;
    margin-top: 1rem;
}
.card-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(15,23,42,0.04);
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.card-close:hover {
    background: rgba(15,23,42,0.1);
    color: var(--fg);
}

/* Source badges in runs table */
.badge-source {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-strava {
    background: rgba(252,76,2,0.1);
    color: #b8390e;
    border: 1px solid rgba(252,76,2,0.25);
}
.badge-manual {
    background: rgba(15,23,42,0.05);
    color: var(--muted);
    border: 1px solid var(--border);
}
.badge-live {
    background: rgba(192,57,43,0.1);
    color: #a02c1d;
    border: 1px solid rgba(192,57,43,0.25);
}

.map-source-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    background: rgba(15,23,42,0.04);
    font-size: 0.8rem;
}
.map-source-toggle button {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 0.25rem 0.7rem;
    cursor: pointer;
    color: var(--muted);
    font: inherit;
}
.map-source-toggle button.is-active {
    background: var(--accent-2, #6366f1);
    color: #fff;
}

.photo {
    position: relative;
}
.photo-source {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 1;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: rgba(15,23,42,0.7);
    color: #fff;
    pointer-events: none;
    letter-spacing: 0.02em;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.photo:hover .photo-source,
.photo:focus-within .photo-source {
    opacity: 1;
}
.photo-source[data-source="strava"] { background: rgba(252,76,2,0.85); }
.photo-source[data-source="live"] { background: rgba(192,57,43,0.85); }
.photo-source[data-source="manual"] { background: rgba(71,85,105,0.85); }

.thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}
.thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    display: block;
    transition: transform 120ms ease;
}
.thumb:hover {
    transform: scale(1.08);
}

.run-link {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}
.run-link:hover {
    color: #4f46e5;
    text-decoration: underline;
}

/* Run detail */
.back-link {
    display: inline-block;
    color: var(--muted);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.back-link:hover { color: var(--fg); text-decoration: none; }

.run-detail h1 {
    margin: 0.25rem 0 0.5rem;
    font-size: 1.8rem;
}

.run-meta {
    color: var(--muted);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}
.run-meta .dot { margin: 0 0.4rem; }
.resync-form { display: inline; margin: 0; }
.resync-btn {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
}
.resync-btn:hover { text-decoration: underline; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}
.stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}
.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}
.stat-value {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--fg);
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.photo {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.photo-media {
    position: relative;
}
.photo-delete-form {
    position: absolute;
    top: 6px;
    right: 6px;
    margin: 0;
    opacity: 0;
    transition: opacity 120ms ease;
}
.photo-media:hover .photo-delete-form,
.photo-media:focus-within .photo-delete-form {
    opacity: 1;
}
.photo-delete-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0;
    background: rgba(15, 23, 42, 0.7);
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 120ms ease;
}
.photo-delete-btn:hover {
    background: var(--danger, #dc2626);
}
.photo img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
    transition: transform 120ms ease;
}
.photo a:hover img {
    transform: scale(1.01);
}
.photo figcaption {
    font-size: 0.85rem;
    color: var(--muted);
}

/* Title + edit-title control on the run detail page */
.title-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}
.title-row h1 {
    margin: 0.25rem 0 0.5rem;
}
.edit-title {
    flex-shrink: 0;
}
.edit-title summary {
    list-style: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.9rem;
    user-select: none;
}
.edit-title summary::-webkit-details-marker { display: none; }
.edit-title summary:hover { color: var(--accent); }
.edit-title-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    align-items: center;
}
.edit-title-form input {
    padding: 0.45rem 0.65rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    color: var(--card-fg);
    min-width: 280px;
}
.edit-title-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.edit-title-form button {
    padding: 0.5rem 0.95rem;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}
.edit-title-form button:hover { background: #4f46e5; }

.run-map {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.photo-marker {
    background: transparent;
    border: 0;
    cursor: pointer;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
    transition: transform 120ms ease;
}
.photo-marker:hover {
    transform: translateY(-1px);
    z-index: 1000 !important;
}
.photo-marker-thumb {
    display: block;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    border: 3px solid #fff;
    box-sizing: border-box;
    background-size: cover;
    background-position: center;
    background-color: #e5e7eb;
}
.photo-marker-tip {
    display: block;
    width: 0;
    height: 0;
    margin: -1px auto 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 10px solid #fff;
}

.saving-state {
    display: inline-block;
    padding: 0.7rem 0;
    font-size: 0.95rem;
    color: var(--muted);
    font-weight: 500;
}

.thumb-more {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    border: 1px dashed var(--border);
    background: rgba(99,102,241,0.06);
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 120ms ease;
}
.thumb-more:hover {
    background: rgba(99,102,241,0.14);
    text-decoration: none;
}

/* Speed bar (sparkline) in dashboard table */
.speed-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    vertical-align: middle;
}
.speed-bar {
    display: inline-block;
    width: 80px;
    height: 8px;
    background: rgba(15,23,42,0.06);
    position: relative;
    overflow: hidden;
}
.speed-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--pct, 0%);
    background: var(--accent);
}
.speed-value {
    font-variant-numeric: tabular-nums;
}

/* Speed chart on run detail */
.speed-chart-wrap {
    position: relative;
}
.speed-chart {
    width: 100%;
    height: 160px;
    display: block;
    position: relative;
}
.speed-chart-y-label {
    position: absolute;
    left: 0.25rem;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--muted);
    pointer-events: none;
}
.chart-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: var(--muted);
}
.speed-chart-axis {
    position: relative;
    height: 1rem;
    margin-top: 0.1rem;
}
.speed-chart-axis-label,
.speed-chart-axis-pace {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--muted);
    white-space: nowrap;
    pointer-events: none;
}
.speed-chart-axis-pace {
    color: #b45309;
    font-weight: 600;
}

/* Month divider rows in the runs table */
.month-row td {
    background: #f1f5f9;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.day-cell {
    color: var(--muted);
    text-align: right;
    width: 3rem;
    font-variant-numeric: tabular-nums;
}

/* Upload drop zone on run detail */
.upload-zone {
    margin-top: 1rem;
    padding: 1.25rem;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    background: #f8fafc;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
    user-select: none;
}
.upload-zone:hover {
    background: #f1f5f9;
    color: var(--fg);
    border-color: var(--accent);
}
.upload-zone.drag-over {
    background: rgba(99,102,241,0.1);
    border-color: var(--accent);
    color: var(--accent);
}
.upload-zone.uploading {
    opacity: 0.7;
    pointer-events: none;
}
.upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.upload-list {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.upload-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px 60px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.6rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
}
.upload-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--fg);
}
.upload-item-bar {
    height: 6px;
    background: rgba(15,23,42,0.08);
    overflow: hidden;
    position: relative;
}
.upload-item-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 120ms ease;
}
.upload-item-status {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-size: 0.8rem;
}
.upload-item.is-done .upload-item-fill { background: #10b981; }
.upload-item.is-done .upload-item-status { color: #065f46; }
.upload-item.is-error .upload-item-fill { background: var(--danger); }
.upload-item.is-error .upload-item-status { color: var(--danger); }

/* Image viewer overlay */
body.viewer-open { overflow: hidden; }
.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    grid-template-rows: 1fr auto;
    align-items: stretch;
    justify-items: center;
}
.image-viewer[hidden] { display: none; }
.iv-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,0.85);
    cursor: pointer;
    z-index: 0;
}
.iv-stage {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(100vw, 1400px);
    max-height: calc(100vh - 140px);
    padding: 1.5rem;
}
.iv-stage img {
    max-width: 100%;
    max-height: calc(100vh - 180px);
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 20px 60px -10px rgba(0,0,0,0.4);
}
.iv-thumbs {
    position: relative;
    z-index: 1;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(6px);
    padding: 0.6rem 1rem;
    width: 100%;
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    justify-content: center;
}
.iv-thumb {
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    border: 2px solid transparent;
    background-size: cover;
    background-position: center;
    background-color: rgba(255,255,255,0.1);
    cursor: pointer;
    padding: 0;
    opacity: 0.7;
    transition: opacity 120ms ease, border-color 120ms ease;
}
.iv-thumb:hover { opacity: 1; }
.iv-thumb.active {
    opacity: 1;
    border-color: var(--accent);
}
.iv-close, .iv-prev, .iv-next {
    position: absolute;
    z-index: 2;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 0;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease;
}
.iv-close:hover, .iv-prev:hover, .iv-next:hover {
    background: rgba(255,255,255,0.2);
}
.iv-close { top: 1rem; right: 1rem; }
.iv-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.iv-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.iv-prev:disabled, .iv-next:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.cover-edit-row {
    margin-top: 0.75rem;
    text-align: right;
}

.cover-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.cover-modal[hidden] { display: none; }
.cover-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,0.7);
    cursor: pointer;
}
.cover-modal-card {
    position: relative;
    z-index: 1;
    background: var(--card, #fff);
    color: inherit;
    border-radius: 10px;
    padding: 1.25rem 1.25rem 1rem;
    width: min(520px, 100%);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    box-shadow: 0 24px 60px -10px rgba(0,0,0,0.35);
}
.cover-modal-card h2 {
    margin: 0 0 0.4rem;
}
.cover-modal-card .muted {
    margin: 0 0 0.9rem;
    font-size: 0.9rem;
    opacity: 0.8;
}
.cover-modal-open {
    overflow: hidden;
}

.cover-preview {
    position: relative;
    aspect-ratio: 1 / 1;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #1f2937;
    cursor: grab;
    touch-action: none;
    user-select: none;
}
.cover-preview.is-dragging {
    cursor: grabbing;
}
.cover-preview img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    -webkit-user-drag: none;
}

.cover-zoom-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0.85rem 0 0.4rem;
    font-size: 0.9rem;
}
.cover-zoom-row input[type="range"] {
    flex: 1;
}
.cover-zoom-value {
    min-width: 3.2em;
    text-align: right;
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
}

.cover-thumbs {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    margin: 0.4rem 0 0.9rem;
}
.cover-thumb {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    border: 2px solid transparent;
    background-size: cover;
    background-position: center;
    background-color: rgba(0,0,0,0.1);
    cursor: pointer;
    padding: 0;
    opacity: 0.75;
    transition: opacity 120ms ease, border-color 120ms ease;
}
.cover-thumb:hover { opacity: 1; }
.cover-thumb.is-active {
    opacity: 1;
    border-color: var(--accent, #6366f1);
}

.cover-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.photo--cover {
    outline: 2px solid var(--accent, #6366f1);
    outline-offset: 2px;
    border-radius: 6px;
}
