:root {
  color-scheme: light dark;
  --bg: #f2f4ef;
  --panel: #fffaf0;
  --ink: #1d2430;
  --muted: #65717e;
  --line: rgba(29, 36, 48, 0.14);
  --accent: #d95532;
  --accent-2: #1f7a8c;
  --surface: rgba(255, 255, 255, 0.68);
  --shadow: 0 24px 70px rgba(22, 28, 36, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 18%, rgba(217, 85, 50, 0.16), transparent 32rem),
    radial-gradient(circle at 82% 76%, rgba(31, 122, 140, 0.14), transparent 34rem),
    linear-gradient(135deg, var(--bg), #e8edf4);
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
}

.app {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: stretch;
}

.clock-stage,
.controls {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.clock-stage {
  min-height: calc(100vh - 64px);
  padding: clamp(20px, 4vw, 44px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 8px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.kicker,
.zone-line,
.date-line,
.alarm-status {
  color: var(--muted);
}

.kicker {
  margin: 0 0 6px;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.status-pill {
  min-width: 74px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: var(--panel);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.clock-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(300px, 1fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  margin-top: 36px;
}

.analog-wrap {
  display: grid;
  place-items: center;
}

.analog-clock {
  --size: min(58vw, 420px);
  position: relative;
  width: var(--size);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--panel) 0 58%, transparent 59%),
    conic-gradient(from -90deg, rgba(31, 122, 140, 0.24), rgba(217, 85, 50, 0.26), rgba(31, 122, 140, 0.24));
  border: 10px solid rgba(255, 255, 255, 0.74);
  box-shadow: inset 0 0 0 1px var(--line), 0 28px 60px rgba(18, 25, 34, 0.22);
}

.ticks {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, var(--ink) 0deg 1deg, transparent 1deg 6deg);
  mask: radial-gradient(circle, transparent 0 72%, #000 73% 100%);
  opacity: 0.28;
}

.hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 6px;
  transform-origin: 50% 100%;
  border-radius: 999px;
  transform: translateX(-50%) rotate(0deg);
}

.hour {
  height: 27%;
  background: var(--ink);
}

.minute {
  height: 38%;
  background: var(--accent-2);
}

.second {
  width: 3px;
  height: 43%;
  background: var(--accent);
}

.center-dot {
  position: absolute;
  width: 20px;
  aspect-ratio: 1;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--accent);
  border: 5px solid var(--panel);
}

.time-panel {
  min-width: 0;
}

.digital-time {
  font-size: clamp(3.2rem, 10vw, 8.8rem);
  line-height: 0.88;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.date-line {
  margin-top: 24px;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  font-weight: 720;
}

.zone-line {
  margin-top: 6px;
}

.progress {
  margin-top: 32px;
  height: 10px;
  width: min(460px, 100%);
  border-radius: 999px;
  background: rgba(29, 36, 48, 0.12);
  overflow: hidden;
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.controls {
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-self: start;
  position: sticky;
  top: 32px;
}

.control-row {
  display: grid;
  gap: 8px;
}

label,
.alarm-head h2 {
  font-size: 0.88rem;
  font-weight: 800;
}

select,
input[type="time"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.4);
}

.segmented button,
.dismiss {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
}

.segmented button {
  background: transparent;
  font-weight: 800;
}

.segmented button.active {
  background: var(--ink);
  color: var(--panel);
}

.alarm-panel {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.alarm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch {
  display: inline-flex;
  align-items: center;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 48px;
  height: 28px;
  display: block;
  border-radius: 999px;
  background: rgba(29, 36, 48, 0.24);
  position: relative;
  transition: background 160ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
}

.switch input:checked + span {
  background: var(--accent-2);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.alarm-status {
  margin: 0;
  min-height: 22px;
}

.dismiss {
  background: var(--accent);
  color: white;
  font-weight: 850;
}

.hidden {
  display: none;
}

body.theme-day {
  --bg: #edf5ff;
  --panel: #ffffff;
  --accent: #e05d2f;
  --accent-2: #146c94;
}

body.theme-dawn {
  --bg: #fbefe6;
  --panel: #fff9f2;
  --accent: #bf3f49;
  --accent-2: #2f7d77;
}

body.theme-night {
  --bg: #121722;
  --panel: #1e2634;
  --ink: #f4f7fb;
  --muted: #abb8c9;
  --line: rgba(244, 247, 251, 0.14);
  --accent: #f56b50;
  --accent-2: #6cc8d3;
  --surface: rgba(30, 38, 52, 0.76);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

@media (prefers-color-scheme: dark) {
  body.theme-system {
    --bg: #121722;
    --panel: #1e2634;
    --ink: #f4f7fb;
    --muted: #abb8c9;
    --line: rgba(244, 247, 251, 0.14);
    --accent: #f56b50;
    --accent-2: #6cc8d3;
    --surface: rgba(30, 38, 52, 0.76);
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .clock-stage {
    min-height: auto;
  }

  .clock-layout {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .analog-clock {
    --size: min(82vw, 380px);
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .status-pill {
    justify-self: start;
  }

  .digital-time {
    font-size: clamp(2.7rem, 15vw, 4.5rem);
  }
}
