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

:root {
  --accent: #0057FF;
  --accent-dark: #003DB3;
  --text: #0d0d0d;
  --text-2: #555;
  --text-3: #767676;
  --bg: #ffffff;
  --bg-2: #f7f8fc;
  --border: #e8e8ec;
  --radius: 12px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header ──────────────────────────────── */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
  text-decoration: none;
}

.header-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.15s;
}

.header-link:hover { color: var(--accent); }

.logo:focus-visible,
.header-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.header-email {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.header-email svg {
  flex-shrink: 0;
  transition: transform 0.15s;
}

.header-email:hover svg {
  transform: translateY(-1px);
}

@media (max-width: 600px) {
  .header-email-text { display: none; }
}

/* ── Hero ────────────────────────────────── */

.hero {
  padding: 40px 0 36px;
  border-bottom: 1px solid var(--border);
}

.hero-title {
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: -0.75px;
  line-height: 1.15;
  margin-bottom: 10px;
}

.hero-sub {
  font-size: 0.9375rem;
  color: var(--text-2);
  margin-bottom: 16px;
}

.hero-count {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  background: #e8f0ff;
  padding: 4px 12px;
  border-radius: 100px;
  min-width: 60px;
}

@media (min-width: 600px) {
  .hero { padding: 56px 0 48px; }
  .hero-title { font-size: 2.5rem; letter-spacing: -1px; }
}

@media (min-width: 900px) {
  .hero-title { font-size: 3rem; }
}

/* ── Filters ─────────────────────────────── */

.filters-wrap {
  position: sticky;
  top: 56px;
  z-index: 90;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 5px 13px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1.4;
  white-space: nowrap;
  min-height: 36px;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.filter-row2 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-selects {
  display: flex;
  gap: 8px;
  flex: 1 1 auto;
}

.filter-select {
  padding: 5px 28px 5px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  flex: 1;
  min-width: 0;
  min-height: 40px;
}

.filter-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.filter-search {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  appearance: none;
  -webkit-appearance: none;
}
.filter-search:focus {
  border-color: var(--accent);
  outline: none;
}
.filter-search:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 599px) {
  .filter-search {
    flex: 1 1 100%;
  }
  .filter-selects {
    flex: 1 1 100%;
  }
}

/* ── Calendar ────────────────────────────── */

.calendar {
  padding: 32px 0 80px;
}

.month-group {
  margin-bottom: 36px;
}

.past-section {
  margin-bottom: 24px;
}

.past-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text-3);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: color 0.15s, border-color 0.15s;
}

.past-toggle:hover {
  color: var(--text);
  border-color: var(--text-3);
}

.past-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.past-toggle svg {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.past-toggle.open svg {
  transform: rotate(180deg);
}

.past-months {
  margin-top: 16px;
}

.month-header {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 10px;
}

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

.race-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-2);
  border-radius: var(--radius);
  border: 1px solid transparent;
  gap: 12px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  flex-wrap: wrap;
}

.race-card:hover {
  background: var(--bg);
  border-color: var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.race-card-main {
  flex: 1;
  min-width: 0;
}

.race-name {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
}

.race-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-2);
}

.race-badge {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.race-date {
  font-weight: 500;
  color: var(--text);
}

.race-place {
  color: var(--text-3);
}

.race-link {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
  min-height: 40px;
}

.race-link:hover {
  background: var(--accent-dark);
}

.race-link-empty {
  display: inline-block;
  padding: 7px 14px;
  color: var(--text-3);
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Skeleton ────────────────────────────── */

.skeleton-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
}

.skeleton-month {
  height: 12px;
  width: 70px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-card {
  height: 70px;
  border-radius: var(--radius);
}

.skeleton-month,
.skeleton-card {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .skeleton-month,
  .skeleton-card {
    animation: none;
    background: #f0f0f0;
  }
}

/* ── Empty state ─────────────────────────── */

.empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-3);
  font-size: 0.9375rem;
}

/* ── Footer ──────────────────────────────── */

.footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-3);
  line-height: 1.9;
}

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

.footer a:hover {
  color: var(--text-2);
}

/* ── Save button ─────────────────────────── */

.race-save-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-3);
  flex-shrink: 0;
  line-height: 1;
  border-radius: 6px;
  transition: color 0.15s;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.race-save-btn:hover { color: var(--text-2); }

.race-save-btn.saved { color: var(--accent); }

.race-save-btn svg {
  display: block;
  fill: none;
  transition: fill 0.15s;
}

.race-save-btn.saved svg { fill: currentColor; }

/* ── Race highlight (from shared ?race= link) ─ */

@keyframes race-highlight {
  0%   { border-color: transparent; box-shadow: none; background: var(--bg-2); }
  15%  { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,87,255,0.12); background: rgba(0,87,255,0.04); }
  80%  { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,87,255,0.12); background: rgba(0,87,255,0.04); }
  100% { border-color: transparent; box-shadow: none; background: var(--bg-2); }
}

.race-card.race-highlight {
  animation: race-highlight 2.5s ease-in-out forwards;
  transition: none;
  will-change: border-color, box-shadow, background;
}

.race-card.race-highlight:hover {
  background: rgba(0,87,255,0.04);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,87,255,0.12);
}

/* ── Shared season banner ────────────────── */

.season-banner {
  position: sticky;
  top: 56px;
  z-index: 99;
  background: #fffbe6;
  border-bottom: 1px solid #ffe58f;
  padding: 10px 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.8;
}

.season-banner-actions {
  display: inline-flex;
  gap: 8px;
  margin-left: 10px;
  align-items: center;
}

.season-banner-btn {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1.5px solid var(--accent);
  background: none;
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.season-banner-btn:hover {
  background: var(--accent);
  color: #fff;
}

.season-banner-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 1rem;
  line-height: 1;
  padding: 4px;
  font-family: inherit;
  transition: color 0.15s;
}

.season-banner-close:hover { color: var(--text); }

.season-banner-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Share button ────────────────────────── */

.share-wrap {
  text-align: center;
  padding: 24px 0 8px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.share-btn:hover { background: var(--accent-dark); }

.share-btn.copied { background: #2e7d32; }

/* ── saved.html hero ─────────────────────── */

.saved-hero {
  padding: 36px 0 20px;
}

.saved-hero h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.saved-hero p {
  color: var(--text-2);
  font-size: 0.9375rem;
}

/* ── Empty state (saved page) ────────────── */

.saved-empty {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-3);
}

.saved-empty-icon {
  margin-bottom: 12px;
  color: var(--text-3);
  display: flex;
  justify-content: center;
}

.saved-empty h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 20px;
}

.saved-empty-cta {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.15s;
}

.saved-empty-cta:hover { background: var(--accent-dark); }
