:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #18202f;
  --muted: #6b7484;
  --line: #dbe2ed;
  --accent: #ff5f46;
  --accent-2: #20a99a;
  --accent-3: #f6b73c;
  --shadow: 0 24px 70px rgba(42, 50, 66, 0.18);
  --angle: 0deg;
  --progress: 0%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(32, 169, 154, 0.22), transparent 34%),
    linear-gradient(315deg, rgba(246, 183, 60, 0.24), transparent 35%),
    var(--bg);
  color: var(--ink);
  padding: 24px;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible + span {
  outline: 3px solid rgba(32, 169, 154, 0.36);
  outline-offset: 3px;
}

.timer-shell {
  width: min(100%, 430px);
  min-height: 620px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 255, 0.93)),
    var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
}

.status-pill {
  min-width: 92px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f9fc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(32, 169, 154, 0.13);
}

body.is-running .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
  animation: blink 1.1s ease-in-out infinite;
}

body.is-done .status-dot {
  background: var(--accent-3);
  box-shadow: 0 0 0 4px rgba(246, 183, 60, 0.2);
}

@keyframes blink {
  50% {
    transform: scale(0.68);
    opacity: 0.55;
  }
}

.timer-face {
  display: grid;
  align-content: center;
  gap: 20px;
}

.dial {
  position: relative;
  width: min(100%, 318px);
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(var(--accent) 0 var(--angle), #e6ebf3 var(--angle) 360deg);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.8),
    0 18px 44px color-mix(in srgb, var(--accent) 18%, transparent);
  transition: box-shadow 180ms ease;
}

.dial::before {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background:
    linear-gradient(180deg, #ffffff, #f6f8fc);
  box-shadow: inset 0 0 0 1px var(--line);
}

.dial::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  transform:
    rotate(var(--angle))
    translateY(calc((min(100vw, 318px) / -2) + 11px));
  box-shadow: 0 4px 13px color-mix(in srgb, var(--accent) 36%, transparent);
}

.dial-ticks {
  position: absolute;
  inset: 26px;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(24, 32, 47, 0.18) 0deg 1deg,
    transparent 1deg 12deg
  );
  mask: radial-gradient(circle, transparent 0 72%, #000 73% 100%);
  -webkit-mask: radial-gradient(circle, transparent 0 72%, #000 73% 100%);
}

.dial-core {
  position: relative;
  z-index: 1;
  width: 67%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, #ffffff 0 32%, #f4f7fb 68%, #e8edf5 100%);
  box-shadow: inset 0 -12px 26px rgba(79, 91, 112, 0.12);
}

#time {
  display: block;
  min-width: 184px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 58px;
  font-weight: 850;
  line-height: 1;
}

#modeLabel {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

.meter-row {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.meter-row span:last-child {
  text-align: right;
}

.meter {
  height: 9px;
  border-radius: 999px;
  background: #e5ebf3;
  overflow: hidden;
}

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

.controls {
  display: grid;
  gap: 14px;
}

.presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.preset,
.tool-button,
.ghost-button,
.primary-button {
  min-height: 48px;
  border-radius: 8px;
  font-weight: 850;
  transition:
    transform 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

.preset {
  background: #eef3f8;
  color: #334056;
}

.preset.is-active {
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(24, 32, 47, 0.18);
}

.action-grid {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  gap: 8px;
}

.ghost-button {
  grid-column: 1 / -1;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tool-button {
  background: #eef3f8;
  color: var(--ink);
  font-size: 18px;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 14px 28px color-mix(in srgb, var(--accent) 28%, transparent);
}

.preset:hover,
.tool-button:hover,
.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.preset:active,
.tool-button:active,
.ghost-button:active,
.primary-button:active {
  transform: translateY(0);
}

.toggles {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.switch {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfe;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.switch input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.switch span {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #d8e0eb;
  padding: 3px;
  transition: background 140ms ease;
}

.switch span::before {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(24, 32, 47, 0.25);
  transition: transform 140ms ease;
}

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

.switch input:checked + span::before {
  transform: translateX(16px);
}

.switch em {
  font-style: normal;
}

body.is-done .dial {
  animation: finishPulse 900ms ease-in-out 3;
}

@keyframes finishPulse {
  50% {
    transform: scale(1.025);
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.8),
      0 18px 54px rgba(246, 183, 60, 0.36);
  }
}

@media (max-width: 420px) {
  body {
    padding: 12px;
  }

  .timer-shell {
    min-height: 600px;
    padding: 18px;
  }

  .topline {
    align-items: center;
  }

  h1 {
    font-size: 25px;
  }

  #time {
    min-width: 162px;
    font-size: 48px;
  }

  .dial::after {
    transform:
      rotate(var(--angle))
      translateY(calc((min(100vw, 318px) / -2) + 25px));
  }
}

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