:root {
  color-scheme: light;
  --bg: #f5f0e8;
  --ink: #1e2524;
  --muted: #69706d;
  --panel: #fffaf2;
  --line: #d9cfc0;
  --accent: #1f7a5a;
  --accent-strong: #155d45;
  --warm: #c96f42;
  --danger: #9f3c30;
  --shadow: 0 22px 70px rgba(43, 35, 24, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(31, 122, 90, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(201, 111, 66, 0.14), transparent 35%),
    var(--bg);
}

button,
input {
  font: inherit;
}

.app {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 42px);
  display: grid;
  place-items: center;
}

.timer {
  width: min(100%, 820px);
  padding: clamp(18px, 4vw, 34px);
  border: 1px solid rgba(94, 76, 50, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.92);
  box-shadow: var(--shadow);
}

.timer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: clamp(24px, 5vw, 38px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.state-pill {
  min-width: 76px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fffef9;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 800;
}

.state-pill.running {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.state-pill.done {
  color: #ffffff;
  border-color: var(--danger);
  background: var(--danger);
}

.display {
  display: grid;
  grid-template-columns: minmax(170px, 230px) 1fr;
  align-items: center;
  gap: clamp(18px, 4vw, 34px);
}

.progress {
  width: min(100%, 230px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress, 0deg), #e9dfd0 0);
  transition: background 180ms ease;
}

.progress span {
  width: 76%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    linear-gradient(180deg, #fffef9, #f8f1e6);
  border: 1px solid rgba(94, 76, 50, 0.15);
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.42);
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.time-card {
  min-height: clamp(78px, 14vw, 120px);
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffef9;
  font-variant-numeric: tabular-nums;
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 900;
  line-height: 1;
}

.time-grid span {
  color: var(--muted);
  font-size: clamp(0.72rem, 2.5vw, 0.88rem);
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0;
}

.status {
  min-height: 1.45em;
  margin: clamp(18px, 3vw, 26px) 0;
  color: var(--muted);
  font-size: 1rem;
}

.panel {
  padding: clamp(14px, 3vw, 20px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 249, 0.76);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #efe5d6;
}

.segmented button,
.actions button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 850;
}

.segmented button {
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: var(--ink);
  background: #fffef9;
  box-shadow: 0 6px 18px rgba(43, 35, 24, 0.1);
}

.mode-panel {
  margin-top: 18px;
}

.hidden {
  display: none;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fffef9;
  font-size: 1rem;
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(201, 111, 66, 0.38);
  outline-offset: 2px;
}

.duration-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.actions button {
  padding: 0 16px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fffef9;
}

.actions .primary {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.actions .primary:hover,
.actions .primary:focus-visible {
  background: var(--accent-strong);
}

.actions button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

@media (max-width: 700px) {
  .timer-header,
  .display {
    display: grid;
  }

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

  .display {
    grid-template-columns: 1fr;
  }

  .progress {
    width: min(62vw, 220px);
    margin: 0 auto;
  }
}

@media (max-width: 520px) {
  .app {
    align-items: start;
  }

  .timer {
    padding: 16px;
  }

  .time-grid,
  .duration-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    grid-template-columns: 1fr;
  }
}
