/* ==========================================================================
   Gymlog — sistema de diseño
   Mobile-first. Se usa parado en el gimnasio, con una mano: todo lo que se
   toca vive en la mitad inferior de la pantalla y mide >= 44px.
   ========================================================================== */

:root {
  --bg: #0d1117;
  --bg-soft: #111823;
  --surface: #161d29;
  --surface-2: #1d2634;
  --surface-3: #273246;
  --border: #26303f;
  --border-soft: #1e2634;

  --text: #e8edf5;
  --text-dim: #93a1b5;
  --text-faint: #6b7a90;

  --accent: #4ade80;
  --accent-strong: #22c55e;
  --accent-soft: rgba(74, 222, 128, 0.13);
  --accent-line: rgba(74, 222, 128, 0.35);
  --on-accent: #06230f;

  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;

  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);

  --tabbar-h: 4.25rem;
  --safe-b: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(1200px 400px at 50% -160px, rgba(74, 222, 128, 0.07), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3 { line-height: 1.25; }

a { color: var(--accent); }

::selection { background: var(--accent-line); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ layout */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  background: rgba(13, 17, 23, 0.82);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.brand img { width: 28px; height: 28px; display: block; border-radius: 7px; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.4rem 0.3rem 0.75rem;
  max-width: 62vw;
}

.user-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip .icon { flex: none; color: var(--text-faint); }
.user-chip:hover .icon { color: var(--danger); }

main {
  padding: 1rem 1rem calc(var(--tabbar-h) + var(--safe-b) + 2.5rem);
  max-width: 560px;
  margin: 0 auto;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0.25rem 0 1rem;
}

.page-title .muted {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 0.95rem;
  display: block;
  letter-spacing: 0;
}

/* --------------------------------------------------------------- tab bar */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(17, 24, 35, 0.94);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  height: var(--tabbar-h);
  color: var(--text-faint);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.15s var(--ease);
  position: relative;
}

.tab .icon { width: 24px; height: 24px; }

.tab.is-active { color: var(--accent); }

.tab.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 26px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}

@media (min-width: 720px) {
  .tabbar {
    max-width: 460px;
    margin: 0 auto;
    bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  .tab.is-active::before { border-radius: 0 0 3px 3px; }
}

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin: 0 0 0.75rem;
}

.card-title a { font-size: 0.8rem; text-transform: none; letter-spacing: 0; }

.card.accent {
  border-color: var(--accent-line);
  background: linear-gradient(160deg, var(--accent-soft), transparent 65%), var(--surface);
}

/* ------------------------------------------------------------------ forms */

form { margin: 0; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
  letter-spacing: 0.01em;
}

.field { margin-bottom: 0.9rem; }
.field:last-child { margin-bottom: 0; }

input, select, textarea {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-family: inherit;
  width: 100%;
  min-height: 48px;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

textarea { min-height: 140px; resize: vertical; font-size: 0.9rem; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface-2);
  outline: none;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

input[type="file"] {
  padding: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

input[type="file"]::file-selector-button {
  background: var(--surface-3);
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  margin-right: 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: right 1.1rem center, right 0.78rem center;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin: 0.4rem 0 0;
}

/* Stepper: -/valor/+ para cargar peso sin teclado numérico */
.stepper {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  gap: 0.4rem;
  align-items: stretch;
}

.stepper input { text-align: center; font-size: 1.35rem; font-weight: 700; }

.stepper button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1;
  padding: 0;
  min-height: 48px;
  cursor: pointer;
  transition: background 0.12s var(--ease);
}

.stepper button:active { background: var(--surface-3); }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 0;
  width: auto;
  cursor: pointer;
  transition: all 0.12s var(--ease);
}

.chip:hover, .chip:focus-visible { color: var(--text); border-color: var(--accent-line); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- buttons */

button, .btn {
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 650;
  padding: 0.85rem 1rem;
  min-height: 48px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  transition: filter 0.15s var(--ease), background 0.15s var(--ease);
}

button:active, .btn:active { filter: brightness(0.9); }

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: var(--on-accent);
  font-weight: 750;
  width: 100%;
  box-shadow: 0 2px 12px rgba(34, 197, 94, 0.22);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.4);
}

.btn-danger:hover { background: var(--danger-soft); }

.btn-sm {
  min-height: 38px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  width: auto;
}

.btn-block { width: 100%; }

.btn-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn-row > * { flex: 1; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-fill { fill: currentColor; stroke: none; }

/* ---------------------------------------------------------------- flashes */

.flash-list {
  position: fixed;
  top: calc(0.75rem + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: min(520px, calc(100vw - 1.5rem));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.flash {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  margin: 0;
  box-shadow: var(--shadow);
  background: var(--surface-2);
  border: 1px solid var(--border);
  animation: toast-in 0.25s var(--ease);
}

.flash-error { background: #2a1418; border-color: rgba(248, 113, 113, 0.5); color: #ffc7c7; }
.flash-ok { background: #10251a; border-color: var(--accent-line); color: #bdf5d1; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ stats */

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.6rem;
  text-align: center;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  display: block;
}

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  font-weight: 650;
}

/* ------------------------------------------------------------------ lists */

.list { list-style: none; padding: 0; margin: 0; }

.list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.list li:last-child { border-bottom: none; }

.list .grow { flex: 1; min-width: 0; }

.exercise {
  font-weight: 650;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail {
  color: var(--text-dim);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.detail .sep { color: var(--text-faint); margin: 0 0.15rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--surface-3);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.actions { display: flex; gap: 0.4rem; align-items: center; flex: none; }
.actions form { display: inline-flex; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  width: 38px;
  min-height: 38px;
  padding: 0;
}

.icon-btn:hover { color: var(--text); border-color: var(--text-faint); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.day-group { margin-bottom: 1.5rem; }

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.day-head h2 { font-size: 1rem; margin: 0; font-weight: 700; }
.day-head .detail { font-size: 0.8rem; }

/* ------------------------------------------------------------ empty state */

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-dim);
}

.empty-state .icon {
  width: 44px; height: 44px;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
  stroke-width: 1.5;
}

.empty-state p { margin: 0 0 1rem; }

/* -------------------------------------------------------------- calendario */

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.cal-head h2 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
  flex: 1;
}

.cal-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  flex: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.segmented {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 0.9rem;
}

.segmented a {
  flex: 1;
  text-align: center;
  padding: 0.45rem 0.5rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--text-dim);
  text-decoration: none;
}

.segmented a.is-active { background: var(--surface-3); color: var(--text); }

.jump-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.jump-form select { font-size: 0.9rem; min-height: 44px; }
.jump-form .btn { min-height: 44px; padding: 0 0.9rem; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-dow {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 0.3rem;
}

.cal-cell {
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-decoration: none;
  color: var(--text-dim);
  border: 1px solid transparent;
  background: var(--bg-soft);
  font-variant-numeric: tabular-nums;
}

.cal-cell.blank { background: transparent; }

.cal-day { font-size: 0.92rem; font-weight: 600; }
.cal-sets { font-size: 0.6rem; font-weight: 700; opacity: 0.85; }

.cal-cell.lvl-1 { background: rgba(74, 222, 128, 0.16); color: #a9e9c1; }
.cal-cell.lvl-2 { background: rgba(74, 222, 128, 0.3); color: #cdf4dc; }
.cal-cell.lvl-3 { background: rgba(74, 222, 128, 0.48); color: #071d10; }
.cal-cell.lvl-4 { background: var(--accent); color: var(--on-accent); }

.cal-cell.is-today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line);
  color: var(--accent);
}

.cal-cell.lvl-3.is-today, .cal-cell.lvl-4.is-today { color: var(--on-accent); }

.cal-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 0.9rem;
  font-size: 0.7rem;
  color: var(--text-faint);
}

.legend-box {
  width: 13px; height: 13px;
  border-radius: 4px;
  background: var(--bg-soft);
}

/* Vista anual */
.year-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

@media (max-width: 400px) {
  .year-grid { grid-template-columns: repeat(2, 1fr); }
}

.mini-month {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.5rem 0.6rem;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.15s var(--ease);
}

.mini-month:hover { border-color: var(--accent-line); }
.mini-month.is-current { border-color: var(--accent-line); background: var(--surface-2); }

.mini-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.mini-name em {
  font-style: normal;
  font-size: 0.66rem;
  color: var(--text-faint);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mini-month.is-current .mini-name { color: var(--accent); }

.mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mini-cell {
  aspect-ratio: 1 / 1;
  border-radius: 2.5px;
  background: var(--bg-soft);
}

.mini-cell.blank { background: transparent; }
.mini-cell.lvl-1 { background: rgba(74, 222, 128, 0.22); }
.mini-cell.lvl-2 { background: rgba(74, 222, 128, 0.42); }
.mini-cell.lvl-3 { background: rgba(74, 222, 128, 0.66); }
.mini-cell.lvl-4 { background: var(--accent); }
.mini-cell.is-today { box-shadow: 0 0 0 1.5px var(--accent); }

/* --------------------------------------------------------------- progreso */

.chart-card { padding: 0.85rem 0.6rem 0.5rem; }

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .axis-text { fill: var(--text-faint); font-size: 9px; font-family: inherit; }
.chart .area { fill: url(#chart-fade); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

/* --------------------------------------------------------------- rutinas */

.routine-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
  margin-bottom: 0.6rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s var(--ease);
}

.routine-card:hover { border-color: var(--accent-line); }

.routine-card .name { font-weight: 700; font-size: 1.02rem; display: block; }

.routine-card .btn-start {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.exercise-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  margin-bottom: 0.55rem;
}

.exercise-row .row-top { display: flex; gap: 0.45rem; grid-column: 1 / -1; }
.exercise-row .row-top input { flex: 1; }

.exercise-row .row-nums {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  grid-column: 1 / -1;
}

.exercise-row .row-nums input { font-size: 0.95rem; min-height: 44px; text-align: center; }

.drag-handle {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: grab;
  width: 34px;
  min-height: 44px;
  padding: 0;
}

.btn-remove-row {
  background: transparent;
  color: var(--text-faint);
  border: 1px solid var(--border);
  width: 44px;
  min-height: 44px;
  padding: 0;
  flex: none;
}

.btn-remove-row:hover { color: var(--danger); border-color: var(--danger); }

.checklist { list-style: none; padding: 0; margin: 0; }

.checklist li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.6rem;
  transition: opacity 0.2s var(--ease);
}

.checklist li.done { opacity: 0.5; }
.checklist li.done .exercise { text-decoration: line-through; }

.check-line {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
  cursor: pointer;
}

.check-line input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 26px; height: 26px;
  min-height: 26px;
  flex: none;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  position: relative;
  cursor: pointer;
  padding: 0;
}

.check-line input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check-line input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 7px; top: 2px;
  width: 6px; height: 12px;
  border: solid var(--on-accent);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.check-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.55rem 0 0 2.3rem;
}

.check-actions { margin: 0.6rem 0 0 2.3rem; }

/* ------------------------------------------------------- import de rutinas */

.preview-routine {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
  margin-bottom: 0.7rem;
}

.preview-routine h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.preview-list { list-style: none; padding: 0; margin: 0; }

.preview-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 0.9rem;
}

.preview-list li:last-child { border-bottom: none; }

.warn-box {
  background: var(--warn-soft);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #f3d99b;
}

.warn-box ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.warn-box li { margin-bottom: 0.2rem; }

.radio-cards { display: flex; flex-direction: column; gap: 0.5rem; }

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  margin: 0;
  font-weight: 500;
  color: var(--text);
  font-size: 0.95rem;
}

.radio-card input { width: auto; min-height: 0; margin: 0.2rem 0 0; accent-color: var(--accent); }
.radio-card small { display: block; color: var(--text-faint); font-size: 0.8rem; font-weight: 400; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.code-sample {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--text-dim);
  overflow-x: auto;
  white-space: pre;
  margin: 0.5rem 0 0;
}

/* ------------------------------------------------------------------ timer */

.timer-fab {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 1rem);
  z-index: 45;
  width: 60px; height: 60px;
  min-height: 60px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-variant-numeric: tabular-nums;
}

.timer-fab .icon { width: 26px; height: 26px; }
.timer-fab .fab-time { font-size: 0.85rem; font-weight: 750; letter-spacing: -0.02em; }

.timer-fab.is-running {
  border-color: var(--accent);
  color: var(--accent);
  background: linear-gradient(180deg, rgba(74, 222, 128, 0.16), var(--surface-2));
}

.timer-fab.is-ringing { animation: pulse 0.7s infinite; border-color: var(--accent); }

@keyframes pulse {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 0 rgba(74, 222, 128, 0.5); }
  50% { box-shadow: var(--shadow), 0 0 0 12px rgba(74, 222, 128, 0); }
}

@media (min-width: 720px) {
  .timer-fab { bottom: calc(var(--tabbar-h) + 2rem); }
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}

.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 51;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 0.6rem 1rem calc(1.25rem + var(--safe-b));
  max-width: 560px;
  margin: 0 auto;
  transform: translateY(102%);
  transition: transform 0.28s var(--ease);
  max-height: 92vh;
  overflow-y: auto;
}

.sheet.is-open { transform: none; }

.sheet-grip {
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  margin: 0.25rem auto 0.9rem;
}

.timer-ring-wrap {
  position: relative;
  width: 190px;
  margin: 0 auto 1rem;
}

.timer-ring { display: block; width: 100%; height: auto; transform: rotate(-90deg); }
.timer-ring .track { fill: none; stroke: var(--surface-3); stroke-width: 9; }
.timer-ring .bar {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s linear;
}

.timer-ring-wrap.is-ringing .bar { stroke: var(--warn); }

.timer-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
}

.timer-time {
  font-size: 2.55rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}

.timer-state {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 700;
}

.timer-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.timer-presets .chip { padding: 0.45rem 0; text-align: center; justify-content: center; }

.timer-nudge {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.timer-nudge button { flex: 1; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); min-height: 42px; font-size: 0.9rem; }

.timer-controls { display: flex; gap: 0.6rem; }
.timer-controls .btn-primary { flex: 2; }
.timer-controls .btn-ghost { flex: 1; }

.timer-options {
  margin-top: 1rem;
  border-top: 1px solid var(--border-soft);
  padding-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.opt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.opt-row > label { margin: 0; font-size: 0.9rem; font-weight: 500; color: var(--text-dim); flex: 1; }
.opt-row select { width: auto; min-width: 130px; min-height: 40px; font-size: 0.88rem; padding: 0.4rem 2rem 0.4rem 0.6rem; }
.opt-row .btn-sm { flex: none; }

.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; min-height: 0; }
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: 999px;
  transition: background 0.2s var(--ease);
}
.switch .thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}
.switch input:checked ~ .track { background: var(--accent-soft); }
.switch input:checked ~ .thumb { transform: translateX(19px); background: var(--accent); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  min-height: 24px;
  width: 130px;
  padding: 0;
  border: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px; background: var(--surface-3);
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--surface-3); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--accent); margin-top: -7px; border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--accent); border: none;
}

/* Overlay de alarma sonando */
.alarm-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(6, 12, 8, 0.93);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 2rem;
  text-align: center;
}

.alarm-overlay.is-open { display: flex; animation: alarm-flash 1s ease-in-out infinite; }

@keyframes alarm-flash {
  0%, 100% { background: rgba(6, 12, 8, 0.93); }
  50% { background: rgba(16, 58, 32, 0.95); }
}

.alarm-overlay h2 { font-size: 1.9rem; margin: 0; letter-spacing: -0.02em; }
.alarm-overlay p { color: var(--text-dim); margin: 0; }
.alarm-overlay .icon { width: 68px; height: 68px; color: var(--accent); stroke-width: 1.5; }
.alarm-overlay .btn-primary { max-width: 320px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .alarm-overlay.is-open { background: rgba(16, 58, 32, 0.95); }
}

/* ------------------------------------------------------------------- auth */

.auth-wrap { max-width: 380px; margin: 2rem auto 0; }

.auth-logo {
  display: block;
  width: 62px; height: 62px;
  margin: 0 auto 1rem;
  border-radius: 16px;
}

.auth-wrap h1 {
  text-align: center;
  font-size: 1.5rem;
  margin: 0 0 1.5rem;
  letter-spacing: -0.02em;
}

.btn-google {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
  margin-top: 0.7rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-faint);
  font-size: 0.8rem;
  margin: 1.25rem 0 0;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.switch-link {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin-top: 1.5rem;
  text-align: center;
}

/* ------------------------------------------------------------------ misc */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1.25rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover { color: var(--text); }

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 1.25rem;
  font-size: 0.88rem;
}

.link-row a { color: var(--text-dim); text-decoration: none; display: inline-flex; align-items: center; gap: 0.35rem; }
.link-row a:hover { color: var(--accent); }
