/* Palette dei fogli Google "Piano atletico 6 settimane": #333333, #FF6600, #006666, #990033, #FFF1CC, #E6F1F1, #FFEFE6 */
/* Tema: giorno (predefinito), notte con data-theme="dark" oppure automatico (segue il dispositivo). */
:root {
  --bg: #edf1f1;
  --surface: #ffffff;
  --surface-2: #f1f5f5;
  --text: #15201f;
  --muted: #586463;
  --border: #d8e1e0;
  --head: #333333;
  --head-ink: #ffffff;
  --accent: #006666;
  --accent-strong: #004a4a;
  --accent-2: #e0efef;
  --accent-ink: #ffffff;
  --orange: #ff6600;
  --orange-strong: #e05200;
  --orange-2: #ffefe6;
  --orange-ink: #b34700;
  --warn: #990033;
  --warn-bg: #fff1cc;
  --danger: #990033;
  --danger-bg: #fbe6ec;
  --done: #006666;
  --nav-bg: #2b2b2b;
  --nav-ink: #b9c2c1;
  --hero: linear-gradient(125deg, #007a7a 0%, #006666 45%, #003d3d 100%);
  --stripe: rgba(0, 102, 102, .035);
  --radius: 18px;
  --tap: 52px;
  --shadow: 0 1px 2px rgba(16, 40, 40, .06), 0 6px 18px rgba(16, 40, 40, .07);
  --shadow-lg: 0 14px 34px rgba(16, 40, 40, .18);
  --font-display: "Bahnschrift", "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1212; --surface: #142020; --surface-2: #1b2a2a; --text: #eef5f4; --muted: #9fb1af;
    --border: #263837; --head: #0b1212; --head-ink: #eef5f4; --accent: #2fb3b3; --accent-strong: #1b8a8a; --accent-2: #10302f; --accent-ink: #031313;
    --orange: #ff7a1f; --orange-strong: #ff6600; --orange-2: #3a2312; --orange-ink: #ffb07a;
    --warn: #ffb3c7; --warn-bg: #3a2f12; --danger: #ff8fab; --danger-bg: #3d1a24; --done: #2fb3b3;
    --nav-bg: #070c0c; --nav-ink: #8fa3a1;
    --hero: linear-gradient(125deg, #0d4f4f 0%, #0a3b3b 50%, #0b1a1a 100%);
    --stripe: rgba(47, 179, 179, .035);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 14px 34px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1212; --surface: #142020; --surface-2: #1b2a2a; --text: #eef5f4; --muted: #9fb1af;
  --border: #263837; --head: #0b1212; --head-ink: #eef5f4; --accent: #2fb3b3; --accent-strong: #1b8a8a; --accent-2: #10302f; --accent-ink: #031313;
  --orange: #ff7a1f; --orange-strong: #ff6600; --orange-2: #3a2312; --orange-ink: #ffb07a;
  --warn: #ffb3c7; --warn-bg: #3a2f12; --danger: #ff8fab; --danger-bg: #3d1a24; --done: #2fb3b3;
  --nav-bg: #070c0c; --nav-ink: #8fa3a1;
  --hero: linear-gradient(125deg, #0d4f4f 0%, #0a3b3b 50%, #0b1a1a 100%);
  --stripe: rgba(47, 179, 179, .035);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 14px 34px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.loading { padding: 2rem; color: var(--muted); }

/* ---------- Navigazione ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav .brand { display: none; }
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600;
}
.nav a .ico { font-size: 1.25rem; line-height: 1; }
.nav a.active { color: var(--accent); }
@media (min-width: 960px) {
  body { padding-bottom: 0; padding-left: 210px; }
  .nav { top: 0; right: auto; width: 210px; flex-direction: column; border-top: 0; border-right: 1px solid var(--border); padding: 16px 10px; gap: 4px; }
  .nav .brand { display: block; font-weight: 800; font-size: 1.35rem; padding: 6px 12px 18px; color: var(--orange); }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; min-height: 48px; font-size: .95rem; border-radius: 10px; }
  .nav a.active { background: var(--accent-2); }
}
body.run-mode .nav { display: none; }
body.run-mode { padding-left: 0; padding-bottom: 0; }

main { max-width: 1120px; margin: 0 auto; padding: 16px 16px 32px; outline: none; }
@media (min-width: 700px) { main { padding: 24px; } }
/* Oggi: orari */
.today-row .t-time { display: flex; flex-direction: column; align-items: center; min-width: 52px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.today-row .t-time b { font-size: 1.05rem; }
.today-row .t-time span { font-size: .78rem; color: var(--muted); }
.today-row.live { box-shadow: inset 4px 0 0 var(--orange); }
.today-row.ok { box-shadow: inset 4px 0 0 var(--done); }
.day-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.day-nav .day-title { flex: 1; text-align: center; min-width: 0; }
.day-nav .day-title h1 { margin: 0; }
.day-arrow { font-size: 1.6rem; line-height: 1; min-width: 52px; min-height: 48px; padding: 0 12px; }
.day-back { margin: -4px 0 14px; justify-content: center; }
.warn-text { color: var(--warn); background: var(--warn-bg); padding: 6px 8px; border-radius: 8px; }
.today-past { margin-top: 10px; }
.today-past .list-row { opacity: .7; }
/* Presenze con salvataggio automatico */
.att-status { margin: 10px 0 0; font-size: .92rem; color: var(--muted); }
.att-status.ok { color: var(--accent); font-weight: 600; }
.att-panel { margin-bottom: 12px; }
/* Pulsante Indietro in alto a destra */
.appbar { max-width: 1120px; margin: 0 auto; padding: calc(8px + env(safe-area-inset-top)) 16px 0; display: flex; justify-content: flex-start; }
.appbar .sync-btn { margin-left: auto; } /* Indietro a sinistra, sincronizzazione a destra */
.appbar[hidden], .appbar [hidden] { display: none !important; }
.appbar + main { padding-top: 4px; }
@media (min-width: 700px) { .appbar { padding: 12px 24px 0; } }
.back-btn { font-weight: 700; }
.appbar { gap: 8px; }
.sync-btn { font-weight: 600; }
.sync-btn.ok { color: var(--accent); }
.sync-btn.dirty { color: var(--orange); border-color: var(--orange); }
.sync-btn.err { color: var(--danger, #990033); border-color: currentColor; }
.sync-btn.run { opacity: .7; }
body.run-mode .appbar, body.board-full .appbar { display: none; }

/* ---------- Componenti ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; flex: 1 1 auto; }
.page-head .back { text-decoration: none; font-weight: 600; }
.crumb { font-size: .9rem; margin-bottom: 4px; display: block; text-decoration: none; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; flex: 1 1 auto; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row-flex { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
  touch-action: manipulation; user-select: none;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btn.icon { padding: 0; width: var(--tap); }
.btn.sm.icon { width: 40px; }
.btn.big { min-height: 72px; font-size: 1.2rem; padding: 0 28px; border-radius: 16px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .85rem; font-weight: 650; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
textarea { min-height: 88px; resize: vertical; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.fields .span2 { grid-column: span 2; }
.fields .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; min-height: 60px; text-decoration: none; color: inherit; }
.list-row .main { flex: 1; min-width: 0; }
.list-row .title { font-weight: 650; }
.list-row .sub { font-size: .87rem; color: var(--muted); }
a.list-row:hover { background: var(--surface-2); }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge.accent { background: var(--accent-2); color: var(--accent); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.orange { background: var(--orange-2); color: #b34700; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip { flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-weight: 650; color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip .count { font-size: .75rem; opacity: .8; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.seg button { min-height: 48px; padding: 0 16px; border: 0; background: transparent; font: inherit; font-weight: 650; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--accent-2); color: var(--accent); }

.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.info { background: var(--accent-2); color: var(--accent); }
.banner p { margin: 0; flex: 1 1 240px; font-weight: 600; }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th, .tbl td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--head-ink); background: var(--head); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .good { color: var(--done); font-weight: 700; }
.tbl .bad { color: var(--danger); font-weight: 700; }
.tbl input { min-height: 44px; }

.stat { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { font-size: .82rem; color: var(--muted); }

/* ---------- Dialog ---------- */
dialog.modal { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog.modal.wide { width: min(860px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(10,14,12,.5); }
dialog.modal form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
dialog.modal header { padding: 18px 20px 6px; }
dialog.modal header h2 { margin: 0; }
.modal-body { padding: 10px 20px; overflow-y: auto; }
dialog.modal footer { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.form-error { color: var(--danger); font-weight: 650; padding: 0 20px; margin: 0; }
.rpe-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rpe-grid button { min-height: 64px; font-size: 1.3rem; }

/* ---------- Toast ---------- */
#toasts { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); transition: opacity .35s, transform .35s; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- Programmazione ---------- */
.week-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.session-card { border-top: 4px solid var(--orange); }
.ex-card { border-left: 4px solid var(--accent); }
.session-card .ex-list { list-style: none; margin: 0; padding: 0; }
.ex-row { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--border); padding: 8px 0; }
.ex-row:first-child { border-top: 0; }
.ex-row .ex-main { flex: 1; min-width: 0; cursor: pointer; padding: 6px 4px; border-radius: 8px; }
.ex-row .ex-main:hover { background: var(--surface-2); }
.ex-row .idx { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: .8rem; font-weight: 700; flex: none; }
.ex-row .name { font-weight: 650; }
.ex-row .presc { font-size: .9rem; color: var(--muted); }
.ex-row .note { font-size: .85rem; color: var(--muted); font-style: italic; }
.ex-row .tools { display: flex; gap: 2px; flex: none; }
.ov-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--orange); margin-left: 6px; vertical-align: middle; }

/* ---------- Sessione in campo ---------- */
body.run-mode main { max-width: 900px; padding-top: 0; padding-bottom: 160px; }

/* ---------- Presenze ---------- */
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
a.chip { text-decoration: none; }
.att-date { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.att-date .field { margin: 0; flex: 0 1 220px; }
.att-date .btn { min-width: 52px; }
.att-count { margin: 12px 0; color: var(--muted); }
.att-count b { color: var(--accent); font-size: 1.3rem; }
.att-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.att-btn { min-height: 72px; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 1.1rem; font-weight: 700; text-align: left; cursor: pointer; touch-action: manipulation; }
.att-btn .tick { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-size: 1.2rem; }
.att-btn .nm { flex: 1; min-width: 0; }
.att-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.att-btn.on .tick { background: var(--accent-ink); color: var(--accent); border-color: var(--accent-ink); }
.att-btn.on .badge { background: var(--accent-ink); }
.tbl tr.sel td { background: var(--accent-2); }
.att-cal .cal { max-width: 520px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cal-head b { font-size: 1.1rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); padding: 2px 0; }
.cal-cell { min-height: 52px; border-radius: 10px; border: 1px solid transparent; background: transparent; font: inherit; color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px; }
button.cal-cell { cursor: pointer; touch-action: manipulation; }
button.cal-cell:hover { border-color: var(--border); }
.cal-cell.empty { visibility: hidden; }
.cal-cell .n { font-weight: 650; line-height: 1; }
.cal-cell .m { font-size: .68rem; font-weight: 800; line-height: 1; }
.cal-cell.has { background: var(--accent-2); color: var(--accent); }
.cal-cell.has.on { background: var(--accent); color: var(--accent-ink); }
.cal-cell.has.abs { background: var(--danger-bg); color: var(--danger); }
.cal-cell.today { border-color: var(--orange); }
.cal-cell.sel { outline: 3px solid var(--orange); outline-offset: -1px; }
@media (min-width: 900px) { .ov-chips { flex-wrap: wrap; overflow: visible; } }
@media (max-width: 480px) { .nav a { font-size: .62rem; letter-spacing: -.01em; } .nav a .ico { font-size: 1.15rem; } }
.ov-layout { display: grid; gap: 16px; align-items: start; }
@media (min-width: 900px) { .ov-layout { grid-template-columns: minmax(320px, 520px) 1fr; } .ov-layout .card { margin: 0; } }
.ov-row .sub b { color: var(--accent); }
.cal-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.cal-key.on { background: var(--accent); } .cal-key.abs { background: var(--danger-bg); border: 1px solid var(--danger); }

/* ---------- Tabellone (sola lettura) ---------- */
body.board-mode main { max-width: none; padding-bottom: 48px; }
body.board-full main { padding-top: calc(10px + env(safe-area-inset-top)); }
.board-top { margin-bottom: 14px; }
.board-top .page-head { margin-bottom: 10px; }
.board-top .chip[disabled] { opacity: .4; cursor: default; }
.board-size button { min-width: 44px; padding: 0 10px; }
.board { display: grid; gap: 14px; align-items: start; grid-template-columns: repeat(auto-fill, minmax(var(--col, 290px), 1fr)); }
.board.size-s { --col: 240px; font-size: .9rem; }
.board.size-m { --col: 290px; font-size: 1rem; }
.board.size-l { --col: 340px; font-size: 1.15rem; }
.board.size-xl { --col: 420px; font-size: 1.35rem; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.board-card header { background: var(--accent); color: var(--accent-ink); padding: .6em .9em; display: flex; align-items: baseline; gap: 8px; }
.board-card header h2 { margin: 0; font-size: 1.3em; flex: 1; }
.board-card header span { font-size: .8em; font-weight: 700; opacity: .85; }
.board-card ol { list-style: none; margin: 0; padding: 0; counter-reset: ex; }
.board-card li { counter-increment: ex; padding: .55em .9em .6em 2.6em; border-top: 1px solid var(--border); position: relative; }
.board-card li:first-child { border-top: 0; }
.board-card li::before { content: counter(ex); position: absolute; left: .9em; top: .55em; font-weight: 800; color: var(--orange); }
.board-card .b-name { font-weight: 650; line-height: 1.3; }
.board-card .b-vol { font-size: 1.25em; font-weight: 800; color: var(--accent); margin-top: 2px; }
.board-card .b-vol small { font-size: .65em; font-weight: 700; color: var(--muted); }
.board-card .b-note { font-size: .85em; color: var(--muted); font-style: italic; margin: 2px 0 0; }
.board-card > .b-note { padding: .6em .9em; border-top: 1px solid var(--border); }
.board-card { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; transition: box-shadow .15s; }
.board-card header, .board-card li { cursor: pointer; }
.board-card li:active { background: var(--accent-2); }
.board-card.dragging { position: relative; z-index: 40; box-shadow: 0 12px 32px rgba(0,0,0,.28); opacity: .95; transition: none; }
.board-card.drop-before { box-shadow: -6px 0 0 var(--orange); }
.board-card.drop-after { box-shadow: 6px 0 0 var(--orange); }
.b-add { display: block; width: 100%; min-height: 44px; border: 0; border-top: 1px dashed var(--border); background: transparent; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.run-top { position: sticky; top: 0; z-index: 15; background: var(--bg); padding: 10px 0 8px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.run-top .bar { display: flex; align-items: center; gap: 8px; }
.run-top .title { flex: 1; min-width: 0; }
.run-top .title b { display: block; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-top .title span { display: block; font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wake { font-size: .75rem; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.wake.on { background: var(--accent-2); color: var(--accent); }

.ex-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px; margin-bottom: 14px; }
.ex-card.complete { border-color: var(--done); }
.ex-card h3 { font-size: 1.25rem; margin: 0; }
.ex-card .presc { color: var(--muted); font-weight: 600; margin-top: 2px; }
.ex-card .note { font-style: italic; color: var(--muted); font-size: .92rem; margin-top: 4px; }
.sets { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.set-row { display: grid; grid-template-columns: 76px 1fr 1fr 76px; gap: 8px; align-items: stretch; }
.set-check { min-height: 76px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface-2); font: inherit; font-size: 1.4rem; font-weight: 800; color: var(--text); cursor: pointer; touch-action: manipulation; }
.set-row.done .set-check { background: var(--done); border-color: var(--done); color: var(--accent-ink); }
.stepper { display: grid; grid-template-columns: 56px 1fr 56px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface); }
.stepper button { border: 0; background: var(--surface-2); font: inherit; font-size: 1.6rem; font-weight: 700; color: var(--text); cursor: pointer; touch-action: manipulation; min-height: 76px; }
.stepper button:active { background: var(--border); }
.stepper .val { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; padding: 0 2px; }
.stepper .val b { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.stepper .val small { font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.stepper button.val { background: var(--surface); font-size: 1rem; font-weight: 400; min-width: 0; }
.stepper button.val:active { background: var(--surface-2); }
.ex-edit { cursor: pointer; border-radius: 8px; }
.ex-edit .pen { font-size: .85rem; color: var(--muted); font-weight: 400; }
.ex-edit:active { background: var(--surface-2); }
input.num-entry { font-size: 2rem; text-align: center; font-variant-numeric: tabular-nums; padding: 12px; }
.rpe-btn { min-height: 76px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); font: inherit; color: var(--muted); font-size: .72rem; font-weight: 700; cursor: pointer; line-height: 1.1; }
.rpe-btn b { display: block; font-size: 1.45rem; color: var(--text); }
.ex-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .set-row { grid-template-columns: 64px 1fr 72px; grid-template-areas: "chk load load" "chk reps rpe"; }
  .set-row .set-check { grid-area: chk; }
  .set-row .s-load { grid-area: load; }
  .set-row .s-reps { grid-area: reps; }
  .set-row .rpe-btn { grid-area: rpe; }
  .stepper { grid-template-columns: 60px 1fr 60px; }
  .stepper button, .rpe-btn { min-height: 64px; }
  .set-row + .set-row { border-top: 1px solid var(--border); padding-top: 10px; }
}

.timer-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--text); color: var(--bg); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; box-shadow: 0 -6px 20px rgba(0,0,0,.2); }
.timer-bar[hidden] { display: none; }
.timer-bar .t { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 4ch; }
.timer-bar .lbl { flex: 1; min-width: 0; font-weight: 600; font-size: .9rem; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-bar .btn { background: transparent; color: var(--bg); border-color: rgba(127,127,127,.6); min-height: 60px; min-width: 60px; font-size: 1.05rem; }
.timer-bar.finished { background: var(--orange); color: #1a1a1a; animation: pulse 1s ease-in-out 3; }
.timer-bar.finished .btn { color: #1a1a1a; border-color: rgba(0,0,0,.4); }
@keyframes pulse { 50% { filter: brightness(1.25); } }

/* =====================================================================
   Stile sportivo (v31): profondità, titoli condensati in corsivo, accenti arancio "a taglio"
   ===================================================================== */
body {
  background-color: var(--bg);
  background-image: repeating-linear-gradient(135deg, transparent 0 26px, var(--stripe) 26px 28px);
  background-attachment: fixed;
}
h1, h2, h3, .brand, .stat b, .t-time b, dialog.modal header h2 { font-family: var(--font-display); }
h1 { font-size: 2rem; font-weight: 800; font-style: italic; text-transform: uppercase; letter-spacing: -.01em; }
.page-head h1::after, .day-title h1::after {
  content: ''; display: block; width: 46px; height: 5px; margin-top: 6px; border-radius: 2px;
  background: linear-gradient(90deg, var(--orange) 0 70%, var(--accent) 70%); transform: skewX(-24deg);
}
.day-title h1::after { margin: 6px auto 0; background: linear-gradient(90deg, var(--orange) 0 70%, #fff 70%); }
.card > h2, .card-head h2, .card > h3:first-child {
  font-size: 1.02rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-style: italic;
  display: flex; align-items: center; gap: 10px;
}
.card > h2::before, .card-head h2::before {
  content: ''; flex: none; width: 6px; height: 1.05em; border-radius: 2px; background: var(--orange); transform: skewX(-18deg);
}

/* Navigazione scura con indicatore arancio */
.nav { background: var(--nav-bg); border-top: 0; box-shadow: 0 -6px 20px rgba(0, 0, 0, .18); }
.nav a { color: var(--nav-ink); position: relative; transition: color .15s; }
.nav a.active { color: #fff; }
.nav a.active .ico { color: var(--orange); transform: translateY(-1px) scale(1.12); }
.nav a .ico { transition: transform .15s; }
.nav a.active::before {
  content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 4px; border-radius: 0 0 4px 4px;
  background: var(--orange);
}
.brand-mark { display: inline-block; width: 14px; height: 22px; margin-right: 10px; vertical-align: -3px; transform: skewX(-18deg);
  background: linear-gradient(90deg, var(--orange) 0 55%, transparent 55% 70%, var(--accent) 70%); border-radius: 2px; }
@media (min-width: 960px) {
  .nav { border-right: 0; box-shadow: 6px 0 24px rgba(0, 0, 0, .14); }
  .nav .brand { color: #fff; font-style: italic; text-transform: uppercase; font-size: 1.6rem; letter-spacing: .02em; }
  .nav a.active { background: rgba(255, 255, 255, .08); }
  .nav a.active::before { top: 10px; bottom: 10px; left: 0; right: auto; width: 4px; height: auto; border-radius: 0 4px 4px 0; }
  .nav a:hover { color: #fff; background: rgba(255, 255, 255, .05); }
}

/* Barra in alto */
.appbar { align-items: center; }
.appbar-fill { flex: 1; }
.appbar .sync-btn { margin-left: 0; }
.theme-btn { font-size: 1.15rem; border-radius: 50%; }

/* Card e liste */
.card { border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); box-shadow: var(--shadow); }
.list-row { border-radius: 12px; transition: background .12s; }
a.list-row:hover, button.list-row:hover { background: var(--surface-2); }
a.list-row:active, button.list-row:active { transform: scale(.995); }
.badge { letter-spacing: .02em; }

/* Pulsanti con profondità */
.btn { border-radius: 14px; box-shadow: 0 1px 0 rgba(0, 0, 0, .04); transition: transform .08s, box-shadow .15s, background .15s; }
.btn.sm { border-radius: 11px; }
.btn.primary { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%); border-color: transparent; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big.primary, .btn.go { background: linear-gradient(135deg, var(--orange) 0%, var(--orange-strong) 100%); color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--orange) 40%, transparent);
  font-family: var(--font-display); font-style: italic; text-transform: uppercase; letter-spacing: .04em; }
.btn.ghost { box-shadow: none; }
.chip { transition: background .12s, border-color .12s; }
.chip.active { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); border-color: transparent; box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 30%, transparent); }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], input:not([type]), select, textarea { border-radius: 12px; background: var(--surface-2); border-color: transparent; }
input:focus, select:focus, textarea:focus { background: var(--surface); border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

/* Oggi: intestazione con i giorni */
.day-nav { background: var(--hero); color: #fff; border-radius: 22px; padding: 16px 12px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.day-nav::after { content: ''; position: absolute; right: -40px; top: -30px; width: 160px; height: 160px; background: var(--orange); opacity: .14; transform: skewX(-24deg); pointer-events: none; }
.day-nav .muted { color: rgba(255, 255, 255, .78); font-weight: 600; }
.day-nav .day-title h1 { font-size: 2.2rem; }
.day-arrow { background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid rgba(255, 255, 255, .25); border-radius: 50%; width: 52px; min-width: 52px; padding: 0; z-index: 1; }
.day-arrow:hover { background: rgba(255, 255, 255, .24); border-color: rgba(255, 255, 255, .4); }
.today-row .t-time { background: var(--accent-2); color: var(--accent); border-radius: 12px; padding: 6px 4px; min-width: 60px; }
.today-row .t-time span { color: inherit; opacity: .75; }
.today-row.live .t-time { background: var(--orange); color: #fff; }
.today-row.live { box-shadow: none; background: var(--orange-2); }
.today-row.ok { box-shadow: none; }
.today-row.ok .t-time { background: var(--accent); color: var(--accent-ink); }

/* Numeri */
.stat { background: var(--surface); box-shadow: var(--shadow); border-radius: 16px; padding: 14px 16px; position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; right: -14px; top: 0; bottom: 0; width: 34px; background: var(--accent-2); transform: skewX(-18deg); }
.stat b { font-size: 2rem; font-weight: 800; font-style: italic; color: var(--orange); line-height: 1.1; }
.stat span { text-transform: uppercase; letter-spacing: .06em; font-weight: 700; font-size: .72rem; }

/* Avvisi */
.banner { box-shadow: var(--shadow); border-left: 5px solid currentColor; }

/* Tabellone e sessione */
.board-card { border: 0; box-shadow: var(--shadow); }
.board-card header { background: var(--hero); }
.board-card header h2 { font-family: var(--font-display); font-style: italic; text-transform: uppercase; letter-spacing: .02em; }
.session-card { border-top: 0; box-shadow: inset 0 4px 0 var(--orange), var(--shadow); }
.ex-card { border: 0; box-shadow: inset 5px 0 0 var(--orange), var(--shadow); padding-left: 18px; }
.ex-card.complete { box-shadow: inset 5px 0 0 var(--done), var(--shadow); }
.ex-card h3 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 800; }
.set-row.done .set-check { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); }
.stepper { border: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.att-btn { border-radius: 18px; box-shadow: var(--shadow); border-color: transparent; transition: transform .08s; }
.att-btn:active { transform: scale(.98); }
.att-btn.on { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); }
dialog.modal { border-radius: 22px; }
dialog.modal header h2 { font-style: italic; text-transform: uppercase; letter-spacing: .02em; }
.tbl th { font-family: var(--font-display); }

.board-card .b-kg { display: inline-block; font-size: .72em; font-weight: 800; color: #fff; background: var(--orange); padding: .1em .55em; border-radius: 999px; vertical-align: .15em; margin-left: .2em; white-space: nowrap; }

/* Video degli esercizi */
.vid { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 800; text-decoration: none; color: #fff;
  background: var(--orange); padding: 2px 9px; border-radius: 999px; vertical-align: middle; font-style: normal; }
.vid:hover { filter: brightness(1.08); }
.vid-ico { color: var(--orange); font-size: 1rem; }
.lib-row { display: flex; align-items: center; gap: 8px; }
.lib-main { flex: 1; min-width: 0; width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.list > li.empty { border: 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Grafici ---------- */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 12px; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
svg.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
svg.chart .dot.best { fill: var(--accent); }
svg.spark path { fill: none; stroke: var(--accent); stroke-width: 2; }

/* ---------- Anteprima / stampa PDF ---------- */
#print-root { display: none; }
.print-preview { background: #fff; color: #111; border: 1px solid var(--border); border-radius: 8px; padding: 28px; overflow-x: auto; }
.doc { font: 11pt/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #111; }
.doc .doc-head { display: flex; align-items: center; gap: 16px; border-bottom: 3px solid #ff6600; padding-bottom: 10px; margin-bottom: 14px; }
.doc .doc-head img { max-height: 56px; max-width: 160px; object-fit: contain; }
.doc .doc-head .who { flex: 1; }
.doc .doc-head .who b { font-size: 14pt; display: block; }
.doc .doc-head .what { text-align: right; }
.doc .doc-head .what b { font-size: 13pt; display: block; }
.doc h2 { font-size: 13pt; margin: 16px 0 6px; color: #006666; }
.doc h3 { font-size: 11.5pt; margin: 12px 0 4px; }
.doc table { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: 9.5pt; }
.doc th, .doc td { border: 1px solid #c9ccc6; padding: 4px 6px; text-align: left; vertical-align: top; }
.doc th { background: #333333; color: #fff; font-size: 8.5pt; text-transform: uppercase; letter-spacing: .02em; }
.doc .meta { color: #555; font-size: 9.5pt; }
.doc .foot { margin-top: 18px; border-top: 1px solid #c9ccc6; padding-top: 6px; font-size: 8.5pt; color: #666; }
.doc .avoid { break-inside: avoid; page-break-inside: avoid; }
.doc .page-break { break-before: page; page-break-before: always; }
.doc svg.chart { max-width: 420px; }
.doc svg.chart .grid { stroke: #ddd; } .doc svg.chart .axis { fill: #666; }
.doc svg.chart .line { stroke: #006666; } .doc svg.chart .dot { stroke: #006666; fill: #fff; } .doc svg.chart .dot.best { fill: #006666; }

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; padding: 0 !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
}
