:root {
  --ink: #161118;
  --ink-2: #221a26;
  --ink-3: #2f2534;
  --cream: #fff4e6;
  --muted: #a8979f;
  --hot: #ff4a3d;
  --hot-2: #ff7a45;
  --sun: #ffd23f;
  --radius: 18px;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 74, 61, 0.18), transparent 60%),
    var(--ink);
  min-height: 100dvh;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

.app {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.top { text-align: center; }
h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.03em;
  text-transform: lowercase;
}
h1 span { color: var(--hot); }
.tag { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.label {
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: 14px;
  color: var(--cream);
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  text-align: center;
  transition: border-color .2s;
}
.label::placeholder { color: #7b6c74; }
.label:focus { border-color: var(--hot); outline: none; }

/* dial */
.dial {
  position: relative;
  width: min(78vw, 290px);
  aspect-ratio: 1;
  margin: 2px auto;
}
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.track { fill: none; stroke: var(--ink-3); stroke-width: 14; }
.progress {
  fill: none;
  stroke: var(--hot);
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset .25s linear, stroke .4s;
  filter: drop-shadow(0 0 10px rgba(255, 74, 61, .45));
}
.dial.calm .progress { stroke: var(--sun); filter: drop-shadow(0 0 10px rgba(255, 210, 63, .35)); }

.readout {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
}
.face { font-size: 40px; line-height: 1; transition: transform .3s; }
.dial.urgent .face { animation: jitter .18s infinite; }
.time {
  font-size: clamp(52px, 17vw, 68px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.05;
}
.dial.urgent .time { color: var(--hot); }
.status { color: var(--muted); font-size: 14px; min-height: 18px; }

/* setup */
.setup { display: flex; flex-direction: column; gap: 12px; transition: opacity .3s, transform .3s; }
.setup.locked { opacity: .35; pointer-events: none; transform: scale(.98); }

.steppers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.step {
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: 12px;
  padding: 10px 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: transform .12s, background .2s;
}
.step:active { transform: scale(.94); background: var(--ink-3); }

.presets { display: flex; gap: 6px; justify-content: space-between; }
.chip {
  flex: 1;
  background: transparent;
  border: 1px solid var(--ink-3);
  border-radius: 999px;
  padding: 7px 0;
  font-size: 14px;
  color: var(--muted);
  transition: all .18s;
}
.chip:active { transform: scale(.94); }
.chip.on { background: var(--cream); color: var(--ink); border-color: var(--cream); font-weight: 700; }

.voices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.voice {
  background: var(--ink-2);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 10px 0 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  transition: all .18s;
}
.voice span { font-size: 26px; transition: transform .25s cubic-bezier(.3,1.8,.5,1); }
.voice.on { border-color: var(--hot); color: var(--cream); background: #2a1a20; }
.voice.on span { transform: scale(1.18) rotate(-6deg); }

.options { display: flex; align-items: center; justify-content: space-between; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.knob {
  width: 42px; height: 24px; border-radius: 999px;
  background: var(--ink-3); position: relative; transition: background .2s;
}
.knob::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--cream);
  transition: transform .22s cubic-bezier(.3,1.5,.5,1);
}
.toggle input:checked + .knob { background: var(--hot); }
.toggle input:checked + .knob::after { transform: translateX(18px); }
.toggle input:focus-visible + .knob { outline: 3px solid var(--sun); outline-offset: 2px; }

.ghost {
  background: transparent; color: var(--sun);
  font-size: 14px; font-weight: 700; padding: 6px 2px;
}
.ghost:active { transform: scale(.95); }

/* controls */
.controls { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 4px; }
.primary, .secondary {
  border-radius: var(--radius);
  padding: 18px 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .01em;
  transition: transform .12s, background .2s, box-shadow .2s;
}
.primary {
  background: linear-gradient(180deg, var(--hot-2), var(--hot));
  color: #fff;
  box-shadow: 0 10px 30px -10px rgba(255, 74, 61, .8), inset 0 1px 0 rgba(255,255,255,.25);
}
.primary.paused { background: var(--cream); color: var(--ink); box-shadow: none; }
.secondary { background: var(--ink-2); border: 1px solid var(--ink-3); color: var(--muted); }
.primary:active, .secondary:active { transform: scale(.96); }

.hint { text-align: center; color: #6f6068; font-size: 12px; margin: 0; }

/* alarm */
.alarm {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: var(--hot);
  animation: flash .32s steps(1) infinite;
  padding: 24px;
}
.alarm[hidden] { display: none; }
.alarm-inner { text-align: center; animation: shake .12s infinite; }
.alarm-face { font-size: 110px; line-height: 1; animation: pulse .5s ease-in-out infinite alternate; }
.alarm h2 {
  margin: 10px 0 4px;
  font-size: clamp(40px, 13vw, 64px);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: .95;
  color: #fff;
  text-shadow: 0 4px 0 rgba(0,0,0,.2);
  word-break: break-word;
}
.alarm-count { margin: 0 0 26px; color: rgba(255,255,255,.85); font-weight: 700; font-variant-numeric: tabular-nums; }
.shutup {
  display: block; width: min(280px, 80vw); margin: 0 auto 10px;
  background: var(--ink); color: var(--cream);
  font-size: 24px; font-weight: 900; padding: 20px 0; border-radius: 22px;
  box-shadow: 0 12px 30px -8px rgba(0,0,0,.6);
  transition: transform .12s;
}
.shutup:active { transform: scale(.94); }
.again {
  background: transparent; color: #fff; font-weight: 700; font-size: 15px;
  text-decoration: underline; text-underline-offset: 3px; padding: 8px;
}

@keyframes flash {
  0% { background: var(--hot); }
  50% { background: var(--ink); }
}
@keyframes shake {
  0% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-3px, 2px) rotate(-.6deg); }
  50% { transform: translate(3px, -2px) rotate(.6deg); }
  75% { transform: translate(-2px, -3px) rotate(0); }
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.15); } }
@keyframes jitter {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(1px, -1px) rotate(4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .alarm { animation: none; }
  .alarm-inner, .alarm-face, .dial.urgent .face { animation: none; }
}

@media (min-height: 800px) {
  .app { gap: 20px; padding-top: calc(36px + env(safe-area-inset-top)); }
}
