:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --background: #050505;
  --foreground: #f7f7f5;
  --muted: #9d9d98;
  --accent: #e82127;
  --surface: #151514;
  --border: #30302e;
  --divider: #262624;
  --placeholder: #858580;
  --focus-border: #696965;
  --focus-ring: rgba(255, 255, 255, 0.08);
  --focus-strong: rgba(255, 255, 255, 0.75);
  --inset-highlight: rgba(255, 255, 255, 0.035);
  --disabled-background: #3a3a37;
  --disabled-foreground: #777772;
  --toggle-active-background: #f7f7f5;
  --toggle-active-foreground: #10100f;
  --panel-shadow: rgba(0, 0, 0, 0.2);
  --accent-glow: rgba(232, 33, 39, 0.22);
  --accent-haze: rgba(232, 33, 39, 0.06);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --background: #e8edf2;
    --foreground: #131518;
    --muted: #596169;
    --surface: rgba(255, 255, 255, 0.78);
    --border: #bec7cf;
    --divider: #c5cdd4;
    --placeholder: #687078;
    --focus-border: #727b84;
    --focus-ring: rgba(19, 21, 24, 0.1);
    --focus-strong: rgba(19, 21, 24, 0.75);
    --inset-highlight: rgba(255, 255, 255, 0.75);
    --disabled-background: #ccd2d7;
    --disabled-foreground: #737b82;
    --toggle-active-background: #17191c;
    --toggle-active-foreground: #ffffff;
    --panel-shadow: rgba(50, 60, 70, 0.12);
    --accent-glow: rgba(232, 33, 39, 0.12);
    --accent-haze: rgba(232, 33, 39, 0.045);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #e8edf2;
  --foreground: #131518;
  --muted: #596169;
  --surface: rgba(255, 255, 255, 0.78);
  --border: #bec7cf;
  --divider: #c5cdd4;
  --placeholder: #687078;
  --focus-border: #727b84;
  --focus-ring: rgba(19, 21, 24, 0.1);
  --focus-strong: rgba(19, 21, 24, 0.75);
  --inset-highlight: rgba(255, 255, 255, 0.75);
  --disabled-background: #ccd2d7;
  --disabled-foreground: #737b82;
  --toggle-active-background: #17191c;
  --toggle-active-foreground: #ffffff;
  --panel-shadow: rgba(50, 60, 70, 0.12);
  --accent-glow: rgba(232, 33, 39, 0.12);
  --accent-haze: rgba(232, 33, 39, 0.045);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--background);
}

body {
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.dashboard {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(15rem, 0.8fr);
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: clamp(1rem, 2vw, 2.5rem);
  row-gap: clamp(1.5rem, 3.5vh, 3rem);
  width: 100%;
  min-height: 100dvh;
  padding: max(5.25rem, env(safe-area-inset-top)) max(3rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(3rem, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 82% 18%, var(--accent-haze), transparent 34%),
    var(--background);
}

.theme-switcher {
  position: absolute;
  z-index: 2;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1.5rem, env(safe-area-inset-right));
  display: flex;
  gap: 0.25rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--surface);
  box-shadow: 0 0.5rem 1.8rem var(--panel-shadow);
}

.theme-switcher button {
  min-height: 2.75rem;
  padding: 0.55rem 0.9rem;
  border: 0;
  border-radius: 0.65rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
}

.theme-switcher button[aria-pressed="true"] {
  background: var(--toggle-active-background);
  color: var(--toggle-active-foreground);
}

.theme-switcher button:focus-visible {
  outline: 3px solid var(--focus-strong);
  outline-offset: 2px;
}

.clock-panel {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: stretch;
  min-width: 0;
  padding-right: clamp(2rem, 5vw, 6rem);
}

.accent {
  width: clamp(0.35rem, 0.55vw, 0.75rem);
  margin-right: clamp(1.5rem, 3vw, 3.5rem);
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 2.5rem var(--accent-glow);
}

.time-row {
  display: flex;
  align-items: flex-start;
  min-width: 0;
}

.time {
  display: block;
  font-size: clamp(8rem, 20vw, 24rem);
  font-weight: 650;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.085em;
  line-height: 0.8;
  white-space: nowrap;
}

.seconds {
  min-width: 2ch;
  margin: 0.15em 0 0 0.42em;
  color: var(--muted);
  font-size: clamp(2rem, 4.5vw, 5rem);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}

.date-panel {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  padding-left: clamp(2rem, 4vw, 5rem);
  border-left: 1px solid var(--divider);
}

.weekday {
  margin-bottom: clamp(0.8rem, 1.6vw, 1.5rem);
  color: var(--accent);
  font-size: clamp(1.8rem, 3.3vw, 4.2rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1;
}

.date {
  display: block;
  max-width: 9ch;
  font-size: clamp(2.2rem, 4.2vw, 5rem);
  font-weight: 440;
  letter-spacing: -0.035em;
  line-height: 1.12;
  text-wrap: balance;
}

.search {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  justify-self: center;
  width: min(100%, 58rem);
}

.search-field {
  position: relative;
  min-width: 0;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 1.4rem;
  width: 1.65rem;
  height: 1.65rem;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--placeholder);
  stroke-width: 1.8;
  stroke-linecap: round;
  pointer-events: none;
}

.search input[type="search"] {
  width: 100%;
  min-height: 4.25rem;
  padding: 0.9rem 1.25rem 0.9rem 4rem;
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  outline: none;
  background: var(--surface);
  color: var(--foreground);
  font: inherit;
  font-size: clamp(1.2rem, 1.8vw, 1.55rem);
  box-shadow: inset 0 1px 0 var(--inset-highlight);
}

.search input[type="search"]::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.search input[type="search"]:focus {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.search button {
  min-width: 8.5rem;
  min-height: 4.25rem;
  padding: 0.9rem 1.7rem;
  border: 0;
  border-radius: 1.15rem;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 720;
  cursor: pointer;
}

.search button:focus-visible {
  outline: 3px solid var(--focus-strong);
  outline-offset: 3px;
}

.search button:disabled {
  background: var(--disabled-background);
  color: var(--disabled-foreground);
  cursor: not-allowed;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.offline {
  position: absolute;
  right: max(1.5rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: clamp(0.75rem, 1vw, 1rem);
  font-weight: 650;
  letter-spacing: 0.13em;
}

.offline[hidden] {
  display: none;
}

.offline-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--muted);
}

.offline-ready {
  position: absolute;
  left: max(1.5rem, env(safe-area-inset-left));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: clamp(0.75rem, 1vw, 1rem);
  font-weight: 650;
  letter-spacing: 0.1em;
}

.offline-ready[hidden] {
  display: none;
}

.ready-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: #39a85b;
}

noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--background);
  color: var(--foreground);
  font-size: 1.25rem;
  text-align: center;
}

@media (max-aspect-ratio: 6 / 5) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    align-content: center;
    gap: clamp(3rem, 8vh, 6rem);
    padding: max(2rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  }

  .clock-panel {
    grid-column: 1;
    grid-row: 1;
    justify-content: center;
    padding-right: 0;
  }

  .time {
    font-size: clamp(6rem, 27vw, 13rem);
  }

  .seconds {
    font-size: clamp(1.8rem, 7vw, 3.5rem);
  }

  .date-panel {
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
    padding: 0;
    border: 0;
    text-align: center;
  }

  .date {
    max-width: none;
  }

  .search {
    grid-column: 1;
    grid-row: 3;
  }
}

@media (max-height: 420px) {
  .dashboard {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
  }

  .time {
    font-size: min(18vw, 11rem);
  }

  .weekday {
    font-size: min(3vw, 2.2rem);
  }

  .date {
    font-size: min(3.8vw, 2.8rem);
  }

  .search input[type="search"],
  .search button {
    min-height: 3.5rem;
  }
}

@media (max-width: 540px) {
  .theme-switcher {
    right: 50%;
    transform: translateX(50%);
  }

  .search {
    grid-template-columns: 1fr;
  }

  .search button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
