:root {
  --bg-canvas: #f3f4f6;
  --surface-white: #ffffff;
  --surface-dark: #0a0a0b;
  --led-unlit: #202024;
  --led-lit: #ffffff;
  --text-primary: #111114;
  --text-muted: #52555e;
  --text-on-dark: #ffffff;
  --text-muted-on-dark: #a1a1aa;
  --accent: #e11d48;
  --accent-glow: 0 6px 18px rgba(225, 29, 72, 0.34);
  --focus-light: #d91b45;
  --focus-dark: #fb7185;
  --card-radius: 30px;
  --inset-radius: 22px;
  --card-shadow: 0 18px 36px -14px rgba(17, 17, 20, 0.1), 0 4px 12px -4px rgba(17, 17, 20, 0.05);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  position: relative;
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ===========================
   Latar Belakang Gerak Cuaca
   =========================== */
.weather-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background-color: #f5f4f0;
  transition: background-color 600ms ease;
}

.weather-backdrop[data-mood='clear'] {
  background-color: #f5f4f0;
}

.weather-backdrop[data-mood='cloudy'] {
  background-color: #edf0f5;
}

.weather-backdrop[data-mood='night'] {
  background-color: #eaedf4;
}

.weather-backdrop[data-mood='rain'] {
  background-color: #e9eef5;
}

.backdrop-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 600ms ease;
}

.weather-backdrop[data-mood='clear'] .backdrop-sun {
  opacity: 1;
}

.weather-backdrop[data-mood='cloudy'] .backdrop-clouds,
.weather-backdrop[data-mood='night'] .backdrop-clouds {
  opacity: 1;
}

.weather-backdrop[data-mood='night'] .backdrop-night {
  opacity: 1;
}

.sun-orb {
  position: absolute;
  border-radius: 999px;
  will-change: transform;
}

.sun-orb-a {
  width: 58vw;
  height: 58vw;
  max-width: 680px;
  max-height: 680px;
  top: -18%;
  left: -10%;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.2) 0%, rgba(251, 191, 36, 0) 70%);
  animation: sunDriftA 22s ease-in-out infinite alternate;
}

.sun-orb-b {
  width: 48vw;
  height: 48vw;
  max-width: 560px;
  max-height: 560px;
  bottom: -16%;
  right: -12%;
  background: radial-gradient(circle, rgba(253, 224, 71, 0.16) 0%, rgba(253, 224, 71, 0) 72%);
  animation: sunDriftB 26s ease-in-out infinite alternate;
}

.cloud-wisp {
  position: absolute;
  border-radius: 999px;
  filter: blur(28px);
  will-change: transform;
}

.cloud-wisp-a {
  width: 62vw;
  height: 22vw;
  max-width: 760px;
  max-height: 240px;
  top: 8%;
  left: -20%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.72) 0%, rgba(148, 163, 184, 0.22) 55%, rgba(148, 163, 184, 0) 76%);
  animation: cloudDriftA 28s ease-in-out infinite alternate;
}

.cloud-wisp-b {
  width: 56vw;
  height: 20vw;
  max-width: 680px;
  max-height: 220px;
  top: 42%;
  right: -18%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.62) 0%, rgba(148, 163, 184, 0.2) 55%, rgba(148, 163, 184, 0) 76%);
  animation: cloudDriftB 34s ease-in-out infinite alternate;
}

.cloud-wisp-c {
  width: 50vw;
  height: 18vw;
  max-width: 620px;
  max-height: 200px;
  bottom: 6%;
  left: 12%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.56) 0%, rgba(148, 163, 184, 0.16) 55%, rgba(148, 163, 184, 0) 76%);
  animation: cloudDriftC 30s ease-in-out infinite alternate;
}

.night-sheen {
  position: absolute;
  width: 64vw;
  height: 64vw;
  max-width: 720px;
  max-height: 720px;
  top: -22%;
  right: -12%;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(148, 163, 184, 0.22) 0%, rgba(148, 163, 184, 0) 70%);
  will-change: transform;
  animation: nightDrift 24s ease-in-out infinite alternate;
}

.backdrop-rain-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 500ms ease;
}

.weather-backdrop[data-mood='rain'] .backdrop-rain-canvas {
  opacity: 1;
}

body.is-motion-paused .sun-orb,
body.is-motion-paused .cloud-wisp,
body.is-motion-paused .night-sheen {
  animation-play-state: paused;
}

@keyframes sunDriftA {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(10vw, 6vh, 0) scale(1.08); }
}

@keyframes sunDriftB {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-9vw, -5vh, 0) scale(1.06); }
}

@keyframes cloudDriftA {
  from { transform: translate3d(-4vw, 0, 0); }
  to { transform: translate3d(24vw, 2vh, 0); }
}

@keyframes cloudDriftB {
  from { transform: translate3d(4vw, 0, 0); }
  to { transform: translate3d(-22vw, -2vh, 0); }
}

@keyframes cloudDriftC {
  from { transform: translate3d(-10vw, 0, 0); }
  to { transform: translate3d(16vw, -2vh, 0); }
}

@keyframes nightDrift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-8vw, 6vh, 0); }
}

.motion-toggle-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background-color: var(--surface-white);
  color: var(--text-primary);
  border: 1px solid rgba(17, 17, 20, 0.14);
  box-shadow: 0 4px 12px rgba(17, 17, 20, 0.08);
  font-size: 0.8125rem;
  font-weight: 600;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.motion-toggle-btn:hover {
  background-color: #f8fafc;
}

.motion-toggle-btn:active {
  transform: scale(0.98);
}

.motion-toggle-btn[aria-pressed='true'] {
  background-color: var(--surface-dark);
  color: var(--text-on-dark);
  border-color: var(--surface-dark);
}

/* R-39: pointer cursor pada semua kontrol interaktif aktif */
a[href],
button:not(:disabled),
summary,
select:not(:disabled),
label[for],
[role='button']:not([aria-disabled='true']),
[role='tab']:not([aria-disabled='true']) {
  cursor: pointer;
}

button:disabled,
[aria-disabled='true'] {
  cursor: not-allowed;
  opacity: 0.55;
}

button {
  font: inherit;
  color: inherit;
}

/* R-32: fokus terlihat jelas dan kontras di permukaan terang maupun gelap */
:focus-visible {
  outline: 2px solid var(--focus-light);
  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;
  border: 0;
}

/* Mobile-first: 1 kolom rapi di layar sempit (< 540px) */
.dashboard {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 20px 16px 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.widget {
  background-color: var(--surface-white);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  min-width: 0;
}

/* ===========================
   Widget 1: Cuaca
   =========================== */
.widget-weather {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 248px;
  padding: 18px;
  background-color: #2f4f32;
}

.weather-media {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

.weather-bg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center 62%;
  transition: filter 220ms ease;
}

.widget-weather[data-mood='cloudy'] .weather-bg {
  filter: saturate(0.84) brightness(0.92);
}

.widget-weather[data-mood='rain'] .weather-bg {
  filter: saturate(0.76) brightness(0.84);
}

.widget-weather[data-mood='night'] .weather-bg {
  filter: saturate(0.7) brightness(0.68);
}

/* Scrim menjaga kontras putih >= 4.5:1 di atas langit cerah dan perbukitan */
.weather-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.58) 0%,
    rgba(15, 23, 42, 0.58) 56%,
    rgba(15, 23, 42, 0.22) 80%,
    rgba(15, 23, 42, 0.12) 100%
  );
}

.weather-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: 100%;
  padding-top: 12px;
}

.weather-temp-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.weather-temp {
  margin: 0;
  color: var(--text-on-dark);
  font-size: clamp(3.5rem, 15vw, 4.75rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(10, 10, 11, 0.35);
}

.weather-feels-like {
  margin: 0;
  color: var(--text-on-dark);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 6px rgba(10, 10, 11, 0.45);
}

.weather-pill {
  border: 1px solid rgba(17, 17, 20, 0.08);
  background-color: var(--surface-white);
  color: var(--text-primary);
  border-radius: 999px;
  min-height: 48px;
  min-width: 152px;
  max-width: 100%;
  padding: 8px 20px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 8px 20px rgba(10, 10, 11, 0.18);
  transition: transform 140ms ease, background-color 140ms ease;
}

.weather-pill:hover {
  background-color: #f8fafc;
}

.weather-pill:active {
  transform: scale(0.98);
}

.weather-pill:focus-visible {
  outline: 3px solid var(--focus-dark);
  outline-offset: 2px;
}

.weather-city {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

.weather-condition {
  font-size: 0.78125rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-muted);
}

/* ===========================
   Widget 2: Kalender & Gathering
   =========================== */
.widget-calendar {
  display: flex;
  flex-direction: column;
  background-color: var(--surface-dark);
  border-radius: var(--card-radius);
  overflow: hidden;
}

.calendar-top {
  flex: 1 1 auto;
  padding: 16px 14px 12px;
  background-color: var(--surface-dark);
  color: var(--text-on-dark);
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 24px;
  margin-bottom: 8px;
}

.calendar-date-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-on-dark);
}

.calendar-day-btn:focus-visible {
  outline: 2px solid var(--focus-dark);
  outline-offset: 2px;
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  text-align: center;
}

.calendar-weekdays {
  margin-bottom: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted-on-dark);
}

.calendar-day-btn {
  min-height: 44px;
  min-width: 0;
  padding: 2px 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-on-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 140ms ease;
}

.calendar-day-btn.is-outside {
  color: #7d7d87;
}

.calendar-day-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.calendar-day-btn:active {
  background-color: rgba(255, 255, 255, 0.18);
}

.calendar-day-num {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1.5px solid transparent;
}

.calendar-day-btn.is-today .calendar-day-num {
  background-color: var(--accent);
  color: var(--text-on-dark);
  box-shadow: var(--accent-glow);
}

.calendar-day-btn.is-selected:not(.is-today) .calendar-day-num {
  border-color: #ffffff;
  background-color: rgba(255, 255, 255, 0.12);
}

.calendar-day-btn.is-selected.is-today .calendar-day-num {
  box-shadow: 0 0 0 2px var(--surface-dark), 0 0 0 3.5px #ffffff, var(--accent-glow);
}

.calendar-sheet {
  flex: 0 0 auto;
  min-height: auto;
  background-color: var(--surface-white);
  color: var(--text-primary);
  border-radius: 20px 20px var(--card-radius) var(--card-radius);
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.calendar-persistent-event {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

/* ===========================
   Widget 3: Countdown LED Matrix
   =========================== */
.widget-countdown {
  padding: 20px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.countdown-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.countdown-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.countdown-subtitle {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
}

.countdown-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  border-radius: 999px;
  background-color: var(--accent);
  color: var(--text-on-dark);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: var(--accent-glow);
  white-space: nowrap;
}

.countdown-days {
  margin: 0;
  font-size: clamp(2rem, 8vw, 2.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.countdown-led-panel {
  background-color: var(--surface-dark);
  border-radius: var(--inset-radius);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.led-matrix-wrap {
  width: 100%;
}

.led-matrix-svg {
  display: block;
  width: 100%;
  height: auto;
}

.led-dot {
  fill: var(--led-unlit);
}

.led-dot.is-lit {
  fill: var(--led-lit);
}

.countdown-status-note {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted-on-dark);
}

/* Breakpoint 2: Tablet & viewport menengah (>= 540px) */
@media (min-width: 540px) {
  .dashboard {
    max-width: 580px;
    padding: 32px 20px 76px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
  }

  .widget-weather,
  .widget-calendar {
    min-height: 296px;
  }

  .widget-countdown {
    grid-column: 1 / -1;
    padding: 22px 24px 20px;
  }

  .countdown-led-panel {
    padding: 22px 20px;
  }
}

/* Breakpoint 3: Desktop (>= 768px) */
@media (min-width: 768px) {
  .dashboard {
    max-width: 620px;
    padding: 40px 24px 76px;
    gap: 22px;
  }

  .widget-weather,
  .widget-calendar {
    min-height: 304px;
  }

  .widget-countdown {
    padding: 24px 26px 22px;
    gap: 18px;
  }

  .countdown-led-panel {
    padding: 24px 22px;
  }
}

/* R-39: hormati preferensi pengurangan gerak */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-play-state: paused !important;
  }
}
