/* Perth Running Calendar - Production-Grade UI Design
   Inspired by Perth's coastal energy and running culture
   Bold, distinctive, purposeful - avoiding generic AI aesthetics */

/* Fonts self-hosted (no @import waterfall; the site CSP also blocks Google
   Fonts). Both are variable — a single file spans the whole weight range, so
   there are no synthetic "fake weight" @font-face rules like the old Rubik set.
   latin + latin-ext subsets each; unicode-range lets the browser skip the one
   it doesn't need. See tokens.css for --font-display / --font-body. */

/* Fraunces — display serif. Subset to opsz + wght; the WONK axis (wonky 'g',
   calligraphic ampersand) is instanced out at WONK=0, so no CSS override needed. */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/static/fonts/fraunces-variable.woff2?v=2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/static/fonts/fraunces-variable-ext.woff2?v=2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Inter — body sans (variable weight) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/inter-variable.woff2?v=1') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/inter-variable-ext.woff2?v=1') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    /* Perth-inspired color palette: Ocean blues + Sunset warmth */

    /* Functional colors. Aliases of the brand tokens (tokens.css) since
       20 Oct 2026: they were the old navy #0A2540 / slate #5A6C7D, which is
       why guides, clubs and results read as a different site. */
    --text-primary: var(--rs-text);
    --text-secondary: var(--rs-text-secondary);
    --text-muted: var(--rs-text-muted);
    --surface: var(--rs-bg-card);
    --surface-light: var(--rs-bg-elevated);
    --border: var(--rs-border);

    /* Status colors - Planning/Target */
    --status-planning-bg: #fef3c7;
    --status-planning-border: #fbbf24;
    --status-planning-text: #92400e;

    /* Status colors - Registered */
    --status-registered-bg: #dbeafe;
    --status-registered-border: #60a5fa;
    --status-registered-text: #1e40af;

    /* Status colors - Completed */
    --status-completed-bg: #d1fae5;
    --status-completed-border: #34d399;
    --status-completed-text: #065f46;

    /* Status colors - Skipped/Cancelled */
    --status-skipped-bg: #f3f4f6;
    --status-skipped-border: #9ca3af;
    --status-skipped-text: #4b5563;

    /* Status colors - Error/Danger */
    --status-error-bg: #fee2e2;
    --status-error-border: #dc2626;
    --status-error-text: #dc2626;

    /* Typography */

    /* Spacing system */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;

    /* Animations */
    --ease-out: cubic-bezier(0.19, 1, 0.22, 1);
    /* Was an overshooting bounce (0.68, -0.55, 0.265, 1.55); an ease-out since the
       20 Oct 2026 review. The name stays because pages use it. */
    --ease-bounce: cubic-bezier(0.16, 1, 0.3, 1);

    /* Border Radius Scale */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 50px;

    /* Shadow Scale */
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.2);

    /* Transition Scale */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== iOS & Touch Device Optimizations ===== */
html {
    /* Prevent double-tap zoom on iOS */
    touch-action: manipulation;
    /* Smooth scrolling */
    -webkit-overflow-scrolling: touch;
}

/* Remove tap highlight on iOS */
a, button, input, select, textarea, [role="button"], .distance-badge, .btn {
    -webkit-tap-highlight-color: transparent;
}

/* Active/pressed states for touch feedback */
.btn:active,
.btn-primary:active,
.btn-secondary:active,
.distance-badge:active,
a:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* Safe area insets for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .my-calendar-sidebar {
        padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
    }

    footer {
        padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
    }
}

body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--surface-light);
    overflow-x: hidden;
}

/* The rotating 3% yellow gradient behind every page (body::before) was removed on
   20 Oct 2026: it showed as a tinted diagonal wherever content had no background
   of its own (results, guides) and composited every frame on phones. */

.container {
    max-width: 100%;
    background: var(--surface);
    min-height: 100vh;
}

/* Header - Bold & Athletic */
header {
    background: linear-gradient(135deg, var(--rs-text) 0%, var(--rs-text-secondary) 70%, var(--rs-accent) 100%);
    color: white;
    padding: 10px var(--space-lg);
    position: relative;
    overflow: hidden;
}

header::after {
    content: '🏃';
    position: absolute;
    font-size: 10rem;
    opacity: 0.15;
    right: -1rem;
    top: 50%;
    transform: translateY(-50%) rotate(-15deg);
    animation: float 6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes float {
    0%, 100% { transform: translateY(-50%) rotate(-15deg) translateX(0); }
    50% { transform: translateY(-50%) rotate(-15deg) translateX(-20px); }
}

.header-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 1;
    padding: 0;
}

a.header-content.header-link {
    text-decoration: none;
    color: inherit;
}

a.header-content.header-link:hover,
a.header-content.header-link:focus {
    text-decoration: none;
    opacity: 0.9;
}

.site-logo {
    height: 80px;
    width: auto;
    filter: brightness(0) invert(1); /* White version for visibility on teal */
    animation: slideInLeft 0.8s var(--ease-out);
    flex-shrink: 0;
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

/* .site-title is the header logo wordmark. It used to be an <h1>, which meant
   every page sent Google the same H1 ("RacesCanada") and race pages had two.
   The bare h1 selector is kept so existing page headings are unaffected. */
h1, .site-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
    animation: slideInLeft 0.8s var(--ease-out);
}

/* Wordmark: heavier + tighter than a page heading so the Fraunces masthead
   reads as a lockup with the icon rather than as running text. */
.site-title {
    font-weight: 700;
    letter-spacing: -0.035em;
}

h1 .highlight, .site-title .highlight {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
}

.subtitle {
    font-size: 15px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    animation: slideInLeft 0.8s var(--ease-out) 0.1s both;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Stats - Asymmetric Cards */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
}

.stat {
    background: white;
    padding: var(--space-sm) var(--space-md);
    border-radius: 12px;
    border: 2px solid var(--border);
    position: relative;
    overflow: hidden;
    transform-origin: center;
    animation: popIn 0.6s var(--ease-bounce) both;
}

.stat:nth-child(1) { animation-delay: 0.2s; }
.stat:nth-child(2) { animation-delay: 0.3s; }
.stat:nth-child(3) { animation-delay: 0.4s; border: 2px solid var(--rs-accent); }

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--rs-text-secondary), var(--rs-accent));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.6s var(--ease-out);
}

.stat:hover::before {
    transform: scaleX(1);
}

.stat-number {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    color: var(--rs-text);
    margin-bottom: 0.25rem;
    display: block;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Controls - Clean & Functional */
.controls {
    background: white;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.controls-row {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    flex-wrap: wrap;
}

/* Multi-select dropdown for event type filter */
.multi-select-dropdown {
    position: relative;
    display: inline-block;
}

.multi-select-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: white;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-family: var(--font-body);
    min-width: 140px;
    justify-content: space-between;
    transition: all 0.2s var(--ease-out);
}

.multi-select-btn:hover {
    border-color: var(--rs-border-dark);
}

.multi-select-btn:focus {
    outline: none;
    border-color: var(--rs-accent);
    box-shadow: 0 0 0 4px rgba(22, 22, 22, 0.1);
}

.dropdown-arrow {
    font-size: 10px;
    color: var(--text-muted);
}

.multi-select-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 2px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 160px;
    margin-top: 4px;
}

.multi-select-dropdown.open .multi-select-options {
    display: block;
}

.multi-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 1rem;
    font-family: var(--font-body);
}

.multi-select-option:hover {
    background: var(--surface-light);
}

.multi-select-option input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.view-toggle {
    display: flex;
    gap: 0;
    background: var(--surface-light);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.view-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    font-family: var(--font-body);
    transition: all 0.3s var(--ease-out);
    color: var(--text-secondary);
}

.view-btn.active {
    background: var(--rs-text);
    color: white;
    transform: scale(1.05);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

select, input[type="text"], input[type="date"] {
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: var(--font-body);
    transition: all 0.2s var(--ease-out);
    background-color: white;
}

/* ============================================================
   FORM CONTROLS — canonical appearance
   Native select and checkbox chrome is drawn by the OS, so a macOS blue
   dropdown sat next to the custom yellow pill controls and read as a
   different application. These set the properties page CSS almost never
   touches (appearance, accent-color), so one rule here reaches nearly every
   control without having to out-specify ~80 scattered page-level rules.
   ============================================================ */
select {
    /* Chevron is an inline data: URI — no extra request, and img-src in the
       CSP already allows data:. */
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23161616' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 8px;
    padding-right: 38px;
    cursor: pointer;
}

/* Leave multi-selects and size>1 alone — they render as list boxes, where a
   chevron would be wrong. */
select[multiple],
select[size]:not([size="1"]) {
    background-image: none;
    padding-right: 14px;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--rs-accent);
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

select:hover, input:hover {
    border-color: var(--rs-border-dark);
}

select:focus, input:focus {
    outline: none;
    border-color: var(--rs-accent);
    box-shadow: 0 0 0 4px rgba(22, 22, 22, 0.1);
}

.search-box {
    min-width: 280px;
}

.btn-toggle-sidebar {
    padding: 10px 24px;
    background: var(--rs-accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
    margin-left: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.btn-toggle-sidebar:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
    background: var(--rs-accent-hover);
}

.btn-toggle-sidebar:active {
    transform: translateY(0);
}

/* Main Layout - Asymmetric Grid with Month Nav */
.main-layout {
    display: grid;
    grid-template-columns: 200px 1fr 420px;
    min-height: calc(100vh - 400px);
    gap: 0;
}

/* Month Navigation Sidebar */
.month-nav-sidebar {
    position: sticky;
    top: 20px;
    align-self: start;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: var(--space-md);
    background: linear-gradient(135deg, #F8FAFB, #FFFFFF);
    border-right: 1px solid var(--border);
}

.month-nav-sidebar h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--rs-text);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.month-nav-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.month-nav-item {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    border-left: 3px solid transparent;
}

.month-nav-item:hover {
    background: white;
    color: var(--rs-text);
    border-left-color: var(--rs-border-dark);
    transform: translateX(4px);
}

.month-nav-item.active {
    background: linear-gradient(135deg, var(--rs-text), var(--rs-text-secondary));
    color: white;
    border-left-color: var(--rs-accent);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.content {
    padding: var(--space-lg);
    background: white;
}

/* Race Cards - Bold & Distinctive */
.month-section {
    margin-bottom: var(--space-xl);
    animation: fadeInUp 0.6s var(--ease-out) both;
}

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

.month-header {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--rs-text);
    margin-bottom: var(--space-md);
    position: relative;
    display: inline-block;
}

.month-header::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60%;
    height: 4px;
    background: linear-gradient(90deg, var(--rs-text-secondary), var(--rs-accent));
    border-radius: 2px;
}

.race-card {
    background: white;
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-sm);
    transition: all 0.4s var(--ease-out);
    position: relative;
    transform-origin: left center;
}

.race-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(180deg, var(--rs-text-secondary), var(--rs-accent));
    border-radius: 20px 0 0 20px;
    opacity: 0;
    transition: opacity 0.3s var(--ease-out);
}

.race-card:hover {
    border-color: var(--rs-accent);
    transform: translateX(8px);
    box-shadow: -4px 8px 24px rgba(0, 0, 0, 0.12);
}

.race-card:hover::before {
    opacity: 1;
}

.race-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: -1.25rem -1.25rem 0.75rem -1.25rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(243, 246, 249, 0.6), rgba(243, 246, 249, 0.3));
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.race-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.race-date {
    background: linear-gradient(135deg, var(--rs-text), var(--rs-text-secondary));
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: var(--font-display);
    white-space: nowrap;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.race-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    flex: 1;
}

.race-organizer-logo {
    height: 64px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    opacity: 0.95;
    transition: all 0.2s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.race-organizer-logo:hover {
    opacity: 1;
    transform: scale(1.05);
}

.race-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-icon {
    font-size: 1rem;
}

.detail-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    min-width: 70px;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 1rem;
    flex: 1;
}

/* Distance Badges - Eye-catching */
.distances {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.distance-badge {
    background: linear-gradient(135deg, var(--rs-accent), var(--rs-accent-hover));
    color: white;
    padding: 10px 22px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s var(--ease-bounce);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.distance-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.distance-badge:hover::before {
    left: 100%;
}

.distance-badge:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
}

.distance-badge:active {
    transform: translateY(0) scale(1);
}

.distance-badge.selected {
    background: var(--rs-success);
    border-color: white;
}

.organizer-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-light);
    color: var(--rs-text);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid var(--border);
}

.organizer-logo {
    height: 24px;
    width: auto;
    max-width: 60px;
    object-fit: contain;
}

/* Terrain Badge */
.terrain-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, var(--rs-success), var(--rs-border-dark));
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: capitalize;
}

/* Race Image */
.race-image {
    width: 100%;
    height: 180px;
    background-size: cover;
    background-position: center;
    border-radius: 12px 12px 0 0;
    margin: -1.25rem -1.25rem 1rem -1.25rem;
}

/* Race Description */
.race-description {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--surface-light);
    border-radius: 8px;
    border-left: 3px solid var(--rs-border-dark);
}

/* ========================================
   Races Table Styles
   ======================================== */
.races-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: var(--space-lg);
    table-layout: fixed;
}

/* Fixed column widths for consistent alignment across months */
.races-table th:nth-child(1),
.races-table td:nth-child(1) { width: 80px; }   /* Date */
.races-table th:nth-child(2),
.races-table td:nth-child(2) { width: 35%; }    /* Event Name */
.races-table th:nth-child(3),
.races-table td:nth-child(3) { width: 200px; }  /* Distances */
.races-table th:nth-child(4),
.races-table td:nth-child(4) { width: auto; }   /* Location - takes remaining space */

.races-table thead {
    background: var(--rs-text);
    color: white;
}

.races-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.races-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.races-table tbody tr:last-child td {
    border-bottom: none;
}

.race-row {
    transition: background 0.15s ease;
}

.race-row:hover {
    background: var(--rs-bg-elevated);
}

/* Featured race styles */

.race-date-cell {
    white-space: nowrap;
    color: var(--text-muted);
    font-weight: 500;
    width: 100px;
}

.race-name-cell {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.race-name-cell .race-name-link {
    color: var(--rs-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.race-name-cell .race-name-link:hover {
    color: var(--rs-text-secondary);
    text-decoration: underline;
}

.race-name-cell .terrain-badge-small {
    display: inline-block;
    background: #ccfbf1;
    color: #115e59;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

/* Sport category badges - only for non-running events */
.race-name-cell .sport-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
    color: white;
}

.sport-badge-running {
    background: #27ae60; /* Green for running */
}

.sport-badge-triathlon {
    background: #3498db; /* Bright blue for swim/bike/run */
}

.sport-badge-duathlon {
    background: #e67e22; /* Orange for bike/run */
}

.sport-badge-aquathon {
    background: #1abc9c; /* Teal for swim/run */
}

.sport-badge-multisport {
    background: #9b59b6; /* Purple for other multi-sport */
}

.sport-badge-wheelchair {
    background: #2980b9; /* Deep blue for wheelchair racing */
}

.sport-badge-backyard {
    background: #8e44ad; /* Dark purple for backyard ultra */
}

.race-name-cell .notes-indicator {
    margin-left: 6px;
    cursor: help;
}

.race-distances-cell {
    min-width: 180px;
    max-width: 320px;
    vertical-align: middle;
}

.race-distances-cell .distance-badges-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.race-distances-cell .distance-badge {
    margin: 0;
    padding: 4px 10px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    white-space: normal;
    max-width: 100%;
    text-align: center;
    line-height: 1.3;
}

.race-distances-cell .tba {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
}

.race-location-cell {
    color: var(--text-secondary);
    word-wrap: break-word;
}

/* Responsive table - tablet view */
@media (max-width: 900px) and (min-width: 769px) {
    .races-table {
        display: block;
        overflow-x: auto;
    }

    .races-table th,
    .races-table td {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .race-location-cell {
        display: none;
    }
}

/* Note: Mobile card layout (≤768px) is defined in the 768px media query below */

/* Sidebar - Sticky & Functional */
.my-calendar-sidebar {
    background: linear-gradient(180deg, #F8FAFB 0%, #FFFFFF 100%);
    border-left: 1px solid var(--border);
    padding: var(--space-lg);
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}

.calendar-header {
    margin-bottom: var(--space-md);
}

.calendar-header h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--rs-text);
    margin-bottom: 0.5rem;
}

.calendar-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.calendar-stats {
    background: white;
    padding: var(--space-md);
    border-radius: 16px;
    margin-bottom: var(--space-md);
    border: 2px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stat-box {
    text-align: center;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.sidebar-header h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--rs-text);
}

.btn-close-sidebar {
    display: none;
}

.calendar-summary {
    background: white;
    padding: var(--space-md);
    border-radius: 16px;
    margin-bottom: var(--space-md);
    border: 2px solid var(--border);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.summary-value {
    color: var(--rs-text);
    font-weight: 700;
    font-size: 1.1rem;
}

/* Calendar Event Cards */
.calendar-event-card {
    background: white;
    padding: var(--space-md);
    border-radius: 14px;
    border-left: 4px solid var(--rs-accent);
    margin-bottom: var(--space-sm);
    transition: all 0.3s var(--ease-out);
    animation: slideInRight 0.4s var(--ease-out) both;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.calendar-event-card:hover {
    transform: translateX(-4px);
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.1);
}

.event-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.event-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.event-distance {
    display: inline-block;
    background: linear-gradient(135deg, var(--rs-text-secondary), var(--rs-border-dark));
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 8px;
}

.event-time-until {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: var(--space-sm);
    padding: 8px 12px;
    background: linear-gradient(135deg, #E0F2FE, #BAE6FD);
    border-left: 3px solid var(--rs-accent);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #0C4A6E;
}

.event-time-until.event-today {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border-left-color: #D97706;
    color: #92400E;
}

.event-gap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.gap-badge {
    background: var(--surface-light);
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    color: var(--text-primary);
}

.gap-warning {
    color: var(--rs-accent-hover);
}

.gap-good {
    color: var(--rs-success);
}

/* Buttons */
.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
    /* One control height everywhere. Page padding overrides were producing a
       37/41/44px row of buttons sitting side by side; 44px is also the tap
       minimum, so this is not a mobile-only concern. */
    min-height: 44px;
}

/* Small icon-only controls (expand carets, row actions) still need a real
   hit area even where the visual button is deliberately tiny. */
.expand-btn,
.btn-icon {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* The one primary button. This used to be a dark navy gradient that no page
   actually wanted: five page stylesheets overrode it to flat brand yellow, six
   more overrode the login modal to a yellow gradient, and the single page that
   did neither (athlete.css) rendered the shared modal navy-on-white. Flat
   yellow is the real consensus, so it lives here and the overrides are gone. */
.btn-primary {
    background: var(--rs-accent);
    color: var(--rs-accent-text);
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.btn-primary:hover {
    background: var(--rs-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

/* Disabled applies to every .btn variant, and must also kill the hover lift —
   race-detail.css, feedback.css and settings.css each had a partial copy. */
.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* The one secondary button. Same story as .btn-primary: the canonical rule was
   another navy gradient with an ocean-blue shadow, so five stylesheets each
   wrote their own. "Cancel" in a modal rendered five different ways — white or
   grey or transparent, 0/1/2px border, 8/10/25px radius. Three of the five
   agreed on a neutral surface with a 2px border, and three of four hovers
   agreed on the accent border, so that is what this is. */
.btn-secondary {
    background: var(--rs-bg-card);
    color: var(--rs-text);
    border: 2px solid var(--rs-border);
}

.btn-secondary:hover {
    background: var(--rs-accent-light);
    border-color: var(--rs-accent);
    color: var(--rs-text);
    transform: translateY(-2px);
}

.btn-remove {
    padding: 8px 16px;
    background: var(--surface-light);
    color: var(--rs-accent-hover);
    border: 2px solid var(--rs-accent);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    margin-top: var(--space-sm);
}

.btn-remove:hover {
    background: var(--rs-accent);
    color: white;
}

/* Navigation Links */
.nav-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--surface-light);
    border-bottom: 1px solid var(--border);
}

.nav-left {
    display: flex;
    gap: 24px;
    align-items: center;
}

.nav-right {
    display: flex;
    gap: 20px;
    align-items: center;
}

/* On most pages the bar is fixed across the whole header, above the logo, so its empty
   space swallowed every tap on the logo (John, 25 Oct 2026: "tapping it never did
   anything"). Clicks pass through the bar itself; its links, menus and buttons still
   take them. */
.nav-links { pointer-events: none; }
.nav-links > * { pointer-events: auto; }

.nav-links a {
    color: var(--rs-text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--rs-text);
    text-decoration: underline;
}

.nav-links a.active {
    color: var(--rs-text);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Hide Contact link by default to prevent flash - shown by JS for logged-out users */
.nav-left a[href="/contact.html"] {
    display: none;
}

/* Nav user dropdown */
.nav-user-dropdown {
    position: relative;
}

.nav-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.nav-user-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.nav-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.nav-user-initials {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    /* Brand yellow everywhere - every page stylesheet already overrode the old
       near-black default, which vanished on the dark header of pages that
       don't (race detail). */
    background: var(--rs-accent, #D52B1E);
    color: var(--rs-accent-text, #161616);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.nav-user-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-dropdown-arrow {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    padding: 8px 0;
    z-index: 9999;
    margin-top: 4px;
}

.nav-dropdown-menu.show {
    display: block;
}

/* Notifications bell, left of the user menu (site-nav.js bellHtml, 31 Oct 2026) */
.nav-bell { position: relative; }
.nav-bell-btn {
    position: relative; display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; padding: 0; border: none; border-radius: 50%;
    background: none; color: inherit; cursor: pointer; transition: background 0.2s;
}
.nav-bell-btn:hover { background: rgba(127, 127, 127, 0.18); }
.nav-bell-btn:focus-visible { outline: 2px solid var(--rs-accent, #D52B1E); outline-offset: 2px; }
.nav-bell-badge {
    position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--rs-accent, #D52B1E); color: var(--rs-accent-text, #161616);
    font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center;
    font-variant-numeric: tabular-nums;
}
.nav-bell-panel {
    position: absolute; top: 100%; right: 0; margin-top: 6px; z-index: 9999;
    width: min(340px, calc(100vw - 24px)); max-height: min(70vh, 480px); overflow-y: auto;
    background: #fff; color: var(--text-primary, #161616); border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); padding: 6px 0;
}
.nav-bell-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px 6px 16px; }
.nav-bell-title { margin: 0; font-size: 0.8rem; font-weight: 700; color: var(--text-secondary, #6b6b6b); }
.nav-bell-readall {
    border: none; background: none; padding: 4px 6px; border-radius: 6px; cursor: pointer;
    font: inherit; font-size: 0.82rem; font-weight: 600; color: #161616; text-decoration: underline;
    text-decoration-color: var(--rs-accent, #D52B1E); text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.nav-bell-readall:hover { background: #f3f2ee; }
.nav-bell-readall[hidden] { display: none; }
.nav-bell-actions { display: flex; gap: 4px; }
.nav-links .nav-bell-panel a.nav-bell-item,
.nav-bell-item {
    display: grid; gap: 2px; padding: 10px 16px; border-top: 1px solid #eee;
    color: var(--text-primary, #161616); text-decoration: none; font-weight: 400;
}
.nav-links .nav-bell-panel a.nav-bell-item:hover { background: #f6f6f4; text-decoration: none; color: var(--text-primary, #161616); }
.nav-bell-item.is-new { box-shadow: inset 3px 0 0 var(--rs-accent, #D52B1E); }
/* Explicit colours: the dark-header pages whiten every link in .nav-links. */
.nav-bell-item-title { font-weight: 600; font-size: 0.92rem; color: #161616 !important; }
.nav-bell-item-body { font-size: 0.88rem; color: #3d3d3d !important; font-variant-numeric: tabular-nums; }
.nav-bell-item-when { font-size: 0.78rem; color: #6b6b6b; }
.nav-bell-empty { margin: 0; padding: 12px 16px 14px; font-size: 0.9rem; color: #3d3d3d; }
/* Phones: the bell sits mid-header, so a panel hung off it ran off the left edge.
   Pin it under the header, full width less a gutter. */
@media (max-width: 600px) {
    .nav-bell-panel { position: fixed; top: 54px; left: 12px; right: 12px; width: auto; margin-top: 0; }
}

.nav-dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text-primary);
    font-weight: 500;
}

.nav-dropdown-menu a:hover {
    background: #f5f5f5;
    text-decoration: none;
}

.nav-dropdown-menu hr {
    margin: 8px 0;
    border: none;
    border-top: 1px solid #eee;
}

.nav-sign-in {
    padding: 8px 18px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    transition: all 0.25s ease;
}

.nav-sign-in:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
    text-decoration: none !important;
    transform: translateY(-1px);
}

/* Mobile nav adjustments */
@media (max-width: 600px) {
    .nav-links {
        flex-wrap: wrap;
        gap: 10px;
    }

    .nav-left {
        gap: 16px;
        flex-wrap: wrap;
    }

    .nav-user-name {
        display: none;
    }

    .nav-dropdown-arrow {
        display: none;
    }
}

/* ========================================
   Mobile Hamburger Menu
   ======================================== */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 102;
    margin-right: 12px;
}

.hamburger-menu span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-menu:hover span {
    background: #D52B1E;
}

/* Hamburger animation when open */
.hamburger-menu.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.open span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile Navigation Overlay */
.mobile-nav-menu {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: rgba(22, 22, 22, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 20px;
    z-index: 100;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-direction: column;
    gap: 8px;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mobile-nav-menu.show {
    display: flex;
}

.mobile-nav-menu a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.mobile-nav-menu a:hover,
.mobile-nav-menu a.active {
    background: rgba(213,43,30, 0.15);
    color: var(--rs-accent-ink);
}

.mobile-nav-menu hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 8px 0;
}

/* Show hamburger on tablet/mobile when nav-left is hidden */
@media (max-width: 1024px) {
    .hamburger-menu {
        display: flex;
    }
}

/* ========================================
   Mobile Navigation Bar (persistent links)
   ======================================== */
.mobile-nav-bar {
    display: none;
    background: rgba(22, 22, 22, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 6px 20px;
    justify-content: flex-start;
    /* 14px, not 24: a signed-in user now has seven links here (Home/Races/
       Guides/Clubs/Calendar/Results/Dashboard). At 24px the gaps alone were
       144px of a 508px requirement — nearly a third — against 323px for the
       link text itself, so tightening them buys back more room than any
       other change. 425px still doesn't fit a 390px phone, but only
       "Dashboard" ends up off-screen instead of two and a half links. */
    gap: 14px;
    /* Scroll the row rather than overflowing the document — at 320px the
       overflow used to push the whole page sideways. overflow-x is safe
       here: nothing inside this bar is position:sticky. */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;

}

/* Fade the trailing edge so it's visible that the row continues. Without it
   the bar looks like it simply ends at whichever link happens to be cut off,
   and the ones past it may as well not exist.

   Painted as a mask rather than a gradient overlay, which would need its own
   opaque colour and would break the backdrop-filter behind it. The mask is
   anchored to the scrollport, so it stays at the right edge as the row
   scrolls.

   Only applied when the row actually overflows — the mask affects the bar's
   background too, so leaving it on unconditionally would fade the right end
   of the bar into nothing on pages where everything already fits (signed
   out, that's four links). CSS can't ask "does this overflow", so
   nav-auth.js sets the class. */
.mobile-nav-bar.is-scrollable {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
}

.mobile-nav-bar::-webkit-scrollbar {
    display: none;
}

.mobile-nav-bar a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    /* 44px tall so the tap target meets the minimum. The row height itself is
       unchanged — the links were 17px of hit area inside it, which is roughly a
       third of what a thumb needs. */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0;
    /* don't let links compress or wrap inside the scrolling row */
    flex: 0 0 auto;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.mobile-nav-bar a:hover,
.mobile-nav-bar a.active {
    color: var(--rs-accent-ink);
}

/* Show mobile nav bar on mobile devices */
@media (max-width: 768px) {
    .mobile-nav-bar {
        display: flex;
        position: fixed;
        top: 50px;
        left: 0;
        right: 0;
        z-index: 99;
        padding-top: 0;
        padding-bottom: 3px;
        background: #0c0c0c;
    }
}

/* Loading & Empty States */
.loading, .empty-state, .empty-calendar {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4em;
    margin-bottom: var(--space-md);
    opacity: 0.2;
}

/* Footer */
footer {
    background: var(--rs-text);
    color: white;
    padding: var(--space-lg);
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* A wrapping row spaced by gap, not "&bull;" text separators: a text bullet
   can't know where the line breaks, so on phones one dangled at the end of
   each wrapped line ("Contact •"). */
footer .footer-links {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    column-gap: 20px;
}

footer .footer-links a {
    color: var(--rs-accent-hover);
    text-decoration: none;
    transition: color 0.2s;
    /* 44px minimum tap height; these were 17px inline anchors */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

footer .footer-links a:hover {
    color: white;
    text-decoration: underline;
}

/* Popular Searches - SEO internal linking */
footer .popular-searches {
    margin: var(--space-md) 0;
    padding-top: var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

footer .popular-searches h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

footer .search-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-xs) var(--space-sm);
}

footer .search-links a {
    color: var(--rs-text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    transition: all 0.2s ease;
}

footer .search-links a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    text-decoration: none;
}

/* Mobile Responsive */
@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .month-nav-sidebar {
        display: none;
    }

    .my-calendar-sidebar {
        position: fixed;
        right: -100%;
        top: 0;
        bottom: 0;
        width: 90%;
        max-width: 420px;
        z-index: 1000;
        box-shadow: -4px 0 20px rgba(0,0,0,0.2);
        transition: right 0.4s var(--ease-out);
    }

    .my-calendar-sidebar.open {
        right: 0;
    }

    .btn-close-sidebar {
        display: flex;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
        border: none;
        background: var(--surface-light);
        border-radius: 50%;
        cursor: pointer;
        font-size: 1.3em;
        color: var(--text-secondary);
    }
}

@media (max-width: 768px) {
    :root {
        --space-lg: 1.5rem;
        --space-xl: 2.5rem;
    }

    header {
        padding: 8px var(--space-lg);
    }

    /* Compact header on mobile */
    header::after {
        display: none; /* Hide decorative emoji */
    }

    .header-content {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 0;
    }

    .site-logo {
        height: 40px;
        width: auto;
    }

    h1 {
        font-size: 18px;
    }

    .subtitle {
        display: none;
    }

    .controls {
        padding: var(--space-sm);
    }

    .controls-row {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: 100%;
    }

    .my-calendar-sidebar {
        width: 100%;
    }

    /* ===== Mobile Race Table → Card Layout ===== */
    .races-table {
        display: block;
        overflow-x: visible;
    }

    .races-table thead {
        display: none;
    }

    .races-table tbody {
        display: flex;
        flex-direction: column;
        gap: var(--space-sm);
    }

    .races-table tbody tr {
        display: flex;
        flex-direction: column;
        background: white;
        border: 2px solid var(--border);
        border-radius: 12px;
        padding: var(--space-sm);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }

    .races-table tbody tr:hover {
        border-color: var(--rs-accent);
    }

    .races-table td {
        display: block;
        padding: 4px 0;
        border: none;
        width: 100% !important;
    }

    /* Date cell styling */
    .race-date-cell {
        font-weight: 700;
        color: var(--rs-text);
        font-size: 0.85rem;
        order: -2;
        padding-bottom: 4px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 8px;
    }

    /* Race name styling */
    .race-name-cell {
        font-size: 1rem;
        font-weight: 600;
        order: -1;
        margin-bottom: 8px;
    }

    .race-name-cell a {
        text-decoration: none;
    }

    /* Location cell */
    .race-location-cell {
        font-size: 0.85rem;
        color: var(--text-muted);
        margin-bottom: 8px;
    }

    /* Distance badges in a row */
    .race-distances-cell {
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--border);
    }

    /* Hide location on mobile cards */
    .race-location-cell {
        display: none;
    }

    /* Improve touch targets for mobile */
    .distance-badge {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 10px 18px;
    }

    .btn, .btn-primary, .btn-secondary {
        min-height: 44px;
        padding: 12px 20px;
    }

    select, input[type="text"], input[type="date"] {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Stack race header on mobile */
    .race-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .race-organizer-logo {
        align-self: flex-end;
        height: 48px;
    }
}

/* Parkrun Section */
.add-parkrun-section, .export-section {
    background: white;
    padding: var(--space-md);
    border-radius: 16px;
    margin-bottom: var(--space-md);
    border: 2px solid var(--border);
}

.add-parkrun-section h3, .export-section h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--rs-text);
    margin-bottom: var(--space-sm);
}

.parkrun-form {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.parkrun-date-input {
    flex: 1;
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Parkrun section styles */
.parkrun-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.parkrun-section h3 {
    margin-bottom: var(--space-xs);
}

.parkrun-section input[type="date"],
.parkrun-section select {
    width: 100%;
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background-color: white;
}

.parkrun-section select {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.parkrun-section .btn-secondary {
    width: 100%;
    margin-top: var(--space-xs);
}

.export-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.selected-events h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--rs-text);
    margin-bottom: var(--space-sm);
}

.calendar-events-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.race-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    flex-wrap: wrap;
}

.notes {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: linear-gradient(135deg, #FFF4E6, #FFE8CC);
    border-left: 4px solid var(--rs-accent);
    border-radius: 10px;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Gap indicators on race cards */
.race-gap {
    margin-top: var(--space-md);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 4px solid;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.race-gap.gap-good {
    background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
    border-left-color: var(--rs-success);
    color: #065f46;
}

.race-gap.gap-too-close {
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
    border-left-color: #DC2626;
    color: #991B1B;
}

.race-gap.gap-too-far {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    border-left-color: #D97706;
    color: #92400E;
}

/* Registration status badges */
.rego-status {
    margin: var(--space-sm) 0;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rego-status.rego-open {
    background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
    color: #065f46;
    border-left: 3px solid var(--rs-success);
}

/* OPENS TODAY - Most urgent! Red pulsing */
.rego-status.rego-opens-today {
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
    color: #B91C1C;
    border-left: 4px solid #EF4444;
    font-weight: 700;
    animation: pulse-urgent-bg 1.5s ease-in-out infinite;
}

/* OPENS TOMORROW - Very urgent, orange */
.rego-status.rego-opens-tomorrow {
    background: linear-gradient(135deg, #FFEDD5 0%, #FED7AA 100%);
    color: #C2410C;
    border-left: 4px solid #F97316;
    font-weight: 600;
}

/* Opens in 2-3 days - Prominent blue */
.rego-status.rego-opens-soon {
    background: linear-gradient(135deg, #DBEAFE 0%, #93C5FD 100%);
    color: #1D4ED8;
    border-left: 4px solid #3B82F6;
    font-weight: 600;
}

.rego-status.rego-pending {
    background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
    color: #1e40af;
    border-left: 3px solid var(--rs-accent);
}

@keyframes pulse-urgent-bg {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
        transform: scale(1.01);
    }
}

.rego-status.rego-closing-soon {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    color: #92400E;
    border-left: 3px solid #D97706;
    animation: pulse-warning 2s ease-in-out infinite;
}

.rego-status.rego-closed {
    background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
    color: #6B7280;
    border-left: 3px solid #9CA3AF;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* Calendar View Styles */
.calendar-view {
    padding: var(--space-lg);
}

.calendar-month {
    margin-bottom: var(--space-xl);
}

.calendar-month-header {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--rs-text);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 3px solid var(--rs-accent);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.calendar-day-header {
    background: linear-gradient(135deg, var(--rs-text), var(--rs-text-secondary));
    color: white;
    padding: var(--space-sm);
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-day {
    background: white;
    min-height: 100px;
    padding: 8px;
    position: relative;
    transition: all 0.2s var(--ease-out);
}

.calendar-day:hover {
    background: var(--surface-light);
}

.calendar-day-empty {
    background: #F8F9FA;
}

.calendar-day-today {
    background: linear-gradient(135deg, #FFF9E6, #FFECB3);
    border: 2px solid var(--rs-accent);
}

.calendar-day-has-race {
    border-left: 3px solid var(--rs-accent);
}

.calendar-day-has-event {
    border-left: 3px solid var(--rs-success);
    font-weight: 600;
}

.calendar-day-number {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.calendar-day-today .calendar-day-number {
    color: var(--rs-accent-hover);
    font-size: 1rem;
}

.calendar-day-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Calendar pills (compact event display) */
.calendar-event-pill,
.calendar-race-pill {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-event-pill {
    background: linear-gradient(135deg, var(--rs-success), #3DBAA2);
    color: white;
    border-left: 3px solid #1E6F64;
}

.calendar-event-pill:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 6px rgba(42, 157, 143, 0.3);
}

.calendar-race-pill {
    background: linear-gradient(135deg, var(--rs-border-dark), #6BC5E8);
    color: white;
    border-left: 3px solid var(--rs-accent);
}

.calendar-race-pill:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.event-pill-icon {
    font-size: 0.7rem;
}

.event-pill-text,
.race-pill-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-pill-distance,
.race-pill-distance {
    font-size: 0.7rem;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.2);
    padding: 1px 4px;
    border-radius: 3px;
}

/* Race Details Modal */
.race-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.race-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 37, 64, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.race-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s var(--ease-out);
}

.race-modal-header {
    background: linear-gradient(135deg, var(--rs-text), var(--rs-text-secondary));
    color: white;
    padding: var(--space-lg);
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.race-modal-header h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
}

.race-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--ease-out);
}

.race-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.race-modal-body {
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.modal-detail {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.modal-detail strong {
    color: var(--rs-text);
    font-weight: 700;
}

.modal-distances {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.distance-badge-large {
    background: linear-gradient(135deg, var(--rs-text-secondary), var(--rs-border-dark));
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
}

.distance-badge-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
    background: linear-gradient(135deg, var(--rs-text), var(--rs-text-secondary));
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Year grouping in sidebar */
.year-group {
    margin-bottom: 10px;
}

.year-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--rs-bg-elevated);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    color: var(--rs-text);
    transition: all 0.2s ease;
}

.year-header:hover {
    background: var(--rs-border-light);
}

.year-toggle {
    font-size: 0.7em;
    transition: transform 0.2s ease;
    display: inline-block;
}

.year-group.expanded .year-toggle {
    transform: rotate(90deg);
}

.year-label {
    flex: 1;
}

.year-count {
    font-size: 0.85em;
    color: var(--text-secondary);
    font-weight: 400;
}

.year-months {
    display: none;
    padding-left: 20px;
    margin-top: 5px;
}

.year-group.expanded .year-months {
    display: block;
}

.year-months .month-nav-item {
    padding: 8px 12px;
    font-size: 0.95em;
}

/* ========================================
   Authentication Styles
   ======================================== */

.auth-section {
    margin-left: auto;
    display: flex;
    align-items: center;
    align-self: flex-start;
    margin-top: -0.5rem;
}

.login-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-google {
    background: white;
    color: #333;
    border: 1px solid #ddd;
}

.btn-google:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.btn-facebook {
    background: #1877f2;
    color: white;
}

.btn-facebook:hover {
    background: #166fe5;
}

.login-hint {
    color: rgba(255,255,255,0.7);
    font-size: 0.875rem;
}

.btn-my-calendar {
    background: linear-gradient(135deg, var(--rs-accent), var(--rs-accent-hover));
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transition: all 0.2s ease;
    margin-right: 10px;
}

.btn-my-calendar:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
}

.btn-my-calendar::before {
    content: '📅';
}

.btn-contact {
    background: white;
    color: var(--rs-text);
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-contact:hover {
    background: var(--rs-bg-elevated);
    transform: translateY(-2px);
}

.btn-contact::before {
    content: '➕';
}

.user-profile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
}

.user-profile:hover {
    background: rgba(255,255,255,0.2);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
}

.user-name {
    font-weight: 500;
    color: white;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 150px;
    z-index: 9999;
}

/* Invisible bridge to prevent hover gap */
.user-profile::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 15px;
}

.user-profile:hover .user-dropdown {
    display: block;
}

.user-dropdown-inner {
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
    background: white;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.dropdown-item:hover {
    background: #f5f5f5;
}

/* Login Modal */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
}

.login-modal-content {
    position: relative;
    background: white;
    padding: 40px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.login-modal-content h2 {
    color: #1e40af;
    margin-bottom: 15px;
}

.login-modal-content p {
    color: #64748b;
    margin-bottom: 25px;
}

.login-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-options .btn {
    width: 100%;
    justify-content: center;
}

/* ========================================
   Visual Polish Enhancements
   ======================================== */

/* Staggered table row animations */
.race-row {
    animation: fadeInRow 0.4s ease-out both;
}

.race-row:nth-child(1) { animation-delay: 0.05s; }
.race-row:nth-child(2) { animation-delay: 0.10s; }
.race-row:nth-child(3) { animation-delay: 0.15s; }
.race-row:nth-child(4) { animation-delay: 0.20s; }
.race-row:nth-child(5) { animation-delay: 0.25s; }
.race-row:nth-child(6) { animation-delay: 0.30s; }
.race-row:nth-child(7) { animation-delay: 0.35s; }
.race-row:nth-child(8) { animation-delay: 0.40s; }
.race-row:nth-child(9) { animation-delay: 0.45s; }
.race-row:nth-child(10) { animation-delay: 0.50s; }

@keyframes fadeInRow {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Enhanced hover effects for table rows */
.race-row:hover {
    background: linear-gradient(90deg, rgba(79, 179, 217, 0.08) 0%, rgba(255, 255, 255, 0) 100%);
    transform: scale(1.002);
}

/* Button press feedback */
.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-table-action:active {
    transform: scale(0.97);
    transition: transform 0.1s ease;
}

.distance-badge:active {
    transform: scale(0.95);
}

/* Skeleton loading animation */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Loading spinner for buttons */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Enhanced focus states for accessibility */
.btn:focus,
.distance-badge:focus,
select:focus,
input:focus {
    outline: 3px solid var(--rs-border-dark);
    outline-offset: 2px;
}

/* No smooth scroll (removed 12 Nov 2026): it animated every jump down the page (a
   #link, Google's jump-to-text, the browser restoring the spot on Back or reload),
   which passed every lazy ad on the way and loaded them unseen. */

/* Month header underline animation on hover */
.month-header:hover::after {
    width: 100%;
    transition: width 0.3s ease;
}

/* Enhanced notification styles */
.notification {
    animation: notificationSlide 0.3s ease-out;
}

@keyframes notificationSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Pulse animation for "Add to Calendar" prompts */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.18); }
    50% { box-shadow: 0 0 0 10px rgba(0, 0, 0, 0); }
}

/* Enhanced card lift on hover */
.calendar-event-card:hover,
.stat:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Smooth transition for sidebar */
.my-calendar-sidebar {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

/* Month nav item active indicator animation */
.month-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--rs-accent);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: scaleY(0);
        transform-origin: top;
    }
    to {
        transform: scaleY(1);
        transform-origin: top;
    }
}

/* Controls bar subtle shadow when scrolled */
.controls {
    transition: box-shadow 0.3s ease;
}

.controls.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Subtle gradient background for main content */
.main-content {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafb 100%);
    padding: var(--space-lg);
}

/* Info button glow effect */
.btn-table-action {
    position: relative;
    overflow: hidden;
}

.btn-table-action::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.btn-table-action:hover::before {
    width: 150%;
    height: 150%;
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* Screen reader only - visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--rs-text);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    font-weight: 600;
    z-index: 1000;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}

/* Enhanced focus indicators for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--rs-accent);
    outline-offset: 2px;
}

/* Remove default focus for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Custom focus for buttons */
button:focus-visible,
.btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible {
    outline: 3px solid var(--rs-accent);
    outline-offset: 2px;
}

/* Custom focus for form inputs */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--rs-accent);
    outline-offset: 0;
    border-color: var(--rs-accent);
}

/* Custom focus for links */
a:focus-visible {
    outline: 3px solid var(--rs-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Focus for clickable table rows */
.race-row:focus-visible {
    outline: 2px solid var(--rs-accent);
    outline-offset: -2px;
    background: var(--rs-accent-light);
}

/* Focus for distance badges */
.distance-badge:focus-visible {
    outline: 2px solid var(--rs-accent);
    outline-offset: 1px;
    transform: scale(1.05);
}

/* ============================================
   ACCESSIBILITY: Reduced Motion Support
   Respects user preference for reduced motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    /* Disable specific hover transforms */
    .btn:hover,
    .btn-primary:hover,
    .btn-secondary:hover,
    .share-btn:hover,
    .distance-badge:hover,
    .race-row:hover {
        transform: none !important;
    }

    /* Keep focus indicators functional but static */
    .distance-badge:focus-visible {
        transform: none;
    }
}

/* ============================================
   ACCESSIBILITY: High Contrast Mode Support
   Enhances visibility for users with visual impairments
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
        --text-secondary: #333333;
    }

    /* Increase border visibility */
    .race-row,
    .my-calendar-sidebar,
    .calendar-event-card,
    .btn,
    .filters,
    input,
    select,
    textarea {
        border-width: 2px !important;
        border-color: #000000 !important;
    }

    /* Ensure sufficient text contrast */
    .text-muted,
    .race-meta-item,
    .detail-label,
    .calendar-subtitle {
        color: #333333 !important;
    }

    /* Make links more visible */
    a {
        text-decoration: underline !important;
    }

    /* Ensure buttons have clear boundaries */
    .btn-primary,
    .btn-secondary {
        border: 2px solid #000000 !important;
    }

    /* Distance badges with higher contrast */
    .distance-badge {
        border: 2px solid #000000 !important;
    }

    /* Focus indicators more prominent */
    *:focus-visible {
        outline-width: 3px !important;
        outline-color: #000000 !important;
    }
}

/* Windows High Contrast Mode (forced colors) */
@media (forced-colors: active) {
    /* Ensure interactive elements are visible */
    .btn,
    .btn-primary,
    .btn-secondary,
    .distance-badge,
    a {
        forced-color-adjust: none;
        border: 2px solid ButtonText;
    }

    /* Ensure focus is visible */
    *:focus-visible {
        outline: 3px solid Highlight !important;
    }

    /* Preserve important visual distinctions */
    .highlight {
        color: Highlight;
    }
}

/* ===================================
   Login Modal Styles
   =================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10001;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content.login-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 420px;
    width: 100%;
    padding: 32px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #333;
}

.modal-title {
    text-align: center;
    margin: 0 0 24px;
    color: var(--text-primary);
    font-size: 1.5rem;
}

.login-context-message {
    text-align: center;
    margin: -12px 0 20px;
    padding: 12px 16px;
    background: #f0f7ff;
    border-radius: 8px;
    color: #1a5fb4;
    font-size: 0.95rem;
    line-height: 1.4;
}

.login-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid #eee;
    padding-bottom: 8px;
}

.login-tab {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: none;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.login-tab:hover {
    background: #f5f5f5;
}

.login-tab.active {
    background: var(--rs-text);
    color: white;
}

.login-panel {
    display: none;
}

.login-panel.active {
    display: block;
}

.oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.oauth-buttons .btn-login {
    display: flex;
    justify-content: center;
    padding: 12px 16px;
    width: 100%;
}

.oauth-icon {
    font-weight: 700;
    font-size: 1.1rem;
    margin-right: 8px;
}

.divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}

.divider span {
    padding: 0 16px;
    color: #999;
    font-size: 0.875rem;
}

.auth-form .form-group {
    margin-bottom: 16px;
}

.auth-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.auth-form input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--rs-accent);
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: #888;
}

/* Password show/hide toggle */
.password-input-wrapper {
    position: relative;
}

.password-input-wrapper input {
    padding-right: 60px;
}

.toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px 8px;
}

.toggle-password:hover {
    color: #374151;
}

.form-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.form-message.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.form-message.success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.btn-full {
    width: 100%;
}

.form-footer {
    text-align: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.form-footer a {
    color: var(--rs-text);
    text-decoration: none;
    font-size: 0.9rem;
}

.form-footer a:hover {
    text-decoration: underline;
}

.panel-description {
    color: #666;
    margin-bottom: 20px;
    text-align: center;
    font-size: 0.95rem;
}

.verify-message {
    text-align: center;
    padding: 20px 0;
}

.verify-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.verify-message h3 {
    margin: 0 0 12px;
    color: var(--text-primary);
}

.verify-message p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

.btn-sign-in {
    background: white;
    color: var(--rs-text);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.btn-sign-in:hover {
    background: var(--rs-bg-elevated);
    transform: translateY(-2px);
}

/* Mobile adjustments for login modal */
@media (max-width: 480px) {
    .modal-content.login-modal-content {
        padding: 24px 20px;
        margin: 10px;
        max-height: 85vh;
    }

    .modal-title {
        font-size: 1.3rem;
    }

    .login-tabs {
        gap: 4px;
    }

    .login-tab {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

/* Every ad slot says what it is, in the site's small-caps label style. An
   unexplained reserved band (--ad-reserve) before fill is what makes a page
   read as "ad-y"; labelled, it reads as intentional. AdSense permits exactly
   "Advertisement(s)" / "Sponsored Links" as a label. Unfilled containers are
   display:none, so the label never outlives an empty slot. */
.ad-container::before {
    content: 'Advertisement';
    display: block;
    font: 600 10.5px/1 var(--font-body, 'Inter', system-ui, sans-serif);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rs-text-muted, #6b6b6b);
    text-align: center;
    padding: 4px 0 8px;
}

/* iOS Safari inflates text in blocks it judges too wide ("text autosizing"),
   which blew the hub intro up to ~2x and ran it off the screen. The layout is
   already responsive, so opt out. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* A processed logo (data-kind="logo") is already a 2:1 tile with its margins
   baked in (image_meta.normalise_logo), so the extra padding that frames an
   unprocessed image shown whole would only shrink it again. */
img.fit-contain[data-kind="logo"] { padding: 0 !important; }

/* ============================================================
   SITE FOOTER (templates/partials/site_footer.html)
   One footer for every page since 20 Oct 2026; it was scoped to the race
   search pages, and the rest had a centred two-line footer. Text on #161616
   is >= 0.62 white (~6:1): the old 0.2-0.4 greys were 1.6-3.4:1.
   ============================================================ */
footer.landing-footer {
    background: var(--rs-text);
    color: #fff;
    padding: 0;
    text-align: left;
    opacity: 1;
    font-family: var(--font-body);
}
/* Mediavine's bottom ad reserves space with body padding (150px with its taller
   "highImpact_adhesion" format), which showed as a white strip under the footer
   (24 Oct 2026). A shadow in the footer's colour fills it; shadows don't add scroll
   height, and Mediavine's padding and code are untouched. */
body.adhesion footer.landing-footer { box-shadow: 0 200px 0 0 var(--rs-text); }
.landing-footer a:focus-visible {
    outline: 2px solid var(--rs-accent);
    outline-offset: 2px;
    border-radius: 2px;
}
.landing-footer .footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 0;
    padding: 56px 48px 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 1200px;
    margin: 0 auto;
}
.landing-footer .footer-brand { padding-right: 48px; }
.landing-footer .footer-logo {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
    text-decoration: none;
    margin-bottom: 12px;
}
.landing-footer .footer-logo .highlight { color: var(--rs-accent-ink); }
.landing-footer .footer-tagline {
    font-size: 0.9rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.72);
    margin: 0;
}
.landing-footer .footer-email { margin: 12px 0 0; }
.landing-footer .footer-email a {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
}
.landing-footer .footer-email a:hover { color: #fff; }
.landing-footer .footer-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.landing-footer .footer-col-heading {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.62);
    margin: 0 0 8px;
}
.landing-footer .footer-col a {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.86);
    text-decoration: none;
    width: fit-content;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s ease-out;
}
.landing-footer .footer-col a:hover { color: var(--rs-accent-ink); }
.landing-footer .footer-seo {
    padding: 24px 48px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    gap: 8px;
}
.landing-footer .footer-seo-row {
    margin: 0;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: baseline;
    gap: 4px 18px;
    font-size: 0.8rem;
    line-height: 1.7;
}
.landing-footer .footer-seo-label {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.62);
}
.landing-footer .footer-seo-links {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 18px;
}
.landing-footer .footer-seo-row a {
    color: rgba(255, 255, 255, 0.66);
    text-decoration: none;
}
.landing-footer .footer-seo-row a:hover { color: #fff; text-decoration: underline; }
.landing-footer .footer-bottom {
    padding: 20px 48px;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
}
.landing-footer .footer-bottom p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.62);
    margin: 0;
}
@media (max-width: 768px) {
    .landing-footer .footer-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 28px 16px;
        padding: 36px 20px 28px;
    }
    .landing-footer .footer-brand { grid-column: 1 / -1; padding-right: 0; }
    /* Touch: the 44px tap target is the spacing. */
    .landing-footer .footer-col { gap: 0; }
    .landing-footer .footer-col a { min-height: 44px; }
    .landing-footer .footer-seo,
    .landing-footer .footer-bottom { padding-left: 20px; padding-right: 20px; }
    .landing-footer .footer-seo-row { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .landing-footer .footer-col a { transition: none; }
}

/* ============================================================
   PAGE FRAME (8 Nov 2026)
   Every page beside Journey's sidebar shares one frame from 1100px: a 1140px
   content box (left edge 150px at 1440, the same as before on the guides
   pages), 24px gutters, and a 320px sidebar 48px from the column. The hero's
   text starts on the same edge (.hero--framed). Each grid opens on a
   full-width .page-head - breadcrumb, intro, search, the tool itself - and the
   sidebar starts in the row below it, so no ad sits beside a page's title or
   its first content (John, 8 Nov 2026: "the top thing all the way across", a
   layout "which doesn't make it look like an ad factory"; it copies the race
   page, whose hero and race-day panel already span the page). Race pages keep
   their own grid (race-detail.css .rd-grid).
   ============================================================ */
:root {
    --frame-w: 1140px;
    --frame-gutter: 24px;
    --frame-max: calc(var(--frame-w) + 2 * var(--frame-gutter));
    --rail-w: 320px;
    --rail-gap: 48px;
}
.page-head { min-width: 0; }
@media (min-width: 1100px) {
    body.race-search-body .frame-grid {
        max-width: var(--frame-max);
        margin-left: auto;
        margin-right: auto;
        padding-left: var(--frame-gutter);
        padding-right: var(--frame-gutter);
        display: grid;
        grid-template-columns: minmax(0, 1fr) var(--rail-w);
        column-gap: var(--rail-gap);
        row-gap: 0;
    }
    /* The sidebar starts at the top of the content, beside the page head (11 Nov 2026,
       John: sidebar ads right under the hero). Under Journey the head ran across both
       columns (8 Nov) so its sidebar ad started lower. */
    body.race-search-body .frame-grid > .page-head { grid-column: 1; grid-row: 1; }
    body.race-search-body .frame-grid > .journey-rail { margin-top: 0; grid-column: 2; grid-row: 1 / span 2; }
    /* Hero text on the frame's left edge, not centred over a two-column page. */
    body.race-search-body .search-hero.hero--framed .hero-content,
    body.race-search-body .tp-hero.hero--framed .tp-hero-inner {
        max-width: var(--frame-max);
        margin-left: auto;
        margin-right: auto;
        padding-left: var(--frame-gutter);
        padding-right: var(--frame-gutter);
        text-align: left;
    }
    body.race-search-body .search-hero.hero--framed .hero-state-links { justify-content: flex-start; }
    body.race-search-body .search-hero.hero--framed .hero-description { margin-left: 0; }
    /* Room between the head and the column + sidebar below it. */
    body.race-search-body .frame-grid > .page-head { padding-bottom: 8px; }
    /* Prose and search fields in the head are as wide as the column below
       them; the head's right-hand side stays open rather than stretching them. */
    .page-head .guides-intro,
    .page-head .rr-search,
    .page-head .clubs-toolbar,
    .page-head .about-section,
    .page-head-intro { max-width: none; }
    /* The breadcrumb bar above a framed hero starts on the same edge. */
    .breadcrumb-nav.breadcrumb-nav--framed { padding-left: max(20px, calc((100% - var(--frame-w)) / 2)); }
}
.page-head-intro { color: var(--rs-text-muted); margin: 0 0 2rem; }

/* ============================================================
   JOURNEY SIDEBAR (templates/partials/journey_rail.html), 20 Oct 2026
   For templates with no sidebar of their own. Journey by Mediavine needs it
   static (never sticky), >= 300px wide inside, shown from 1100px. It is empty,
   so the sticky sidebar ad starts at its top - which is why it now starts
   below the full-width .page-head (PAGE FRAME above).
   ============================================================ */
.journey-rail { display: none; }
@media (min-width: 1100px) {
    /* Stretches the full height of the content beside it: the sticky ad runs
       the length of the article. */
    .journey-rail {
        display: block;
        position: static;
        width: 320px;
        padding: 0;
        align-self: stretch;
    }
}
/* Content pages with no sidebar of their own (guides index, What's On archive,
   clubs, about): content column + Journey's sidebar from 1100px. */
@media (min-width: 1100px) {
    main.journey-layout {
        max-width: 1180px;
        margin-left: auto;
        margin-right: auto;
        display: grid;
        grid-template-columns: minmax(0, 1fr) 320px;
        gap: 48px;
    }
    .journey-layout > .journey-col { max-width: none; margin-left: 0; margin-right: 0; }
}
.journey-col { min-width: 0; }

/* "Is this your result?" rows at the top of the Results table and cards
   (results.js renderMatchRow / renderMatchCard, 31 Oct 2026). */
.results-table tr.found-result td { background: #fffbe6; }
.results-table tr.found-result td:first-child { box-shadow: inset 3px 0 0 var(--rs-accent, #D52B1E); }
.results-table tr.just-confirmed td { background: #fffbe6; }
.rc.just-confirmed { background: #fffbe6; box-shadow: inset 3px 0 0 var(--rs-accent, #D52B1E); }
.found-tag { display: block; margin-top: 2px; font-size: 0.78rem; color: #6b6b6b; }
.found-cell { white-space: normal; }
.found-q { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.found-who { display: block; font-weight: 400; font-size: 0.8rem; color: #6b6b6b; }
.found-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.found-actions .btn-sm { padding: 6px 12px; font-size: 0.85rem; min-height: 36px; }
.found-time input { width: 7.5em; min-height: 36px; padding: 4px 8px; border: 1px solid #d9cfb4; border-radius: 6px; font: inherit; font-variant-numeric: tabular-nums; }
.found-who a { color: inherit; text-decoration: underline; text-decoration-color: var(--rs-accent, #D52B1E); text-underline-offset: 2px; }
.rc.found-result { background: #fffbe6; box-shadow: inset 3px 0 0 var(--rs-accent, #D52B1E); }
.rc.found-result .found-cell { padding: 8px 0 2px; }

/* ============================================================
   DISPLAY ADS (static/ads.js), AdSense from 11 Nov 2026
   A slot is closed (1px, no label) until the reader nears it, opens to the
   reserve band when the request goes out, grows to the ad when it fills, and
   goes away if nothing comes back. The label shows only on a filled slot.
   ============================================================ */
.mrh-ad {
    min-height: 1px;
    margin: 0 auto;
    padding: 0;
    text-align: center;
    overflow: hidden;
    clear: both;
}
.mrh-ad::before { display: none; }
.mrh-ad--live { min-height: var(--ad-reserve, 100px); }
.mrh-ad:has(ins[data-ad-status="filled"]) { overflow: visible; }
.mrh-ad:has(ins[data-ad-status="filled"])::before { display: block; }
.mrh-ad:has(ins[data-ad-status="unfilled"]) { display: none; }

/* In-content: a reader-width band, set before the request (AdSense sizes the ad
   to the box it is pushed into), with clear space either side of it so it never
   sits against a button or link. */
.mrh-ad--incontent { max-width: 728px; width: 100%; }
.mrh-ad--incontent:has(ins[data-ad-status="filled"]) { margin: 40px auto; }

/* Sidebar: .rail-ads takes whatever height the sidebar has left; each .rail-seg
   is an equal share of it and its ad sticks under the 70px header while that
   share scrolls past, so one ad is in view at a time. */
.rail-ads { display: none; }
@media (min-width: 1024px) {
    .journey-sidebar:has(> .rail-ads) { display: flex; flex-direction: column; }
    .rail-ads { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
    .rail-seg { flex: 1 1 0; min-height: 0; }
    .mrh-ad--rail { position: sticky; top: 92px; width: 300px; overflow: visible; }
    .mrh-ad--rail.mrh-ad--live { min-height: 250px; }
    .mrh-ad--rail:has(ins[data-ad-status="unfilled"]) { display: none; }
    .journey-rail > .rd-aff + .rail-ads,
    .rd-rail > .rd-aff + .rail-ads{ margin-top: 28px; }
}
@media print { .mrh-ad, .rail-ads { display: none !important; } }
