:root {
  --bg: #fafafb;
  --surface: #f1f1f3;
  --line: #e3e3e7;
  --text: #18191b;
  --muted: #66676d;
  --faint: #a3a4aa;
  --ink: #18191b;
  --on-ink: #fafafb;
  --danger: #c9353d;
  --scrim: rgba(10, 10, 12, 0.32);

  --accent: var(--profile-color, var(--text));

  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.1875rem;
  --fs-xl: 1.4375rem;
  --fs-display: clamp(4rem, 19vw, 5.5rem);

  --s1: 4px;
  --s2: 8px;
  --s3: 16px;
  --s4: 24px;
  --s5: 32px;
  --s6: 48px;
  --s7: 64px;

  --radius: 12px;
  --radius-sm: 8px;
  --tap: 44px;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  color-scheme: light;
}

@supports (color: oklch(0 0 0)) {
  :root {
    --bg: oklch(0.985 0.002 260);
    --surface: oklch(0.962 0.003 260);
    --line: oklch(0.915 0.004 260);
    --text: oklch(0.205 0.005 260);
    --muted: oklch(0.52 0.006 260);
    --faint: oklch(0.74 0.005 260);
    --ink: oklch(0.205 0.005 260);
    --on-ink: oklch(0.985 0.002 260);
    --danger: oklch(0.56 0.19 25);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1012;
    --surface: #18191c;
    --line: #2a2b2f;
    --text: #f2f2f4;
    --muted: #9d9ea4;
    --faint: #5c5d63;
    --ink: #f2f2f4;
    --on-ink: #0f1012;
    --danger: #f2555a;
    --scrim: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
  @supports (color: oklch(0 0 0)) {
    :root {
      --bg: oklch(0.165 0.004 260);
      --surface: oklch(0.205 0.004 260);
      --line: oklch(0.285 0.005 260);
      --text: oklch(0.965 0.002 260);
      --muted: oklch(0.71 0.006 260);
      --faint: oklch(0.47 0.005 260);
      --ink: oklch(0.965 0.002 260);
      --on-ink: oklch(0.165 0.004 260);
      --danger: oklch(0.68 0.19 25);
    }
  }
}

@media (prefers-color-scheme: light) {
  :root[data-accent-light] { --accent: var(--ink); }
  .profile[data-light] { --pc: var(--ink); }
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto;
  max-width: 480px;
  min-height: 100vh;
  padding: env(safe-area-inset-top, 0px) var(--s4) calc(env(safe-area-inset-bottom, 0px) + var(--s5));
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-md)/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
b { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }

.label, .eyebrow, .stats dt {
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 4px; }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding-block: var(--s2);
  background: var(--bg);
}
.brand { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.logo { font-size: var(--fs-sm); font-weight: 650; letter-spacing: 0.02em; }
.dev-name { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: flex; align-items: center; gap: var(--s3); }

.battery { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.bat-icon {
  position: relative;
  width: 25px;
  height: 12px;
  padding: 1.5px;
  border: 1px solid var(--faint);
  border-radius: 3.5px;
}
.bat-icon::after {
  content: "";
  position: absolute;
  top: 3px;
  right: -3px;
  width: 1.5px;
  height: 3px;
  border-radius: 0 1px 1px 0;
  background: var(--faint);
}
.bat-icon i { display: block; height: 100%; width: 50%; border-radius: 1px; background: var(--text); }
.battery.charging .bat-icon i { background: var(--accent); }

.bolt {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 11px;
  transform: translate(-50%, -50%);
  fill: var(--text);
  stroke: var(--bg);
  stroke-width: 1.4px;
  paint-order: stroke;
  display: none;
}
.battery.charging .bolt { display: block; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s var(--ease), transform 0.1s var(--ease), background 0.2s var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.35; cursor: default; transform: none; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.quiet { border-color: transparent; color: var(--muted); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 var(--s3); font-size: var(--fs-sm); }

.text-btn {
  appearance: none;
  min-height: var(--tap);
  padding: 0 var(--s1);
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
}
.text-btn.center { display: block; margin: var(--s5) auto 0; }

.connect { padding-top: var(--s7); }
.connect h1 { font-size: var(--fs-xl); margin-bottom: var(--s2); }
.connect > .muted { margin-bottom: var(--s5); }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: var(--s3);
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface);
}
.segmented button {
  appearance: none;
  min-height: 40px;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.segmented button.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.hint { min-height: 1.45em; margin-top: var(--s2); font-size: var(--fs-sm); color: var(--muted); text-align: center; }
.notice {
  margin-bottom: var(--s4);
  padding: var(--s3);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.notice-error { color: var(--danger); }
.notice-link { display: block; color: var(--text); text-decoration: none; -webkit-tap-highlight-color: transparent; }
.notice-link b { display: block; font-weight: 600; }
.notice-link span { display: block; margin-top: var(--s1); color: var(--muted); }
.notice-link[href] span::after { content: " ›"; }
.notice-link[href]:active { transform: scale(0.98); }

.disclosure { border-top: 1px solid var(--line); }
.connect .disclosure:first-of-type { margin-top: var(--s5); }
.disclosure summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  list-style: none;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--muted);
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::after { content: "+"; font-size: var(--fs-lg); font-weight: 300; }
.disclosure[open] summary::after { content: "−"; }
.disclosure > *:not(summary) { margin-bottom: var(--s3); }
.stack { display: flex; flex-direction: column; gap: var(--s2); }
.steps { padding-left: 1.2em; font-size: var(--fs-sm); color: var(--muted); }
.steps li { margin-bottom: var(--s2); }
.steps b { color: var(--text); }

.hero { padding-top: var(--s4); }
.ring-wrap { position: relative; width: min(76vw, 300px); max-width: 100%; aspect-ratio: 1; margin: 0 auto var(--s5); }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 2.5; }
.ring-bg { stroke: var(--line); }
.ring-fg {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 552.92;
  stroke-dashoffset: 552.92;
  transition: stroke-dashoffset 0.8s var(--ease), stroke 0.4s var(--ease);
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
  text-align: center;
}
.temp {
  display: flex;
  align-items: flex-start;
  font-size: var(--fs-display);
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.04em;
}
.temp-unit { margin-top: 0.35em; margin-left: 0.06em; font-size: var(--fs-lg); font-weight: 400; letter-spacing: 0; color: var(--muted); }
.sub { font-size: var(--fs-sm); color: var(--muted); }
.timer { font-size: var(--fs-lg); font-weight: 500; color: var(--text); }

.actions { display: flex; gap: var(--s2); }
.actions .btn { flex: 1; }

.block { margin-top: var(--s6); }
.block > .label { margin-bottom: var(--s2); }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}
.block > .label + .row { border-top: 1px solid var(--line); }
.row.col { flex-direction: column; align-items: stretch; justify-content: center; gap: var(--s1); padding-block: var(--s3); }
.row-head { display: flex; justify-content: space-between; align-items: baseline; width: 100%; }
.value { color: var(--muted); font-size: var(--fs-sm); }
.inline { display: flex; align-items: center; gap: var(--s2); }

.row-text { display: flex; flex-direction: column; gap: 2px; padding-block: var(--s2); }
.row-text small { font-size: var(--fs-xs); color: var(--muted); }

.row.link {
  width: 100%;
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.block > .label + .row.link { border-top: 1px solid var(--line); }

.actions.adjust { margin-bottom: var(--s2); }
.actions.adjust .btn { min-height: 40px; font-size: var(--fs-sm); color: var(--muted); }
.hero > .text-btn.center { margin-top: var(--s3); }

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2) var(--s3);
  margin-top: var(--s3);
  padding: var(--s3);
  border-radius: var(--radius);
  background: var(--surface);
}
.banner > div:first-child { display: flex; flex-direction: column; }

.hist-summary { display: grid; grid-template-columns: repeat(3, 1fr); padding-block: var(--s2) var(--s3); border-top: 1px solid var(--line); }
.hist-summary > div { display: flex; flex-direction: column; }
.hist-num { font-size: var(--fs-xl); font-weight: 300; letter-spacing: -0.01em; }
.hist-chart { display: block; width: 100%; height: auto; margin-bottom: var(--s2); }
.hist-chart .bar { fill: var(--line); }
.hist-chart .bar.today { fill: var(--accent); }
.hist-chart text { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.hist-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.hist-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s2);
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.hist-list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.hist-list .when { color: var(--muted); }
#histEmpty { padding-block: var(--s2); }

.sheet-note { margin: calc(-1 * var(--s2)) 0 var(--s4); }

.profiles { border-top: 1px solid var(--line); }
.profile {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name edit" "info edit";
  align-items: center;
  min-height: 64px;
  padding: var(--s2) 0 var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;

  --pc: var(--pc-raw, var(--text));
}

.profile::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 2px;
  border-radius: 2px;
  background: var(--pc);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.profile.active::before { opacity: 1; }
.profile .pname {
  grid-area: name;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.profile .dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pc-raw, var(--text));
  box-shadow: inset 0 0 0 1px var(--line);
}
.profile .pinfo { grid-area: info; padding-left: 20px; font-size: var(--fs-sm); color: var(--muted); }
.profile:not(.active) .pname { color: var(--muted); }
.profile .edit {
  grid-area: edit;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--faint);
  font-size: var(--fs-md);
  cursor: pointer;
}
.profile .edit:active { background: var(--surface); }

.switch { position: relative; flex: none; width: 46px; height: 28px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.2s var(--ease); }
.switch span::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s var(--ease);
}
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--tap);
  margin: 0;
  background: transparent;
}
input[type=range]::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: var(--line); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line);
}
input[type=range]::-moz-range-track { height: 2px; background: var(--line); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--ink); border: 0; }

input[type=text], select {
  min-height: var(--tap);
  padding: 0 var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
select { padding-right: var(--s2); }

.swatch {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  overflow: hidden;
}
.swatch::-webkit-color-swatch-wrapper { padding: 0; }
.swatch::-webkit-color-swatch { border: 0; border-radius: 50%; }
.swatch::-moz-color-swatch { border: 0; border-radius: 50%; }

.bat-summary { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); padding-top: var(--s2); }
.bat-pct { font-size: var(--fs-xl); font-weight: 300; letter-spacing: -0.01em; }
.meter { height: 4px; margin: var(--s2) 0 var(--s3); border-radius: 2px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--text); transition: width 0.6s var(--ease); }
.meter.low i { background: var(--danger); }
.meter.charging i { background: var(--accent); animation: charging 2.4s ease-in-out infinite; }
@keyframes charging { 50% { opacity: 0.55; } }
.bat-details { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin: 0; padding-bottom: var(--s3); border-bottom: 1px solid var(--line); }
.bat-details dt { font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: var(--s1); }
.bat-details dd { margin: 0; font-size: var(--fs-md); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats > div { padding: var(--s3) var(--s2) var(--s3) 0; }
.stats.four { grid-template-columns: repeat(2, 1fr); }
.stats dt { margin-bottom: var(--s1); }
.stats dd { margin: 0; font-size: var(--fs-xl); font-weight: 300; letter-spacing: -0.01em; }
#fwInfo { margin-top: var(--s2); }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--scrim);
  animation: fade 0.2s var(--ease);
}
.sheet-body {
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  padding: var(--s2) var(--s4) calc(env(safe-area-inset-bottom, 0px) + var(--s4));
  border-radius: 20px 20px 0 0;
  background: var(--bg);
  animation: slide-up 0.28s var(--ease);
}
.grabber { width: 36px; height: 4px; margin: 0 auto var(--s4); border-radius: 2px; background: var(--line); }
.sheet-body h2 { font-size: var(--fs-lg); margin-bottom: var(--s4); }
.field { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); font-size: var(--fs-sm); color: var(--muted); }
.field input[type=text], .field select { color: var(--text); }
.sheet .actions { margin-top: var(--s2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--s4));
  z-index: 30;
  max-width: calc(100% - var(--s6));
  padding: var(--s2) var(--s3);
  border-radius: 999px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: var(--fs-sm);
  text-align: center;
  transform: translateX(-50%);
  animation: fade 0.25s var(--ease);
}
.toast.error { background: var(--danger); color: #fff; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(16px); opacity: 0; } }

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

a.btn { text-decoration: none; }
.text-btn.danger { color: var(--danger); }

.login { padding-top: var(--s7); }
.login h1 { font-size: var(--fs-xl); margin-bottom: var(--s2); }
.login > .muted:first-of-type { margin-bottom: var(--s5); }
.login-btn { gap: var(--s2); margin-top: 0; text-align: center; }
.login-btn svg { width: 18px; height: 18px; flex: none; }
.login-btn.google { background: #fff; border-color: #747775; color: #1f1f1f; }
.login-btn.apple { background: #000; border-color: #000; color: #fff; }
.apple-logo { font-size: 1.15em; line-height: 1; }
.login-legal { margin-top: var(--s5); }
.login-demo { margin-top: var(--s3); }
.login-nota { margin-bottom: var(--s3); text-align: center; }
.notice .detalle { display: block; margin-top: var(--s1); color: var(--muted); font-size: var(--fs-xs); word-break: break-word; }
.icono-rostro { width: 20px; height: 20px; }
.login-nuevo { margin-top: 0; }
.login-crear { margin-top: var(--s2); }
.login-crear .field { margin: 0; }
.login-separador { display: flex; align-items: center; gap: var(--s3); margin: var(--s4) 0; color: var(--faint); font-size: var(--fs-sm); }
.login-separador::before, .login-separador::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.account-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  margin-right: calc(-1 * var(--s2));
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.large { width: 48px; height: 48px; font-size: var(--fs-lg); }
.account-btn[data-estado="error"] .avatar,
.account-btn[data-estado="sinConexion"] .avatar { box-shadow: inset 0 0 0 2px var(--danger); }
.account-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.account-who { min-width: 0; }
.account-who h2 { margin-bottom: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-who p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-sync { margin-bottom: var(--s4); }
.sheet .btn.block { margin-top: 0; }
.account-methods { margin-bottom: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--line); }
.account-methods h3 { margin: 0 0 var(--s2); }
.account-list { margin: 0 0 var(--s3); padding: 0; list-style: none; }
.account-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: var(--tap); border-bottom: 1px solid var(--line); }
.account-list li:last-child { border-bottom: 0; }
.account-list .when { color: var(--muted); font-size: var(--fs-sm); }
.account-list .text-btn { min-height: 36px; }
.sheet .account-logout { margin-top: var(--s2); }

@media (prefers-color-scheme: dark) {
  .login-btn.google { background: #131314; border-color: #8e918f; color: #e3e3e3; }
  .login-btn.apple { background: #fff; border-color: #fff; color: #000; }
}
