body {
    margin: 0;
    padding: 0;
    padding-top: 0px !important; 
}

.page {
    position: relative;
    z-index: 1;
}

.course-wrapper {
    display: flex;
    min-height: calc(100vh - var(--nav-h, 4.5rem));
    background: var(--bg);
    align-items: stretch;
}

.course-sidebar {
    width: 195px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1.5px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    overflow-y: auto;
}

.sb-search-wrap {
    padding: 0.7rem 0.7rem 0.5rem;
}
.sb-search-wrap input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.4rem 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: 1.5rem;
    font-size: 0.77rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color 0.18s, background 0.18s;
}
.sb-search-wrap input:focus {
    border-color: var(--accent);
    background: #fff;
}
.sb-search-wrap input::placeholder { color: var(--muted); }

.sb-cat-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0.5rem 0.85rem 0.2rem;
}

.sb-link {
    display: flex;
    align-items: flex-start;
    gap: 0.38rem;
    padding: 0.44rem 0.85rem;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 0.13s, border-color 0.13s;
}
.sb-link:hover { background: var(--frame-soft); }
.sb-link.active {
    background: var(--frame-soft);
    border-left-color: var(--accent);
}
.sb-link-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    margin-top: 0.3rem;
}
.sb-link-name {
    display: block;
    font-size: 0.79rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
}
.sb-link-sub {
    display: block;
    font-size: 0.66rem;
    color: var(--muted);
    margin-top: 0.05rem;
    line-height: 1.3;
}

.sb-hint {
    margin-top: auto;
    padding: 0.9rem 0.85rem 1.1rem;
    font-size: 0.7rem;
    color: var(--muted);
    line-height: 1.5;
    border-top: 1px solid var(--border);
}

.course-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.course-hero {
    background: linear-gradient(135deg, var(--nav) 0%, #1a6fc4 100%);
    padding: clamp(1.3rem, 3vw, 2rem) clamp(1.5rem, 3vw, 2.5rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}
.course-hero::before {
    content: '';
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 38%;
    background: rgba(255,255,255,0.04);
    clip-path: polygon(8% 0%, 100% 0%, 100% 100%, 0% 100%);
}
.hero-left { position: relative; z-index: 1; }
.hero-cat {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: rgba(255,255,255,0.75);
    margin-bottom: 0.35rem;
    letter-spacing: 0.03em;
}
.hero-title {
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(1.9rem, 4vw, 2.9rem);
    font-weight: 700;
    color: #fff;
    line-height: 1.05;
    margin-bottom: 0.85rem;
}
.hero-years { display: flex; gap: 0.38rem; flex-wrap: wrap; }
.year-pill {
    display: inline-block;
    padding: 0.2rem 0.78rem;
    border-radius: 1.5rem;
    font-size: 0.77rem;
    font-weight: 600;
    text-decoration: none;
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.28);
    color: rgba(255,255,255,0.82);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.year-pill:hover, .year-pill.active {
    background: #fff;
    color: var(--nav);
    border-color: #fff;
}
.hero-map {
    position: relative; 
    z-index: 1; 
    flex-shrink: 0;
}
.hero-map img {
    width: clamp(90px, 11vw, 155px);
    object-fit: contain;
    filter: drop-shadow(0 4px 14px rgba(0,0,0,0.18));
}

.course-tabs {
    background: #fff; 
    border-bottom: 1.5px solid var(--border);
    display: flex;
    padding: 0 clamp(1.5rem, 3vw, 2.5rem);
    position: relative; 
    margin-top: 0; 
}
.c-tab {
    display: inline-block;
    padding: 1rem 1.15rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -1.5px;
    transition: all 0.2s;
}
.c-tab:hover { color: var(--accent); }
.c-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.course-content {
    padding: clamp(1.2rem, 2.5vw, 1.8rem) clamp(1.5rem, 3vw, 2.5rem);
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    background: var(--bg);
}

.section-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.podium-row-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.podium-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    flex: 1;
}

.podium-card {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
}
.podium-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.podium-card-photo {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.podium-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.p1 .podium-card-photo { background: linear-gradient(135deg, #c8960c 0%, #FFD700 60%, #e6b800 100%); }
.p2 .podium-card-photo { background: linear-gradient(135deg, #6e7880 0%, #C0C0C0 60%, #a8b2bb 100%); }
.p3 .podium-card-photo { background: linear-gradient(135deg, #7a4712 0%, #CD7F32 60%, #a0632a 100%); }

.pc-initials {
    font-family: 'Fredoka', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: rgba(255,255,255,0.92);
    user-select: none;
}

.pc-pos-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.6rem;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.podium-card-body {
    padding: 0.8rem 0.9rem 0.85rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.pc-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.pc-team {
    font-size: 0.63rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.3;
}

/* Footer de la carte */
.podium-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border);
}

.pc-extra {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text2);
}
.pc-pts {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text2);
}

.pc-medal-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.p1 .pc-medal-dot { background: #FFD700; }
.p2 .pc-medal-dot { background: #C0C0C0; }
.p3 .pc-medal-dot { background: #CD7F32; }

.podium-plus-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.btn-plus {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: #fff;
    color: var(--text2);
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s, color 0.14s;
    line-height: 1;
    flex-shrink: 0;
}
.btn-plus:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.etapes-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1.5px solid var(--border);
}
.etapes-table thead tr {
    background: var(--bg2); 
    border-bottom: 1.5px solid var(--border); 
}
.etapes-table th {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 0.62rem 1rem;
    text-align: left;
}
.etapes-table td {
    font-size: 0.83rem;
    color: var(--text);
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
}
.etapes-table tr:last-child td { border-bottom: none; }
.etapes-table tbody tr:hover { background: var(--frame-soft); }
.etape-num-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
}
.type-badge {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border-radius: 0.35rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.type-montagne { background: rgba(255,92,53,0.1); color: var(--accent2); }
.type-plat     { background: rgba(63,145,226,0.1); color: var(--accent); }
.type-clm      { background: rgba(245,184,0,0.15); color: #c89400; }

.btn-show-rank {
    background: var(--bg2);
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-show-rank:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.rank-row {
    background: var(--bg); 
}

.rank-dropdown-content {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    animation: slideDown 0.2s ease-out;
}

.rank-list-mini ol {
    margin: 0.5rem 0 0 1.2rem;
    padding: 0;
    font-size: 0.8rem;
    column-count: 2; 
}

@media (max-width: 1024px) {
  .course-sidebar {
    width: 170px;
  }

  .podium-cards {
    gap: 0.55rem;
  }

  .podium-card-photo {
    height: 85px;
  }

  .pc-initials {
    font-size: 1.7rem;
  }
}

@media (max-width: 860px) {
  .course-wrapper {
    flex-direction: column;
  }

  .course-sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1.5px solid var(--border);
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.4rem 0;
  }
  .course-sidebar::-webkit-scrollbar { display: none; }

  .sb-search-wrap,
  .sb-cat-label,
  .sb-hint {
    display: none;
  }

  .sb-group {
    display: contents; 
  }

  .sb-link {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }
  .sb-link.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }
  .sb-link-dot {
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    margin-top: 0;
  }
  .sb-link-name {
    font-size: 0.78rem;
  }
  .sb-link-sub {
    display: none; 
  }

  .course-hero {
    padding: 1.3rem 1.5rem;
  }
  .hero-title {
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    margin-bottom: 0.65rem;
  }
  .hero-map img {
    width: clamp(70px, 9vw, 110px);
  }

  /* Tabs */
  .course-tabs {
    padding: 0 1.5rem;
  }

  .course-content {
    padding: 1.2rem 1.5rem;
    gap: 1.4rem;
  }

  .podium-card-photo {
    height: 75px;
  }
  .pc-initials {
    font-size: 1.5rem;
  }
  .pc-pos-badge {
    font-size: 1.1rem;
  }
  .podium-card-body {
    padding: 0.65rem 0.75rem 0.7rem;
  }
  .pc-name  { font-size: 0.76rem; }
  .pc-team  { font-size: 0.6rem;  }

  .etapes-table th,
  .etapes-table td {
    padding: 0.55rem 0.75rem;
    font-size: 0.78rem;
  }
}

@media (max-width: 640px) {
  .course-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.2rem 1.2rem;
  }
  .course-hero::before { display: none; }

  .hero-map {
    align-self: flex-end;
    margin-top: -3.5rem; 
  }
  .hero-map img {
    width: clamp(60px, 18vw, 90px);
    opacity: 0.7;
  }

  .hero-title {
    font-size: clamp(1.4rem, 7vw, 1.9rem);
    margin-bottom: 0.5rem;
  }
  .hero-cat {
    font-size: 0.68rem;
  }
  .year-pill {
    font-size: 0.7rem;
    padding: 0.18rem 0.6rem;
  }

  .course-tabs {
    padding: 0 1rem;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .course-tabs::-webkit-scrollbar { display: none; }
  .c-tab {
    padding: 0.85rem 0.85rem;
    font-size: 0.82rem;
    flex-shrink: 0;
  }

  .course-content {
    padding: 1rem 1rem;
    gap: 1.25rem;
  }

  .podium-row-wrap {
    flex-direction: column;
    gap: 0.5rem;
  }
  .podium-cards {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
  .podium-card {
    flex-direction: row;
  }
  .podium-card-photo {
    width: 80px;
    height: auto;
    min-height: 80px;
    flex-shrink: 0;
    border-radius: 0; 
  }
  .podium-card-body {
    padding: 0.7rem 0.85rem;
  }
  .pc-initials  { font-size: 1.6rem; }
  .pc-pos-badge { font-size: 1.1rem; top: 0.35rem; right: 0.4rem; }
  .pc-name      { font-size: 0.82rem; }
  .pc-team      { font-size: 0.63rem; }

  .podium-plus-block {
    flex-direction: row;
    justify-content: flex-end;
  }

  .etapes-table {
    font-size: 0.76rem;
  }
  .etapes-table th:nth-child(4),
  .etapes-table td:nth-child(4) {
    display: none; /* Distance masquée */
  }
  .etapes-table th,
  .etapes-table td {
    padding: 0.5rem 0.6rem;
  }

  .rank-list-mini ol {
    column-count: 1;
    font-size: 0.76rem;
  }
  .rank-dropdown-content {
    padding: 0.75rem 0.85rem;
  }
}

@media (max-width: 400px) {
  .hero-title {
    font-size: 1.3rem;
  }

  .etapes-table th:nth-child(5),
  .etapes-table td:nth-child(5) {
    display: none;
  }

  .podium-card-photo {
    width: 68px;
  }
  .pc-initials { font-size: 1.35rem; }

  .course-content {
    padding: 0.85rem 0.85rem;
  }
}