:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --card: #ffffff;
  --text: #102a2a;
  --muted: #647777;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --success: #15803d;
  --danger: #b42318;
  --border: #dbe5e3;
  --shadow: 0 10px 30px rgba(16, 42, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button, input { font: inherit; }

button {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  font-weight: 750;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary { background: var(--primary); color: white; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: #e7f2f0; color: var(--primary-dark); }
.success { background: var(--success); color: white; }
.danger { background: #feeceb; color: var(--danger); }
.small { min-height: 40px; border-radius: 11px; padding: 0 14px; }

.hidden { display: none !important; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: rgba(244, 247, 246, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.45rem; }
h2 { margin-bottom: 4px; font-size: 1.08rem; }
.eyebrow {
  margin-bottom: 2px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

main {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px 14px calc(32px + env(safe-area-inset-bottom));
}

.hero-card,
.card,
.controls-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 18px;
  align-items: center;
  padding: 22px;
}

.progress-ring {
  --progress: 0deg;
  width: 138px;
  height: 138px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--primary) var(--progress), #dfeae8 0);
  position: relative;
}

.progress-ring::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: white;
}

.progress-ring div {
  position: relative;
  text-align: center;
}
.progress-ring strong { display: block; font-size: 2.6rem; line-height: 1; }
.progress-ring span { color: var(--muted); font-size: 0.78rem; }

.status-panel { min-width: 0; }
.status-panel p { margin: 4px 0 0; color: var(--muted); }
.timer {
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.65rem, 8vw, 2.7rem);
  font-weight: 850;
  letter-spacing: -0.04em;
}
.status {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e7f2f0;
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 800;
}
.status.running { background: #dcfce7; color: #166534; }
.status.paused { background: #fff7d6; color: #8a6500; }
.status.complete { background: #e8e8ff; color: #3f3b99; }

.controls-card {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
}
.controls-card #startBtn,
.controls-card #finishBtn,
.controls-card #resetBtn {
  grid-column: span 2;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0;
}
.stats-grid article {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: white;
}
.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}
.stats-grid strong {
  display: block;
  margin-top: 9px;
  font-size: 1.28rem;
  font-variant-numeric: tabular-nums;
}

.card {
  margin-top: 14px;
  padding: 18px;
}
.section-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}
.section-heading p, .note { color: var(--muted); font-size: 0.84rem; margin-bottom: 0; }

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
}
.field-row label { font-weight: 700; }
.input-suffix {
  display: flex;
  align-items: center;
  gap: 7px;
}
.input-suffix input {
  width: 86px;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 8px 10px;
  text-align: right;
}
.input-suffix span { color: var(--muted); }

.manual-step-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.split-list {
  margin: 14px 0 0;
  padding-left: 22px;
}
.split-list li {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.split-list li:last-child { border-bottom: 0; }
.split-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.split-row span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.history-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  background: #f0f7f6;
}
.history-summary strong { font-size: 1.6rem; }

.history-item {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.history-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.history-item h3 { margin: 0; font-size: 0.98rem; }
.history-item time { color: var(--muted); font-size: 0.78rem; }
.history-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 14px;
  margin-top: 12px;
  font-size: 0.83rem;
}
.history-meta span { color: var(--muted); }

.empty { color: var(--muted); }

dialog {
  width: min(420px, calc(100% - 28px));
  border: 0;
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 20px 70px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(3, 22, 22, .56); }
dialog form { padding: 24px; }
dialog button { width: 100%; margin-top: 14px; }

@media (max-width: 520px) {
  .hero-card {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .controls-card { grid-template-columns: 1fr; }
  .controls-card #startBtn,
  .controls-card #finishBtn,
  .controls-card #resetBtn { grid-column: auto; }
}

@media (display-mode: standalone) {
  .app-header { padding-top: calc(18px + env(safe-area-inset-top)); }
}
