:root {
  color-scheme: dark light;
  --page: #0b1118;
  --surface: #20262a;
  --surface-raised: #2c3236;
  --surface-accent: #173f6c;
  --border: #1675d1;
  --text: #f7f8fa;
  --muted: #a9b0b6;
  --accent: #4ca4ff;
  --approaching: #d7a137;
  --soon: #e77f32;
  --urgent: #e05252;
  --shadow: 0 22px 56px rgb(0 0 0 / 38%);
}

:root[data-theme="Light"] {
  color-scheme: light;
  --page: #edf3f8;
  --surface: #ffffff;
  --surface-raised: #edf1f4;
  --surface-accent: #e7f2ff;
  --border: #1675d1;
  --text: #16212b;
  --muted: #5f6b75;
  --accent: #0969c8;
  --shadow: 0 22px 56px rgb(29 53 74 / 18%);
}

:root[data-theme="Dark"] {
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="Auto"] {
    color-scheme: light;
    --page: #edf3f8;
    --surface: #ffffff;
    --surface-raised: #edf1f4;
    --surface-accent: #e7f2ff;
    --border: #1675d1;
    --text: #16212b;
    --muted: #5f6b75;
    --accent: #0969c8;
    --shadow: 0 22px 56px rgb(29 53 74 / 18%);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
  background: var(--page);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  text-rendering: optimizeLegibility;
}

.stage {
  width: 740px;
  height: 380px;
  transform: scale(var(--widget-scale, 1));
  transform-origin: top left;
}

.widget {
  position: relative;
  width: 740px;
  height: 380px;
  display: grid;
  grid-template-rows: auto 70px 1fr auto;
  gap: 12px;
  padding: 24px 30px 20px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 4%);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.widget__header {
  min-width: 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow,
h1,
.date,
.next p,
.widget__footer {
  margin: 0;
}

.eyebrow {
  margin-bottom: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

h1 {
  font-size: 26px;
  line-height: 1.08;
}

.date {
  flex: 0 0 auto;
  padding-bottom: 2px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.next {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-accent);
}

.next__label {
  margin-bottom: 4px !important;
  font-size: 12px;
  font-weight: 700;
}

.next__countdown {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.next__value {
  font-size: 25px;
  line-height: 1;
  white-space: nowrap;
}

.times {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.time {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-raised);
  font-size: 15px;
  font-weight: 600;
}

.time[data-next="true"] {
  border-color: var(--border);
  background: var(--surface-accent);
}

.time[data-current="true"] {
  box-shadow: inset 3px 0 0 var(--accent);
}

[dir="rtl"] .time[data-current="true"] {
  box-shadow: inset -3px 0 0 var(--accent);
}

.time[data-informational="true"] .time__name {
  color: var(--muted);
}

.time__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time__value {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.widget__footer {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

[data-state="error"] .status-dot {
  background: #e18b45;
}

.widget[data-state="offline"] .status-dot {
  background: var(--approaching);
}

.widget[data-severity="APPROACHING"] .next {
  border-color: var(--approaching);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--approaching) 34%, transparent);
}

.widget[data-severity="SOON"] .next {
  border-color: var(--soon);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--soon) 24%, transparent);
  animation: soft-pulse 2.4s ease-in-out infinite;
}

.widget[data-severity="URGENT"] .next {
  border-color: var(--urgent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--urgent) 26%, transparent);
  animation: urgent-pulse 1.8s ease-in-out infinite;
}

.toast {
  position: absolute;
  z-index: 3;
  inset-inline: 30px;
  bottom: 18px;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border: 1px solid var(--urgent);
  border-radius: 12px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, var(--urgent));
  box-shadow: 0 14px 34px rgb(0 0 0 / 36%);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
}

.toast[data-severity="SALAH_TIME"] {
  border-color: var(--accent);
  background: var(--surface-accent);
  background: color-mix(in srgb, var(--surface) 88%, var(--accent));
}

.toast[hidden] {
  display: none;
}

[dir="rtl"] .widget,
[dir="rtl"] .time,
[dir="rtl"] .next {
  direction: rtl;
}

@media (prefers-reduced-motion: no-preference) {
  .widget {
    animation: reveal 180ms ease-out both;
  }

  @keyframes reveal {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }

  @keyframes soft-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.08); }
  }

  @keyframes urgent-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.14); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .widget,
  .widget .next {
    animation: none !important;
  }
}
