:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --paper: #f4f4f1;
  --ink: #171815;
  --muted: #666861;
  --line: #c9cbc4;
  --green: #08784a;
  --amber: #e3ad16;
  --red: #c73735;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app,
.setup,
.timer {
  min-height: 100vh;
  min-height: 100dvh;
}

.setup {
  display: grid;
  place-items: center;
  padding: 48px 24px;
}

.setup-panel {
  width: min(100%, 680px);
  container-type: inline-size;
}

.setup-header {
  margin-bottom: 42px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 11cqi, 4.8rem);
  font-weight: 760;
  line-height: 0.98;
  letter-spacing: 0;
}

.field {
  display: grid;
  gap: 9px;
}

.field label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.92rem;
  font-weight: 720;
}

.field input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  caret-color: transparent;
  transition: border-color 160ms ease;
}

.field input:focus {
  border-color: var(--ink);
}

.field > span {
  color: var(--muted);
  font-size: 0.78rem;
}

.field-primary input {
  padding: 4px 0 12px;
  font-size: clamp(2.3rem, 12cqi, 5.2rem);
  font-weight: 680;
  line-height: 1;
}

.thresholds {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
  margin-top: 42px;
}

.threshold input {
  padding: 2px 0 10px;
  font-size: clamp(1.5rem, 6.5cqi, 2.5rem);
  font-weight: 620;
}

.signal {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

.signal.amber {
  color: var(--amber);
}

.signal.red {
  color: var(--red);
}

.error {
  min-height: 24px;
  margin: 24px 0 0;
  color: #a01f1d;
  font-size: 0.9rem;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.start-button,
.fullscreen-button {
  min-height: 50px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 0 22px;
  font-weight: 720;
}

.start-button {
  flex: 1;
  background: var(--ink);
  color: #fff;
}

.fullscreen-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: transparent;
  color: var(--ink);
}

.start-button:hover,
.start-button:focus-visible {
  background: #343530;
}

.fullscreen-button:hover,
.fullscreen-button:focus-visible {
  background: #e7e8e2;
}

.fullscreen-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.credit {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.credit a,
.timer-credit {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.timer {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 72px 28px;
  background: var(--green);
  color: #fff;
  container-type: inline-size;
  transition: background-color 300ms ease;
}

.timer[hidden],
.setup[hidden] {
  display: none;
}

.timer.is-amber {
  background: var(--amber);
  color: #17170f;
}

.timer.is-red,
.timer.is-overdue {
  background: var(--red);
  color: #fff;
}

.timer.is-overdue {
  animation: flash-red 1s steps(1, end) infinite;
}

@keyframes flash-red {
  0%,
  100% {
    background: #ad211f;
  }

  50% {
    background: #f04642;
  }
}

.timer-center {
  width: 100%;
  text-align: center;
}

.status {
  margin: 0 0 clamp(8px, 2vh, 22px);
  font-size: clamp(0.8rem, 3.5cqi, 1.25rem);
  font-weight: 720;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.clock {
  display: block;
  width: 100%;
  font-size: clamp(4.5rem, min(32cqi, 42dvh), 24rem);
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  line-height: 0.86;
  letter-spacing: 0;
  white-space: nowrap;
}

.clock.has-hours {
  font-size: clamp(3.5rem, min(20cqi, 38dvh), 18rem);
}

.clock.is-negative {
  font-size: clamp(4rem, min(26cqi, 38dvh), 20rem);
}

.clock.has-hours.is-negative {
  font-size: clamp(3rem, min(17cqi, 34dvh), 16rem);
}

.stop-button,
.timer-fullscreen,
.timer-credit {
  position: absolute;
  z-index: 2;
}

.stop-button,
.timer-fullscreen {
  border: 0;
  background: transparent;
  color: currentColor;
}

.stop-button {
  top: max(18px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  width: 52px;
  height: 52px;
  padding: 0;
  font-size: 3rem;
  font-weight: 250;
  line-height: 44px;
}

.timer-fullscreen {
  right: max(24px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

.timer-credit {
  bottom: max(28px, env(safe-area-inset-bottom));
  left: max(28px, env(safe-area-inset-left));
  color: currentColor;
  font-size: 0.75rem;
  font-weight: 650;
  opacity: 0.68;
}

.stop-button:hover,
.stop-button:focus-visible,
.timer-fullscreen:hover,
.timer-fullscreen:focus-visible {
  opacity: 0.72;
}

.timer-credit:hover,
.timer-credit:focus-visible {
  opacity: 1;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 4px;
}

@media (max-width: 560px) {
  .setup {
    place-items: start center;
    padding: 34px 20px;
  }

  .setup-header {
    margin-bottom: 34px;
  }

  .thresholds {
    gap: 22px;
    margin-top: 34px;
  }

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

  .fullscreen-button {
    width: 100%;
  }

  .fullscreen-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .timer {
    transition: none;
  }

  .timer.is-overdue {
    animation-duration: 2s;
  }
}
