/* ============================================================
   CLEAR CONNECT — Wearables Dashboard
   ============================================================ */
.wearables-page {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: 'Space Mono', monospace;
  color: #15233a;
  background: #cfe6ff; /* pastel-blue fallback under the galaxies lottie */
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Galaxies backdrop layers ── */
.wd-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.wd-bg lottie-player {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  transform: translate(-50%, -50%);
  display: block;
}
/* Soft white glow up top to brighten the pastel-blue sky. */
.wd-bg-lighten {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(120% 80% at 50% -10%, rgba(255, 255, 255, 0.5) 0%, transparent 55%);
}
/* Pastel-blue veil so the white cards and dark text stay crisp over the busy art. */
.wd-bg-scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(214, 233, 255, 0.45) 0%, rgba(214, 233, 255, 0.62) 100%);
}

/* Quirky corner tip — dismiss on tap */
.wd-phone-hint {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right, 0px));
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  max-width: min(260px, calc(100vw - 80px));
  margin: 0;
  padding: 12px 14px 10px;
  text-align: left;
  font-family: inherit;
  font-size: 0.72rem;
  line-height: 1.45;
  color: #0f2847;
  background: linear-gradient(145deg, #fff9e6 0%, #ffe8f3 48%, #e8f4ff 100%);
  border: 2px solid rgba(26, 115, 232, 0.35);
  border-radius: 16px 16px 4px 16px;
  box-shadow:
    0 10px 28px rgba(26, 115, 232, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.8) inset;
  cursor: pointer;
  transform-origin: 100% 100%;
  animation: wd-phone-hint-pop 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) both;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.wd-phone-hint:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}
.wd-phone-hint.is-dismissed {
  opacity: 0;
  transform: scale(0.92) translateY(6px);
  pointer-events: none;
}
.wd-phone-hint-kicker {
  display: block;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: #7c3aed;
  margin-bottom: 4px;
}
.wd-phone-hint-body {
  display: block;
  font-weight: 600;
}
.wd-phone-hint-dismiss {
  display: block;
  margin-top: 8px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(15, 40, 71, 0.55);
}
@keyframes wd-phone-hint-pop {
  from { opacity: 0; transform: scale(0.75) rotate(-2deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.wd-home-dot {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: calc(14px + env(safe-area-inset-left, 0px));
  z-index: 20;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ffffff;
  color: #1a73e8;
  font-size: 1.3rem;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(26, 115, 232, 0.18);
  border: 1px solid rgba(26, 115, 232, 0.16);
}

.wd-container {
  position: relative;
  z-index: 3;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: calc(72px + env(safe-area-inset-top, 0px)) 18px calc(28px + env(safe-area-inset-bottom, 0px));
}

/* ── Header ── */
.wd-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.wd-title {
  font-size: clamp(1.9rem, 7vw, 2.8rem);
  font-weight: 800;
  margin: 0;
  letter-spacing: -1px;
  line-height: 1;
}
.wd-title-accent {
  background: linear-gradient(135deg, #1a73e8 0%, #16a34a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.wd-subtitle {
  margin: 8px 0 0;
  font-size: 0.86rem;
  color: #4a5e7a;
  max-width: 42ch;
  line-height: 1.4;
}

.wd-health-api-notice {
  margin: 10px 0 0;
  padding: 10px 12px;
  max-width: 52ch;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #1e3a5f;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(26, 115, 232, 0.28);
  border-left: 3px solid #16a34a;
  border-radius: 10px;
}

.wd-health-api-notice--onboard {
  max-width: none;
  text-align: left;
  margin-bottom: 12px;
}

.wd-health-api-notice-link {
  color: #1a73e8;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.wd-health-platform-pill {
  color: #1e3a8a;
  background: #e8f0fe;
  border-color: rgba(26, 115, 232, 0.25);
}

.wd-sync-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wd-last-sync {
  font-size: 0.74rem;
  color: #5a6b85;
  white-space: nowrap;
}
.wd-last-sync strong { color: #15233a; font-weight: 700; }

.wd-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 100px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  color: #fff;
  background: linear-gradient(135deg, #1a73e8 0%, #16a34a 100%);
  box-shadow: 0 4px 16px rgba(26, 115, 232, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.wd-refresh-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(26, 115, 232, 0.34); }
.wd-refresh-btn:active:not(:disabled) { transform: scale(0.97); }
.wd-refresh-btn:disabled { opacity: 0.7; cursor: default; }
.wd-refresh-icon { font-size: 1.05rem; line-height: 1; display: inline-block; }
.wd-refresh-btn.is-syncing .wd-refresh-icon { animation: wd-spin 0.9s linear infinite; }

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

/* ── Generic state cards (empty / error / hint / onboarding) ── */
.wd-root { min-height: 280px; }

.wd-state {
  background: #ffffff;
  border: 1px solid rgba(26, 115, 232, 0.12);
  border-radius: 24px;
  padding: 38px 26px;
  text-align: center;
  box-shadow: 0 10px 34px rgba(26, 60, 110, 0.08);
}
.wd-state--loading { display: flex; flex-direction: column; align-items: center; gap: 14px; color: #4a5e7a; }
.wd-state-emoji { font-size: 2.6rem; line-height: 1; margin-bottom: 6px; }
.wd-state-title { font-size: 1.3rem; font-weight: 800; margin: 0 0 8px; }
.wd-state-body { font-size: 0.9rem; color: #4a5e7a; line-height: 1.5; margin: 0 auto 18px; max-width: 44ch; }
.wd-muted { color: #8392a8; }

.wd-onboard-points {
  list-style: none;
  padding: 0;
  margin: 0 auto 22px;
  max-width: 40ch;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wd-onboard-points li {
  font-size: 0.84rem;
  color: #3d4f6b;
  background: #f3f8ff;
  border: 1px solid rgba(26, 115, 232, 0.1);
  border-radius: 12px;
  padding: 10px 12px;
}

.wd-state-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.wd-cta {
  display: inline-block;
  padding: 13px 26px;
  border-radius: 100px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, #1a73e8 0%, #16a34a 100%);
  box-shadow: 0 6px 22px rgba(26, 115, 232, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.wd-cta:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(26, 115, 232, 0.4); }
.wd-cta--ghost {
  background: #fff;
  color: #1a73e8;
  border: 1.5px solid rgba(26, 115, 232, 0.4);
  box-shadow: none;
}

.wd-spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(26, 115, 232, 0.18);
  border-top-color: #1a73e8;
  animation: wd-spin 0.8s linear infinite;
}

/* ── Single device card ── */
.wd-single { display: flex; justify-content: center; }
.wd-device-card {
  width: 100%;
  max-width: 520px;
  background: #ffffff;
  border: 1px solid rgba(26, 115, 232, 0.12);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 10px 34px rgba(26, 60, 110, 0.08);
}
.wd-device-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.wd-device-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, #1a73e8, #16a34a);
  flex-shrink: 0;
}
.wd-device-name { font-size: 1.1rem; font-weight: 800; margin: 0; }

/* ── Daily / Weekly / Total timeframe selector ── */
.wd-period-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(26, 115, 232, 0.12);
  backdrop-filter: blur(8px);
}
.wd-period-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(26, 115, 232, 0.08);
}
.wd-period-tab {
  border: none;
  background: transparent;
  color: #4a5e7a;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.wd-period-tab.is-active {
  background: #ffffff;
  color: #15233a;
  box-shadow: 0 2px 8px rgba(26, 60, 110, 0.12);
}
.wd-period-tab:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}
.wd-period-hint {
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7c94;
  white-space: nowrap;
}

.wd-metrics { display: flex; flex-direction: column; gap: 8px; }
.wd-metric {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f5f9ff;
  border: 1px solid rgba(26, 115, 232, 0.08);
}
.wd-metric-icon { font-size: 1.15rem; text-align: center; }
.wd-metric-label { font-size: 0.84rem; color: #4a5e7a; font-weight: 600; }
.wd-metric-value { font-size: 1rem; font-weight: 800; color: #15233a; }

/* ── Multi-device comparison matrix ── */
.wd-compare {
  background: #ffffff;
  border: 1px solid rgba(26, 115, 232, 0.12);
  border-radius: 24px;
  padding: 8px;
  box-shadow: 0 10px 34px rgba(26, 60, 110, 0.08);
  overflow: hidden;
}
.wd-compare-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.wd-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 360px;
}
.wd-th {
  position: sticky;
  top: 0;
  padding: 16px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #15233a;
  text-align: center;
  border-bottom: 2px solid rgba(26, 115, 232, 0.16);
  white-space: nowrap;
}
.wd-th .wd-device-dot { display: inline-block; margin-right: 6px; vertical-align: middle; }
.wd-th--metric { width: 1%; }
.wd-row-label {
  text-align: left;
  font-size: 0.82rem;
  font-weight: 700;
  color: #4a5e7a;
  padding: 14px 12px;
  white-space: nowrap;
}
.wd-row-label .wd-metric-icon { margin-right: 8px; }
.wd-td {
  text-align: center;
  font-size: 0.98rem;
  font-weight: 800;
  color: #15233a;
  padding: 14px 12px;
}
.wd-tr:nth-child(even) { background: #f5f9ff; }

/* ── Footer ── */
.wd-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  text-align: center;
}
.wd-privacy-pill {
  font-size: 0.74rem;
  color: #2f6a4a;
  background: #e3ffe9;
  border: 1px solid rgba(22, 163, 74, 0.2);
  padding: 7px 14px;
  border-radius: 100px;
}
.wd-privacy-link { font-size: 0.74rem; color: #1a73e8; }

@media (max-width: 520px) {
  .wd-header { flex-direction: column; align-items: flex-start; }
  .wd-sync-row { width: 100%; justify-content: space-between; }
}

/* ── Sync management toast (+ / −) ── */
.wd-toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 1000;
  width: min(420px, calc(100vw - 28px));
  pointer-events: none;
}

.wd-toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  border-radius: 100px;
  background: #15233a;
  color: #fff;
  box-shadow: 0 10px 34px rgba(21, 35, 58, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.32s ease, transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.wd-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.wd-toast--panel {
  flex-direction: column;
  align-items: stretch;
  border-radius: 20px;
  padding: 14px 14px 12px;
}

.wd-toast-msg {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}

.wd-toast-msg--panel {
  text-align: center;
  margin-bottom: 4px;
}

.wd-toast-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.wd-toast-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.wd-toast-btn:active { transform: scale(0.92); }

.wd-toast-btn--add {
  background: linear-gradient(135deg, #1a73e8, #16a34a);
  color: #fff;
}

.wd-toast-btn--remove {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.wd-toast-btn--restore {
  background: rgba(22, 163, 74, 0.25);
  color: #86efac;
  border: 1px solid rgba(22, 163, 74, 0.45);
}

.wd-toast-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  margin: 4px 0 8px;
}

.wd-toast-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.wd-toast-row-name {
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wd-toast-done {
  align-self: center;
  padding: 8px 18px;
  border-radius: 100px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: #15233a;
  background: #fff;
}

.wd-hidden-list {
  list-style: none;
  padding: 0;
  margin: 0 auto 18px;
  max-width: 36ch;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wd-hidden-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f3f8ff;
  border: 1px solid rgba(26, 115, 232, 0.1);
  font-size: 0.84rem;
  font-weight: 600;
}

.wd-hidden-restore {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 100px;
  color: #16a34a;
  background: #e3ffe9;
}

/* ============================================================
   NIGHT MODE
   ============================================================ */
body.night-mode.wearables-page {
  color: #e8eefb;
  background:
    radial-gradient(1200px 600px at 80% -10%, #11203a 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 110%, #0f2a20 0%, transparent 55%),
    linear-gradient(180deg, #0b1220 0%, #0e1526 100%);
}
/* Night mode keeps the original dark theme — hide the bright galaxies backdrop. */
body.night-mode .wd-bg,
body.night-mode .wd-bg-lighten,
body.night-mode .wd-bg-scrim {
  display: none;
}
body.night-mode .wd-home-dot { background: #16203a; color: #8ab4f8; border-color: rgba(138, 180, 248, 0.25); }
body.night-mode .wd-health-api-notice {
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(96, 165, 250, 0.35);
  border-left-color: #4ade80;
}

body.night-mode .wd-health-api-notice-link {
  color: #93c5fd;
}

body.night-mode .wd-health-platform-pill {
  color: #bfdbfe;
  background: rgba(30, 58, 138, 0.45);
  border-color: rgba(96, 165, 250, 0.35);
}

body.night-mode .wd-subtitle,
body.night-mode .wd-last-sync { color: #9fb2d0; }
body.night-mode .wd-last-sync strong { color: #e8eefb; }

body.night-mode .wd-state,
body.night-mode .wd-device-card,
body.night-mode .wd-compare {
  background: #131c30;
  border-color: rgba(138, 180, 248, 0.16);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}
body.night-mode .wd-state-body { color: #9fb2d0; }
body.night-mode .wd-state-title,
body.night-mode .wd-device-name,
body.night-mode .wd-metric-value,
body.night-mode .wd-td,
body.night-mode .wd-th { color: #e8eefb; }
body.night-mode .wd-onboard-points li {
  background: #0f1830;
  border-color: rgba(138, 180, 248, 0.14);
  color: #c5d4ee;
}
body.night-mode .wd-period-bar {
  background: rgba(19, 28, 48, 0.88);
  border-color: rgba(138, 180, 248, 0.16);
}
body.night-mode .wd-period-tabs { background: rgba(138, 180, 248, 0.1); }
body.night-mode .wd-period-tab { color: #9fb2d0; }
body.night-mode .wd-period-tab.is-active {
  background: #1a2740;
  color: #e8eefb;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
body.night-mode .wd-period-hint { color: #9fb2d0; }
body.night-mode .wd-metric {
  background: #0f1830;
  border-color: rgba(138, 180, 248, 0.12);
}
body.night-mode .wd-metric-label,
body.night-mode .wd-row-label { color: #9fb2d0; }
body.night-mode .wd-tr:nth-child(even) { background: #0f1830; }
body.night-mode .wd-th { border-bottom-color: rgba(138, 180, 248, 0.22); }
body.night-mode .wd-cta--ghost { background: #16203a; color: #8ab4f8; border-color: rgba(138, 180, 248, 0.4); }
body.night-mode .wd-privacy-pill { background: rgba(22, 163, 74, 0.16); color: #86efac; border-color: rgba(22, 163, 74, 0.3); }
body.night-mode .wd-privacy-link { color: #8ab4f8; }
body.night-mode .wd-toast {
  background: #1a2740;
  border-color: rgba(138, 180, 248, 0.2);
}
body.night-mode .wd-toast-row { background: rgba(138, 180, 248, 0.1); }
body.night-mode .wd-toast-done { background: #8ab4f8; color: #0b1220; }
body.night-mode .wd-hidden-item {
  background: #0f1830;
  border-color: rgba(138, 180, 248, 0.14);
  color: #c5d4ee;
}
body.night-mode .wd-hidden-restore {
  background: rgba(22, 163, 74, 0.2);
  color: #86efac;
}
