/* Climb con Paolino — stile mobile-first (A1) */
:root {
  --bg: #F5EFE6;          /* magnesite su roccia */
  --surface: #FFFCF7;
  --ink: #221A15;
  --muted: #6E625A;
  --line: #E4D9CB;
  --accent: #E8692C;      /* il gilet del coach */
  --accent-ink: #FFFFFF;
  --accent-soft: #FBE3D5;
  --green: #2F6B4F;
  --green-soft: #DDEDE3;
  --warn: #8A4B00;
  --warn-soft: #FFF1D6;
  --danger: #B3261E;
  --vest: #E8692C;
  --vest-dark: #B94E1C;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(34 26 21 / .06), 0 6px 20px rgb(34 26 21 / .06);
  --display: 'Bricolage Grotesque', ui-rounded, system-ui, sans-serif;
  --text: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1B1714; --surface: #26201C; --ink: #F3ECE4; --muted: #B3A79C; --line: #3A322C;
    --accent: #F07A3E; --accent-soft: #4A2A1A; --green: #7FC4A0; --green-soft: #1F3A2D;
    --warn: #FFC56B; --warn-soft: #3D2E12; --danger: #FF8A80;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1B1714; --surface: #26201C; --ink: #F3ECE4; --muted: #B3A79C; --line: #3A322C;
  --accent: #F07A3E; --accent-soft: #4A2A1A; --green: #7FC4A0; --green-soft: #1F3A2D;
  --warn: #FFC56B; --warn-soft: #3D2E12; --danger: #FF8A80;
  --shadow: 0 1px 2px rgb(0 0 0 / .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--text); min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; margin-top: 1em; }
p { margin: 0 0 .8em; }
a { color: inherit; }
button { font: inherit; color: inherit; }

.page { max-width: 560px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom)); }
.page.bare { padding-bottom: 40px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; display: block; }
.lead { font-size: 1.05rem; color: var(--muted); }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; margin-bottom: .3em; }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.top { margin: 8px 0 16px; }
.section { margin-top: 28px; }

/* card e moduli */
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
.field input, .field textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.error { color: var(--danger); font-size: .9rem; margin: 0; }
.warn { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: 12px; font-size: .92rem; }
.warn-card h2 { color: var(--warn); }

/* bottoni */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 48px; padding: 12px 18px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none;
  margin-top: 8px; transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.big { min-height: 56px; font-size: 1.1rem; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.small { min-height: 40px; font-size: .9rem; width: auto; margin: 0 auto; }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1.5px currentColor; }
.btn.sticky { position: sticky; bottom: calc(80px + env(safe-area-inset-bottom)); box-shadow: 0 8px 24px rgb(232 105 44 / .35); }
.link { background: none; border: 0; padding: 6px 0; color: var(--accent); font-weight: 600; text-decoration: none; cursor: pointer; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow); cursor: pointer; font-size: 1.1rem; flex: none; }
.row-btns { display: flex; gap: 10px; width: 100%; }
.row-btns .btn { flex: 1; }
.chip { border: 1.5px solid var(--line); background: var(--surface); border-radius: 99px; padding: 10px 16px; cursor: pointer; font-weight: 600; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* coach */
.coach-row { display: flex; align-items: flex-end; gap: 6px; margin: 4px 0 16px; }
.coach { flex: none; display: block; }
.bubble {
  position: relative; background: var(--surface); border-radius: 18px 18px 18px 4px; padding: 12px 14px;
  box-shadow: var(--shadow); font-weight: 600; margin-bottom: 30px;
}
.brand { text-align: center; margin: 12px 0 20px; }
.brand .coach { margin: 0 auto 4px; }
.loading { text-align: center; padding-top: 30vh; color: var(--muted); }
.loading .coach { margin: 0 auto; }

/* segmented accedi/registrati */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--line); padding: 4px; border-radius: 14px; margin-bottom: 12px; }
.seg a { text-align: center; padding: 10px; border-radius: 10px; text-decoration: none; font-weight: 700; color: var(--muted); }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* onboarding */
.ob-top { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; margin-bottom: 8px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.q { font-size: 1.5rem; }
.options { display: grid; gap: 10px; margin: 16px 0; }
.option {
  text-align: left; padding: 16px 18px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; min-height: 56px;
}
.option.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.summary-list { list-style: none; padding: 0; margin: 0 0 8px; }
.summary-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.summary-list li div { display: grid; }

/* home */
.hero { text-align: left; }
.hero .coach { margin: 0 auto; }
.hero h2 { font-size: 1.6rem; }
.stats { display: flex; gap: 20px; align-items: center; }
.stats dl { margin: 0; display: grid; gap: 8px; flex: 1; }
.stats dl div, .summary div { display: flex; justify-content: space-between; gap: 8px; }
.stats dt, .summary dt { color: var(--muted); font-size: .9rem; }
.stats dd, .summary dd { margin: 0; font-weight: 700; white-space: nowrap; text-align: right; }
.pring {
  --p: 0; width: 96px; height: 96px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--green) calc(var(--p) * 360deg), var(--green-soft) 0);
}
.pring span { width: 74px; height: 74px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 1.3rem; }
.flash { position: sticky; top: 0; z-index: 5; background: var(--green); color: #fff; padding: 12px 16px; text-align: center; font-weight: 600; }

/* piano */
.week { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; overflow: hidden; }
.week summary { display: flex; justify-content: space-between; padding: 16px 18px; cursor: pointer; font-weight: 700; list-style: none; }
.week summary::-webkit-details-marker { display: none; }
.sessions { list-style: none; margin: 0; padding: 0 8px 8px; }
.sessions a { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 12px 10px; border-radius: 12px; text-decoration: none; }
.sessions li.next a { background: var(--accent-soft); }
.sessions .st { font-size: 1.1rem; text-align: center; }
.sessions li.done .st { color: var(--green); }
.sessions li.partial .st { color: var(--accent); }
.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.history li > div:first-child { display: grid; }
.history .right { text-align: right; }
.history .note { flex-basis: 100%; margin: 0; font-style: italic; color: var(--muted); }
.block h2 { font-size: 1.05rem; color: var(--muted); }
.items { list-style: none; padding: 0; margin: 0; }
.item {
  width: 100%; display: grid; grid-template-columns: 1fr 24px; text-align: left; gap: 2px 8px;
  padding: 12px 0; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer;
}
.items li:last-child .item { border-bottom: 0; }
.item .i { grid-row: 1 / 3; grid-column: 2; align-self: center; color: var(--accent); }

/* barra in basso */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { display: grid; justify-items: center; padding: 8px 0 10px; text-decoration: none; font-size: .75rem; font-weight: 600; color: var(--muted); }
.tabbar a span { font-size: 1.3rem; line-height: 1.2; }
.tabbar a.on { color: var(--accent); }

/* pannello informazioni */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 10; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-height: 85dvh; overflow: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; animation: up .2s ease-out;
}
.sheet h2 { padding-right: 48px; }
.sheet ol, .sheet ul { padding-left: 1.2em; }
.sheet li { margin-bottom: .4em; }
.sheet .btn { margin-top: 10px; }
.sheet-close { position: absolute; top: 16px; right: 16px; }
.ex-img { width: 100%; border-radius: 12px; }
@keyframes up { from { transform: translateY(40px); } }

/* sessione live */
.run { min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
.run-head { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; }
.run-meta { display: grid; line-height: 1.25; }
.run-meta span { color: var(--muted); font-size: .85rem; }
.run-elapsed { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
.run-progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 12px 0 0; }
.run-progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.run-body { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 24px; gap: 6px; }
.set-label { color: var(--muted); font-weight: 600; margin: 0; }
.ex-title { font-size: 2rem; margin: 4px 0 0; }
.ring {
  --p: 0; width: min(64vw, 240px); aspect-ratio: 1; border-radius: 50%; margin: 18px 0 8px;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 360deg), var(--line) 0);
}
.ring span {
  width: 84%; aspect-ratio: 1; border-radius: 50%; background: var(--bg); display: grid; place-items: center;
  font-family: var(--display); font-size: clamp(2.6rem, 14vw, 3.6rem); font-weight: 800; font-variant-numeric: tabular-nums;
}
.rest-ring { background: conic-gradient(var(--green) calc(var(--p) * 360deg), var(--line) 0); }
.reps { margin: 26px 0 10px; display: grid; }
.reps b { font-family: var(--display); font-size: 5rem; line-height: 1; }
.run-coach { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 16px; color: var(--muted); font-weight: 600; text-align: left; }
.run-coach p { margin: 0; }
.run-foot { padding-top: 8px; }
.next-up { width: 100%; background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-top: 16px; text-align: left; }
.next-up h2 { margin-bottom: .2em; }
.next-up p { margin: 0; color: var(--muted); }
.end h1 { margin-top: 8px; }
.end .coach { margin: 0 auto; }
.summary { width: 100%; display: grid; gap: 8px; background: var(--surface); padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); margin: 8px 0 16px; }
.effort { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.effort legend { width: 100%; font-weight: 700; margin-bottom: 8px; }
.end .field { width: 100%; text-align: left; }

.prose { background: var(--surface); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 12px; }
.prose h1 { font-size: 1.4rem; margin-top: .6em; }

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

/* v0.2: durata, Google, Garmin */
.estimate { margin: 4px 0 8px; }
.estimate .link { margin-left: 6px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 10px; }
.chips .chip { display: grid; justify-items: center; line-height: 1.2; min-width: 76px; padding: 8px 12px; }
.chips .chip small { font-weight: 500; font-size: .75rem; opacity: .8; }
.duration h2 { font-size: 1.05rem; margin-bottom: 0; }
.google { gap: 10px; margin-top: 0; background: var(--surface); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* v0.3: uso senza account */
.guest { display: grid; gap: 4px; }
.guest .btn { margin-top: 0; }
.guest p { margin: 6px 0 0; }
.section-label { margin: 18px 0 8px; }
.upgrade { background: var(--accent-soft); }
.upgrade p { margin-bottom: 4px; }
.guest-note { border: 1.5px solid var(--accent); }
.guest-note .btn + .btn { margin-top: 8px; }

/* Paolino (illustrazione) */
img.coach { display: block; object-fit: cover; border-radius: 24px; background: #84A580; box-shadow: var(--shadow); }
img.coach.coach-face { border-radius: 50%; }
.brand img.coach { border-radius: 28px; }
.coach-celebrate, .coach-cheer { animation: hop 1.2s ease-in-out infinite; }
.coach-wave { animation: tilt 2.4s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes tilt { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-3deg); } }

/* v0.4: Paolino spiega, allunga il piano */
.explain-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-right: 44px; }
.explain-head h2 { margin: 0; }
.explain-head .eyebrow { margin: 0; }
.bubble-block { margin: 0 0 10px; font-weight: 400; border-radius: 4px 18px 18px 18px; }
.bubble-block strong { display: block; margin-bottom: 4px; }
.bubble-block ol, .bubble-block ul { margin: 0; padding-left: 1.2em; }
.bubble-block p { margin: 0; }
.sheet .bubble-block { background: var(--bg); box-shadow: none; }
.extend .coach-row { margin-bottom: 8px; }
.run-coach p { font-weight: 500; }

/* Presentazione di Paolino nell'onboarding */
.intro { text-align: center; padding-top: 12px; }
.intro img.coach { margin: 0 auto 16px; border-radius: 32px; }
.intro h1 { font-size: 1.9rem; }
.intro-list { list-style: none; padding: 0; margin: 16px 0 20px; text-align: left; display: grid; gap: 10px; }
.intro-list li { background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); font-weight: 600; }
