  :root {
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    color-scheme: light;

    --bg: #FFFFFF;
    --surface: #FFFFFF;
    --surface-2: #F3F3F3;
    --surface-3: #E9E9E9;
    --text: #111111;
    --text-muted: #555555;
    --accent: #111111;
    --accent-ink: #FFFFFF;
    --good: #15803D;
    --danger: #C62828;
    --border: #111111;
    --line: #D4D4D4;
    --shadow: 0 1px 0 rgba(0,0,0,.04);
    --p-bg: #FFFFFF; --p-text: #111111; --p-muted: #555555;
    --p-tile: #F3F3F3; --p-tile-border: #111111; --p-video-bg: #E4E4E4;
    --p-btn-bg: #FFFFFF; --p-btn-border: #111111; --p-btn-text: #111111;
    --p-accent: #111111; --p-accent-ink: #FFFFFF;
    --p-work: #111111; --p-rest: #7A7A7A; --p-ending: #D32F2F;
    --p-seg: #D9D9D9; --p-seg-done: #111111; --p-seg-fill: #111111;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #2B2E33; --surface: #34373D; --surface-2: #3C4046; --surface-3: #464A51;
    --text: #F2F2F2; --text-muted: #A8ADB4; --accent: #FFD21F; --accent-ink: #1B1B1B;
    --good: #FFD21F; --danger: #FF6B6B; --border: #565B63; --line: #454951;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    --p-bg: #2B2E33; --p-text: #F2F2F2; --p-muted: #A8ADB4;
    --p-tile: #34373D; --p-tile-border: #565B63; --p-video-bg: #22252A;
    --p-btn-bg: #3C4046; --p-btn-border: #565B63; --p-btn-text: #F2F2F2;
    --p-accent: #FFD21F; --p-accent-ink: #1B1B1B;
    --p-work: #FFD21F; --p-rest: #E6E6E6; --p-ending: #FF5252;
    --p-seg: rgba(255,255,255,.18); --p-seg-done: #FFD21F; --p-seg-fill: #FFD21F;
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #2B2E33; --surface: #34373D; --surface-2: #3C4046; --surface-3: #464A51;
    --text: #F2F2F2; --text-muted: #A8ADB4; --accent: #FFD21F; --accent-ink: #1B1B1B;
    --good: #FFD21F; --danger: #FF6B6B; --border: #565B63; --line: #454951;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    --p-bg: #2B2E33; --p-text: #F2F2F2; --p-muted: #A8ADB4;
    --p-tile: #34373D; --p-tile-border: #565B63; --p-video-bg: #22252A;
    --p-btn-bg: #3C4046; --p-btn-border: #565B63; --p-btn-text: #F2F2F2;
    --p-accent: #FFD21F; --p-accent-ink: #1B1B1B;
    --p-work: #FFD21F; --p-rest: #E6E6E6; --p-ending: #FF5252;
    --p-seg: rgba(255,255,255,.18); --p-seg-done: #FFD21F; --p-seg-fill: #FFD21F;
  }
  html { scroll-padding-top: env(safe-area-inset-top, 0px); height: 100%; }
  * { box-sizing: border-box; }
  body {
    margin: 0; min-height: 100%;
    background: var(--bg); color: var(--text);
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  .num { font-family: 'Oswald', 'Manrope', sans-serif; font-variant-numeric: tabular-nums; }
  button { font-family: inherit; cursor: pointer; }
  input, select { font-family: inherit; }

  /* ---------- shared controls ---------- */
  button {
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 10px; padding: 9px 14px; font-size: 13.5px; font-weight: 600;
    transition: transform .08s ease, background .15s ease, border-color .15s ease;
  }
  button:active { transform: scale(0.97); }
  button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  button.ghost { background: transparent; }
  button.danger-ghost { background: transparent; color: var(--danger); border-color: var(--border); }
  button.icon { padding: 7px 9px; line-height: 1.1; }
  button.small { padding: 6px 10px; font-size: 12.5px; }
  button:disabled { opacity: .4; cursor: not-allowed; }
  input[type="text"], input[type="number"], select {
    width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); font-size: 14px;
  }
  input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  label.f-label { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; }
  input[type="file"] { display: none; }

  /* ---------- header ---------- */
  header {
    position: sticky; top: 0; z-index: 20;
    padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 12px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .header-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 1100px; margin: 0 auto; flex-wrap: wrap; }
  .brand h1 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
  .brand p { margin: 2px 0 0; color: var(--text-muted); font-size: 12.5px; }
  .header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

  main { max-width: 1100px; margin: 0 auto; padding: 18px 18px 70px; }

  /* ---------- scheda picker ---------- */
  .scheda-section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); margin: 0 0 10px; }
  .scheda-bar { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 24px; }
  .scheda-card {
    border: 1.5px solid var(--border); border-radius: 14px; padding: 14px; background: var(--surface);
    display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); cursor: pointer;
    transition: border-color .15s ease;
  }
  .scheda-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
  .scheda-card .sc-name { font-size: 15px; font-weight: 700; }
  .scheda-card .sc-sub { font-size: 12px; color: var(--text-muted); }
  .scheda-card .sc-actions { display: flex; gap: 6px; margin-top: 4px; }
  .scheda-card .sc-actions button { flex: 1; }
  .scheda-card .sc-actions .rm { flex: 0 0 auto; }
  .add-scheda-card {
    border: 1.5px dashed var(--border); border-radius: 14px; min-height: 108px;
    background: transparent; color: var(--text-muted); font-size: 13.5px; font-weight: 600;
  }

  .scheda-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
  .scheda-title-row input { font-size: 20px; font-weight: 800; padding: 6px 10px; background: transparent; border-color: transparent; }
  .scheda-title-row input:hover, .scheda-title-row input:focus-visible { background: var(--surface-2); border-color: var(--border); }

  .empty-schede { border: 1.5px dashed var(--border); border-radius: 16px; padding: 48px 22px; text-align: center; color: var(--text-muted); }
  .empty-schede h2 { color: var(--text); margin: 0 0 6px; font-size: 17px; }

  /* ---------- blocks ---------- */
  .block-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
  }
  .block-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
  .block-num {
    width: 30px; height: 30px; border-radius: 9px; background: var(--surface-3);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
  }
  .drag-handle { cursor: grab; touch-action: none; user-select: none; font-size: 16px; padding: 7px 8px; }
  .drag-handle:active { cursor: grabbing; }
  .block-card { transition: transform .15s ease; }
  .block-card.dragging { position: relative; z-index: 40; box-shadow: 0 10px 28px rgba(0,0,0,.25); opacity: .96; transition: none; cursor: grabbing; }
  .block-top input[type="text"] { flex: 1; min-width: 140px; font-size: 15px; font-weight: 700; }
  .block-time-badge { font-size: 12.5px; color: var(--text-muted); background: var(--surface-3); padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
  .block-top-actions { display: flex; gap: 4px; }

  .duration-banner {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px;
    padding: 10px 16px; margin-bottom: 16px; font-size: 13.5px; font-weight: 700; color: var(--text-muted);
  }
  .duration-banner .db-time { font-size: 18px; color: var(--accent); }

  .mode-toggle { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
  .mode-toggle button {
    border: none; border-radius: 0; background: var(--surface-2); color: var(--text-muted);
    font-size: 12.5px; padding: 8px 12px;
  }
  .mode-toggle button.active { background: var(--accent); color: var(--accent-ink); }

  .settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 12px 0; }
  .settings-grid .field-hint { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

  .exercises-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; }
  .exercise-card { border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--surface-2); }
  .exercise-card .ex-head { display: flex; gap: 6px; margin-bottom: 8px; }
  .exercise-card input[type="text"] { font-size: 13.5px; font-weight: 600; }
  .exercise-card .ex-file-row { display: flex; align-items: center; gap: 6px; }
  .exercise-card .ex-file-row span { font-size: 11.5px; color: var(--text-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .exercise-card .ex-note { margin-top: 6px; font-size: 12.5px; padding: 7px 9px; }
  .exercise-card .rm-ex { flex-shrink: 0; }

  .add-exercise-btn { border: 1.5px dashed var(--border); background: transparent; border-radius: 12px; min-height: 84px; color: var(--text-muted); font-size: 13px; }

  .cascata-columns { display: flex; gap: 14px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; }
  .cascata-column { flex: 1 1 210px; min-width: 200px; display: flex; flex-direction: column; gap: 8px; }
  .cascata-col-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
  .cascata-col-empty { margin: 0; padding: 10px; border: 1.5px dashed var(--border); border-radius: 10px; text-align: center; }
  .cascata-add-under { min-height: 44px; }

  .block-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
  .rest-after-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
  .rest-after-field input { width: 70px; }

  .add-block-btn { width: 100%; border: 1.5px dashed var(--border); background: transparent; border-radius: 16px; padding: 18px; color: var(--text-muted); font-size: 14px; font-weight: 600; }

  .go-present {
    position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); z-index: 25;
    padding: 14px 22px; border-radius: 999px; font-size: 14.5px; box-shadow: var(--shadow);
  }

  /* ---------- present mode ---------- */
  .present {
    position: fixed; inset: 0; z-index: 100; background: var(--p-bg); color: var(--p-text);
    display: flex; flex-direction: column;
  }
  .present.hidden { display: none; }
  .present-top {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: calc(env(safe-area-inset-top, 0px) + 12px) 18px 10px;
    font-size: 13px; color: var(--p-muted);
  }
  .present-top .p-meta { display: flex; gap: 14px; flex-wrap: wrap; }
  .present-top button { background: var(--p-btn-bg); border-color: var(--p-btn-border); color: var(--p-btn-text); }
  .present-top .mode-toggle { border-color: var(--p-btn-border); }
  .present-top .mode-toggle button.active { background: var(--p-accent); color: var(--p-accent-ink); }
  .present-top-right { display: flex; align-items: center; gap: 8px; }

  .present-timeline-wrap { padding: 0 18px 6px; }
  .present-timeline { display: flex; gap: 3px; height: 7px; }
  .present-timeline .pt-seg { flex-grow: 1; border-radius: 4px; background: var(--p-seg); position: relative; overflow: hidden; }
  .present-timeline .pt-seg.pt-done { background: var(--p-seg-done); }
  .present-timeline .pt-seg.pt-current { background: var(--p-seg); }
  .present-timeline .pt-seg.pt-current .pt-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--p-seg-fill); border-radius: 4px; }
  .present-timeline-label { text-align: center; font-size: 12px; color: var(--p-muted); margin-top: 6px; }

  .present-body { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: stretch; padding: clamp(16px, 4vh, 44px) 16px 10px; overflow: hidden; }

  .p-timer { font-size: clamp(40px, min(11vw, 15vh), 140px); font-weight: 600; line-height: 1; letter-spacing: 0.01em; transition: color .15s ease; text-align: center; flex: 0 0 auto; }
  .p-timer.rest { color: var(--p-rest); }
  .p-timer.work { color: var(--p-work); }
  .p-timer.ending { color: var(--p-ending); animation: pTimerPulse .5s ease-in-out; }
  .p-timer.compact { font-size: clamp(32px, min(8vw, 10vh), 100px); }
  @keyframes pTimerPulse { 0% { transform: scale(1); } 35% { transform: scale(1.12); } 100% { transform: scale(1); } }
  .p-phase-label { font-size: clamp(12px, 2vw, 17px); letter-spacing: 0.04em; color: var(--p-muted); margin-bottom: 8px; font-weight: 700; text-align: center; flex: 0 0 auto; }
  .p-preview-label { text-align: center; flex: 0 0 auto; }

  /* full-screen responsive tile stage: rows and tiles stretch to fill all available space */
  .p-stage { width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
  .p-row {
    flex: 1; min-height: 0; display: grid; gap: 10px; grid-auto-rows: 1fr;
    align-items: center; justify-items: center;
    transition: opacity .25s ease;
  }
  .p-row.done { opacity: .35; }
  .p-row.preview, .p-solo.preview { opacity: .5; }
  .p-row.upcoming { opacity: 0; visibility: hidden; }
  .p-tile { background: var(--p-tile); border-radius: 16px; overflow: hidden; border: 1px solid var(--p-tile-border); display: flex; flex-direction: column; min-height: 0; }
  /* inside a grid row: the card hugs the video's own aspect ratio instead of stretching to fill the whole row height */
  .p-row .p-tile { width: 100%; max-height: 100%; }
  .p-row .p-tile .p-video-wrap { flex: 0 1 auto; width: 100%; aspect-ratio: var(--vr, 3 / 4); max-height: 100%; min-height: 0; }
  .p-tile .p-video-wrap { position: relative; flex: 1; min-height: 0; background: var(--p-video-bg); display: flex; align-items: center; justify-content: center; }
  .p-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
  .p-tile .p-noVideo { color: var(--p-muted); font-size: 12.5px; }
  .p-tile .p-tile-title, .p-tile .p-tile-note {
    flex: 0 0 auto; padding: clamp(6px, 1vh, 12px) 10px; font-weight: 700;
    font-size: clamp(12px, min(1.8vw, 2.6vh), 19px); line-height: 1.25; text-align: center;
    min-height: calc(clamp(12px, min(1.8vw, 2.6vh), 19px) * 1.25 * 2 + clamp(6px, 1vh, 12px) * 2);
    display: flex; align-items: center; justify-content: center;
  }
  .p-tile .p-tile-title > span, .p-tile .p-tile-note > span {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; width: 100%;
  }
  .p-tile .p-tile-note { color: var(--p-accent); border-bottom: 1px solid var(--p-tile-border); }

  .p-solo { width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: 0; }
  .p-solo .p-tile { flex: 0 0 auto; width: 100%; max-height: 100%; border-radius: 18px; }
  .p-solo .p-video-wrap { border-radius: 18px; overflow: hidden; flex: 0 1 auto; width: 100%; aspect-ratio: var(--vr, 3 / 4); max-height: 100%; min-height: 0; }
  .p-solo .p-tile-title, .p-solo .p-tile-note {
    font-size: clamp(16px, 2.6vh, 24px);
    min-height: calc(clamp(16px, 2.6vh, 24px) * 1.25 * 2 + clamp(6px, 1vh, 12px) * 2);
  }

  .p-restinfo { text-align: center; color: var(--p-muted); font-size: 15px; margin-top: 4px; max-width: 480px; align-self: center; flex: 0 0 auto; }
  .p-restinfo b { color: var(--p-text); }

  .present-bottom {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 14px 18px calc(env(safe-area-inset-bottom, 0px) + 18px);
  }
  .present-bottom button {
    background: var(--p-btn-bg); border-color: var(--p-btn-border); color: var(--p-btn-text);
    padding: 12px 18px; border-radius: 999px; font-size: 14px;
  }
  .present-bottom button.big-play { background: var(--p-accent); border-color: var(--p-accent); color: var(--p-accent-ink); padding: 14px 28px; font-size: 15px; }

  .p-done { text-align: center; }
  .p-done h2 { font-size: clamp(28px, 5vw, 44px); margin-bottom: 10px; }
  .p-done p { color: var(--p-muted); margin-bottom: 20px; }

  /* ---------- library & modals ---------- */
  textarea {
    width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; resize: vertical;
  }
  .lib-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
  .lib-title { margin: 0 0 2px; font-size: 20px; font-weight: 800; }
  .lib-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .lib-tools input[type="text"] { width: 220px; }
  .lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
  .lib-card { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; display: flex; flex-direction: column; }
  .lib-thumb {
    aspect-ratio: 16/10; background: var(--surface-3); display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 12px; text-align: center; padding: 6px; cursor: pointer; position: relative;
  }
  .lib-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
  .lib-thumb .lib-playhint { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 999px; }
  .lib-body { padding: 10px; display: flex; flex-direction: column; gap: 6px; }
  .lib-body input[type="text"] { font-size: 13.5px; font-weight: 700; }
  .lib-meta { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lib-actions { display: flex; gap: 6px; }
  .lib-actions button { flex: 1; }
  .lib-empty { grid-column: 1 / -1; border: 1.5px dashed var(--border); border-radius: 14px; padding: 40px 18px; text-align: center; color: var(--text-muted); }
  .picker-card { cursor: pointer; }
  .picker-card:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
  .picker-card .lib-thumb { cursor: pointer; }
  .picker-card .lib-title-line { padding: 8px 10px; font-weight: 700; font-size: 13.5px; }

  .modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 150; display: none; align-items: center; justify-content: center; padding: 16px; }
  .modal-overlay.open { display: flex; }
  .modal-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 780px;
    max-height: 88vh; display: flex; flex-direction: column; gap: 10px; padding: 16px; overflow: hidden;
  }
  .modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .modal-head h2 { margin: 0; font-size: 17px; }
  .modal-body { overflow-y: auto; }
  .modal-actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
  .modal-box.small-box { max-width: 420px; }
  .confirm-message { margin: 4px 0 4px; font-size: 14.5px; line-height: 1.5; white-space: pre-line; }
  .modal-actions-row.end { justify-content: flex-end; }
  button.danger-btn { background: var(--danger); border-color: var(--danger); color: #fff; }

  .ex-btn-row { display: flex; gap: 6px; margin-top: 8px; }
  .ex-btn-row button { flex: 1; }

  /* ---------- trainer login ---------- */
  .trainer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 4px; }
  .trainer-pick {
    border: 1.5px solid var(--border); border-radius: 14px; padding: 16px 10px; background: var(--surface);
    display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; text-align: center;
  }
  .trainer-pick:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
  .trainer-pick .tp-avatar {
    width: 44px; height: 44px; border-radius: 50%; background: var(--surface-3); display: flex;
    align-items: center; justify-content: center; font-weight: 800; font-size: 16px;
  }
  .trainer-pick .tp-name { font-size: 13.5px; font-weight: 700; word-break: break-word; }
  .trainer-add-pick { border: 1.5px dashed var(--border); background: transparent; color: var(--text-muted); min-height: 92px; }
  .pin-target-name { text-align: center; font-size: 15px; font-weight: 700; margin: 2px 0 6px; }
  .pin-dots { display: flex; justify-content: center; gap: 10px; margin: 14px 0; }
  .pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--border); background: transparent; }
  .pin-dots span.filled { background: var(--accent); border-color: var(--accent); }
  .pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 260px; margin: 0 auto; }
  .pin-pad button { padding: 14px 0; font-size: 17px; border-radius: 12px; }
  .pin-error { color: var(--danger); text-align: center; font-size: 13px; min-height: 18px; margin: 0 0 2px; }
  .trainer-form-row { margin-bottom: 10px; }
  .history-day-label { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin: 18px 0 8px; }
  .history-day-label:first-child { margin-top: 0; }
  .history-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; background: var(--surface);
  }
  .history-row .hr-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .history-row .hr-time { font-weight: 800; font-family: 'Oswald', sans-serif; font-size: 15px; }
  .history-row .hr-name { font-weight: 700; }
  .history-row .hr-meta { font-size: 12.5px; color: var(--text-muted); }
  .history-status { font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
  .history-status.ok { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
  .history-status.mid { background: var(--surface-3); color: var(--text-muted); }
  .history-status.bad { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
  .history-empty { border: 1.5px dashed var(--border); border-radius: 14px; padding: 40px 18px; text-align: center; color: var(--text-muted); }

  .p-preview-label { margin-top: 6px; font-size: 13px; letter-spacing: .05em; color: var(--p-muted); font-weight: 700; text-transform: uppercase; }

  .toast {
    position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
    transform: translateX(-50%) translateY(20px);
    background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
    font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none;
    transition: opacity .2s ease, transform .2s ease; z-index: 200; box-shadow: var(--shadow);
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* ---------- versione online: accesso, account, caricamenti ---------- */
  input[type="email"], input[type="password"] {
    width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); font-size: 14px; font-family: inherit;
  }
  .auth-form { display: flex; flex-direction: column; gap: 10px; }
  .auth-form .form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0; }
  .auth-form .auth-switch { text-align: center; font-size: 13px; color: var(--text-muted); }
  .auth-form .auth-switch button { border: none; background: none; color: var(--text); text-decoration: underline; padding: 0; font-size: 13px; }
  .user-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface);
  }
  .user-row .ur-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .user-row .ur-text { min-width: 0; }
  .user-row .ur-name { font-weight: 700; font-size: 14px; }
  .user-row .ur-email { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-row .ur-actions { display: flex; gap: 6px; flex-wrap: wrap; }
  .user-row .tp-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
  .upload-bar {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
    width: min(420px, calc(100% - 32px)); z-index: 180; background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow);
  }
  .upload-bar-text { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .upload-bar-track { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
  .upload-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
