:root {
  --bg: #f7faf7;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --ink: #141b18;
  --muted: #68706c;
  --line: #edf0ee;
  --green: #19b848;
  --green-deep: #0e9b39;
  --green-soft: #dcf7e3;
  --green-pale: #ecfaef;
  --blue: #2685f4;
  --blue-soft: #eaf4ff;
  --orange: #ff781b;
  --orange-soft: #fff1e7;
  --purple-soft: #f5eefd;
  --danger: #d94c4a;
  --accent: #15ba47;
  --shadow: 0 8px 21px rgba(24, 57, 36, 0.07), 0 1px 3px rgba(24, 57, 36, 0.04);
  --radius: 21px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 8px 9px calc(80px + env(safe-area-inset-bottom));
  border: 1px solid #b8eea6;
  border-radius: 0;
  background: #fbfdfb;
  overflow: hidden;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.home-banner {
  position: relative;
  min-height: 213px;
  margin: -8px -9px 10px;
  padding: calc(55px + env(safe-area-inset-top)) 22px 19px;
  overflow: hidden;
  border-radius: 0;
  background:
    radial-gradient(circle at 77% 36%, rgba(255, 255, 255, 0.2) 0 9px, transparent 10px),
    linear-gradient(116deg, #46cf57 0%, #6eda69 52%, #c7efd0 100%);
  color: white;
}

.home-banner::before,
.home-banner::after {
  content: "";
  position: absolute;
  border-radius: 52% 48% 42% 58%;
  background: rgba(8, 155, 55, 0.18);
}

.home-banner::before {
  right: -24px;
  bottom: -32px;
  width: 165px;
  height: 83px;
}

.home-banner::after {
  right: 65px;
  bottom: -12px;
  width: 76px;
  height: 44px;
}

.home-banner h1 {
  position: relative;
  z-index: 1;
  margin: 0 0 8px;
  font-size: 29px;
  letter-spacing: -0.05em;
}

.home-banner h1 span {
  margin-left: 5px;
  font-size: 22px;
}

.banner-date {
  position: relative;
  z-index: 1;
  margin: 0 0 13px;
  font-size: 15px;
  font-weight: 560;
}

.banner-slogan {
  position: relative;
  z-index: 1;
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 560;
}

.streak-pill {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 99px;
  padding: 8px 13px;
  background: white;
  color: #243029;
  font-size: 13px;
  font-weight: 600;
}

.streak-pill span {
  color: var(--green-deep);
}

.banner-leaves {
  position: absolute;
  right: 27px;
  bottom: 21px;
  width: 74px;
  height: 95px;
}

.banner-leaves::before {
  content: "";
  position: absolute;
  left: 35px;
  top: 12px;
  width: 2px;
  height: 82px;
  transform: rotate(15deg);
  background: rgba(10, 159, 54, 0.35);
}

.banner-leaves i {
  position: absolute;
  display: block;
  width: 36px;
  height: 18px;
  border-radius: 35px 0 35px 0;
  background: rgba(17, 181, 60, 0.37);
  transform: rotate(-27deg);
}

.banner-leaves i:nth-child(1) { top: 25px; left: 7px; }
.banner-leaves i:nth-child(2) { top: 47px; left: 39px; transform: scaleX(-1) rotate(-27deg); }
.banner-leaves i:nth-child(3) { top: 68px; left: 5px; }

.icon-button {
  position: absolute;
  top: calc(55px + env(safe-area-inset-top));
  right: 19px;
  z-index: 2;
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.24);
}

.icon-button svg {
  width: 22px;
  fill: none;
  stroke: white;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel {
  margin-bottom: 10px;
  padding: 15px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 13px;
}

.panel h2,
.panel-heading h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.03em;
}

.panel-heading h2 small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.badge {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-size: 14px;
}

.badge.green {
  background: var(--green);
}

.badge.blue {
  background: var(--blue);
}

.badge.orange {
  background: var(--orange);
}

.panel-link,
.text-button {
  border: 0;
  background: transparent;
  color: #858b88;
  font-size: 13px;
  font-weight: 560;
}

.text-button {
  color: var(--green-deep);
  padding: 6px 1px 6px 12px;
}

.weight-dashboard {
  padding-top: 14px;
}

.weight-cards {
  display: grid;
  grid-template-columns: 1fr 95px 1fr;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
}

.summary-card {
  min-height: 113px;
  padding: 13px 9px;
  border-radius: 15px;
}

.summary-card.morning {
  background: linear-gradient(145deg, #e9f4ff, #fff);
}

.summary-card.evening {
  background: linear-gradient(145deg, #f6ebff, #fff);
}

.summary-card span {
  display: block;
  margin-bottom: 10px;
  color: #3a4452;
  font-size: 12px;
  font-weight: 570;
}

.summary-card strong {
  display: block;
  white-space: nowrap;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.summary-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
}

.ring {
  position: relative;
  display: grid;
  align-content: center;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, #e6f4e9 0deg);
  text-align: center;
}

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

.ring span,
.ring small {
  position: relative;
  z-index: 1;
}

.ring span {
  color: var(--orange);
  font-size: 17px;
  font-weight: 720;
}

.ring small {
  order: -1;
  margin-bottom: 3px;
  color: #4a524e;
  font-size: 11px;
}

.trend-caption {
  margin: 0 0 14px;
  padding: 8px 10px;
  border-radius: 11px;
  background: var(--green-pale);
  color: #4e5f55;
  font-size: 12px;
}

.goal-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  color: #4f5753;
}

.goal-row strong {
  color: var(--green-deep);
  font-size: 14px;
}

.goal-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e5ebe7;
}

.goal-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #42d65a, #10a53c);
  transition: width 220ms ease;
}

.input-panel {
  padding-bottom: 14px;
}

.record-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.record-heading .date-input {
  width: 139px;
}

.record-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin: 2px 0 5px;
  padding: 14px;
  border: 0;
  border-radius: 27px;
  background: linear-gradient(90deg, #28c64f, #0aac39);
  box-shadow: 0 7px 16px rgba(18, 183, 64, 0.23);
  color: white;
  font-size: 16px;
  font-weight: 660;
}

.record-cta strong {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: white;
  color: var(--green);
  font-size: 18px;
  line-height: 1;
}

.date-input {
  width: 135px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfc;
  color: var(--ink);
  font-size: 12px;
}

label {
  display: block;
  margin-bottom: 12px;
}

label > span:first-child {
  display: block;
  margin-bottom: 6px;
  color: #58625e;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #e5eae7;
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

textarea {
  resize: vertical;
}

.input-with-unit {
  display: flex;
  align-items: center;
  border: 1px solid #e5eae7;
  border-radius: 12px;
  background: #fff;
}

.input-with-unit:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.input-with-unit input {
  border: 0;
  box-shadow: none;
  background: transparent;
}

.input-with-unit small {
  margin-right: 13px;
  color: var(--muted);
}

.primary-button,
.secondary-button,
.danger-button {
  width: 100%;
  border-radius: 26px;
  padding: 13px 14px;
  font-weight: 650;
}

.primary-button {
  border: 0;
  background: linear-gradient(90deg, #27c24d, #08aa39);
  color: white;
  box-shadow: 0 5px 14px rgba(19, 184, 67, 0.24);
}

.secondary-button {
  margin-top: 12px;
  border: 1px solid #daf0df;
  background: white;
  color: var(--green-deep);
}

.danger-button {
  margin-top: 16px;
  border: 1px solid #f4dad9;
  background: #fff7f7;
  color: var(--danger);
}

.activity-totals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 13px;
  border-radius: 15px;
  background: linear-gradient(105deg, #f1fff4, #fff);
}

.activity-totals article {
  margin: 12px 0;
  padding: 0 14px;
  border-right: 1px solid var(--line);
}

.activity-totals article:last-child {
  border: 0;
}

.activity-totals span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.activity-totals strong {
  font-size: 20px;
  letter-spacing: -0.04em;
}

.entry-form {
  margin: 2px 0 13px;
  padding: 13px;
  border-radius: 15px;
  background: #f7faf8;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1.18fr 0.82fr;
  gap: 9px;
}

.hidden {
  display: none !important;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.empty-state {
  padding: 5px 2px;
  color: var(--muted);
  font-size: 12px;
}

.entry-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: #fafcfb;
  font-size: 13px;
}

.entry-item strong {
  display: block;
  margin-bottom: 3px;
}

.entry-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.delete-entry {
  border: 0;
  background: transparent;
  color: #9ba19e;
  font-size: 18px;
}

.section-intro {
  padding: calc(57px + env(safe-area-inset-top)) 12px 15px;
}

.section-intro h2 {
  margin: 0 0 5px;
  font-size: 27px;
  letter-spacing: -0.05em;
}

.section-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.period-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  height: 38px;
  margin-bottom: 10px;
  border-radius: 20px;
  background: #eff1f0;
  color: #2d3430;
  text-align: center;
  font-size: 13px;
}

.period-tabs strong {
  display: grid;
  height: 100%;
  place-items: center;
  border-radius: inherit;
  background: var(--green);
  color: white;
  font-weight: 580;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.stat-strip article {
  padding: 13px 7px;
  border-radius: 15px;
  background: linear-gradient(145deg, #eaf4ff, #fff);
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-strip article:nth-child(2) {
  background: linear-gradient(145deg, #fff0e5, #fff);
}

.stat-strip article:nth-child(3) {
  background: linear-gradient(145deg, #e6faea, #fff);
}

.stat-strip span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
}

.stat-strip strong {
  font-size: 16px;
}

.weight-chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-legend {
  display: flex;
  gap: 17px;
  margin: -2px 0 13px;
  color: #515954;
  font-size: 11px;
}

.chart-legend span::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 3px;
  margin-right: 5px;
  border-radius: 4px;
  vertical-align: middle;
}

.chart-legend .morning-line::before {
  background: #2685f4;
}

.chart-legend .evening-line::before {
  background: #ff781b;
}

.chart-legend .goal-line::before {
  height: 0;
  border-top: 2px dashed var(--green);
}

.chart-empty {
  padding: 31px 10px;
  border-radius: 14px;
  background: var(--surface-soft);
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.history-day {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.history-day:first-child {
  padding-top: 0;
  border-top: 0;
}

.history-day header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
}

.history-day p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.help-text {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.data-panel h2 {
  margin-bottom: 7px;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.file-button {
  text-align: center;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 5;
  display: flex;
  width: min(calc(100% - 2px), 428px);
  transform: translateX(-50%);
  padding: 9px 27px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: #67706c;
  font-size: 11px;
}

.bottom-nav svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav button.active {
  color: var(--green-deep);
  font-weight: 650;
}

.bottom-nav button.active svg {
  fill: var(--green-soft);
}

.install-dialog {
  width: min(calc(100% - 35px), 390px);
  border: 0;
  border-radius: 23px;
  padding: 25px 21px 20px;
  color: var(--ink);
  background: white;
}

.install-dialog::backdrop {
  background: rgba(10, 19, 13, 0.38);
  backdrop-filter: blur(3px);
}

.install-dialog .eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.install-dialog h2 {
  margin: 6px 0 16px;
}

.install-dialog ol {
  margin: 0 0 17px;
  padding-left: 22px;
  font-size: 13px;
  line-height: 2;
}

.install-dialog .primary-button {
  margin-top: 17px;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 10;
  transform: translate(-50%, 16px);
  max-width: calc(100% - 46px);
  border-radius: 40px;
  padding: 10px 18px;
  background: #17251c;
  color: white;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  font-size: 12px;
  transition: all 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 370px) {
  .weight-cards {
    grid-template-columns: 1fr 79px 1fr;
  }

  .ring {
    width: 78px;
    height: 78px;
  }
}
