/* ==========================================================================
   BULLDER · cronómetros (prefijo tm-)
   ========================================================================== */

/* ------------------------------------------------------------------ lista /timers */
.tm-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.tm-list > section { margin-bottom: var(--sp-2); }
.tm-activebar { align-items: center; margin-bottom: var(--sp-2); }
.tm-activebar > .ic { color: var(--accent); margin-top: 0; }
.tm-activebar b { display: block; font-weight: 700; }

.tm-pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
@media (min-width: 720px) { .tm-pgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .tm-pgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tm-pcard { position: relative; display: flex; flex-direction: column; padding: 0; overflow: hidden; transition: border-color .15s, transform .12s var(--ease); }
.tm-pcard:hover { border-color: var(--line-strong); }
.tm-pcard-main { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 14px 6px; text-align: left; flex: 1; min-width: 0; }
.tm-pcard-main:active { transform: scale(.985); }
.tm-pic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 6px;
  background: color-mix(in srgb, var(--tm-pc) 16%, transparent); color: var(--tm-pc); }
.tm-pname { font: 700 15.5px/1.2 var(--font-display); color: var(--text); }
.tm-pdesc { font: 650 13px/1.25 var(--font); color: var(--text); font-variant-numeric: tabular-nums; }
.tm-pblurb { font-size: 12.5px; line-height: 1.35; color: var(--text-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tm-pfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 10px 12px 14px; }
.tm-ptotal { display: inline-flex; align-items: center; gap: 5px; font: 650 13px/1 var(--font); color: var(--text-2); }
.tm-play-sm { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent); color: var(--on-accent); transition: transform .12s var(--ease), background .15s; }
.tm-play-sm:hover { background: var(--accent-press); }
.tm-play-sm:active { transform: scale(.9); }
.tm-play-sm .ic { width: 18px; height: 18px; margin-left: 2px; }
.tm-strip { display: flex; gap: 2px; height: 5px; padding: 0 14px 12px; box-sizing: content-box; }
.tm-strip i, .tm-ed-strip i { display: block; min-width: 2px; border-radius: 2px; background: var(--tm-pc, var(--accent)); }
.tm-strip i.is-rest, .tm-ed-strip i.is-rest { background: var(--info); opacity: .55; }
.tm-strip i.is-setrest, .tm-ed-strip i.is-setrest { background: var(--c6); opacity: .6; }
.tm-strip i.is-prep, .tm-ed-strip i.is-prep { background: var(--warn); }

.tm-kgrid { display: grid; grid-template-columns: 1fr; gap: var(--sp-2); }
@media (min-width: 720px) { .tm-kgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tm-kind { display: flex; align-items: center; gap: var(--sp-3); padding: 12px 14px; min-height: 64px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); text-align: left; transition: border-color .15s, transform .12s var(--ease); }
.tm-kind:hover { border-color: var(--line-strong); }
.tm-kind:active { transform: scale(.985); }
.tm-kind b { display: block; font: 700 15px/1.2 var(--font-display); }
.tm-kind .grow > span { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.tm-kic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--tm-pc) 16%, transparent); color: var(--tm-pc); }

.tm-mine .tm-mrow { padding-right: 10px; gap: 10px; }
.tm-mrow-main { text-align: left; padding: 4px 0; }
.tm-mrow-main[disabled] { cursor: default; }
.tm-mic { background: color-mix(in srgb, var(--tm-pc) 16%, transparent); color: var(--tm-pc); }
.tm-grip { width: 38px; height: 44px; display: grid; place-items: center; color: var(--text-3); cursor: grab; touch-action: none; flex: none; }
.tm-mine.is-reorder .tm-mrow { user-select: none; }
.tm-mrow.is-drag { z-index: 2; background: var(--surface-2); box-shadow: var(--shadow); border-radius: var(--r-sm); transition: none; }
.tm-mrow.is-drag::before { display: none; }
.tm-mine .icon-btn[disabled] { opacity: .3; pointer-events: none; }
.tm-empty { padding: 0; }
.tm-empty .empty { padding: 22px 16px 24px; gap: 6px; }
.tm-empty .empty .empty-icon { width: 56px; height: 56px; border-radius: 18px; margin-bottom: 2px; }
.tm-empty .empty .btn { margin-top: 6px; }

/* ------------------------------------------------------------------ editor (hoja) */
.tm-ed { display: flex; flex-direction: column; gap: var(--sp-4); padding-bottom: var(--sp-2); }
.tm-ed-kinds { padding-top: 2px; padding-bottom: 4px; }
.tm-ed-hint { display: flex; align-items: center; gap: 8px; margin-bottom: var(--sp-3); }
.tm-ed-seg { margin-bottom: var(--sp-3); }
.tm-row { gap: var(--sp-3); padding-top: 10px; padding-bottom: 10px; }
.tm-step { display: inline-flex; align-items: center; gap: 2px; flex: none; background: var(--surface-2); border-radius: var(--r-full); padding: 3px; }
.tm-step-b { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--text); transition: background .15s, transform .1s; touch-action: manipulation; user-select: none; }
.tm-step-b:hover { background: var(--surface-3); }
.tm-step-b:active { transform: scale(.88); background: var(--surface-3); }
.tm-step-b .ic { width: 18px; height: 18px; }
.tm-step-v { min-width: 62px; height: 40px; padding: 0 6px; border-radius: 10px; font: 750 16px/1 var(--font); text-align: center; color: var(--text); }
.tm-step-v:hover { background: var(--surface-3); }
.tm-ed-total { display: flex; gap: var(--sp-5); margin-top: var(--sp-4); padding: 14px var(--sp-4); border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.tm-ed-total > div { display: flex; flex-direction: column; gap: 6px; }
.tm-ed-total b { font: 700 22px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.tm-ed-strip { display: flex; gap: 2px; height: 8px; margin-top: var(--sp-3); }

.tm-blocks { margin-bottom: var(--sp-4); }
.tm-blocks .section-head { margin-top: 0; }
.tm-block { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-areas: "dot name menu" ". step step"; align-items: center; column-gap: 6px; row-gap: 2px; padding: 8px 6px 10px 10px; min-height: 60px; }
.tm-block + .tm-block::before { left: 10px; }
.tm-bdot { grid-area: dot; width: 36px; height: 44px; display: grid; place-items: center; border-radius: 10px; }
.tm-bdot i { width: 22px; height: 22px; border-radius: 50%; background: var(--tm-bc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tm-bc) 25%, transparent); }
.tm-bdot:hover { background: var(--surface-2); }
.tm-bname { grid-area: name; min-width: 0; min-height: 42px; padding: 0 10px; font-size: 15.5px; font-weight: 600; background: transparent; border-color: transparent; }
.tm-bname:hover { border-color: var(--line); }
.tm-block .tm-step { grid-area: step; justify-self: start; margin-left: 4px; }
.tm-block .tm-step-b { width: 36px; height: 36px; }
.tm-block .tm-step-v { min-width: 56px; height: 36px; font-size: 14.5px; }
.tm-block .icon-btn { grid-area: menu; width: 40px; height: 44px; border-radius: 10px; }
@media (min-width: 560px) {
  .tm-block { grid-template-columns: 36px minmax(0, 1fr) auto auto; grid-template-areas: "dot name step menu"; }
  .tm-block .tm-step { margin-left: 0; }
}
.tm-block.is-rest .tm-bname { color: var(--text-2); font-style: italic; }

/* ------------------------------------------------------------------ guardar como entrenamiento */
.tm-save-ex { width: 100%; text-align: left; }
.tm-save-ex .list-item:hover { background: var(--surface-2); }
.tm-save-sum { gap: 8px; font-weight: 600; color: var(--text-2); font-size: 14px; }
.tm-save-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tm-save-chips .badge { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ cuenta rápida (hoja) */
.tm-q { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); padding: var(--sp-2) 0 var(--sp-2); }
.tm-q-dial { position: relative; width: min(260px, 70vw); aspect-ratio: 1; }
.tm-q-dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.tm-q-track { fill: none; stroke: var(--surface-2); stroke-width: 14; }
.tm-q-arc { fill: none; stroke: var(--accent); stroke-width: 14; stroke-linecap: round; transition: stroke .2s; }
.tm-q.is-done .tm-q-arc, .is-done .tm-q-arc { stroke: var(--warn); }
.tm-q-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.tm-q-num { font: 800 64px/1 var(--font); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tm-q-sub { font: 600 14px/1 var(--font); color: var(--text-3); }
.is-done .tm-q-sub { color: var(--warn); font-weight: 750; }
.tm-q-adj { display: flex; gap: var(--sp-3); }
.tm-q-adj .btn { min-width: 108px; }
.tm-q-chips { justify-content: center; flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }

/* ------------------------------------------------------------------ /timers/run  (pantalla completa) */
.tm-run {
  --tm-c: var(--bg);
  --tm-ink: #0b0d1c;
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 6px) max(16px, env(safe-area-inset-right, 0px)) calc(var(--safe-b) + 14px) max(16px, env(safe-area-inset-left, 0px));
  background: var(--tm-bg, var(--tm-c)); color: var(--tm-ink);
  transition: background-color .35s var(--ease), color .35s var(--ease);
  overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.tm-run[data-phase="idle"], .tm-run[data-phase="done"] { --tm-c: var(--bg); --tm-ink: var(--text); }
.tm-run[data-phase="prep"] { --tm-c: var(--warn); }
.tm-run[data-phase="work"] { --tm-c: var(--accent); }
.tm-run[data-phase="rest"] { --tm-c: var(--info); }
.tm-run[data-phase="setrest"] { --tm-c: var(--c6); }
.tm-run { --tm-dot-work: var(--accent); --tm-dot-rest: var(--info); --tm-dot-setrest: var(--c6); --tm-dot-prep: var(--warn); }
/* en tema claro los colores de la app son más oscuros: se aclaran para que la tinta oscura tenga buen contraste */
:root[data-theme="light"] .tm-run:not([data-phase="idle"]):not([data-phase="done"]) { --tm-bg: color-mix(in srgb, var(--tm-c) 70%, #fff); }
.tm-run.is-paused:not([data-phase="idle"]):not([data-phase="done"]) { --tm-bg: var(--bg); --tm-ink: var(--text); }
.tm-run.is-paused .tm-digits, .tm-run.is-paused .tm-phase { color: var(--tm-c); }
.tm-run.is-paused .tm-bar i { background: var(--tm-c); }
:root[data-theme="light"] .tm-run.is-paused:not([data-phase="idle"]):not([data-phase="done"]) { --tm-bg: var(--bg); --tm-ink: var(--text); }
:root[data-theme="light"] .tm-run.is-paused .tm-digits, :root[data-theme="light"] .tm-run.is-paused .tm-phase { color: color-mix(in srgb, var(--tm-c) 68%, #000); }

.tm-top { display: flex; align-items: center; gap: 8px; min-height: 52px; flex: none; }
.tm-top-title { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.tm-top-title b { font: 700 16px/1.2 var(--font-display); }
.tm-top-title span { font: 600 12.5px/1.2 var(--font); opacity: .72; font-variant-numeric: tabular-nums; }
.tm-ib { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none; color: inherit;
  background: color-mix(in srgb, var(--tm-ink) 10%, transparent); transition: background .15s, transform .12s; }
.tm-ib:hover { background: color-mix(in srgb, var(--tm-ink) 18%, transparent); }
.tm-ib:active { transform: scale(.9); }
.tm-run :focus-visible { outline-color: currentColor; }
.tm-hint { align-self: center; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-full); font: 650 13px/1 var(--font);
  background: color-mix(in srgb, var(--tm-ink) 12%, transparent); margin-top: 4px; }

.tm-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 10px; padding: 8px 0; }
.tm-phase-row { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.tm-phase { font: 800 clamp(26px, 8vw, 54px)/1.05 var(--font-display); letter-spacing: .02em; text-transform: uppercase; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-round { font: 700 clamp(16px, 4.6vw, 26px)/1.2 var(--font); font-variant-numeric: tabular-nums; opacity: .8; min-height: 1.2em; }
.is-paused .tm-phase { animation: tm-blink 1.4s ease-in-out infinite; }
@keyframes tm-blink { 50% { opacity: .45; } }

/* número gigante: escala al ancho y alto disponibles (container queries) */
.tm-big { flex: 1; min-height: 120px; max-height: 64vh; container-type: size; display: flex; align-items: center; justify-content: center; --tm-w: 2; }
.tm-digits { font: 800 min(calc(94cqw / var(--tm-w)), 92cqh)/.9 var(--font); font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "cv11"; letter-spacing: -.035em; white-space: nowrap; }
.tm-tenths { font: 750 min(calc(94cqw / var(--tm-w) * .32), 28cqh)/1 var(--font); font-variant-numeric: tabular-nums; opacity: .7; align-self: flex-end; margin-bottom: 12cqh; }
.tm-tenths:empty { display: none; }
.tm-bar { height: 12px; border-radius: 6px; background: color-mix(in srgb, var(--tm-ink) 16%, transparent); overflow: hidden; flex: none; }
.tm-bar i { display: block; height: 100%; background: var(--tm-ink); border-radius: 6px; transform-origin: left center; transform: scaleX(0); }
.tm-run[data-phase="idle"] .tm-bar i { background: var(--accent); }
.tm-next { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 28px; font: 650 clamp(14px, 4vw, 19px)/1.25 var(--font); text-align: center; opacity: .88; }
.tm-next b { font-weight: 800; }
.tm-next-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--tm-ink) 45%, transparent); }

.tm-tapbox { display: flex; align-items: stretch; gap: 10px; margin-top: 4px; }
.tm-tap { flex: 1; min-height: 72px; border-radius: 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 22px;
  background: var(--tm-ink); color: var(--tm-c); font: 750 18px/1.1 var(--font); transition: transform .12s var(--ease); }
.tm-run[data-phase="idle"] .tm-tap, .tm-run.is-paused .tm-tap { background: var(--surface-2); color: var(--text); }
.tm-tap b { font: 800 40px/1 var(--font); font-variant-numeric: tabular-nums; }
.tm-tap:active { transform: scale(.97); }
.tm-tap.is-pop b { animation: tm-pop .35s var(--ease); }
@keyframes tm-pop { 40% { transform: scale(1.35); } }
.tm-untap { width: 72px; height: 72px; border-radius: 22px; }
.tm-laps { display: flex; flex-direction: column; gap: 2px; max-height: 30vh; overflow: hidden; }
.tm-lap { display: flex; justify-content: space-between; padding: 7px 4px; font: 650 15px/1.2 var(--font); font-variant-numeric: tabular-nums; border-bottom: 1px solid color-mix(in srgb, var(--tm-ink) 14%, transparent); }
.tm-lap.is-best b { text-decoration: underline; text-underline-offset: 4px; }

.tm-ctrl { flex: none; display: flex; flex-direction: column; gap: 14px; }
.tm-total-bar { height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--tm-ink) 14%, transparent); overflow: hidden; }
.tm-total-bar i { display: block; height: 100%; background: color-mix(in srgb, var(--tm-ink) 70%, transparent); transform-origin: left center; transform: scaleX(0); }
.tm-total-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font: 650 13px/1.2 var(--font); font-variant-numeric: tabular-nums; opacity: .78; }
.tm-btns { display: flex; align-items: center; justify-content: space-between; gap: 6px; max-width: 520px; width: 100%; margin: 0 auto; }
.tm-cb { width: 58px; display: flex; flex-direction: column; align-items: center; gap: 5px; color: inherit; font: 650 11px/1 var(--font); }
.tm-cb > .ic { width: 52px; height: 52px; padding: 14px; border-radius: 50%; background: color-mix(in srgb, var(--tm-ink) 11%, transparent); transition: background .15s, transform .12s; box-sizing: border-box; }
.tm-cb:hover > .ic { background: color-mix(in srgb, var(--tm-ink) 19%, transparent); }
.tm-cb:active > .ic { transform: scale(.9); }
.tm-cb > .ic-fill { padding: 17px; }
.tm-play { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--tm-ink); color: var(--tm-c); box-shadow: 0 8px 26px rgba(0, 0, 0, .22); transition: transform .12s var(--ease); }
.tm-play .ic { width: 34px; height: 34px; }
.tm-play:active { transform: scale(.92); }
.tm-run[data-phase="idle"] .tm-play { background: var(--accent); color: var(--on-accent); }
.tm-run.is-paused .tm-play { background: var(--accent); color: var(--on-accent); }
.tm-run[data-phase="idle"] .tm-cb[data-act="prev"], .tm-run[data-phase="idle"] .tm-cb[data-act="skip"], .tm-run[data-phase="idle"] .tm-cb[data-act="restart"],
.tm-run[data-phase="idle"] .tm-cb[data-act="lap"] { opacity: .35; pointer-events: none; }

/* resumen al terminar */
.tm-done { position: absolute; inset: 0; z-index: 2; overflow-y: auto; background: var(--bg); color: var(--text); padding: calc(var(--safe-t) + 24px) 20px calc(var(--safe-b) + 24px); animation: tm-in .3s var(--ease); }
@keyframes tm-in { from { opacity: 0; transform: translateY(16px); } }
.tm-done-in { max-width: 520px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; }
.tm-done-badge { width: 88px; height: 88px; border-radius: 30px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); margin-bottom: 8px; }
.tm-done-badge.is-ok { background: rgba(255, 207, 64, .16); color: var(--pr); }
.tm-done h1 { font-size: 32px; }
.tm-done-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; margin: 18px 0 6px; text-align: left; }
.tm-done-stats .stat-value { font-size: 26px; }
.tm-done-laps { width: 100%; text-align: left; max-height: 220px; overflow-y: auto; }
.tm-done-actions { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.tm-done-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* horizontal (teléfono acostado): número a la izquierda, controles en columna a la derecha */
@media (orientation: landscape) and (max-height: 600px) {
  .tm-run { display: grid; grid-template-columns: minmax(0, 1fr) 248px; grid-template-rows: auto minmax(0, 1fr); column-gap: 20px; padding-top: calc(var(--safe-t) + 4px); padding-bottom: calc(var(--safe-b) + 8px); }
  .tm-top { grid-column: 1 / -1; min-height: 44px; }
  .tm-ib { width: 42px; height: 42px; }
  .tm-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); margin: 0; }
  .tm-stage { grid-column: 1; grid-row: 2; padding: 0; gap: 6px; }
  .tm-phase-row { flex-direction: row; justify-content: center; gap: 14px; align-items: baseline; }
  .tm-phase { font-size: clamp(22px, 5vh, 34px); }
  .tm-round { font-size: 16px; }
  .tm-big { max-height: none; }
  .tm-bar { height: 9px; }
  .tm-next { font-size: 14px; min-height: 22px; }
  .tm-tap { min-height: 54px; }
  .tm-tap b { font-size: 30px; }
  .tm-untap { width: 54px; height: 54px; }
  .tm-ctrl { grid-column: 2; grid-row: 2; justify-content: center; gap: 16px; }
  .tm-btns { display: grid; grid-template-columns: repeat(2, 1fr); justify-items: center; row-gap: 10px; }
  .tm-play { grid-column: 1 / -1; grid-row: 1; width: 76px; height: 76px; }
  .tm-cb { width: 64px; }
  .tm-cb > .ic { width: 46px; height: 46px; padding: 12px; }
  .tm-done-stats { margin-top: 10px; }
}
/* escritorio: más aire y botones algo mayores */
@media (min-width: 960px) and (min-height: 640px) {
  .tm-run { padding-left: 40px; padding-right: 40px; }
  .tm-stage { max-width: 1100px; width: 100%; margin: 0 auto; }
  .tm-ctrl { max-width: 720px; width: 100%; margin: 0 auto; }
  .tm-cb { width: 72px; font-size: 12px; }
  .tm-cb > .ic { width: 60px; height: 60px; padding: 17px; }
  .tm-play { width: 96px; height: 96px; }
}
@media (prefers-reduced-motion: reduce) { .is-paused .tm-phase { animation: none; } }

/* hoja de sonido */
.tm-range { accent-color: var(--accent); height: 30px; min-width: 0; }
.tm-vol { gap: var(--sp-3); }
