  :root {
    --bg: #0f1115;
    --surface: #181b22;
    --surface-2: #20242e;
    --border: #2b303b;
    --text: #e7e9ee;
    --muted: #9aa3b2;
    --accent: #ff5a36;
    --accent-soft: #ff5a3622;
    --green: #36d399;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(0,0,0,.35);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }
  .container { max-width: 1000px; margin: 0 auto; padding: 0 20px 80px; }

  header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(15,17,21,.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
  }
  .header-inner { max-width: 1000px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.3px; }
  .logo .dot { width: 11px; height: 11px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
  nav { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 11px; border: 1px solid var(--border); }
  nav button {
    background: none; border: none; color: var(--muted); font-weight: 600; font-size: 13px;
    padding: 8px 16px; border-radius: 8px; cursor: pointer; transition: .15s; font-family: inherit;
  }
  nav button.active { background: var(--accent); color: #fff; }
  nav button:not(.active):hover { color: var(--text); }

  h1 { font-size: 26px; font-weight: 750; letter-spacing: -.5px; margin: 28px 0 4px; }
  .sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
  h2 { font-size: 16px; font-weight: 700; margin-bottom: 14px; letter-spacing: -.2px; }

  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }

  label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
  input, select {
    width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    padding: 11px 13px; border-radius: 10px; font-size: 15px; font-family: inherit; transition: .15s;
  }
  input:focus, select:focus { outline: none; border-color: var(--accent); background: #262b36; }
  input::placeholder { color: #5a6373; }

  button.btn {
    background: var(--accent); color: #fff; border: none; padding: 11px 18px; border-radius: 10px;
    font-weight: 650; font-size: 14px; cursor: pointer; font-family: inherit; transition: .15s;
  }
  button.btn:hover { filter: brightness(1.08); }
  button.btn:active { transform: translateY(1px); }
  button.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
  button.ghost:hover { border-color: var(--muted); filter: none; }
  button.small { padding: 7px 12px; font-size: 13px; }

  .row { display: flex; gap: 12px; flex-wrap: wrap; }
  .row > * { flex: 1; min-width: 120px; }

  .pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent); text-transform: uppercase; letter-spacing: .4px; }

  /* exercise picker */
  .ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .ex-chip {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 12px 14px;
    cursor: pointer; transition: .15s; text-align: left;
  }
  .ex-chip:hover { border-color: var(--muted); }
  .ex-chip.selected { border-color: var(--accent); background: var(--accent-soft); }
  .ex-chip .name { font-weight: 650; font-size: 14px; }
  .ex-chip .grp { font-size: 11px; color: var(--muted); margin-top: 2px; }

  .del { background: none; border: none; color: #6b7280; cursor: pointer; font-size: 18px; line-height: 1; padding: 4px; border-radius: 6px; }
  .del:hover { color: var(--accent); background: var(--accent-soft); }

  /* ===== mode séance guidée ===== */
  .btn.big { width: 100%; padding: 16px; font-size: 17px; border-radius: 14px; }
  .wk-top { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; }
  .wk-progress { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
  #wk-bar { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
  #wk-count { font-size: 12px; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
  .wk-card { text-align: center; padding: 24px 18px 20px; }
  #wk-exo-name { font-size: 24px; margin: 8px 0 14px; }
  .wk-sets { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
  .set-chip { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); border-radius: 99px; padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
  .set-chip.ok { color: var(--green); border-color: #36d39955; }
  .set-chip.cur { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
  .wk-set-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; margin-bottom: 14px; }
  .steppers { display: flex; gap: 12px; justify-content: center; margin-bottom: 18px; }
  .stepper { flex: 1; max-width: 210px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; display: flex; align-items: stretch; overflow: hidden; }
  .stepper > button { width: 52px; min-height: 68px; background: none; border: none; color: var(--accent); font-size: 26px; font-weight: 700; cursor: pointer; flex: 0 0 auto; }
  .stepper > button:active { background: var(--accent-soft); }
  .stepper .val { flex: 1; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
  .stepper input { background: none; border: none; text-align: center; font-size: 24px; font-weight: 750; color: var(--text); width: 100%; padding: 0; }
  .stepper input:focus { outline: none; }
  .stepper .unit { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
  .wk-actions { display: flex; gap: 10px; margin-top: 12px; }
  .wk-actions button { flex: 1; }
  .exo-nav { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; }
  .exo-nav-chip { white-space: nowrap; background: var(--surface); border: 1px solid var(--border); color: var(--muted); border-radius: 99px; padding: 9px 14px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; flex: 0 0 auto; }
  .exo-nav-chip.cur { border-color: var(--accent); color: var(--text); }
  .exo-nav-chip.ok { color: var(--green); }
  .rest { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
  .rest b { font-variant-numeric: tabular-nums; font-size: 18px; color: var(--accent); }
  .quick-chip { display: block; width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 10px; cursor: pointer; font: inherit; color: var(--text); }
  .quick-chip:hover, .quick-chip:active { border-color: var(--accent); }
  .quick-chip .q-title { display: block; font-weight: 700; font-size: 15px; margin-bottom: 2px; }
  .quick-chip .q-sub { font-size: 12px; color: var(--muted); }
  .resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
  .start-bar { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 35%); }
  .sheet { position: fixed; inset: 0; z-index: 90; background: rgba(15,17,21,.8); display: flex; align-items: flex-end; }
  .sheet-inner { background: var(--surface); border-radius: 18px 18px 0 0; width: 100%; max-height: 75vh; overflow: auto; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
  .login { position: fixed; inset: 0; z-index: 95; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 20px; }
  .login-card { max-width: 380px; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; text-align: center; box-shadow: var(--shadow); }

  /* stats */
  .stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 8px; }
  .stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
  .stat .v { font-size: 28px; font-weight: 750; letter-spacing: -1px; }
  .stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

  /* history */
  .hist-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
  .hist-item:last-child { border-bottom: none; }
  .hist-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
  .hist-date { font-weight: 650; font-size: 15px; }
  .hist-ex { font-size: 13px; color: var(--muted); }
  .hist-ex b { color: var(--text); font-weight: 600; }

  .empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }
  .empty .big { font-size: 38px; margin-bottom: 10px; }

  svg text { fill: var(--muted); font-size: 11px; }
  .chart-wrap { overflow-x: auto; }
  .legend { display: flex; flex-wrap: wrap; gap: 9px 16px; margin-top: 14px; }
  .legend .item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
  .legend .swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
  .toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--green); color: #062b1f; padding: 12px 22px; border-radius: 11px; font-weight: 650;
    box-shadow: var(--shadow); opacity: 0; transition: .3s; pointer-events: none; z-index: 100; font-size: 14px;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  select.mini { width: auto; display: inline-block; padding: 8px 12px; font-size: 14px; }
  .flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
  .hide { display: none !important; }

  .type-tag { font-size: 10px; color: var(--muted); border: 1px solid var(--border); padding: 2px 7px; border-radius: 999px; margin-left: 8px; text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }

  /* file pill (état de connexion) */
  .file-pill { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
  .file-pill.warn { color: var(--accent); cursor: pointer; }
  .header-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
  .header-inner { flex-wrap: wrap; }

  /* safe-area (encoche / barre iOS) */
  header { padding-top: max(16px, env(safe-area-inset-top)); }
  .container { padding-bottom: max(80px, env(safe-area-inset-bottom)); }

  /* tactile : pas de délai double-tap ni de flash de sélection */
  button, .ex-chip, input, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .ex-chip, .quick-chip, .set-chip, .exo-nav-chip { user-select: none; -webkit-user-select: none; }

  /* barre d'onglets mobile (cachée sur desktop) */
  .tabbar { display: none; }

  @media (max-width: 700px) {
    /* nav en bas, header allégé */
    .topnav { display: none; }
    .tabbar {
      position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
      display: flex; background: rgba(24,27,34,.97); backdrop-filter: blur(12px);
      border-top: 1px solid var(--border);
      padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    }
    .tabbar button {
      flex: 1; background: none; border: none; color: var(--muted);
      font-family: inherit; font-size: 11px; font-weight: 650;
      display: flex; flex-direction: column; align-items: center; gap: 3px;
      padding: 6px 4px; border-radius: 10px; cursor: pointer;
    }
    .tabbar button .ico { font-size: 22px; line-height: 1; }
    .tabbar button.active { color: var(--accent); }
    .container { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
    .start-bar { bottom: calc(70px + env(safe-area-inset-bottom)); }

    /* confort tactile */
    input, select { font-size: 16px; }        /* <16px = zoom auto iOS au focus */
    select.mini { font-size: 14px; }
    .card { padding: 16px; }
    h1 { font-size: 22px; margin-top: 20px; }
    .ex-grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
    .ex-chip { padding: 14px; }
    .btn.big { padding: 17px; font-size: 18px; }
    .set-chip { padding: 10px 15px; font-size: 14px; }
    .exo-nav-chip { padding: 11px 15px; }
    .stepper > button { min-height: 74px; width: 56px; }
    .stepper input { font-size: 26px; }
    #wk-exo-name { font-size: 26px; }
    .wk-actions button { padding: 13px 12px; }
    .del { font-size: 20px; padding: 8px; }
    .logo { font-size: 16px; }
  }
