:root {
  color-scheme: light;
  --ink: #12312f;
  --muted: #6f817e;
  --soft-muted: #9aa8a5;
  --line: #e3ebe8;
  --canvas: #f4f7f5;
  --paper: #ffffff;
  --teal: #0f766e;
  --teal-deep: #075e59;
  --teal-soft: #dff2ed;
  --teal-pale: #eef9f6;
  --coral: #de755e;
  --coral-soft: #fce9e4;
  --amber: #b87920;
  --amber-soft: #fff3d8;
  --violet: #7764ae;
  --violet-soft: #eeeafb;
  --shadow: 0 20px 60px rgba(21, 58, 52, 0.06);
  --radius: 22px;
  --small-radius: 13px;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(220, 244, 237, 0.82), transparent 25rem),
    var(--canvas);
  -webkit-font-smoothing: antialiased;
}

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.24);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 1100px);
  margin: 0 auto;
  padding: 0 24px 34px;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  border-radius: 14px;
  background: var(--teal);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.2);
  transform: rotate(-10deg);
}

.brand-lockup h1,
.intro-row h2,
.card h3,
.today-content h4,
.today-content p {
  margin: 0;
}

.brand-lockup h1 {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--soft-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
  line-height: 1;
}

.eyebrow.accent {
  color: var(--teal);
}

.icon-button,
.primary-button,
.secondary-button,
.text-button {
  border: 0;
  transition: transform 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.text-button:hover {
  transform: translateY(-1px);
}

.icon-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  color: var(--teal-deep);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.icon-button span:first-child {
  font-size: 18px;
  line-height: 0;
}

.main-content {
  display: grid;
  gap: 18px;
}

.intro-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 26px;
  padding: 25px 4px 12px;
}

.intro-row h2 {
  max-width: 570px;
  font-size: clamp(28px, 5vw, 48px);
  letter-spacing: -0.055em;
  line-height: 1.08;
}

.intro-copy {
  max-width: 570px;
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.privacy-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  color: var(--teal-deep);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #cfe8e1;
  border-radius: 999px;
  background: rgba(238, 249, 246, 0.85);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #31a982;
  box-shadow: 0 0 0 4px rgba(49, 169, 130, 0.13);
}

.card {
  position: relative;
  min-width: 0;
  padding: 25px;
  overflow: hidden;
  border: 1px solid rgba(217, 230, 225, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.card::after {
  position: absolute;
  width: 130px;
  height: 130px;
  right: -75px;
  bottom: -76px;
  border-radius: 50%;
  background: rgba(223, 242, 237, 0.32);
  content: "";
  pointer-events: none;
}

.card-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 23px;
}

.card h3 {
  font-size: 21px;
  letter-spacing: -0.035em;
}

.card-index {
  color: #bfd0cc;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 18px;
}

.entry-card {
  background:
    linear-gradient(135deg, rgba(238, 249, 246, 0.9), rgba(255, 255, 255, 0.96) 58%),
    var(--paper);
}

.today-card {
  background:
    linear-gradient(135deg, rgba(254, 249, 238, 0.94), rgba(255, 255, 255, 0.96) 62%),
    var(--paper);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field,
.weight-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field small,
.weight-field small {
  color: var(--soft-muted);
  font-size: 10px;
  font-weight: 500;
}

.field input,
.field textarea,
.weight-input-wrap input,
.small-input-wrap input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fbfdfc;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.date-input-wrap {
  position: relative;
  display: block;
  min-width: 0;
}

.field input[type="date"] {
  min-width: 0;
  max-width: 100%;
  padding: 12px 43px 12px 13px;
  color: var(--ink);
  text-align: left;
  color-scheme: light;
  -webkit-appearance: none;
  appearance: none;
}

.field input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute;
  top: 0;
  right: 0;
  width: 42px;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.date-input-icon {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 16px;
  height: 15px;
  border: 1.5px solid var(--muted);
  border-radius: 3px;
  transform: translateY(-50%);
  pointer-events: none;
}

.date-input-icon::before {
  position: absolute;
  top: 3px;
  right: 1px;
  left: 1px;
  border-top: 1.5px solid var(--muted);
  content: "";
}

.date-input-icon::after {
  position: absolute;
  top: -3px;
  left: 3px;
  width: 2px;
  height: 5px;
  border-radius: 2px;
  background: var(--muted);
  box-shadow: 6px 0 0 var(--muted);
  content: "";
}

.field input,
.field textarea {
  padding: 12px 13px;
}

.field input:focus,
.field textarea:focus,
.weight-input-wrap input:focus,
.small-input-wrap input:focus {
  border-color: #82c4b8;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.08);
  outline: none;
}

.field textarea {
  resize: vertical;
  line-height: 1.5;
}

.weight-field {
  margin: 18px 0;
}

.weight-input-wrap,
.small-input-wrap {
  position: relative;
  display: block;
}

.weight-input-wrap input {
  padding: 12px 55px 12px 15px;
  color: var(--teal-deep);
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -0.04em;
}

.weight-input-wrap b,
.small-input-wrap b {
  position: absolute;
  top: 50%;
  right: 15px;
  color: var(--soft-muted);
  font-size: 13px;
  transform: translateY(-50%);
}

.small-input-wrap input {
  padding: 11px 43px 11px 13px;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfc;
}

.segment {
  min-height: 39px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.segment.is-active {
  color: var(--teal-deep);
  background: #fff;
  box-shadow: 0 3px 9px rgba(36, 78, 69, 0.08);
}

.form-hint {
  min-height: 19px;
  margin: 9px 0 0;
  color: var(--soft-muted);
  font-size: 11px;
  line-height: 1.5;
}

.form-hint.is-existing {
  color: var(--teal);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.primary-button,
.secondary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
}

.primary-button {
  padding: 0 18px;
  color: #fff;
  background: var(--teal);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
}

.primary-button:hover {
  background: var(--teal-deep);
}

.secondary-button {
  padding: 0 16px;
  color: var(--teal-deep);
  border: 1px solid #d6e5e0;
  background: #f5fbf9;
}

.secondary-button:hover {
  background: var(--teal-soft);
}

.secondary-button.compact {
  min-height: 35px;
  padding: 0 11px;
  font-size: 11px;
}

.text-button {
  min-height: auto;
  padding: 5px 2px;
  color: var(--teal);
  background: transparent;
}

.text-button:hover {
  color: var(--teal-deep);
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--coral);
  font-size: 11px;
  line-height: 1.5;
}

.settings-actions .form-error {
  flex: 1;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  color: #71501e;
  border: 1px solid #f4dfad;
  border-radius: 15px;
  background: #fff9e9;
}

.notice div {
  display: grid;
  gap: 3px;
}

.notice strong {
  font-size: 12px;
}

.notice span {
  font-size: 11px;
  line-height: 1.4;
}

.today-content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 15px;
}

.today-date {
  color: var(--muted);
  font-size: 12px;
}

.today-pulse {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(222, 225, 210, 0.8);
}

.today-number {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--ink);
  font-size: 42px;
  font-weight: 780;
  letter-spacing: -0.06em;
  line-height: 1;
}

.today-number small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.today-label {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: right;
}

.record-pills,
.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.record-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
}

.record-pill.is-done {
  color: var(--teal-deep);
  border-color: #cfe8e1;
  background: var(--teal-pale);
}

.mini-insight {
  display: grid;
  gap: 8px;
  padding: 13px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.72);
}

.pace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mini-insight-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.mini-insight-copy {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  border-radius: 999px;
  background: #edf2f0;
  white-space: nowrap;
}

.status-badge.good {
  color: #237d61;
  background: #e2f5ed;
}

.status-badge.slow,
.status-badge.low {
  color: #8a641e;
  background: var(--amber-soft);
}

.status-badge.fast,
.status-badge.high,
.status-badge.bad {
  color: #a85340;
  background: var(--coral-soft);
}

.status-badge.neutral {
  color: #6e67a0;
  background: var(--violet-soft);
}

.analysis-card,
.history-card,
.settings-card {
  padding-bottom: 22px;
}

.analysis-header {
  align-items: center;
  margin-bottom: 18px;
}

.range-select-label select {
  min-height: 35px;
  padding: 0 28px 0 10px;
  color: var(--teal-deep);
  font-size: 11px;
  font-weight: 800;
  border: 1px solid #d6e5e0;
  border-radius: 10px;
  outline: 0;
  background: #f5fbf9;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 19px;
}

.summary-stat {
  min-width: 0;
  padding: 13px;
  border: 1px solid #edf2f0;
  border-radius: 15px;
  background: #fbfdfc;
}

.summary-stat-label {
  display: block;
  margin-bottom: 7px;
  color: var(--soft-muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.summary-stat-value {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-stat-value small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

.summary-stat-detail {
  display: block;
  min-height: 16px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 13px;
  margin: 0 0 6px 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.morning {
  background: var(--teal);
}

.legend-dot.evening {
  background: var(--coral);
}

.legend-line {
  display: inline-block;
  width: 18px;
  height: 2px;
  border-radius: 99px;
  background: var(--teal);
}

.legend-line.average {
  border-top: 2px dashed var(--teal);
  background: transparent;
}

.legend-line.target {
  border-top: 2px dashed var(--violet);
  background: transparent;
}

.chart-shell {
  position: relative;
  min-height: 250px;
  margin: 0 -5px;
}

#weightChart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 250px;
  overflow: visible;
}

.chart-empty {
  position: absolute;
  inset: 20px 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.chart-empty strong {
  color: var(--ink);
  font-size: 13px;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--teal);
  font-size: 27px;
  border-radius: 14px;
  background: var(--teal-soft);
}

.chart-tooltip {
  position: absolute;
  left: 50%;
  bottom: 5px;
  max-width: calc(100% - 30px);
  padding: 7px 10px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(20, 59, 52, 0.1);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 5px);
  transition: opacity 160ms ease, transform 160ms ease;
  white-space: nowrap;
}

.chart-tooltip.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.data-tools {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: -5px 0 14px;
}

.tool-spacer {
  flex: 1;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-empty {
  padding: 28px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  border: 1px dashed #d8e6e1;
  border-radius: 14px;
  background: #fbfdfc;
}

.history-day {
  padding: 13px 14px;
  border: 1px solid #edf2f0;
  border-radius: 15px;
  background: #fbfdfc;
}

.history-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.history-date {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.history-delta {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.history-entries {
  display: grid;
  gap: 7px;
}

.history-entry {
  display: grid;
  grid-template-columns: 46px minmax(75px, auto) 1fr auto;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 8px 0 0;
  border-top: 1px solid #edf2f0;
}

.history-period {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  color: var(--teal-deep);
  font-size: 10px;
  font-weight: 800;
  border-radius: 7px;
  background: var(--teal-soft);
}

.history-period.evening {
  color: #9c5342;
  background: var(--coral-soft);
}

.history-weight {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.history-note {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tiny-button {
  padding: 3px 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  border: 0;
  background: transparent;
}

.tiny-button:hover {
  color: var(--teal);
}

.tiny-button.danger:hover {
  color: var(--coral);
}

.section-copy {
  position: relative;
  z-index: 1;
  margin: -9px 0 20px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.settings-form {
  position: relative;
  z-index: 1;
}

.settings-target {
  max-width: 230px;
}

.settings-divider {
  height: 1px;
  margin: 20px 0;
  background: var(--line);
}

.settings-label {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.three-cols {
  grid-template-columns: 1fr 1fr minmax(70px, 0.8fr);
  align-items: end;
  margin-bottom: 14px;
}

.settings-unit {
  padding: 0 0 12px 5px;
  color: var(--soft-muted);
  font-size: 10px;
  font-weight: 700;
}

.settings-actions {
  margin-top: 5px;
}

.app-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 22px 0 0;
  color: var(--soft-muted);
  font-size: 10px;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 22px;
  max-width: calc(100vw - 32px);
  padding: 11px 15px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 12px;
  background: #153e3a;
  box-shadow: 0 15px 35px rgba(15, 50, 44, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0 14px 27px;
  }

  .topbar {
    min-height: 76px;
  }

  .intro-row {
    display: block;
    padding: 20px 2px 11px;
  }

  .privacy-pill {
    margin-top: 17px;
  }

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

  .card {
    padding: 21px 17px;
    border-radius: 19px;
  }

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

  .data-tools {
    gap: 8px;
  }

  .tool-spacer {
    display: none;
  }

  .history-entry {
    grid-template-columns: 43px 70px minmax(0, 1fr) auto;
    gap: 7px;
  }

  .history-note {
    display: none;
  }
}

@media (max-width: 560px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .field input[type="date"] {
    min-width: 0;
    max-width: 100%;
    font-size: 16px;
  }
}

@media (max-width: 420px) {
  .desktop-only {
    display: none;
  }

  .intro-row h2 {
    font-size: 31px;
  }

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

  .three-cols {
    grid-template-columns: 1fr 1fr;
  }

  .settings-unit {
    grid-column: 1 / -1;
    padding: 0;
  }

  .form-actions {
    align-items: stretch;
  }

  .form-actions .primary-button {
    flex: 1;
  }

  .history-entry {
    grid-template-columns: 43px 1fr auto;
  }

  .history-weight {
    font-size: 14px;
  }

  .history-actions {
    grid-column: 3;
  }
}
