:root {
  color: #101513;
  background: #f4f5f1;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 255, 255, 0.95), transparent 34rem),
    linear-gradient(180deg, #f9faf7 0%, #eef0eb 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.svg-icon,
.svg-icon svg {
  display: inline-block;
  width: 1em;
  height: 1em;
}

.svg-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 18px 96px;
  background: rgba(255, 255, 255, 0.55);
}

.phone-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
  margin-bottom: 18px;
  color: #090d0b;
  font-size: 0.92rem;
  font-weight: 800;
}

.phone-status span:last-child {
  width: 66px;
  height: 13px;
  background:
    linear-gradient(90deg, #111 0 18px, transparent 18px 24px, #111 24px 42px, transparent 42px 48px, #111 48px 66px);
  opacity: 0.8;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  align-items: start;
  gap: 16px;
  margin-bottom: 26px;
}

.eyebrow {
  margin-bottom: 18px;
  color: #141817;
  font-size: 1.28rem;
  font-weight: 850;
  text-align: center;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.topline {
  margin-top: 8px;
  color: #626862;
  font-size: 0.96rem;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.score-ring {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 0 56%, transparent 57%),
    conic-gradient(#178846 var(--progress), #e3e8df 0);
  box-shadow: inset 0 0 0 1px #e2e6df;
}

.score-ring span {
  margin-top: 13px;
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1;
}

.score-ring small {
  margin-top: -18px;
  color: #5e665f;
  font-size: 0.68rem;
  font-weight: 800;
}

.view-stack {
  display: grid;
  gap: 16px;
}

.section-heading,
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading strong {
  font-size: 1rem;
}

.section-heading button {
  border: 0;
  background: transparent;
  color: #168044;
  font-weight: 750;
}

.habit-list {
  display: grid;
  gap: 12px;
}

.habit-card {
  --accent: #178846;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 56px 48px;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 13px 12px;
  border: 1px solid #e9ece6;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 28px rgba(15, 21, 18, 0.08);
}

.habit-icon {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 92%, white), color-mix(in srgb, var(--accent) 70%, black));
  color: white;
  font-size: 1.55rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.habit-main {
  min-width: 0;
}

.habit-title-row h2 {
  overflow: hidden;
  color: #121614;
  font-size: 1.08rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-card p {
  overflow: hidden;
  margin-top: 3px;
  color: #303832;
  font-size: 0.93rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-streak {
  display: grid;
  gap: 2px;
  justify-items: center;
  color: var(--accent);
}

.habit-streak span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 850;
}

.habit-streak small {
  color: #343a35;
  font-size: 0.78rem;
}

.complete-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
  font-size: 1.02rem;
}

.complete-button.is-done {
  background: var(--accent);
  color: white;
}

.habit-actions {
  display: none;
}

.week-board {
  border: 1px solid #e6e9e2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  padding: 15px;
  box-shadow: 0 12px 28px rgba(15, 21, 18, 0.07);
}

.week-board-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 13px;
}

.week-board-grid > div {
  display: grid;
  gap: 7px;
  justify-items: center;
}

.week-board-grid small {
  color: #6a706b;
  font-size: 0.73rem;
  font-weight: 800;
}

.week-board-grid span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: #eef1ed;
  color: white;
  font-size: 0.75rem;
  font-weight: 850;
}

.week-board-grid .day-1 { background: #c7e7c2; color: #347145; }
.week-board-grid .day-2 { background: #7bc870; }
.week-board-grid .day-3 { background: #218b43; }
.week-board-grid .is-today { box-shadow: 0 0 0 2px #178846, 0 0 0 4px #d9efdf; }

.recovery-panel,
.quote-card,
.insight-panel,
.form-section,
.metric-card,
.segment-control,
.stepper {
  border: 1px solid #e6e9e2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 28px rgba(15, 21, 18, 0.07);
}

.recovery-panel {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: #fff6f2;
  border-color: #f2ded6;
}

.recovery-panel > .svg-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: #f45b4e;
  color: white;
  font-size: 1.24rem;
}

.recovery-panel div {
  min-width: 0;
}

.recovery-panel strong {
  display: block;
  margin-bottom: 4px;
}

.recovery-panel span,
.quote-card p,
.loop-row p,
.metric-card span {
  color: #60665f;
  font-size: 0.86rem;
  line-height: 1.35;
}

.recover-button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: #f45b4e;
  color: white;
  padding: 0 13px;
  font-size: 0.84rem;
  font-weight: 850;
}

.quote-card {
  padding: 18px;
}

.quote-card > span {
  display: block;
  height: 20px;
  color: #c7c8c3;
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 0.7;
}

.quote-card p {
  color: #303530;
  font-size: 0.95rem;
}

.quote-card small {
  display: block;
  margin-top: 10px;
  color: #626862;
}

.garden-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border: 1px solid #cbe6d2;
  border-radius: 8px;
  background: linear-gradient(135deg, #eef9ef, #f8fcf6);
}

.garden-leaf {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: #d9f0de;
  color: #178846;
  font-size: 1.35rem;
}

.garden-card strong { font-size: 0.95rem; }
.garden-card p { margin-top: 4px; color: #5f6d61; font-size: 0.82rem; line-height: 1.35; }
.garden-card > span { color: #178846; font-size: 1.65rem; font-weight: 900; }

.build-form {
  display: grid;
  gap: 14px;
}

.stepper {
  display: grid;
  grid-template-columns: 32px 1fr 32px 1fr 32px;
  gap: 6px;
  align-items: center;
  padding: 14px 18px 8px;
}

.stepper i {
  height: 1px;
  background: #c8cec6;
}

.step {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #e7e9e5;
  color: #101513;
  font-weight: 850;
}

.step.active {
  background: #178846;
  color: white;
}

.stepper small {
  color: #60665f;
  font-size: 0.72rem;
  text-align: center;
}

.form-section {
  display: grid;
  gap: 13px;
  padding: 16px;
}

.form-section h2 {
  margin-bottom: 2px;
  font-size: 1.05rem;
}

label {
  display: grid;
  gap: 8px;
  color: #171c19;
  font-size: 0.9rem;
  font-weight: 800;
}

label > .svg-icon {
  margin-right: 6px;
  color: #178846;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid #b8d8c3;
  border-radius: 8px;
  background: #fff;
  color: #101513;
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: #178846;
  box-shadow: 0 0 0 4px rgba(23, 136, 70, 0.11);
}

.stack-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}

.stack-grid > span {
  padding-bottom: 14px;
  color: #5b625d;
  font-weight: 900;
}

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

.color-row {
  display: flex;
  gap: 14px;
  padding: 2px 4px 6px;
}

.swatch {
  width: 34px;
  height: 34px;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #d7dbd4;
}

.swatch.active {
  box-shadow:
    0 0 0 2px #178846,
    0 0 0 6px rgba(23, 136, 70, 0.12);
}

.primary-button {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #23a857, #14833f);
  color: white;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(20, 131, 63, 0.22);
}

.secondary-button,
.text-button {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #cde0d1;
  border-radius: 999px;
  background: white;
  color: #176f3c;
  font-weight: 850;
}

.text-button {
  min-height: 38px;
  border: 0;
  background: transparent;
  color: #69716b;
  font-size: 0.86rem;
}

.danger-button { color: #a54635; }

.sync-hero {
  display: grid;
  justify-items: center;
  padding: 26px 22px;
  border: 1px solid #e5e9e3;
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.sync-hero > div {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: 18px;
  background: #e6f5e9;
  color: #178846;
  font-size: 1.6rem;
}

.sync-hero h2 { font-size: 1.08rem; }
.sync-hero p { max-width: 31ch; margin-top: 7px; color: #606a62; font-size: 0.9rem; line-height: 1.4; }
.sync-hero.connected > div { background: #d9f0de; }

.sync-form .primary-button,
.sync-form .secondary-button { width: 100%; }
.form-note { color: #69716b; font-size: 0.78rem; line-height: 1.4; }
.form-note code { color: #2f7045; }

.sync-status-card {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: center;
  padding: 15px;
  border: 1px solid #e6e9e2;
  border-radius: 8px;
  background: white;
}

.sync-status-card > span {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: #e6f5e9;
  color: #178846;
}

.sync-status-card p { margin-top: 3px; color: #69716b; font-size: 0.84rem; }
.sync-message { margin: 0; padding: 12px 14px; border-radius: 8px; font-size: 0.86rem; line-height: 1.35; }
.sync-message.success { background: #e9f7ed; color: #1e733d; }
.sync-message.error { background: #fff0ed; color: #a54635; }

.segment-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 4px;
  background: #f1f2ef;
}

.segment-control button {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #252b27;
}

.segment-control button.active {
  background: white;
  color: #178846;
  box-shadow: 0 1px 8px rgba(15, 21, 18, 0.08);
}

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

.metric-card {
  display: grid;
  gap: 5px;
  min-height: 102px;
  padding: 13px 9px;
}

.metric-card div {
  color: #178846;
  font-size: 1.15rem;
}

.metric-card strong {
  font-size: 1.28rem;
}

.metric-card span {
  font-size: 0.74rem;
}

.insight-panel {
  padding: 16px;
}

.panel-title span {
  color: #178846;
  font-weight: 850;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 14px;
}

.heatmap span {
  aspect-ratio: 1;
  border-radius: 4px;
  background: #ecefec;
}

.heatmap .heat-1 {
  background: #c9e8c1;
}

.heatmap .heat-2 {
  background: #79c86d;
}

.heatmap .heat-3 {
  background: #238e45;
}

.week-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  align-items: end;
  margin-top: 16px;
}

.bar-column {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.bar-track {
  display: flex;
  width: 100%;
  height: 116px;
  align-items: end;
  border-radius: 5px;
  background: repeating-linear-gradient(to top, #eef1ed 0 1px, transparent 1px 28px);
  overflow: hidden;
}

.bar-track span {
  display: block;
  width: 100%;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, #31aa5d, #14833f);
}

.bar-column small {
  color: #60665f;
  font-size: 0.76rem;
  font-weight: 800;
}

.loop-row {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
  margin-top: 14px;
}

.loop-row > span {
  width: 12px;
  min-height: 100%;
  border-radius: 999px;
}

.empty-state {
  display: grid;
  min-height: 300px;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 28px;
  border: 1px solid #e6e9e2;
  border-radius: 8px;
  background: white;
  text-align: center;
}

.tabbar {
  position: fixed;
  right: 18px;
  bottom: 14px;
  left: 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: min(calc(100% - 36px), 394px);
  margin: 0 auto;
  padding: 8px 4px 12px;
  border-top: 1px solid rgba(20, 25, 22, 0.08);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 -12px 30px rgba(15, 21, 18, 0.09);
  backdrop-filter: blur(18px);
}

.tab-button {
  display: grid;
  min-height: 56px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #4f5751;
  font-size: 0.7rem;
  font-weight: 750;
}

.tab-button svg {
  width: 22px;
  height: 22px;
}

.tab-button.active {
  color: #178846;
}

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

  .habit-card {
    grid-template-columns: 46px minmax(0, 1fr) 45px 38px;
    gap: 9px;
  }

  .habit-icon {
    width: 44px;
    height: 44px;
  }

  .habit-streak small {
    display: none;
  }

  .compact-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 760px) {
  body {
    padding: 24px;
  }

  .app-shell {
    border: 1px solid #e4e7e0;
    border-radius: 36px;
    box-shadow: 0 28px 70px rgba(15, 21, 18, 0.14);
  }
}
