/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  background: #F2F2F7;
  color: #1C1C1E;
}

/* ── Screen containers ────────────────────────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  background: #F2F2F7;
}

/* ── Login Screen ─────────────────────────────────────────────────────────── */
.login-screen {
  align-items: center;
  justify-content: center;
}

.login-wrap {
  width: 100%;
  max-width: 320px;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.login-icon {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  box-shadow: 0 6px 24px rgba(255, 45, 85, 0.35);
  margin-bottom: 4px;
}

.login-title {
  font-size: 30px;
  font-weight: 700;
  color: #1C1C1E;
  letter-spacing: -0.5px;
}

.login-sub {
  font-size: 15px;
  color: #8E8E93;
  margin-top: -6px;
  margin-bottom: 4px;
}

.login-input {
  width: 100%;
  padding: 16px;
  border: 1.5px solid #E5E5EA;
  border-radius: 14px;
  font-size: 18px;
  text-align: center;
  font-family: inherit;
  outline: none;
  background: #FFFFFF;
  color: #1C1C1E;
  transition: border-color 0.15s;
}

.login-input:focus { border-color: #FF2D55; }

.login-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: #FF2D55;
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.5px;
  transition: opacity 0.15s;
}

.login-btn:active { opacity: 0.8; }
.login-btn:disabled { opacity: 0.5; }

/* ── Content Area ─────────────────────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 24px;
  -webkit-overflow-scrolling: touch;
}

/* ── Tab Bar ──────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid rgba(0, 0, 0, 0.18);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 0;
  background: none;
  border: none;
  cursor: pointer;
  color: #8E8E93;
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s;
}

.tab-btn.active { color: #FF2D55; }

.tab-icon { width: 26px; height: 26px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ── Height Row ─────────────────────────────────────────────────────────────*/
.height-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 0.5px solid #E5E5EA;
}

.h-label  { font-size: 14px; color: #8E8E93; font-weight: 500; }
.h-value  { flex: 1; font-size: 15px; font-weight: 600; color: #1C1C1E; }
.h-unset  { flex: 1; font-size: 14px; color: #FF9500; }

.h-edit-btn {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: #FF2D55;
  cursor: pointer;
  padding: 4px 8px;
}

/* ── Field Label ─────────────────────────────────────────────────────────── */
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: #8E8E93;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}

/* ── Stepper ──────────────────────────────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  padding: 4px 0;
}

.step-btn {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  border: none;
  background: #F2F2F7;
  color: #FF2D55;
  font-size: 22px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
  transition: opacity 0.1s;
}

.step-btn:active { opacity: 0.5; }

.step-input {
  flex: 1;
  border: none;
  outline: none;
  text-align: center;
  background: transparent;
  font-family: inherit;
  font-size: 28px;
  font-weight: 600;
  color: #1C1C1E;
  min-width: 0;
}

.stepper.lg .step-btn {
  width: 54px;
  height: 54px;
  border-radius: 27px;
  background: rgba(255, 45, 85, 0.1);
  font-size: 26px;
}

.stepper.lg .step-input {
  font-size: 54px;
  font-weight: 700;
  letter-spacing: -1px;
}

input[type=number] { -webkit-appearance: none; -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── BMI Row ──────────────────────────────────────────────────────────────── */
.bmi-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 0.5px solid #E5E5EA;
}

.bmi-num { font-size: 26px; font-weight: 700; color: #1C1C1E; }
.bmi-tag { font-size: 15px; font-weight: 600; }
.bmi-lbl { font-size: 13px; color: #8E8E93; margin-right: 2px; }

/* ── Notes Card ──────────────────────────────────────────────────────────── */
.notes-card { padding: 14px 16px; }

.notes-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: #1C1C1E;
  background: transparent;
  min-height: 72px;
}

.notes-textarea::placeholder { color: #C7C7CC; }

/* ── Date Row ────────────────────────────────────────────────────────────── */
.date-row {
  display: flex;
  align-items: center;
  background: #FFFFFF;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  gap: 12px;
}

.date-lbl   { font-size: 15px; font-weight: 500; color: #8E8E93; flex-shrink: 0; }
.date-input { flex: 1; border: none; outline: none; font-family: inherit; font-size: 15px; font-weight: 600; color: #1C1C1E; background: transparent; text-align: right; }

/* ── Record Button ────────────────────────────────────────────────────────── */
.record-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: #FF2D55;
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity 0.15s;
}

.record-btn:active { opacity: 0.8; }

/* ── History ──────────────────────────────────────────────────────────────── */
.hist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #FFFFFF;
  border-radius: 14px;
  padding: 14px 12px 14px 16px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: opacity 0.25s, transform 0.25s;
}

.hist-date { font-size: 13px; color: #8E8E93; width: 36px; flex-shrink: 0; text-align: center; line-height: 1.3; padding-top: 2px; }
.hist-body { flex: 1; min-width: 0; }

.hist-weight { font-size: 20px; font-weight: 700; color: #1C1C1E; }
.hist-weight small { font-size: 13px; font-weight: 400; color: #8E8E93; }
.hist-waist { font-size: 14px; color: #8E8E93; font-weight: 400; }

.hist-sub { display: flex; gap: 10px; margin-top: 2px; font-size: 13px; }

.hist-notes {
  margin-top: 6px;
  font-size: 13px;
  color: #3C3C43;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.del-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #C7C7CC;
  padding: 8px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.15s;
}

.del-btn:active { color: #FF3B30; }

/* ── Chart ────────────────────────────────────────────────────────────────── */
.chart-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.pill-group { display: flex; gap: 6px; }

.pill {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #E5E5EA;
  background: #FFFFFF;
  font-size: 13px;
  font-weight: 500;
  color: #3C3C43;
  cursor: pointer;
  transition: all 0.15s;
}

.pill.active { background: #FF2D55; color: #FFFFFF; border-color: #FF2D55; }

.chart-card { padding: 12px 4px 8px; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.stat {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.sv { font-size: 16px; font-weight: 700; color: #1C1C1E; }
.sv.stat-good { color: #34C759; }
.sv.stat-warn { color: #FF9500; }
.sk { font-size: 11px; color: #8E8E93; margin-top: 2px; }

/* ── Settings Page ────────────────────────────────────────────────────────── */
.settings-card { padding: 0; overflow: hidden; }

.settings-item {
  display: flex;
  align-items: center;
  padding: 16px;
  cursor: pointer;
  gap: 8px;
  border-bottom: 0.5px solid #F2F2F7;
  transition: background 0.1s;
}

.settings-item:last-child { border-bottom: none; }
.settings-item:active { background: #F2F2F7; }

.settings-label { flex: 1; font-size: 16px; color: #1C1C1E; }
.settings-value { font-size: 15px; color: #8E8E93; }
.settings-arrow { font-size: 18px; color: #C7C7CC; }
.settings-item.danger .settings-label { color: #FF3B30; }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty { text-align: center; color: #C7C7CC; padding: 60px 0 20px; font-size: 16px; }

/* ── Modal (Bottom Sheet) ─────────────────────────────────────────────────── */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-bg.open { opacity: 1; pointer-events: all; }

.modal-sheet {
  background: #FFFFFF;
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 430px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-bg.open .modal-sheet { transform: translateY(0); }

.modal-handle { width: 36px; height: 4px; background: #E5E5EA; border-radius: 2px; margin: 0 auto 18px; }
.modal-title  { font-size: 17px; font-weight: 600; text-align: center; margin-bottom: 18px; color: #1C1C1E; }

.modal-input {
  width: 100%;
  padding: 14px;
  border: 1.5px solid #E5E5EA;
  border-radius: 12px;
  font-size: 20px;
  font-family: inherit;
  text-align: center;
  outline: none;
  color: #1C1C1E;
  background: #FAFAFA;
  transition: border-color 0.15s;
  display: block;
}

.modal-input:focus { border-color: #FF2D55; background: #FFFFFF; }

.modal-btns { display: flex; gap: 12px; margin-top: 16px; }

.m-cancel, .m-ok {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}

.m-cancel { background: #F2F2F7; color: #3C3C43; }
.m-ok     { background: #FF2D55; color: #FFFFFF; }
.m-cancel:active, .m-ok:active { opacity: 0.75; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(0, 0, 0, 0.72);
  color: #FFFFFF;
  padding: 10px 22px;
  border-radius: 22px;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 400;
}

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