:root {
  --bg: #f7fbf7;
  --surface: #ffffff;
  --surface-strong: #eef7ef;
  --text: #17211b;
  --muted: #68746d;
  --line: #dfe9e1;
  --green: #2f9f67;
  --green-dark: #217a4e;
  --coral: #d86e5f;
  --blue: #3d7cc9;
  --shadow: 0 18px 50px rgba(35, 60, 42, 0.12);
  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:
    linear-gradient(180deg, rgba(47, 159, 103, 0.08), transparent 300px),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px 112px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 18px;
}

.date-label,
.section-heading span,
.stat-card span,
.stat-card small,
.reason-card span,
.reason-card small,
.saving-card span,
.saving-card small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
  font-weight: 820;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 760;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
}

.icon-button svg,
.breath-card svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.hero-panel {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 20px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.ring-wrap {
  position: relative;
  width: min(70vw, 260px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track,
.ring-value {
  fill: none;
  stroke-width: 14;
}

.ring-track {
  stroke: #e7efe9;
}

.ring-value {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 603.19;
  stroke-dashoffset: 603.19;
  transition: stroke-dashoffset 350ms ease;
}

.timer-copy {
  display: grid;
  gap: 4px;
  text-align: center;
}

.timer-copy strong {
  font-size: clamp(44px, 15vw, 64px);
  line-height: 0.95;
  letter-spacing: 0;
}

.timer-copy span {
  color: var(--muted);
  font-size: 15px;
}

.ready-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--green-dark);
  font-weight: 720;
  font-size: 14px;
}

.ready-pill.wait {
  background: #fff2ef;
  color: #a8493d;
}

.primary-action,
.ghost-action,
.reason-card button,
.step-actions button,
.nav-item,
.breath-card {
  border: 0;
}

.primary-action {
  width: 100%;
  min-height: 58px;
  border-radius: 18px;
  background: var(--green);
  color: white;
  font-size: 17px;
  font-weight: 780;
  box-shadow: 0 12px 28px rgba(47, 159, 103, 0.26);
}

.primary-action:active {
  transform: translateY(1px);
}

.primary-action.compact {
  min-height: 48px;
}

.ghost-action {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 680;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.stat-card,
.control-panel,
.support-panel,
.history-view,
.goals-view,
.reason-card,
.saving-card,
.week-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  border-radius: 20px;
}

.stat-card {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 13px 11px;
}

.stat-card strong {
  font-size: 27px;
  line-height: 1;
}

.stat-card small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.control-panel,
.support-panel,
.history-view,
.goals-view {
  display: grid;
  gap: 16px;
  padding: 16px;
  margin-bottom: 16px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-heading span {
  max-width: 190px;
  text-align: right;
}

.range-row,
.number-row,
.text-row {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 680;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.step-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.step-actions button {
  min-height: 42px;
  border-radius: 14px;
  background: var(--surface-strong);
  color: var(--green-dark);
  font-weight: 760;
}

.step-actions button.active {
  background: var(--green);
  color: white;
}

.breath-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 78px;
  padding: 16px;
  border-radius: 18px;
  background: #eef5ff;
  color: #1f5d9f;
  text-align: left;
}

.breath-card span {
  display: grid;
  gap: 4px;
}

.breath-card strong {
  font-size: 17px;
}

.breath-card small {
  color: #527499;
}

.breath-card.running {
  animation: breathe 10s ease-in-out infinite;
}

.reason-card,
.saving-card,
.week-card {
  display: grid;
  gap: 9px;
  padding: 15px;
}

.reason-card p {
  font-size: 17px;
  line-height: 1.42;
}

.reason-card button {
  justify-self: start;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 12px;
  background: #fff2ef;
  color: #a8493d;
  font-weight: 740;
}

.history-view,
.goals-view {
  display: none;
}

.history-view.visible,
.goals-view.visible {
  display: grid;
}

.log-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.log-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.log-list strong {
  color: var(--text);
}

.week-card {
  gap: 16px;
}

.week-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.week-card-head div {
  display: grid;
  gap: 5px;
}

.week-card-head span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.week-card-head strong {
  font-size: 34px;
  line-height: 1;
}

.week-card-head p {
  max-width: 190px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}

.week-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  min-height: 146px;
}

.week-bar {
  display: grid;
  grid-template-rows: 22px 1fr 20px;
  gap: 7px;
  min-width: 0;
  justify-items: center;
}

.week-bar strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
}

.week-bar small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-transform: lowercase;
}

.bar-track {
  position: relative;
  display: flex;
  align-items: flex-end;
  width: 100%;
  min-height: 92px;
  overflow: hidden;
  border-radius: 999px;
  background: #eaf2ec;
}

.bar-track span {
  display: block;
  width: 100%;
  min-height: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #54bf83, var(--green));
  transition: height 250ms ease;
}

.number-row {
  grid-template-columns: 1fr 110px;
  align-items: center;
}

.number-row input,
.text-row textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--text);
  padding: 11px 12px;
  font-weight: 720;
}

.saving-card strong {
  font-size: 28px;
  line-height: 1.05;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  display: grid;
  width: min(100%, 460px);
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 14px max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border-top: 1px solid rgba(223, 233, 225, 0.86);
  background: rgba(247, 251, 247, 0.9);
  backdrop-filter: blur(18px);
}

.nav-item {
  min-height: 46px;
  border-radius: 15px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
}

.nav-item.active {
  background: var(--text);
  color: white;
}

.settings-dialog {
  width: min(calc(100% - 32px), 420px);
  border: 0;
  border-radius: 24px;
  padding: 0;
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgba(23, 33, 27, 0.36);
}

.settings-dialog form {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.025);
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-inline: 12px;
  }

  .stats-grid {
    gap: 7px;
  }

  .stat-card {
    padding-inline: 8px;
  }

  .section-heading {
    display: grid;
  }

  .section-heading span {
    max-width: none;
    text-align: left;
  }
}
