:root {
  --bg: #0c0c0e; --card: #18181c; --card-2: #222228; --line: #2e2e36; --text: #f4f4f5; --muted: #9a9aa3;
  --accent: #ff7a00; --accent-ink: #1a0c00; --rest: #3aa0ff; --prep: #f4f4f5;
  font-family: 'Montserrat', system-ui, sans-serif; color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; font-weight: 700; background: var(--bg); color: var(--text); overflow-x: hidden; }
body { min-height: 100dvh; user-select: none; -webkit-user-select: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
h1 { font-weight: 900; text-transform: uppercase; margin: 0; letter-spacing: .5px; }
.muted { color: var(--muted); font-weight: 700; } .small { font-size: 14px; }

.page { max-width: 560px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 40px; }
.brand { font-weight: 900; font-size: 28px; letter-spacing: 1px; margin: 8px 0 18px; }
.brand b { color: var(--accent); }
.brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 2px; }


.promo { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 16px; border-radius: 18px;
  background: linear-gradient(135deg, #2a1400, #18181c 70%); border: 1px solid #5a2c00; }
.promo small { display: block; color: var(--accent); font-weight: 800; font-size: 11px; letter-spacing: 1px; }
.promo b { display: block; font-weight: 900; font-size: 17px; margin: 4px 0; }
.promo span { font-size: 13px; color: #d4d4d8; }
.promo i { font-style: normal; font-size: 34px; color: var(--accent); font-weight: 900; }


.top { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; }
.top h1 { font-size: 30px; }
.back { font-size: 34px; font-weight: 700; padding: 0 8px 4px 0; line-height: 1; }
.field { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; margin: 12px 0; }
.field > label { font-weight: 900; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stepper { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.stepper button { width: 64px; height: 64px; border-radius: 50%; background: var(--card-2); font-size: 32px; font-weight: 700; }
.stepper button:active { background: var(--accent); color: var(--accent-ink); }
.stepper output { font-size: 38px; font-weight: 900; font-variant-numeric: tabular-nums; }
.sum { text-align: center; color: var(--muted); font-weight: 800; font-size: 15px; }
.go, .btn { display: block; width: 100%; text-align: center; background: var(--accent); color: var(--accent-ink); font-weight: 900;
  font-size: 22px; letter-spacing: 1px; padding: 18px; border-radius: 18px; margin-top: 8px; }
.btn { background: var(--card-2); color: var(--text); }

.sw { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 16px; margin: 12px 0; font-weight: 700; }
.sw input { width: 24px; height: 24px; accent-color: var(--accent); }
.seg { display: flex; gap: 8px; margin-top: 10px; }
.seg button { flex: 1; padding: 12px 0; border-radius: 12px; background: var(--card-2); font-weight: 800; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* ----- timer in corso ----- */
.run { min-height: 100dvh; display: flex; flex-direction: column; padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.rtop { display: flex; align-items: center; justify-content: space-between; font-weight: 900; font-size: 18px; letter-spacing: 1px; }
.rtop .x { width: 44px; height: 44px; border-radius: 50%; background: var(--card); font-size: 18px; }
.rtop span { min-width: 44px; text-align: right; font-size: 22px; }
.clock { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.clock small { font-weight: 900; font-size: 22px; letter-spacing: 3px; color: var(--accent); }
#t { font-weight: 900; font-size: min(29vw, 40vh); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -3px; margin: 4px 0 18px; }
.bar { width: 100%; height: 10px; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }
#info { color: var(--muted); font-weight: 700; margin: 14px 0 0; min-height: 1.3em; }
.ctrl { display: flex; flex-direction: column; gap: 10px; }
.ctrl .row, .end .row { display: flex; gap: 10px; }
.ctrl .row button { flex: 1; padding: 18px 0; border-radius: 18px; background: var(--card-2); font-weight: 900; font-size: 18px; letter-spacing: 1px; }
.ctrl .fin { background: var(--text) !important; color: var(--bg); }
.round { background: var(--accent); color: var(--accent-ink); border-radius: 22px; padding: 22px 0; font-weight: 900; font-size: 28px; letter-spacing: 1px; }
.round small { display: block; font-size: 14px; font-weight: 800; opacity: .8; }
.round:active { transform: scale(.98); }
body[data-kind^='rest'] .clock small, body[data-kind^='rest'] #t { color: var(--rest); }
body[data-kind^='rest'] .bar i { background: var(--rest); }
body[data-kind^='prep'] .clock small, body[data-kind^='prep'] #t { color: var(--prep); }
body[data-kind^='prep'] .bar i { background: var(--prep); }
body[data-kind$='last'] #t { animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }
body.paused #t { opacity: .35; }
body.paused .clock::after { content: 'IN PAUSA'; font-weight: 900; letter-spacing: 3px; color: var(--muted); margin-top: 8px; }

/* ----- fine ----- */
.end { text-align: center; padding-top: 48px; }
.end h1 { font-size: 44px; color: var(--accent); }
.res { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin: 18px 0; }
.res small { color: var(--muted); font-weight: 700; font-size: 13px; }
.res b { display: block; font-size: 48px; font-weight: 900; margin: 6px 0; font-variant-numeric: tabular-nums; }
.res span { font-weight: 800; }
.end .row > * { flex: 1; margin: 0; }
.end .promo { text-align: left; }

/* ----- workout (UN-MEMBER, link esterno) ----- */
.wk h1 { font-size: 26px; margin: 8px 0; }
.wk p { line-height: 1.5; }
.wk ul { list-style: none; padding: 0; margin: 14px 0 18px; display: grid; gap: 8px; }
.wk li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font-weight: 600; font-size: 14px; }

/* ----- timer salvati ----- */
h2 { font-weight: 900; font-size: 15px; letter-spacing: 1px; color: var(--muted); margin: 26px 0 10px; }
.saved { display: grid; gap: 10px; }
.sv { display: flex; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.sv a { flex: 1; padding: 12px 14px; min-width: 0; }
.sv small { color: var(--accent); font-weight: 800; font-size: 11px; letter-spacing: 1px; }
.sv b { display: block; font-weight: 800; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv span { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }
.sv button { background: none; color: var(--muted); padding: 16px; font-size: 16px; }

/* ----- impostazioni del timer ----- */
.chips { display: flex; gap: 8px; margin-top: 10px; }
.chips button { flex: 1; padding: 12px 0; border-radius: 12px; background: var(--card-2); font-weight: 800; }
.chips button.on { background: var(--accent); color: var(--accent-ink); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair .field { padding: 12px; margin: 6px 0; }
.pair .stepper button { width: 46px; height: 46px; font-size: 26px; }
.pair .stepper output { font-size: 22px; white-space: nowrap; }
.pair .stepper { gap: 4px; }
.page, .field { min-width: 0; } .field { overflow: hidden; }
.list { display: grid; gap: 8px; margin-top: 10px; }
.li { display: flex; align-items: center; gap: 8px; }
.li em { font-style: normal; font-weight: 900; color: var(--accent); width: 18px; text-align: center; }
.li input { flex: 1 1 0; width: 0; min-width: 0; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  font: 800 17px 'Montserrat', sans-serif; padding: 12px; }
.li input.reps { flex: 0 0 64px; width: 64px; text-align: center; font-weight: 800; }
.li .restlab { flex: 1; padding: 12px; border-radius: 12px; background: #0f2236; color: var(--rest); font-weight: 900; letter-spacing: 1px; font-size: 14px; }
.li .tg, .li .rm { width: 44px; height: 44px; border-radius: 12px; background: var(--card-2); flex: none; }
.li .tg.on { background: var(--rest); }
.li .rm { color: var(--muted); }
.row2 { display: flex; gap: 8px; margin-top: 10px; }
.add { flex: 1; padding: 12px; border-radius: 12px; background: none; border: 1px dashed var(--line) !important; font-weight: 800; color: var(--muted); }
.ghost { display: block; width: 100%; background: none; color: var(--muted); font-weight: 800; padding: 16px; }
.center { text-align: center; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg); font-weight: 800;
  padding: 12px 18px; border-radius: 30px; z-index: 9; white-space: nowrap; }

/* ----- in corso: testo dell'intervallo e lista AFAP ----- */
#txt { font-weight: 900; font-size: 26px; text-transform: uppercase; margin: -8px 0 16px; min-height: 0; }
#txt:empty { display: none; }
.withlist .clock { flex: none; padding: 18px 0 8px; }
.withlist #t { font-size: min(20vw, 22vh); margin-bottom: 10px; }
.checklist { flex: 1; overflow-y: auto; display: grid; gap: 8px; align-content: start; padding: 8px 0 12px; }
.ck { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px; }
.ck .box { width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--muted) !important; background: none; flex: none; }
.ck .nm { flex: 1; min-width: 0; }
.ck .nm b { display: block; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck .nm span { color: var(--muted); font-weight: 700; font-size: 14px; }
.ck .nm i { font-style: normal; color: var(--accent); font-size: 18px; font-weight: 900; }
.ck .pl { width: 46px; height: 46px; border-radius: 12px; background: var(--card-2); font-weight: 900; flex: none; }
.ck .pl:active { background: var(--accent); color: var(--accent-ink); }
.ck.ok { opacity: .5; }
.ck.ok .box { background: var(--ok, #3ccf7a); border-color: #3ccf7a !important; }
.ck.ok .box::after { content: '✓'; color: #08130c; font-weight: 900; font-size: 20px; }
.ck.ok .nm b { text-decoration: line-through; }
.laps { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.laps span { background: var(--card-2); border-radius: 10px; padding: 6px 10px; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.laps em { font-style: normal; color: var(--accent); margin-right: 6px; }
.laps.items { flex-direction: column; align-items: stretch; text-align: left; }
.laps.items .ok { color: #3ccf7a; }

/* schermi larghi (PC, iPad, tablet, telefono girato): timer gigante a sinistra, lista e comandi a destra */
@media (min-width: 760px) and (orientation: landscape) {
  .run { display: grid; grid-template-columns: 1fr minmax(320px, 34vw); grid-template-rows: auto 1fr auto;
    grid-template-areas: "top top" "clock side" "clock ctrl"; gap: 0 32px; height: 100dvh; }
  .rtop { grid-area: top; }
  .clock, .withlist .clock { grid-area: clock; padding: 0; }
  .wod, .checklist { grid-area: side; align-self: center; max-height: 100%; }
  .ctrl { grid-area: ctrl; padding-bottom: 8px; }
  .run:not(.withlist) .ctrl { grid-row: 2 / 4; justify-content: flex-end; }
  #t, .withlist #t { font-size: min(21vw, 52vh); }
  .clock small { font-size: 28px; } #txt { font-size: 34px; } #info { font-size: 18px; }
}
/* schermi grandi: home e pagine più grandi */
@media (min-width: 760px) {
  .home { max-width: 640px; }
  .logo.big svg { width: 220px; } .logo.big b { font-size: 38px; }
  .pills { gap: 16px; } .pill { min-height: 76px; } .pill b { font-size: 36px; } .pill span { font-size: 15px; }
  .hfoot a { font-size: 19px; }
  .page { max-width: 680px; padding-top: 32px; }
  .modes, .saved { gap: 14px; }
}


/* finestra di conferma */
.ask { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.askbox { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px; width: 100%; max-width: 380px; }
.askbox p { font-weight: 800; font-size: 18px; margin: 0 0 14px; }
.askbox input { width: 100%; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font: 800 17px 'Montserrat', sans-serif; padding: 12px; margin-bottom: 14px; }
.askbox .row { display: flex; gap: 10px; } .askbox .row > * { flex: 1; margin: 0; font-size: 17px; padding: 14px; }

/* ----- home: logo al centro e un pulsante colorato per timer ----- */
.home { min-height: 100dvh; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.hbar { display: flex; height: 52px; align-items: center; }
.burger { background: none; width: 48px; height: 48px; display: grid; align-content: center; gap: 6px; padding: 0 10px 0 2px; }
.burger i { display: block; height: 3px; border-radius: 2px; background: var(--text); }
.logo { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text); }
.logo svg { width: 90px; height: auto; }
.logo b { font-weight: 900; letter-spacing: .32em; margin-right: -.32em; font-size: 18px; }
.logo.big { margin: 6vh 0 7vh; gap: 16px; }
.logo.big svg { width: 190px; }
.logo.big b { font-size: 32px; }
.pills { display: grid; gap: 12px; }
.pill { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60px; border-radius: 34px;
  background: var(--c); color: #120a00; padding: 6px 24px; }
.pill b { font-weight: 900; font-size: 30px; letter-spacing: 1px; line-height: 1.1; }
.pill span { font-size: 13px; font-weight: 800; opacity: .8; }
.pill:active { transform: scale(.98); filter: brightness(1.1); }
.hfoot { margin-top: auto; padding-top: 28px; display: grid; gap: 14px; text-align: center; }
.hfoot a { font-weight: 900; letter-spacing: 1px; font-size: 17px; }
.hlinks { display: flex; justify-content: center; gap: 28px; }
.hfoot em { font-style: normal; background: var(--card-2); border-radius: 10px; padding: 1px 8px; margin-left: 4px; }
.hfoot .hpromo { font-weight: 700; letter-spacing: 0; font-size: 14px; color: var(--muted); }
.hfoot .hpromo b { color: var(--accent); font-weight: 900; }

/* menu laterale */
.drawer { position: fixed; inset: 0; background: #000b; z-index: 15; }
.drawer aside { position: absolute; inset: 0 auto 0 0; width: min(82vw, 320px); background: var(--card); border-right: 1px solid var(--line);
  padding: max(24px, env(safe-area-inset-top)) 20px 24px; display: flex; flex-direction: column; gap: 4px; animation: slide .18s ease-out; }
.dlogo { padding: 8px 0 24px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.drawer a { display: flex; align-items: center; gap: 14px; padding: 14px 4px; font-size: 20px; }
.drawer a span { font-size: 18px; font-weight: 900; }
@keyframes slide { from { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .drawer aside { animation: none; } }

/* timer salvati: striscia del colore del timer */
.sv { border-left: 6px solid var(--c, var(--accent)); }
.sv small { color: var(--c, var(--accent)); }

/* AMRAP: il workout sotto il timer */
.wod { flex: 1; overflow-y: auto; display: grid; gap: 8px; align-content: start; padding: 8px 0 12px; }
.wod div { display: flex; gap: 12px; align-items: baseline; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; font-weight: 900; font-size: 20px; text-transform: uppercase; }
.wod b { color: var(--accent); min-width: 32px; }
/* fine AMRAP: giri e giro non finito */
.end .am { text-align: left; }
.li.part { gap: 6px; }
.li.part .pn { flex: 1; min-width: 0; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li.part .pn small { color: var(--muted); }
.li.part button { width: 42px; height: 42px; border-radius: 12px; background: var(--card-2); font-weight: 900; font-size: 20px; flex: none; }
.li.part output { min-width: 34px; text-align: center; font-weight: 900; font-size: 20px; color: var(--accent); }
.li.part .all { width: auto; padding: 0 10px; font-size: 12px; letter-spacing: .5px; }
.res .when { display: block; color: var(--muted); font-size: 12px; font-weight: 700; margin-top: 10px; }
.res b { font-size: clamp(28px, 9vw, 44px) !important; line-height: 1.15; }
/* diario */
.lg { align-items: stretch; }
.lgx { flex: 1; min-width: 0; padding: 12px 14px; }
.lg b { white-space: normal !important; }
.lg button { padding: 0 12px; }
.lg button[data-redo] { font-size: 22px; color: var(--c); }
h2 { text-transform: uppercase; }

.chips.lang button { font-size: 15px; }
.field .chips + .muted { margin: 10px 0 0; }

/* Death EMOM: STOP rosso */
.ctrl .fin.stopd { background: #ff3b3b !important; color: #fff; }

/* promemoria tastiera: solo dove c'è un mouse (PC) */
.keys { display: none; margin: 0; text-align: center; color: var(--muted); font-size: 13px; }
@media (hover: hover) and (pointer: fine) { .keys { display: block; } }
