:root {
  --bg: #0b0f17;
  --bg-elev: #131a26;
  --bg-elev-2: #1a2334;
  --border: #233044;
  --text: #e7ecf3;
  --text-dim: #8b97a8;
  --accent: #6c7bff;
  --accent-2: #00d3a7;
  --success: #2ecc8f;
  --error: #ff6b6b;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

/* El atributo [hidden] debe ganar siempre: varios contenedores usan
   display:flex/grid, que por especificidad pisaría al display:none del
   navegador y dejaría la pantalla de clave visible tras desbloquear. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2440 0%, var(--bg) 55%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 480px;
  padding: 48px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Header */
.header {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logo {
  font-size: 40px;
  line-height: 1;
  filter: drop-shadow(0 6px 16px rgba(108, 123, 255, 0.45));
}

.title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, #b9c2ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
}

/* Action cards */
.actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.card:hover {
  transform: translateY(-2px) scale(1.02);
  border-color: var(--accent);
  box-shadow: 0 14px 34px rgba(108, 123, 255, 0.18);
}

.card:active {
  transform: translateY(0) scale(0.98);
}

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

.card[disabled] {
  cursor: progress;
  opacity: 0.85;
}

.card__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  font-size: 24px;
  border-radius: 12px;
  background: rgba(108, 123, 255, 0.12);
  border: 1px solid rgba(108, 123, 255, 0.25);
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
}

.card__title {
  font-size: 16px;
  font-weight: 600;
}

.card__desc {
  font-size: 13px;
  color: var(--text-dim);
}

/* Spinner */
.card__spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  opacity: 0;
  transition: opacity 0.18s var(--ease);
}

.card.is-loading .card__spinner {
  opacity: 1;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Status message */
.status {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 13px 15px;
  border-radius: 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: rise 0.28s var(--ease);
}

.toast--success {
  border-color: rgba(46, 204, 143, 0.4);
  background: rgba(46, 204, 143, 0.1);
  color: #b9f3dc;
}

.toast--error {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.1);
  color: #ffd2d2;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer */
.footer {
  margin-top: auto;
  padding-top: 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ============================ Dashboard ============================ */
.section-label {
  margin: 0 0 4px 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.dashboard {
  margin-bottom: 22px;
}

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

.widget {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
  padding: 14px;
  min-height: 86px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease);
}

.widget:hover {
  transform: translateY(-2px);
  border-color: rgba(108, 123, 255, 0.45);
}

.widget--wide {
  grid-column: 1 / -1;
}

.widget--soon {
  opacity: 0.55;
}

.widget--soon:hover {
  transform: none;
  border-color: var(--border);
}

.widget__head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.widget__body {
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.big {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nafta-unit {
  font-size: 13px;
  font-weight: 400;
}

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.kv span {
  color: var(--text-dim);
  font-size: 13px;
}

.up {
  color: var(--success);
  font-size: 14px;
}

.down {
  color: var(--error);
  font-size: 14px;
}

.meter {
  height: 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin: -1px 0 4px;
}

.meter i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.akela-extra {
  font-size: 12px;
  margin-top: 2px;
}

/* Spotify */
.sp {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sp-cover {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  flex: 0 0 auto;
  object-fit: cover;
  background: var(--bg-elev-2);
}

.sp-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sp-info b {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-bar {
  margin-top: 8px;
}

.skel {
  color: var(--text-dim);
  font-size: 13px;
  opacity: 0.7;
}

.pill {
  font-size: 12px;
  color: var(--text-dim);
}

.pill--err {
  color: var(--error);
}

.pill--off {
  color: var(--text-dim);
}

/* Per-action "app" pages */
.action-app {
  justify-content: center;
  text-align: center;
}

.action-app .status {
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}

.action-app .logo {
  font-size: 56px;
}

.muted {
  color: var(--text-dim);
  margin: 0;
}

.ok {
  color: var(--success);
  font-size: 17px;
  margin: 0;
}

.err {
  color: var(--error);
  font-size: 16px;
  margin: 0;
}

.hint {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  max-width: 320px;
  margin: 6px auto 0;
}

.bigbtn {
  width: 100%;
  padding: 18px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.bigbtn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 16px 36px rgba(108, 123, 255, 0.22);
}

.bigbtn:active {
  transform: scale(0.98);
}

.action-app input {
  width: 100%;
  padding: 13px 15px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.spin {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

/* "Add as app" hint on the main page */
.apps-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin: 18px 0 0;
}

.apps-hint a {
  color: var(--accent);
  text-decoration: none;
}

.apps-hint a:hover {
  text-decoration: underline;
}

/* ===================== Clima: horas + viento + días ===================== */
.clima-sub {
  margin-top: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hours {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.hours::-webkit-scrollbar {
  display: none;
}

.hr {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.hr__t {
  font-size: 12px;
  font-weight: 600;
}

.hr__e {
  font-size: 14px;
  line-height: 1;
}

.hr__bar {
  height: 30px;
  width: 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.hr__bar i {
  display: block;
  width: 100%;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  transition: height 0.4s var(--ease);
}

.hr__w {
  font-size: 10px;
  color: var(--text);
}

.hr__h {
  font-size: 10px;
  color: var(--text-dim);
}

/* Próximos días: fila horizontal compacta. */
.days {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.day {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.day__n {
  color: var(--text-dim);
  font-size: 10px;
}

.day__e {
  font-size: 15px;
  line-height: 1;
}

.day__mx {
  font-weight: 600;
  font-size: 13px;
}

.day__mn {
  color: var(--text-dim);
  font-size: 11px;
}

/* ===================== Garmin ===================== */
.g-week {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  padding: 1px 0;
}

.g-week__v .muted {
  font-size: 12px;
}

.g-acts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.g-act {
  display: flex;
  align-items: center;
  gap: 10px;
}

.g-act__e {
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}

.g-act__b {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.g-act__b b {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-act__b .muted {
  font-size: 12px;
}

.g-act__d {
  font-size: 12px;
  flex: 0 0 auto;
}

.g-preds {
  display: flex;
  gap: 8px;
}

.g-pred {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.g-pred span {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.g-pred b {
  font-size: 15px;
}

/* ===================== Entrada suave (página moderna) ===================== */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header {
  animation: fadeUp 0.5s var(--ease) both;
}

.dashboard {
  animation: fadeUp 0.5s var(--ease) both;
  animation-delay: 0.06s;
}

.actions {
  animation: fadeUp 0.5s var(--ease) both;
  animation-delay: 0.14s;
}

.apps-hint {
  animation: fadeUp 0.5s var(--ease) both;
  animation-delay: 0.2s;
}

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