/* ── DARK MODE (default) ──────────────────────── */
  :root {
    --bg: #07090d;
    --surface: #181b22;
    --surface2: #1f2430;
    --border: #2b3240;
    --accent: #f2efeb;
    --accent2: #9a8cff;
    --accent3: #ff8ebc;
    --text: #f4f6fb;
    --text-muted: #adb3bf;
    --z1: #8ac5ff;
    --z2: #8de1b8;
    --z3: #ffd27e;
    --z4: #b69aff;
    --z5: #ff8ebc;
    --header-bg: rgba(7,9,13,0.94);
    --overlay-bg: rgba(6,8,12,0.72);
    --overlay-bg2: rgba(6,8,12,0.80);
    --row-border: rgba(74,86,108,0.45);
    --row-border2: rgba(74,86,108,0.35);
    --badge-future-bg: rgba(58,69,88,0.85);
    --badge-done-bg: rgba(141,225,184,0.14);
    --badge-next-bg: rgba(255,142,188,0.18);
    --alert-bg: rgba(255,142,188,0.10);
    --alert-border: rgba(255,142,188,0.28);
    --alert-ok-bg: rgba(141,225,184,0.10);
    --alert-ok-border: rgba(141,225,184,0.25);
    --filter-active-bg: rgba(154,140,255,0.15);
    --confirm-border: rgba(200,208,222,0.28);
    --shadow: 0 12px 40px rgba(0,0,0,0.45);
  }

  /* ── LIGHT MODE ────────────────────────────────── */
  [data-theme="light"] {
    --bg: #f1f3f8;
    --surface: #ffffff;
    --surface2: #f1f4fa;
    --border: #d9e0ec;
    --accent: #4d9eee;
    --accent2: #d96a74;
    --accent3: #d7a344;
    --text: #1b2533;
    --text-muted: #5c6f8a;
    --z1: #4d9eee;
    --z2: #27b07c;
    --z3: #d7a344;
    --z4: #8f73df;
    --z5: #d96a74;
    --header-bg: rgba(246,247,251,0.94);
    --overlay-bg: rgba(15,23,42,0.28);
    --overlay-bg2: rgba(15,23,42,0.38);
    --row-border: rgba(151,167,191,0.36);
    --row-border2: rgba(151,167,191,0.26);
    --badge-future-bg: #e9eef7;
    --badge-done-bg: rgba(39,176,124,0.16);
    --badge-next-bg: rgba(217,106,116,0.16);
    --alert-bg: rgba(228,111,127,0.10);
    --alert-border: rgba(228,111,127,0.26);
    --alert-ok-bg: rgba(39,176,124,0.10);
    --alert-ok-border: rgba(39,176,124,0.24);
    --filter-active-bg: rgba(91,140,255,0.14);
    --confirm-border: rgba(151,167,191,0.38);
    --shadow: 0 10px 28px rgba(67,84,110,0.14);
  }

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

  body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: radial-gradient(circle at top center, rgba(154,140,255,0.08), transparent 42%), var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
  }

  .global-announcement {
    width: min(1200px, calc(100% - 64px));
    margin: 12px auto 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
  }

  .global-announcement.alert-success {
    border-color: #badbcc;
    background: #d4edda;
    color: #0f5132;
  }

  .global-announcement.alert-info {
    border-color: #b6effb;
    background: #d1ecf1;
    color: #055160;
  }

  .global-announcement.alert-warning {
    border-color: #ffecb5;
    background: #fff3cd;
    color: #664d03;
  }

  .global-announcement.alert-danger {
    border-color: #f5c2c7;
    background: #f8d7da;
    color: #842029;
  }

  .global-announcement-inner {
    max-width: none;
    margin: 0;
    padding: 10px 46px 10px 12px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    column-gap: 10px;
    row-gap: 2px;
    font-size: 13px;
    line-height: 1.4;
    position: relative;
  }

  .global-announcement.alert {
    border-radius: 12px;
    margin: 12px auto 0;
  }

  .global-announcement-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.12);
    line-height: 1;
    margin-top: 1px;
  }

  .global-announcement-message {
    white-space: normal;
    overflow-wrap: anywhere;
    display: block;
    margin-top: 10px;
    line-height: 1.45;
  }

  .global-announcement-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }

  .global-announcement-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0;
    text-transform: none;
    padding: 0;
    border-radius: 0;
    border: none;
    background: transparent;
  }

  .global-announcement-expiry {
    font-size: 12px;
    color: currentColor;
    opacity: 0.8;
    white-space: normal;
  }

  .global-announcement-close {
    margin-left: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.72;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    position: absolute;
    top: 6px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .global-announcement-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
  }

  .global-announcement.alert-success .global-announcement-icon { background: rgba(15, 81, 50, 0.16); }
  .global-announcement.alert-info .global-announcement-icon { background: rgba(5, 81, 96, 0.14); }
  .global-announcement.alert-warning .global-announcement-icon { background: rgba(102, 77, 3, 0.14); }
  .global-announcement.alert-danger .global-announcement-icon { background: rgba(132, 32, 41, 0.14); }

  .global-announcement.alert-success .global-announcement-label { color: #0f5132; }
  .global-announcement.alert-info .global-announcement-label { color: #055160; }
  .global-announcement.alert-warning .global-announcement-label { color: #664d03; }
  .global-announcement.alert-danger .global-announcement-label { color: #842029; }

  /* MAIN */
  main {
    flex: 1 0 auto;
    width: 100%;
    padding: 32px;
    max-width: 1200px;
    margin: 0 auto;
  }

  .app-footer {
    margin-top: auto;
    flex-shrink: 0;
  }

  @media (max-width: 640px) {
    .global-announcement {
      width: calc(100% - 24px);
      margin-top: 10px;
      border-radius: 10px;
    }

    .global-announcement-inner {
      padding: 9px 40px 9px 10px;
      column-gap: 8px;
      row-gap: 2px;
    }

    .global-announcement-label,
    .global-announcement-message {
      font-size: 12.5px;
    }

    .global-announcement-expiry {
      font-size: 11px;
    }
  }

  section { display: none; }
  section.visible { display: block; }

  /* DASHBOARD */
  .section-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
  }

  .section-sub {
    font-size: 15px;
    color: var(--text-muted);
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin-bottom: 28px;
  }

  .field input[type="date"] {
    color-scheme: dark;
  }

  .field input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.72);
    cursor: pointer;
  }

  /* CHART SIMPLE */
  .chart-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 28px;
  }

  .chart-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .chart-title::before {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 2px;
    background: var(--accent);
  }

  .bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 120px;
  }

  .bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    justify-content: flex-end;
  }

  .bar {
    width: 100%;
    background: var(--accent2);
    border-radius: 3px 3px 0 0;
    transition: height 0.6s ease;
    position: relative;
    cursor: pointer;
    overflow: visible;
  }

  .bar:hover { filter: brightness(1.3); }

  .bar-value {
    position: absolute;
    left: 50%;
    top: 6px;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.2px;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
    background: rgba(10, 18, 33, 0.42);
    padding: 2px 6px;
    border-radius: 999px;
    white-space: nowrap;
    line-height: 1;
    pointer-events: none;
  }

  .bar-value--dark {
    color: #0f172a;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.72);
  }

  .bar--tiny .bar-value {
    top: auto;
    bottom: calc(100% + 6px);
    color: var(--text);
    text-shadow: none;
    font-size: 10px;
    font-weight: 600;
    background: color-mix(in srgb, var(--surface2) 92%, #000);
    border: 1px solid var(--border);
  }

  .bar-label {
    font-size: 9px;
    color: var(--text-muted);
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    text-align: center;
    line-height: 1.2;
  }

  @media (max-width: 480px) {
    .bar-chart {
      gap: 3px;
      height: 100px;
    }

    .bar-label {
      font-size: 7px;
      line-height: 1;
      word-break: break-word;
    }

    .bar-value {
      font-size: 10px;
      top: 4px;
    }

    .bar--tiny .bar-value {
      font-size: 8px;
      bottom: calc(100% + 3px);
    }
  }

  /* COURSES TABLE */
  .table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 28px;
  }

  .table-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  table { width: 100%; border-collapse: collapse; }

  th {
    text-align: left;
    padding: 10px 16px;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    border-bottom: 1px solid var(--border);
    font-weight: 400;
  }

  td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--row-border);
  }

  tr:last-child td { border-bottom: none; }
  tr:hover td { background: var(--surface2); }

  .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-weight: 700;
  }

  .badge-done { background: var(--badge-done-bg); color: var(--z1); }
  .badge-next { background: var(--badge-next-bg); color: var(--z5); }
  .badge-future { background: var(--badge-future-bg); color: var(--text-muted); }

  .badge--dark {
    color: #0f172a !important;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.4);
  }

  /* PLAN VIEW */
  .week-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 28px;
  }

  .week-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
  }

  .week-header {
    background: var(--surface2);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
  }

  .week-num {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 12px;
    color: var(--accent);
    letter-spacing: 2px;
  }

  .week-date {
    font-size: 14px;
    color: var(--text-muted);
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  }

  .session-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--row-border2);
    transition: background 0.15s;
    cursor: pointer;
  }

  .session-row:last-child { border-bottom: none; }
  .session-row:hover { background: var(--surface2); }

  .session-check {
    width: 18px; height: 18px;
    border-radius: 4px;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    font-size: 11px;
  }

  .session-check.done { background: var(--z1); border-color: var(--z1); color: #000; }

  .session-format {
    flex: 1;
    font-size: 13px;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.4;
  }

  .zone-tag {
    display: inline-block;
    width: 20px; height: 16px;
    border-radius: 3px;
    font-size: 9px;
    text-align: center;
    line-height: 16px;
    font-weight: 700;
    margin-right: 1px;
  }

  .session-meta {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
  }

  .session-date-badge {
    font-size: 12px;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-muted);
    background: var(--surface2);
    padding: 3px 8px;
    border-radius: 3px;
    white-space: nowrap;
  }

  .pe-badge {
    font-size: 12px;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-muted);
    background: var(--surface2);
    padding: 3px 8px;
    border-radius: 3px;
  }

  .duration-badge {
    font-size: 13px;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--accent2);
    font-weight: 600;
  }

  .optional-tag {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
  }

  /* LOG FORM */
  .form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    margin-bottom: 28px;
  }

  .form-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
  }

  .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
  }

  .field label {
    display: block;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin-bottom: 6px;
  }

  .field input, .field select, .field textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.2s;
  }

  .field input:focus, .field select:focus { border-color: var(--accent2); }

  .btn {
    background: var(--accent);
    color: #11131a;
    border: none;
    padding: 11px 24px;
    border-radius: 16px;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .btn:hover { filter: brightness(1.1); transform: translateY(-1px); }

  .btn-ghost {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
  }

  .btn-ghost:hover { border-color: var(--text-muted); background: var(--surface2); transform: none; }

  /* Log table */
  .mono { font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }

  .allure-fast { color: var(--z1); }
  .allure-mid { color: var(--accent2); }
  .allure-slow { color: var(--text-muted); }
  .allure-type-endurance { color: var(--z2); }
  .allure-type-fractionne { color: var(--z5); }
  .allure-type-tempo { color: var(--z4); }
  .allure-type-race { color: var(--z3); }

  /* Alerts */
  .alert {
    background: var(--alert-bg);
    border: 1px solid var(--alert-border);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 16px;
    font-size: 13px;
  }

  .alert-title {
    font-weight: 700;
    color: var(--accent3);
    margin-bottom: 4px;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  }

  .alert-ok {
    background: var(--alert-ok-bg);
    border-color: var(--alert-ok-border);
  }

  .alert-ok .alert-title { color: var(--z1); }


  @media (max-width: 640px) {
    main { padding: 16px; }

    /* Keep date inputs visually aligned with text/select fields on mobile browsers. */
    .field input,
    .field select {
      min-height: 40px;
    }

    .field input[type="date"] {
      display: block;
      line-height: 1.2;
      padding-top: 10px;
      padding-bottom: 10px;
      -webkit-appearance: none;
      appearance: none;
    }
  }

  /* Light mode specific overrides */
  [data-theme="light"] body {
    background: radial-gradient(circle at top center, rgba(91,140,255,0.10), transparent 40%), var(--bg);
    color: var(--text);
  }
  [data-theme="light"] .bar {
    background: var(--accent2);
  }
  [data-theme="light"] input,
  [data-theme="light"] select,
  [data-theme="light"] textarea {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
  }
  [data-theme="light"] .field input[type="date"] {
    color-scheme: light;
  }
  [data-theme="light"] .field input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
  }
  [data-theme="light"] input::placeholder {
    color: var(--text-muted);
  }
  [data-theme="light"] .btn:not(.btn-ghost) {
    color: #f6fbff;
  }
  [data-theme="light"] .btn-ghost {
    color: var(--text);
    border-color: var(--border);
    background: transparent;
  }
  [data-theme="light"] tr:hover td {
    background: var(--surface2);
  }

