/* Color vive solo en .stage (tomate = enfoque, hoja = descanso, agua = descanso largo); el resto es papel neutro. */
:root {
  --bg: #f4f6f3; --fg: #1b211d; --muted: #5a645e; --card: #fff; --line: #d5dbd6;
  --accent: #c2281d; --inv: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141816; --fg: #eef1ed; --muted: #a3aea7; --card: #1e2421; --line: #343c37; }
}
body.break { --accent: #1f6b45; }
body.long { --accent: #1f4e8c; }

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.4 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap {
  max-width: 480px; margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
h1 { font-size: 1rem; font-weight: 700; margin: 0; padding: 12px 0 0; }
h2 { font-size: 1.15rem; margin: 0; }

button, input { font: inherit; color: inherit; }
button { min-height: 44px; min-width: 44px; cursor: pointer; }
:focus-visible { outline: 3px solid var(--fg); outline-offset: 2px; }

/* Escenario */
.stage {
  --fg: #fff; --muted: #fff; --inv: var(--accent);
  background: var(--accent); color: var(--fg);
  padding: env(safe-area-inset-top) 0 8px;
}
.stage .modes { background: rgba(0, 0, 0, .22); border: 0; margin-bottom: 12px; }
.stage .modes button { padding: 0 4px; } /* tres botones caben en 320px */
.stage input { background: #fff; color: #1b211d; border-color: transparent; }
.stage input::placeholder { color: #5a645e; }

.modes { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin: 12px 0 16px; }
.modes button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 0 16px; }
.modes button[aria-pressed="true"] { background: var(--fg); color: var(--inv); font-weight: 700; }

.field { display: grid; gap: 6px; }
label { color: var(--muted); font-size: .95rem; }
input { width: 100%; min-height: 48px; padding: 8px 12px; font-size: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }

.time {
  font-size: clamp(4rem, 25vw, 8rem); font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin: 24px 0 0;
}
/* Escala de timer de cocina: 60 marcas, las que quedan a la izquierda de --p estan encendidas */
.ruler { position: relative; height: 20px; margin: 10px 0 12px; }
.ruler::before, .ruler::after {
  content: ""; position: absolute; inset: 0;
  background:
    repeating-linear-gradient(90deg, currentColor 0 2px, transparent 2px calc(100% / 12)) 0 0 / 100% 100% no-repeat,
    repeating-linear-gradient(90deg, currentColor 0 2px, transparent 2px calc(100% / 60)) 0 100% / 100% 50% no-repeat;
}
.ruler::before { opacity: .35; }
.ruler::after { clip-path: inset(0 calc(100% - var(--p, 100%)) 0 0); }

.msg { min-height: 1.4em; margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.msg.err { font-weight: 800; }

.settings summary { padding: 12px 0; cursor: pointer; }
.row { display: flex; gap: 8px; padding-bottom: 8px; }
.row label { flex: 1; min-width: 0; display: grid; gap: 6px; }

/* Registro */
.log { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
.head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; min-height: 44px; margin-top: 24px; }
.head .modes { margin: 0; }
.total { margin: 0; color: var(--muted); }
.total strong { color: var(--fg); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 4px 0 12px; padding: 0; }
.list:empty::before { content: attr(data-empty); display: block; padding: 12px 0; color: var(--muted); }
.list li { display: flex; align-items: center; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--line); }
.list .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.list .n { flex: 1; overflow-wrap: anywhere; }
.list .m { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.icon-btn { display: inline-grid; place-items: center; border: 0; background: none; border-radius: 12px; color: var(--muted); }

.secondary { width: 100%; min-height: 48px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }

/* Zona del pulgar */
.dock {
  position: fixed; inset: auto 0 0 0; display: flex; gap: 12px; justify-content: center;
  padding: 28px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(transparent, var(--bg) 28px); pointer-events: none;
}
.dock button { pointer-events: auto; height: 56px; border-radius: 16px; }
.dock .icon-btn { width: 56px; background: var(--card); border: 1px solid var(--line); color: var(--fg); }
.primary { flex: 1; max-width: 380px; border: 0; background: var(--fg); color: var(--bg); font-size: 1.2rem; font-weight: 800; }
.primary:active, .secondary:active, .dock .icon-btn:active { opacity: .8; }

@media (prefers-reduced-motion: no-preference) { .stage { transition: background-color .3s; } }
@media (hover: hover) { .primary:hover, .secondary:hover { filter: brightness(1.12); } }
@media (min-width: 600px) {
  h1 { padding-top: 32px; }
  .stage { padding-bottom: 24px; }
}

/* Secuencia del ciclo: enfoque (ancho), descanso (corto), descanso largo al final */
.cycle { display: flex; align-items: center; gap: 6px; height: 14px; }
.cycle span { flex: 3; height: 6px; border-radius: 3px; background: currentColor; opacity: .32; }
.cycle .b { flex: 1; }
.cycle .l { flex: 2; }
.cycle .on { opacity: 1; }
.cycle .now { opacity: 1; height: 14px; border-radius: 4px; }
.next { margin: 6px 0 14px; font-size: .95rem; }

/* Barra proporcional por etiqueta (--w = minutos / maximo) sobre la linea divisoria */
#totals li {
  border-bottom: 0; padding: 4px 0 10px;
  background:
    linear-gradient(var(--fg), var(--fg)) 0 100% / calc(var(--w, 0) * 100%) 3px no-repeat,
    linear-gradient(var(--line), var(--line)) 0 100% / 100% 1px no-repeat;
}
