:root {
  color-scheme: dark;
  --bg: #101215;
  --ink: #f5f1e6;
  --muted: rgba(245, 241, 230, 0.68);
  --quiet: rgba(245, 241, 230, 0.45);
  --line: rgba(245, 241, 230, 0.18);
  --panel: rgba(17, 19, 22, 0.62);
  --panel-strong: rgba(17, 19, 22, 0.78);
  --accent: #e9b872;
  --accent-two: #79b8a8;
  --accent-three: #d77d6f;
  --shadow: rgba(0, 0, 0, 0.42);
  --day-offset: 653.45;
  --second-offset: 515.22;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(233, 184, 114, 0.2), transparent 42%),
    linear-gradient(135deg, #101215 0%, #18221f 42%, #251918 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.is-dim {
  --ink: #e7e1d2;
  --muted: rgba(231, 225, 210, 0.56);
  --quiet: rgba(231, 225, 210, 0.34);
  --line: rgba(231, 225, 210, 0.13);
  --panel: rgba(12, 14, 16, 0.54);
  --panel-strong: rgba(12, 14, 16, 0.68);
}

button,
time {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

#ambient {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.clock-shell {
  position: relative;
  z-index: 1;
  width: min(100% - 28px, 720px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  padding: clamp(18px, 4vw, 42px) 0;
}

.topbar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.controls {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 12, 14, 0.32);
  backdrop-filter: blur(18px) saturate(128%);
}

.mode-button,
.icon-button {
  height: 34px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition:
    color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.mode-button {
  min-width: 38px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.icon-button {
  width: 34px;
  display: grid;
  place-items: center;
}

.icon-button span {
  width: 15px;
  height: 15px;
  display: block;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
  box-shadow: inset -5px 0 0 currentColor;
}

.mode-button:hover,
.icon-button:hover {
  color: var(--ink);
  background: rgba(245, 241, 230, 0.1);
  transform: translateY(-1px);
}

.mode-button:focus-visible,
.icon-button:focus-visible {
  outline: 3px solid color-mix(in oklab, var(--accent-two), white 18%);
  outline-offset: 3px;
}

.mode-button.is-active,
.icon-button[aria-pressed="true"] {
  color: #121416;
  background: linear-gradient(135deg, var(--accent), var(--accent-two));
}

.clock-card {
  align-self: center;
  min-height: min(660px, calc(100svh - 128px));
  display: grid;
  grid-template-columns: minmax(220px, 0.68fr) minmax(0, 1fr);
  gap: clamp(22px, 4vw, 44px);
  align-items: center;
  padding: clamp(24px, 5vw, 50px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(245, 241, 230, 0.1), transparent 58%),
    var(--panel);
  box-shadow: 0 32px 90px var(--shadow);
  backdrop-filter: blur(26px) saturate(132%);
}

.ring-wrap {
  position: relative;
  width: min(100%, 310px);
  aspect-ratio: 1;
  justify-self: center;
}

.day-ring {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.28));
  transform: rotate(-90deg);
}

.ring-track,
.ring-progress,
.ring-second {
  fill: none;
  stroke-linecap: round;
}

.ring-track {
  stroke: var(--line);
  stroke-width: 13;
}

.ring-progress {
  stroke: var(--accent);
  stroke-width: 13;
  stroke-dasharray: 653.45;
  stroke-dashoffset: var(--day-offset);
}

.ring-second {
  stroke: var(--accent-two);
  stroke-width: 5;
  stroke-dasharray: 515.22;
  stroke-dashoffset: var(--second-offset);
  opacity: 0.82;
}

.ring-core {
  position: absolute;
  inset: 22%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background:
    linear-gradient(145deg, rgba(245, 241, 230, 0.12), transparent),
    var(--panel-strong);
}

.ring-core span {
  color: var(--quiet);
  font-size: clamp(1rem, 3vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.time-panel {
  min-width: 0;
  display: grid;
  gap: 10px;
}

#time {
  display: block;
  color: var(--ink);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: clamp(3.1rem, 13vw, 8rem);
  font-weight: 730;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 0.94;
  text-shadow: 0 18px 52px rgba(0, 0, 0, 0.32);
}

#seconds,
#date {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.96rem, 2.2vw, 1.2rem);
  line-height: 1.35;
}

#seconds {
  color: var(--accent);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.status-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding-top: clamp(10px, 2vw, 20px);
  border-top: 1px solid var(--line);
}

.status-strip span {
  min-width: 0;
  padding: 12px 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 10, 12, 0.24);
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.is-dim #ambient {
  opacity: 0.48;
}

body.is-dim .clock-card {
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

@media (max-width: 680px) {
  body {
    overflow: auto;
  }

  .clock-shell {
    width: min(100% - 24px, 480px);
  }

  .clock-card {
    min-height: auto;
    grid-template-columns: 1fr;
    align-content: center;
  }

  .ring-wrap {
    width: min(76vw, 250px);
  }

  .time-panel {
    text-align: center;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 410px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls {
    align-self: stretch;
    justify-content: flex-end;
  }

  #time {
    font-size: clamp(2.8rem, 18vw, 4.2rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
