:root {
  color-scheme: dark;
  --background: #0a0d14;
  --surface: #131925;
  --surface-raised: #1a2230;
  --line: #2a3445;
  --text: #f7f9fc;
  --muted: #96a2b5;
  --accent: #d9ff43;
  --accent-ink: #121700;
  --prepare: #62a8ff;
  --exercise: #ff5c45;
  --rest: #4ce0aa;
  --danger: #ff6b6b;
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  min-width: 300px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 80% -10%, rgba(217, 255, 67, .09), transparent 30rem),
    var(--background);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { width: min(100%, 760px); min-height: 100dvh; margin: 0 auto; }
.screen { min-height: 100dvh; padding: max(24px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(26px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
[hidden] { display: none !important; }

.app-header, .section-heading, .timer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-header { margin-bottom: 24px; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 9vw, 3.2rem); line-height: .95; letter-spacing: -.055em; }
h1 span { color: var(--accent); }
h2 { margin-bottom: 0; font-size: 1.35rem; letter-spacing: -.025em; }

.config-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255,255,255,.035), transparent 55%), var(--surface);
  box-shadow: 0 22px 60px rgba(0,0,0,.22);
}

.field { min-width: 0; }
.field label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .8rem; font-weight: 750; }
.field-name { margin-bottom: 18px; }

input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  color: var(--text);
  background: #0e131d;
  transition: border-color .2s, box-shadow .2s;
}

input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,255,67,.12); }
.field-name input { padding: 0 15px; font-weight: 700; }
.duration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.number-control { position: relative; }
.number-control input { padding: 0 43px 0 13px; font-size: 1.35rem; font-weight: 850; }
.number-control span { position: absolute; right: 11px; top: 50%; translate: 0 -50%; color: var(--muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; pointer-events: none; }
.preparation-field input:focus { border-color: var(--prepare); box-shadow: 0 0 0 3px rgba(98,168,255,.12); }
.exercise-field input:focus { border-color: var(--exercise); box-shadow: 0 0 0 3px rgba(255,92,69,.12); }
.rest-field input:focus { border-color: var(--rest); box-shadow: 0 0 0 3px rgba(76,224,170,.12); }

.primary-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.button { min-height: 50px; padding: 0 16px; border: 1px solid transparent; border-radius: 14px; font-weight: 850; cursor: pointer; }
.button:active, .control-button:active, .icon-button:active, .preset-action:active { transform: translateY(1px) scale(.99); }
.button-primary { color: var(--accent-ink); background: var(--accent); }
.button-secondary { color: var(--text); border-color: var(--line); background: var(--surface-raised); }
.button-ghost { color: var(--muted); border-color: var(--line); background: transparent; }
.button-start { grid-column: 1 / -1; min-height: 62px; font-size: 1.05rem; }
.play-icon { display: inline-block; margin-right: 8px; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-left: 11px solid currentColor; vertical-align: -2px; }
.install-button { min-height: 42px; }
.form-error { margin: 14px 0 0; color: #ff9b9b; font-size: .86rem; font-weight: 700; }

.presets-section { margin-top: 30px; }
.section-heading { margin-bottom: 13px; }
.count-badge { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 9px; border-radius: 99px; color: var(--accent-ink); background: var(--accent); font-weight: 900; }
.preset-list { display: grid; gap: 10px; }
.preset-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.preset-main { min-width: 0; }
.preset-name { overflow: hidden; margin: 0 0 5px; font-size: .98rem; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; }
.preset-meta { margin: 0; color: var(--muted); font-size: .75rem; }
.preset-actions { display: flex; gap: 5px; }
.preset-action { min-width: 42px; min-height: 42px; padding: 0 10px; border: 0; border-radius: 11px; color: var(--muted); background: var(--surface-raised); font-size: .74rem; font-weight: 800; cursor: pointer; }
.preset-action.load { color: var(--accent-ink); background: var(--accent); }
.preset-action.delete { color: #ff9b9b; }
.empty-state { padding: 22px 15px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; font-size: .86rem; }

.timer-screen { display: flex; flex-direction: column; overflow: hidden; }
.timer-header { position: relative; z-index: 1; }
.round-chip { padding: 10px 14px; border: 1px solid rgba(255,255,255,.13); border-radius: 99px; background: rgba(10,13,20,.35); font-size: .82rem; }
.round-chip strong { font-size: 1rem; }
.icon-button { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; color: var(--text); background: rgba(10,13,20,.35); font-size: 2rem; line-height: 1; cursor: pointer; }
.icon-button span { translate: 0 -2px; }

.timer-content { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; width: 100%; padding: 30px 0; }
.phase-label { margin-bottom: 4px; font-size: clamp(1.2rem, 6vw, 2rem); font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.time-display { font-variant-numeric: tabular-nums; font-size: clamp(5rem, 27vw, 11rem); font-weight: 950; line-height: 1; letter-spacing: -.09em; text-indent: -.09em; text-shadow: 0 12px 45px rgba(0,0,0,.22); }
.progress-track { width: min(82%, 460px); height: 8px; margin-top: 28px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.15); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: currentColor; transition: width .09s linear; }
.next-label { margin: 15px 0 0; color: rgba(255,255,255,.68); font-size: .88rem; font-weight: 700; }

.timer-controls { display: grid; grid-template-columns: 1fr 1.25fr 1fr; align-items: end; gap: 9px; }
.control-button { min-width: 0; min-height: 76px; padding: 8px 5px; border: 1px solid rgba(255,255,255,.13); border-radius: 18px; color: var(--text); background: rgba(10,13,20,.35); font-size: clamp(.66rem, 3vw, .8rem); font-weight: 800; cursor: pointer; }
.control-button-main { min-height: 94px; color: #111; border-color: transparent; background: #fff; font-size: .9rem; }
.control-icon { display: block; margin-bottom: 4px; font-size: 1.55rem; font-weight: 900; line-height: 1; }
.control-button:disabled { opacity: .38; cursor: not-allowed; }

body[data-phase="preparation"] { background: radial-gradient(circle at 50% 42%, rgba(98,168,255,.36), transparent 60%), #08111f; }
body[data-phase="exercise"] { background: radial-gradient(circle at 50% 42%, rgba(255,92,69,.46), transparent 58%), #1d0907; }
body[data-phase="rest"] { background: radial-gradient(circle at 50% 42%, rgba(76,224,170,.36), transparent 60%), #061712; }
body[data-phase="complete"] { background: radial-gradient(circle at 50% 42%, rgba(217,255,67,.33), transparent 60%), #111600; }
body[data-phase="preparation"] .timer-content { color: var(--prepare); }
body[data-phase="exercise"] .timer-content { color: #ff806d; }
body[data-phase="rest"] .timer-content { color: var(--rest); }
body[data-phase="complete"] .timer-content { color: var(--accent); }

.toast { position: fixed; z-index: 10; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); max-width: calc(100% - 36px); padding: 12px 17px; border-radius: 99px; color: #111; background: #fff; box-shadow: 0 10px 35px rgba(0,0,0,.4); font-size: .84rem; font-weight: 800; opacity: 0; pointer-events: none; translate: -50% 14px; transition: opacity .2s, translate .2s; }
.toast.visible { opacity: 1; translate: -50% 0; }

@media (min-width: 620px) {
  .setup-screen { padding-inline: 32px; }
  .duration-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .primary-actions { grid-template-columns: 1.5fr 1fr 1fr; }
  .button-start { grid-column: auto; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .timer-content { padding: 10px 0; }
  .time-display { font-size: 5rem; }
  .progress-track { margin-top: 14px; }
  .timer-controls { grid-template-columns: repeat(3, 1fr); }
  .control-button, .control-button-main { min-height: 62px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
