/* Shared base styles for the Season Tracking Dashboard (index.html) and the
   Season Planner (planner.html): colour tokens, light/dark, header, tabs, stats,
   tables, badges. Moved out of index.html unchanged on 2026-10-01. */
  :root {
    color-scheme: light;
    --surface-page:   #f9f9f7;
    --surface-card:   #fcfcfb;
    --surface-sunken: #f0f0ee;
    --ink-primary:    #0b0b0b;
    --ink-secondary:  #52514e;
    --ink-muted:      #898781;
    --gridline:       #e1e0d9;
    --border:         rgba(11,11,11,0.10);
    --brand-blue:     #272a48;
    --brand-header:   #272a48;
    --brand-gold:     #d7a738;
    --pts-0:          var(--surface-sunken);
    --pts-1:          #9c9dab;
    --pts-2:          #7c7e90;
    --pts-3:          #52546c;
    --pts-4:          #272a48;
    --pts-ink-0:      var(--ink-secondary);
    --pts-ink-1:      #ffffff;
    --pts-ink-2:      #ffffff;
    --pts-ink-3:      #ffffff;
    --pts-ink-4:      #ffffff;
  }
  @media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) {
      color-scheme: dark;
      --surface-page:   #0d0d0d;
      --surface-card:   #1a1a19;
      --surface-sunken: #232322;
      --ink-primary:    #ffffff;
      --ink-secondary:  #c3c2b7;
      --ink-muted:      #8f8d86;
      --gridline:       #2c2c2a;
      --border:         rgba(255,255,255,0.10);
      --brand-blue:     #4a5490;
      --brand-header:   #34375c;
      --brand-gold:     #e6bb52;
      --pts-1:          #4f546c;
      --pts-2:          #68709a;
      --pts-3:          #7e88bb;
      --pts-4:          #969fd6;
      --pts-ink-0:      var(--ink-secondary);
      --pts-ink-1:      #ffffff;
      --pts-ink-2:      #0b0b0b;
      --pts-ink-3:      #0b0b0b;
      --pts-ink-4:      #0b0b0b;
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --surface-page:   #0d0d0d;
    --surface-card:   #1a1a19;
    --surface-sunken: #232322;
    --ink-primary:    #ffffff;
    --ink-secondary:  #c3c2b7;
    --ink-muted:      #8f8d86;
    --gridline:       #2c2c2a;
    --border:         rgba(255,255,255,0.10);
    --brand-blue:     #4a5490;
    --brand-header:   #34375c;
    --brand-gold:     #e6bb52;
    --pts-1:          #4f546c;
    --pts-2:          #68709a;
    --pts-3:          #7e88bb;
    --pts-4:          #969fd6;
    --pts-ink-0:      var(--ink-secondary);
    --pts-ink-1:      #ffffff;
    --pts-ink-2:      #0b0b0b;
    --pts-ink-3:      #0b0b0b;
    --pts-ink-4:      #0b0b0b;
  }

  * { box-sizing: border-box; }
  body {
    margin: 0;
    background: var(--surface-page);
    color: var(--ink-primary);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  a { color: inherit; }

  header.top {
    background: var(--brand-header);
    color: #fff;
    padding: 20px 24px 18px;
    border-bottom: 3px solid var(--brand-gold);
  }
  header.top .eyebrow {
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--brand-gold);
    font-weight: 700;
    margin: 0 0 4px;
  }
  header.top h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
  }
  header.top p.sub {
    margin: 6px 0 0;
    font-size: 13.5px;
    color: rgba(255,255,255,0.78);
    max-width: 720px;
    line-height: 1.45;
  }
  .header-row { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
  .header-links { display: flex; gap: 14px; align-items: center; font-size: 12.5px; }
  .user-chip { font-size: 12px; color: rgba(255,255,255,0.78); }
  .btn-light {
    appearance: none; border: 1px solid rgba(255,255,255,0.4); background: transparent; color: #fff;
    border-radius: 6px; padding: 5px 11px; font-size: 12px; font-weight: 600; cursor: pointer;
  }
  .gate { padding: 60px 20px; text-align: center; color: var(--ink-muted); font-size: 14px; }
  .gate h2 { color: var(--ink-primary); font-size: 18px; margin: 0 0 8px; }
  .gate p { margin: 0 0 16px; }
  .btn-primary {
    appearance: none; font: inherit; font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 6px; cursor: pointer;
    border: 1px solid var(--brand-header); background: var(--brand-header); color: #fff;
  }

  main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 24px 64px;
  }
  /* the 2027 Plan table has 11 columns - give it the room planning.html had */
  main.wide { max-width: 1440px; }

  .toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
  }

  .rider-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1 1 auto;
  }
  .rider-tab {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface-card);
    color: var(--ink-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
  }
  .rider-tab:hover { border-color: var(--brand-header); }
  .rider-tab[aria-selected="true"] {
    background: var(--brand-header);
    color: #fff;
    border-color: var(--brand-header);
  }
  .rider-tab .tag {
    display: inline-block;
    margin-left: 6px;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--brand-gold);
    color: #201703;
  }
  .rider-tab[aria-selected="true"] .tag { background: rgba(255,255,255,0.22); color: #fff; }

  .season-filter {
    display: flex;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    background: var(--surface-card);
  }
  .season-filter button {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--ink-secondary);
    font-size: 15px;
    font-weight: 700;
    padding: 9px 20px;
    border-radius: 7px;
    cursor: pointer;
  }
  .season-filter button:hover:not([aria-pressed="true"]) {
    background: var(--surface-sunken);
    color: var(--ink-primary);
  }
  .season-filter button[aria-pressed="true"] {
    background: var(--brand-header);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
  }

  .table-toggle {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface-card);
    color: var(--ink-secondary);
    font-size: 12.5px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 8px;
    cursor: pointer;
  }

  .stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
  }
  .stat-tile {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
  }
  .stat-tile .label {
    font-size: 11.5px;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
  }
  .stat-tile .value {
    font-size: 24px;
    font-weight: 800;
    margin-top: 2px;
    font-variant-numeric: proportional-nums;
  }
  .stat-tile .value small { font-size: 13px; font-weight: 600; color: var(--ink-muted); }

  section.blocks h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-secondary);
    margin: 0 0 12px;
  }

  .block {
    margin-bottom: 18px;
  }
  .block-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
  }
  .block-head .n {
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    background: var(--brand-header);
    border-radius: 6px;
    padding: 2px 8px;
  }
  .block-head .meta {
    font-size: 12.5px;
    color: var(--ink-muted);
  }
  .block-head .meta strong { color: var(--ink-secondary); font-weight: 700; }

  .block-races {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    position: relative;
    padding-left: 10px;
    border-left: 2px solid var(--gridline);
  }

  .race-card {
    width: 168px;
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--surface-card);
    border: 1px solid var(--border);
    position: relative;
  }
  .race-card .rname {
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 4px;
    min-height: 2.5em;
    color: var(--ink-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .race-card .rdate {
    font-size: 10.5px;
    line-height: 1.3;
    color: var(--ink-muted);
    margin-bottom: 6px;
    min-height: 2.6em;
  }
  .race-card .rpts {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    font-size: 13px;
    font-weight: 800;
    border-radius: 6px;
    padding: 2px 7px;
  }
  .race-card .rpts .u { font-size: 9.5px; font-weight: 700; opacity: .85; }
  .race-card .rbadge {
    position: absolute;
    top: -7px;
    right: -6px;
    background: var(--brand-gold);
    color: #201703;
    font-size: 9.5px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
  }
  .race-card .rrank {
    font-size: 10px;
    color: var(--ink-muted);
    margin-top: 4px;
  }

  .pts-0 { background: var(--pts-0); color: var(--pts-ink-0); }
  .pts-1 { background: var(--pts-1); color: var(--pts-ink-1); }
  .pts-2 { background: var(--pts-2); color: var(--pts-ink-2); }
  .pts-3 { background: var(--pts-3); color: var(--pts-ink-3); }
  .pts-4 { background: var(--pts-4); color: var(--pts-ink-4); }

  .legend {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 11.5px;
    color: var(--ink-muted);
    margin: 4px 0 22px;
  }
  .legend .swatch {
    display: inline-flex;
    align-items: center;
    gap: 5px;
  }
  .legend .sw {
    width: 12px; height: 12px; border-radius: 3px; display: inline-block;
    border: 1px solid var(--border);
  }

  table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
  }
  table.data-table caption {
    text-align: left;
    font-size: 12px;
    color: var(--ink-muted);
    padding: 8px 12px;
  }
  table.data-table th, table.data-table td {
    text-align: left;
    padding: 7px 10px;
    border-bottom: 1px solid var(--gridline);
    font-variant-numeric: tabular-nums;
  }
  table.data-table th {
    color: var(--ink-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em;
    background: var(--surface-sunken);
  }
  table.data-table tbody tr:last-child td { border-bottom: none; }
  table.data-table tbody tr:hover { background: var(--surface-sunken); }
  table.data-table td.rname { font-weight: 700; }
  table.data-table td.datecol { color: var(--ink-muted); white-space: nowrap; }

  .top-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--gridline);
    margin-bottom: 20px;
  }
  .top-tab {
    appearance: none;
    border: none;
    background: none;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--ink-muted);
    padding: 10px 4px 11px;
    margin-right: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    position: relative;
    top: 1px;
  }
  .top-tab:hover { color: var(--ink-primary); }
  .top-tab[aria-selected="true"] { color: var(--ink-primary); border-bottom-color: var(--brand-gold); }

  .filter-chip {
    appearance: none;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-card);
    color: var(--ink-secondary);
    cursor: pointer;
  }
  .filter-chip:hover { border-color: var(--brand-header); }
  .filter-chip[aria-pressed="true"] { background: var(--brand-header); color: #fff; border-color: var(--brand-header); }
  .result-count { font-size: 12px; color: var(--ink-muted); margin: 0 0 10px; }

  .scorer-list { display: flex; flex-wrap: wrap; gap: 5px; }
  .scorer-chip {
    font-size: 11px;
    font-weight: 600;
    background: var(--surface-sunken);
    color: var(--ink-primary);
    border-radius: 6px;
    padding: 3px 7px;
    white-space: nowrap;
  }
  .scorer-chip b { color: var(--pts-4); font-weight: 700; }
  .scorer-chip.incoming { border: 1px dashed var(--brand-gold); background: transparent; }
  .dash { color: var(--ink-muted); }
  .not-on-plan { font-size: 11px; color: var(--ink-muted); font-style: italic; }

  .chart-card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px 12px;
  }
  .chart-card svg { width: 100%; height: auto; overflow: visible; display: block; }
  .bar-label { font-size: 11px; fill: var(--ink-primary); font-weight: 600; }
  .bar-value { font-size: 11px; fill: var(--ink-secondary); font-weight: 600; }
  .axis-label { font-size: 9.5px; fill: var(--ink-muted); }

  .method-note {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    margin-top: 14px;
    font-size: 12px;
    color: var(--ink-secondary);
    line-height: 1.6;
  }
  .method-note p { margin: 0 0 8px; }
  .method-note p:last-child { margin-bottom: 0; }
  .method-note code {
    background: var(--surface-sunken);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11.5px;
  }

  .table-card { overflow-x: auto; }
  .section-title { margin: 0 0 12px; }
  .section-title h2 { font-size: 15.5px; font-weight: 700; margin: 0; }
  .section-title .hint { font-size: 12px; color: var(--ink-muted); display: block; margin-top: 2px; }

  .hidden { display: none !important; }

  .empty, .loading, .error {
    padding: 40px 20px;
    text-align: center;
    color: var(--ink-muted);
    font-size: 13.5px;
  }
  .error { color: #c21632; }

  footer.foot {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px 40px;
    font-size: 11.5px;
    color: var(--ink-muted);
  }

  @media (max-width: 720px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .race-card { width: 140px; }
  }
  .seg-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; margin: 0 0 16px; }
  .seg-switch button { padding: 8px 16px; border: 0; background: var(--surface-card); color: var(--ink-secondary); cursor: pointer; font: inherit; font-weight: 600; font-size: 14px; }
  .seg-switch button + button { border-left: 1px solid var(--border); }
  .seg-switch button[aria-pressed="true"] { background: var(--brand-header); color: #fff; }
  details.how { margin: 12px 0; font-size: 13px; color: var(--ink-secondary); }
  details.how > summary { cursor: pointer; color: var(--ink-muted); font-size: 12.5px; width: max-content; }
  details.how > p, details.how > div { margin-top: 8px; max-width: 95ch; line-height: 1.5; }

  /* ?embed=<tab> (shown inside the Season Planner): no header, no tab bar */
  body.embed header.top, body.embed #topTabs { display: none !important; }
  body.embed main { padding-top: 12px; }
