:root {
  --bg-page: #232946; --bg-card: #1e2540; --bg-input: #232946;
  --text-headline: #fffffe; --text-paragraph: #b8c1ec; --text-muted: rgba(184, 193, 236, 0.5);
  --accent-pink: #eebbc3; --accent-pink-text: #232946;
  --accent-pink-dim: rgba(238, 187, 195, 0.12); --accent-pink-border: rgba(238, 187, 195, 0.25);
  --border-card: rgba(184, 193, 236, 0.12); --border-input: rgba(184, 193, 236, 0.2);
  --border-subtle: rgba(184, 193, 236, 0.08);
  --avg-line-color: #fffffe; --avg-label-bg: #232946; --avg-label-border: #fffffe; --avg-label-color: #fffffe;
  --weight-line: rgba(184, 193, 236, 0.14); --weight-fill: rgba(184, 193, 236, 0.07);
  --weight-point: rgba(184, 193, 236, 0.35); --weight-point-border: rgba(184, 193, 236, 0.25);
  --goal-line: #d4929e;
  --bar-monday: #eebbc3; --bar-default: rgba(184, 193, 236, 0.4);
  --bar-border-monday: #eebbc3; --bar-border-default: rgba(184, 193, 236, 0.4);
  --goal-box-bg: rgba(238, 187, 195, 0.15); --goal-box-border: rgba(238, 187, 195, 0.3);
  --forecast-line: rgba(255, 255, 254, 0.15);
  --forecast-bar: rgba(238, 187, 195, 0.4); --forecast-bar-border: rgba(238, 187, 195, 0.5);
  --event-star: #ff6b6b; --event-tri: #ff9f43;
  --note-dot: #ff6b6b;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg-page); color: var(--text-headline); margin: 0; padding: 0; -webkit-font-smoothing: antialiased; overflow-x: hidden; }

.snap-section { width: 100%; padding: 0 20px; }
.section-1, .section-2 { height: 100dvh; display: flex; align-items: center; justify-content: center; }
.section-3 { min-height: auto; padding-top: 20px; padding-bottom: 40px; }
.legal-footer { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; padding-top: 48px; padding-bottom: 24px; font-size: 12px; color: #b8c1ec; }
.legal-footer a { color: #eebbc3; text-decoration: none; transition: text-decoration 0.15s; }
.legal-footer a:hover { text-decoration: underline; }
.legal-footer-sep { color: #b8c1ec; }
.section-inner { max-width: 920px; width: 100%; margin: 0 auto; }
.section-1 .section-inner { display: flex; flex-direction: column; justify-content: space-around; height: calc(100dvh - 40px); padding: 8px 0 20px 0; }
.section-2 .section-inner { display: flex; flex-direction: column; height: calc(100dvh - 16px); padding: 8px 0; }

.chart-wrapper { display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 12px; padding: 10px 12px; }
.chart-controls-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex-shrink: 0; margin-bottom: 6px; }
.range-group { display: flex; }
.range-button { background: transparent; border: 1px solid var(--border-input); padding: 3px 11px; font-size: 11px; font-family: 'DM Sans', sans-serif; color: var(--text-paragraph); cursor: pointer; transition: all 0.15s; border-right-width: 0; height: 26px; }
.range-button:first-child { border-radius: 5px 0 0 5px; }
.range-button:last-child { border-radius: 0 5px 5px 0; border-right-width: 1px; }
.range-button.active { background: var(--accent-pink); border-color: var(--accent-pink); color: var(--accent-pink-text); font-weight: 600; }
.range-button:hover:not(.active) { border-color: var(--text-paragraph); }
.date-range { display: flex; align-items: center; gap: 5px; }
.date-pair { display: flex; flex-direction: row; align-items: center; gap: 5px; }
.date-pair label { font-size: 11px; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.input-sm { padding: 3px 6px; font-size: 11px; height: 26px; border-radius: 5px; background: var(--bg-input); border: 1px solid var(--border-input); font-family: 'DM Sans', sans-serif; color: var(--text-headline); }
.input-sm:focus { outline: none; border-color: var(--accent-pink); }
.input-sm::-webkit-calendar-picker-indicator { filter: invert(0.7); width: 11px; height: 11px; }
.btn-sm { padding: 3px 10px; font-size: 11px; height: 26px; border-radius: 5px; background: transparent; color: var(--text-paragraph); border: 1px solid var(--border-input); font-family: 'DM Sans', sans-serif; cursor: pointer; transition: all 0.15s; }
.btn-sm:hover { border-color: var(--text-paragraph); color: var(--text-headline); }
.toggle-group { display: flex; align-items: center; gap: 8px; }
.toggle-sm { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text-paragraph); cursor: pointer; }
.toggle-sm input { width: 12px; height: 12px; accent-color: var(--accent-pink); cursor: pointer; margin: 0; }
.avg-window { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.ctrl-label { font-size: 11px; color: var(--text-paragraph); }
.pill-radio input { display: none; }
.pill-sm { display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--border-input); border-radius: 5px; padding: 0 9px; height: 26px; font-size: 11px; color: var(--text-paragraph); cursor: pointer; transition: all 0.15s; }
.pill-radio input:checked + .pill-sm { background: var(--accent-pink-dim); border-color: var(--accent-pink-border); color: var(--accent-pink); font-weight: 500; }
.pill-sm:hover { border-color: var(--text-paragraph); }
.chart-area { position: relative; min-height: 0; }
.chart-weight { flex: 3; }
.chart-calorie { flex: 1; }
.chart-area canvas { width: 100% !important; height: 100% !important; }

/* ── Chart info icon ─────────────────────────────────────────── */
.chart-info-wrap {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 10;
}
.chart-info-wrap .info-tip {
  right: 0;
  top: 22px;
  width: 280px;
}

/* ── Info icon shared ────────────────────────────────────────── */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-page);
  color: var(--text-paragraph);
  border: 1px solid var(--text-paragraph);
  font-size: 10px;
  font-weight: 700;
  font-style: italic;
  font-family: 'DM Sans', sans-serif;
  cursor: default;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
}

.info-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  flex-shrink: 0;
}

.info-tip {
  display: none;
  position: absolute;
  right: 0;
  top: 22px;
  background: var(--bg-card);
  border: 1px solid var(--accent-pink-border);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-paragraph);
  line-height: 1.55;
  width: 230px;
  z-index: 500;
  white-space: normal;
  pointer-events: none;
}
.info-tip strong { color: var(--text-headline); font-weight: 600; }
.info-tip-left { right: 0; left: auto; }

.info-icon-wrap:hover .info-tip,
.chart-info-wrap:hover .info-tip {
  display: block;
}

/* ── Section nav ─────────────────────────────────────────────── */
.section-nav { position: fixed; right: max(20px, calc((100vw - 920px) / 2 - 80px)); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 12px; z-index: 900; }
.nav-arrow { width: 52px; height: 52px; border-radius: 50%; background: var(--bg-card); border: 1px solid var(--border-card); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
.nav-arrow svg { width: 24px; height: 24px; color: var(--text-paragraph); }
.nav-arrow:hover { border-color: var(--accent-pink); }
.nav-arrow:hover svg { color: var(--accent-pink); }
.nav-arrow:disabled { opacity: 0.2; cursor: default; }
.nav-arrow:disabled:hover { border-color: var(--border-card); }
.nav-arrow:disabled:hover svg { color: var(--text-paragraph); }
.nav-dots { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.nav-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(184,193,236,0.2); cursor: pointer; transition: all 0.2s; }
.nav-dot.active { background: var(--accent-pink); width: 12px; height: 12px; }

.header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-logo { height: 100px; width: auto; display: block; }
.header-intelligence { color: #eebbc3; }
h1 { font-size: 30px; font-weight: 600; letter-spacing: -0.5px; margin: 0; text-align: justify; text-align-last: justify; }
.subtitle { font-size: 16px; color: var(--text-paragraph); margin-top: 2px; }
.header-actions { display: flex; gap: 6px; align-items: center; }
.unit-toggle-group { display: flex; align-items: center; margin-right: 4px; }
.card { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem; }
.card-label { font-size: 11px; color: var(--text-paragraph); text-transform: uppercase; letter-spacing: 1px; font-weight: 500; margin-bottom: 12px; }
.btn-primary { background: var(--accent-pink); color: var(--accent-pink-text); border: none; border-radius: 8px; padding: 10px 20px; font-size: 14px; font-weight: 600; font-family: 'DM Sans', sans-serif; cursor: pointer; transition: opacity 0.15s; white-space: nowrap; }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { background: transparent; color: var(--text-paragraph); border: 1px solid var(--border-input); border-radius: 6px; padding: 6px 14px; font-size: 12px; font-family: 'DM Sans', sans-serif; cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.btn-secondary:hover { border-color: var(--text-paragraph); color: var(--text-headline); }
.btn-danger { border-color: #e06c75 !important; color: #e06c75 !important; }
.btn-danger:hover { background: rgba(224,108,117,0.12) !important; }
.btn-file { display: inline-flex; align-items: center; cursor: pointer; }
.btn-file input[type="file"] { display: none; }
.input-field { background: var(--bg-input); border: 1px solid var(--border-input); border-radius: 8px; padding: 10px 14px; font-size: 14px; font-family: 'DM Sans', sans-serif; color: var(--text-headline); transition: border-color 0.15s; }
.input-field:focus { outline: none; border-color: var(--accent-pink); }
.input-field::placeholder { color: var(--text-muted); }
.input-field::-webkit-calendar-picker-indicator { filter: invert(0.7); }
/* iOS Safari enforces a large intrinsic min-width on date inputs, overriding flex stretch.
   Scoped to mobile-mode only so desktop browser layout is not affected. */
body.mobile-mode input[type="date"].input-field { width: 100%; min-width: 0; }
.input-note { width: 200px; flex-shrink: 0; }
.input-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.event-checkboxes { display: flex; flex-direction: column; gap: 4px; }
.event-row { display: flex; align-items: center; gap: 8px; }
.event-icon { font-size: 12px; width: 14px; text-align: center; flex-shrink: 0; }
.event-icon-star { color: var(--event-star); }
.event-icon-tri { color: var(--event-tri); }
.event-cb { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-paragraph); cursor: pointer; white-space: nowrap; }
.event-cb input { width: 13px; height: 13px; accent-color: var(--accent-pink); cursor: pointer; margin: 0; }
.signal-box { background: var(--bg-card); border: 2px solid #fffffe; border-radius: 12px; padding: 1rem 1.5rem; text-align: center; }
.signal-text { font-size: 22px; font-weight: 600; letter-spacing: -0.5px; color: var(--text-headline); line-height: 1.4; }

/* Goal date pair */
.goal-date-pair { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.goal-date-label { font-size: 9px; color: var(--text-muted); font-weight: 500; line-height: 1; }
#goalInputCard .input-row { align-items: flex-end; }
#goalInputCard .input-row .btn-primary { height: 42px; }

/* Goal hint */
.goal-hint { font-size: 12px; font-style: italic; color: var(--text-paragraph); line-height: 1.4; white-space: nowrap; }

/* Goal unit select */
.goal-unit-select {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  padding: 10px 10px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-paragraph);
  cursor: pointer;
  transition: border-color 0.15s;
  height: 42px;
  appearance: none;
  -webkit-appearance: none;
  min-width: 52px;
  text-align: center;
}
.goal-unit-select:focus { outline: none; border-color: var(--accent-pink); }

/* Goal rate sign toggle */
.goal-rate-wrap { display: flex; align-items: center; gap: 6px; width: 170px; flex-shrink: 0; }
.goal-rate-wrap .input-field { flex: 1; min-width: 0; }
.btn-sign-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  font-size: 20px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  height: 42px;
  width: 42px;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.btn-sign-toggle[data-sign="-1"] { color: #ff6b6b; border-color: rgba(255,107,107,.5); }
.btn-sign-toggle[data-sign="1"]  { color: #a8e6cf; border-color: rgba(168,230,207,.5); }
.btn-sign-toggle:hover { opacity: 0.8; }

/* Save toast */
.save-toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.8);
  background: var(--accent-pink); color: var(--accent-pink-text);
  padding: 16px 40px; border-radius: 14px;
  font-size: 20px; font-weight: 600; font-family: 'DM Sans', sans-serif;
  opacity: 0; pointer-events: none; z-index: 2000;
  transition: opacity 0.25s, transform 0.25s;
}
.save-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* Info cards */
.info-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.info-card { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 12px; padding: 1rem 1.25rem; display: flex; flex-direction: column; justify-content: space-between; min-height: 72px; }
.info-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.info-title { font-size: 11px; color: var(--text-paragraph); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; flex: 1; }
.info-subtitle { text-transform: uppercase; }
.info-value { font-size: 24px; font-weight: 500; font-family: 'JetBrains Mono', monospace; color: var(--text-headline); margin-top: 4px; white-space: nowrap; }
.info-card-deficit { border: 1px solid #fffffe; }
.info-bracket { font-weight: 400; }

.chart-tooltip { position: fixed; background: var(--bg-card); border: 1px solid var(--accent-pink-border); border-radius: 10px; padding: 12px 16px; font-size: 13px; color: var(--text-headline); pointer-events: auto; z-index: 1000; display: none; min-width: 160px; max-width: 320px; }
.chart-tooltip .tt-date { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-paragraph); margin-bottom: 6px; }
.chart-tooltip .tt-weight { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.chart-tooltip .tt-avg { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-paragraph); margin-bottom: 2px; }
.chart-tooltip .tt-events { margin-top: 6px; font-size: 12px; color: var(--text-paragraph); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chart-tooltip .tt-events .ev-star { color: var(--event-star); }
.chart-tooltip .tt-events .ev-tri { color: var(--event-tri); }
.chart-tooltip .tt-note { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-subtle); font-size: 13px; color: var(--accent-pink); line-height: 1.4; word-wrap: break-word; }
.chart-tooltip .tt-actions { display: inline-flex; gap: 4px; margin-left: 6px; }
.chart-tooltip .tt-actions button { background: none; border: none; font-size: 12px; cursor: pointer; opacity: 0.6; padding: 0 2px; }
.chart-tooltip .tt-actions button:hover { opacity: 1; }

/* Calorie tooltip */
.cal-tooltip { max-width: 360px; pointer-events: none; }
.cal-tooltip .cal-tt-text { font-size: 13px; color: var(--text-paragraph); line-height: 1.5; }
.cal-tooltip .cal-tt-value { font-family: 'JetBrains Mono', monospace; font-weight: 500; color: var(--text-headline); display: block; }

/* Goals list */
.goal-list { display: flex; flex-direction: column; gap: 8px; }
.goal-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.goal-row.goal-active { background: var(--accent-pink-dim); border: 1px solid var(--accent-pink-border); }
.goal-row.goal-future { background: rgba(184, 193, 236, 0.06); border: 1px solid rgba(184, 193, 236, 0.18); }
.goal-row.goal-past { background: rgba(184, 193, 236, 0.05); border: 1px solid var(--border-subtle); opacity: 0.65; }
.goal-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; margin-right: 8px; }
.goal-badge-active { background: var(--accent-pink); color: var(--accent-pink-text); }
.goal-badge-future { background: rgba(184, 193, 236, 0.22); color: var(--text-paragraph); }
.goal-badge-past { background: rgba(184, 193, 236, 0.15); color: var(--text-paragraph); }
.goal-info { color: var(--text-headline); }
.goal-dates { color: var(--text-paragraph); font-size: 12px; margin-left: 8px; }
.goal-actions { display: flex; gap: 4px; }
.goal-actions button { background: none; border: none; font-size: 14px; cursor: pointer; opacity: 0.45; padding: 2px 4px; transition: opacity 0.15s; }
.goal-actions button:hover { opacity: 1; }

.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table .col-date { width: 18%; } .data-table .col-weight { width: 14%; } .data-table .col-interp { width: 10%; }
.data-table .col-note { width: 24%; } .data-table .col-events { width: 20%; } .data-table .col-actions { width: 14%; }
.data-table th { text-align: left; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); }
.data-table td { padding: 10px 10px; font-size: 13px; font-family: 'JetBrains Mono', monospace; border-bottom: 1px solid var(--border-subtle); color: var(--text-headline); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table .td-note { font-family: 'DM Sans', sans-serif; font-size: 12px; color: var(--accent-pink); }
.data-table .td-events { font-family: 'DM Sans', sans-serif; font-size: 11px; color: var(--text-paragraph); }
.data-table .interpolated-row td { background: var(--accent-pink-dim); color: var(--text-paragraph); }
.data-table .interp-marker { color: var(--accent-pink); font-family: 'DM Sans', sans-serif; font-size: 11px; }
.data-table button { background: none; border: none; font-size: 14px; cursor: pointer; opacity: 0.45; padding: 2px 4px; transition: opacity 0.15s; }
.data-table button:hover { opacity: 1; }

@media (max-width: 1100px) { .section-nav { right: 10px; } .nav-arrow { width: 40px; height: 40px; } .nav-arrow svg { width: 18px; height: 18px; } }
@media (max-width: 700px) { .info-cards { grid-template-columns: 1fr 1fr; } .header { flex-direction: column; align-items: flex-start; } .chart-controls-row { flex-direction: column; align-items: flex-start; } .avg-window { margin-left: 0; } .section-nav { display: none; } .input-row { flex-direction: column; align-items: stretch; } .input-row .input-field, .input-note { width: 100%; } }
@media (max-width: 480px) { .info-cards { grid-template-columns: 1fr; } }

/* ── Large screens (≥ 1440px) ───────────────────────────────── */
@media (min-width: 1440px) {
  .section-inner { max-width: 1200px; }
  .section-nav { right: max(20px, calc((100vw - 1200px) / 2 - 80px)); }

  h1 { font-size: 38px; }
  .subtitle { font-size: 20px; }
  .header-logo { height: 130px; }

  .card { padding: 1.6rem 1.8rem; border-radius: 14px; }
  .card-label { font-size: 13px; }

  .input-field { font-size: 16px; padding: 12px 16px; }
  .input-note { width: 240px; }
  .btn-primary { font-size: 16px; padding: 12px 26px; }
  .btn-secondary { font-size: 14px; padding: 8px 18px; }
  .event-cb { font-size: 14px; }
  .event-icon { font-size: 14px; }

  .info-cards { gap: 16px; }
  .info-card { padding: 1.25rem 1.6rem; min-height: 90px; border-radius: 14px; }
  .info-title { font-size: 13px; }
  .info-value { font-size: 30px; }
  .signal-box { padding: 1.25rem 2rem; border-radius: 14px; }
  .signal-text { font-size: 28px; }

  .chart-wrapper { padding: 14px 16px; border-radius: 14px; }
  .chart-controls-row { gap: 14px; margin-bottom: 10px; }
  .range-button { font-size: 13px; height: 30px; padding: 3px 14px; }
  .pill-sm { height: 30px; font-size: 13px; padding: 0 11px; }
  .toggle-sm { font-size: 13px; }
  .toggle-sm input { width: 14px; height: 14px; }
  .ctrl-label { font-size: 13px; }
  .input-sm { font-size: 13px; height: 30px; }
  .btn-sm { font-size: 13px; height: 30px; padding: 3px 12px; }
  .date-pair label { font-size: 13px; }

  .goal-row { font-size: 15px; padding: 12px 16px; }
  .goal-badge { font-size: 12px; }
  .goal-dates { font-size: 14px; }
  .goal-unit-select { font-size: 16px; height: 46px; }

  .data-table th { font-size: 13px; padding: 10px 12px; }
  .data-table td { font-size: 15px; padding: 12px 12px; }

  .account-toggle-btn {
    height: 38px;
    font-size: 12px;
    background: transparent;
    color: var(--text-paragraph);
    border: 1px solid var(--border-input);
    border-radius: 6px;
    padding: 6px 14px;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    display: flex;
    align-items: center;
  }
  .account-toggle-btn:hover {
    border-color: var(--text-paragraph);
    color: var(--text-headline);
  }
  .chart-controls-dropdown-group .account-toggle-btn { height: 30px; font-size: 11px; }
  .btn-faq { width: 48px; height: 48px; }
}

/* ── Very large screens (≥ 1920px) ──────────────────────────── */
@media (min-width: 1920px) {
  .section-inner { max-width: 1440px; }
  .section-nav { right: max(20px, calc((100vw - 1440px) / 2 - 80px)); }

  h1 { font-size: 44px; }
  .subtitle { font-size: 22px; }
  .header-logo { height: 150px; }

  .info-value { font-size: 34px; }
  .signal-text { font-size: 32px; }
  .info-title { font-size: 14px; }

  .input-field { font-size: 17px; }
  .btn-primary { font-size: 17px; }
  .data-table td { font-size: 16px; }
}

/* ── Card header row ────────────────────────────────────────── */
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-header-row .card-label { margin-bottom: 0; }

/* ── Feature lock overlay ────────────────────────────────────── */
.export-import-group { display: flex; gap: 6px; align-items: center; }
.menu-export-import { display: flex; flex-direction: column; position: relative; }
.deficit-group { grid-row: span 2; display: flex; flex-direction: column; gap: 12px; }

.feature-locked {
  position: relative;
}
.feature-locked::after {
  content: attr(data-lock-label);
  white-space: normal;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  color: var(--accent-pink-text);
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(238, 187, 195, 0.85);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}
[data-feature="exportImport"].feature-locked::after,
[data-feature="goalsExportImport"].feature-locked::after {
  font-size: 9px;
  border-radius: 6px;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE LAYOUT  (≤767px)
   Activated by JS adding .mobile-mode to <body>.
   Desktop layout is completely unaffected.
   ═══════════════════════════════════════════════════════════════ */

/* Hidden by default; JS reveals when mobile */
#mobileLayout { display: none; }
#mobileNav    { display: none; }

/* ── Activate mobile mode ─────────────────────────────────────── */
body.mobile-mode .snap-section { display: none !important; }
body.mobile-mode .section-nav  { display: none !important; }

body.mobile-mode #mobileLayout {
  display: flex;
  flex-direction: row;
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: 48px;
  overflow-x: scroll;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: none;
}

body.mobile-mode .msec {
  width: 100vw;
  min-width: 100vw;
  height: calc(100dvh - 48px);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Sections that need internal scrolling */
body.mobile-mode .msec-4,
body.mobile-mode .msec-5 {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Mobile nav bar ───────────────────────────────────────────── */
body.mobile-mode #mobileNav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 48px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-card);
  z-index: 1000;
}

.mnav-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(184,193,236,0.25);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.mnav-dot.active {
  background: var(--accent-pink);
  width: 10px; height: 10px;
}

/* ── Section 1 — Input + Stats (merged) ──────────────────────── */
body.mobile-mode .msec-1 {
  padding: 10px 14px 8px;
  gap: 0;
  justify-content: space-between;
  overflow: hidden;
}

body.mobile-mode .msec-1 .header {
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  flex-direction: row;
  gap: 8px;
  flex-shrink: 0;
}

body.mobile-mode .msec-1 .header-brand { gap: 8px; align-items: center; }
body.mobile-mode .msec-1 .header-logo { height: 60px; }

body.mobile-mode .msec-1 h1 {
  font-size: clamp(16px, 4.9vw, 22px);
  letter-spacing: -0.3px;
  text-align: left;
  text-align-last: unset;
}

body.mobile-mode .msec-1 .subtitle { font-size: clamp(10px, 3.1vw, 13px); text-align: left; }

body.mobile-mode .msec-1 .header-actions {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Account dropdown */
.account-dropdown-group { position: relative; flex-shrink: 0; }
.account-toggle-btn {
  background: transparent;
  color: var(--text-paragraph);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  height: 34px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
}
.account-toggle-btn:hover { border-color: var(--text-paragraph); color: var(--text-headline); }
.account-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  min-width: 148px;
  z-index: 200;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.account-dropdown.open { display: block; }
.account-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-paragraph);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.account-dropdown-item:hover { background: rgba(184,193,236,0.08); color: var(--text-headline); }
.account-dropdown-danger { color: #e06c75 !important; }
.account-dropdown-danger:hover { background: rgba(224,108,117,0.12) !important; }

/* Anchor and label items inside dropdown look identical to button items */
a.account-dropdown-item {
  display: block;
  text-decoration: none;
}
a.account-dropdown-item:hover { background: rgba(184,193,236,0.08); color: var(--text-headline); }
.account-dropdown-label {
  display: block;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
}
.account-dropdown-label input[type="file"] { display: none; }

/* New reading card — compact */
body.mobile-mode .msec-1 .card {
  margin-bottom: 0;
  flex-shrink: 0;
  padding: 8px 10px;
}
body.mobile-mode .msec-1 .card .card-header-row {
  margin-bottom: 6px;
  align-items: center;
}
body.mobile-mode .msec-1 .card-label { font-size: 9px; margin-bottom: 0; }

body.mobile-mode .msec-1 .input-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 5px;
  align-items: stretch;
}

body.mobile-mode .msec-1 #date {
  flex: 0 0 100%;
  box-sizing: border-box;
  font-size: 12px;
  padding: 7px 8px;
  -webkit-appearance: none;
  appearance: none;
}

body.mobile-mode .msec-1 #weight {
  flex: 0 0 100%;
  box-sizing: border-box;
  font-size: 12px;
  padding: 7px 8px;
}

body.mobile-mode .msec-1 #note {
  flex: 0 0 100%;
  box-sizing: border-box;
  font-size: 12px;
  padding: 7px 8px;
}

body.mobile-mode .msec-1 .event-checkboxes {
  flex: 0 0 100%;
  gap: 3px;
}

body.mobile-mode .msec-1 .event-row { gap: 8px; }
body.mobile-mode .msec-1 .event-cb { font-size: 11px; }

body.mobile-mode .msec-1 .btn-primary {
  flex: 0 0 100%;
  padding: 9px 16px;
  font-size: 13px;
}

/* Info cards — compact */
body.mobile-mode .msec-1 .info-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Reorder cards: current weight | forecast weight */
body.mobile-mode #icCW { order: 1; }
body.mobile-mode #icFW { order: 2; }
/* deficit-group spans full row, shows both side by side */
body.mobile-mode .msec-1 .deficit-group {
  order: 3;
  grid-column: 1 / -1;
  display: flex;
  flex-direction: row;
  gap: 5px;
  grid-row: unset;
}
body.mobile-mode .msec-1 .deficit-group .info-card {
  flex: 1;
  min-width: 0;
}
body.mobile-mode #icCS { order: 4; }
body.mobile-mode #icCG { order: 5; }

body.mobile-mode .msec-1 .info-card {
  min-height: 0;
  padding: 5px 7px;
  overflow: hidden;
}

body.mobile-mode .msec-1 .info-title {
  font-size: 9px;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.2;
}

body.mobile-mode .msec-1 .info-value {
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

body.mobile-mode .msec-1 .signal-box {
  padding: 8px 12px;
  flex-shrink: 0;
}

body.mobile-mode .msec-1 .signal-text {
  font-size: clamp(16px, 4.8vw, 20px);
  white-space: normal;
  line-height: 1.35;
}

/* ── Section 2 — Charts ───────────────────────────────────────── */
body.mobile-mode .msec-2 {
  padding: 8px 10px 8px;
  gap: 0;
}

body.mobile-mode .msec-2 .chart-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 8px;
}

/* Simplified controls: show range + avg only, hide date-range & toggles */
body.mobile-mode .msec-2 .chart-controls-row {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

/* Unify range buttons and Controls button height on mobile */
body.mobile-mode .msec-2 .range-button {
  height: 30px;
}
body.mobile-mode .msec-2 .chart-controls-dropdown-group .account-toggle-btn {
  height: 30px;
  border-radius: 5px;
  font-size: 11px;
  padding: 0 10px;
}

body.mobile-mode .msec-2 .date-range  { display: none; }
body.mobile-mode .msec-2 .toggle-group { display: none; }

/* Controls dropdown (mobile chart section) */
.chart-controls-dropdown-group { position: relative; flex-shrink: 0; display: block; }
.toggle-group { display: none; }
/* Controls button inside chart controls row — match 26px row height on desktop */
.chart-controls-dropdown-group .account-toggle-btn {
  height: 26px;
  border-radius: 5px;
  font-size: 11px;
  padding: 0 10px;
}
.account-dropdown-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.account-dropdown-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent-pink);
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

body.mobile-mode .msec-2 .avg-window {
  margin-left: auto;
}

body.mobile-mode .msec-2 .chart-area {
  min-height: 0;
}

/* Weight chart gets more vertical space */
body.mobile-mode .msec-2 .chart-weight  { flex: 2.5; }
body.mobile-mode .msec-2 .chart-calorie { flex: 1; }

/* ── Section 3 — Goals ────────────────────────────────────────── */
body.mobile-mode .msec-3 {
  padding: 14px 16px 14px;
  gap: 12px;
}

body.mobile-mode .msec-3 .card {
  margin-bottom: 0;
}

/* Stack goal input row on mobile */
body.mobile-mode .msec-3 #goalInputCard .input-row {
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

body.mobile-mode .msec-3 #goalInputCard .input-field,
body.mobile-mode .msec-3 #goalInputCard .goal-unit-select,
body.mobile-mode .msec-3 #goalInputCard .btn-primary {
  width: 100%;
  box-sizing: border-box;
}
body.mobile-mode .msec-3 #goalInputCard input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}
body.mobile-mode .msec-3 #goalInputCard .goal-rate-wrap {
  width: 100%;
}
body.mobile-mode .msec-3 #goalInputCard .goal-rate-wrap .input-field {
  width: auto;
  flex: 1;
}

body.mobile-mode .msec-3 #goalInputCard .goal-hint {
  white-space: normal;
  font-size: 11px;
}

/* Goals list: scrollable */
body.mobile-mode .msec-3 #currentGoal {
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Hide goals export/import on mobile */
body.mobile-mode [data-feature="goalsExportImport"] { display: none !important; }

body.mobile-mode .msec-3 .card-header-row {
  margin-bottom: 10px;
}

/* ── Section 4 — Table ────────────────────────────────────────── */
body.mobile-mode .msec-4 {
  padding: 14px 16px 14px;
}

body.mobile-mode .msec-4 .card {
  margin-bottom: 0;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.mobile-mode .msec-4 .data-table {
  table-layout: fixed;
}

/* Hide Interp., Events and Note columns on mobile */
body.mobile-mode .msec-4 .col-interp,
body.mobile-mode .msec-4 .col-events,
body.mobile-mode .msec-4 .col-note,
body.mobile-mode .msec-4 tbody td:nth-child(3),
body.mobile-mode .msec-4 tbody td:nth-child(4),
body.mobile-mode .msec-4 tbody td:nth-child(5) {
  display: none;
}

/* Adjust column widths for 3-column mobile table */
body.mobile-mode .msec-4 .col-date    { width: 40%; }
body.mobile-mode .msec-4 .col-weight  { width: 30%; }
body.mobile-mode .msec-4 .col-actions { width: 30%; }

body.mobile-mode .msec-4 .data-table td {
  font-size: 11px;
  padding: 8px 6px;
}

body.mobile-mode .msec-4 .data-table th {
  font-size: 10px;
  padding: 6px 6px;
}

/* Table scroll area */
body.mobile-mode .msec-4 .table-scroll-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* msec-5 is now unused (sections 1+2 merged) */
body.mobile-mode .msec-5 { display: none !important; }

/* More button */
.mobile-more-btn {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  background: transparent;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  color: var(--text-paragraph);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.mobile-more-btn:hover {
  border-color: var(--text-paragraph);
  color: var(--text-headline);
}

/* ── Tap-to-toggle tooltips on mobile ────────────────────────── */
body.mobile-mode .info-icon-wrap .info-tip,
body.mobile-mode .chart-info-wrap .info-tip {
  display: none;
  pointer-events: auto;
}
body.mobile-mode .info-icon-wrap.tip-open .info-tip,
body.mobile-mode .chart-info-wrap.tip-open .info-tip {
  display: block;
  position: fixed;
  top: auto;
  bottom: 60px;
  left: 12px;
  right: 12px;
  width: auto;
  max-width: none;
  z-index: 999;
}
/* Disable hover on mobile (tap takes over) */
body.mobile-mode .info-icon-wrap:hover .info-tip,
body.mobile-mode .chart-info-wrap:hover .info-tip {
  display: none;
}
body.mobile-mode .info-icon-wrap.tip-open:hover .info-tip,
body.mobile-mode .chart-info-wrap.tip-open:hover .info-tip {
  display: block;
}

/* ── Auth screens ────────────────────────────────────────────── */
#loginScreen {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-page);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
#app {
  display: block;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 360px;
  width: 90%;
  text-align: center;
}
.login-logo { height: 80px; width: auto; }
.login-title { font-size: 24px; font-weight: 600; margin: 0; }
.login-subtitle { font-size: 14px; color: var(--text-paragraph); margin: 0; }
.btn-google-signin {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: box-shadow 0.15s;
  width: 100%;
  justify-content: center;
}
.btn-google-signin:hover { box-shadow: 0 1px 6px rgba(0,0,0,0.2); }

/* ─── iOS Install Prompt ──────────────────────────────────────────────────── */
#install-prompt {
  position: fixed;
  bottom: -160px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 420px;
  background: #1e2540;
  border: 1px solid rgba(184, 193, 236, 0.2);
  border-radius: 16px;
  padding: 16px 16px 12px;
  z-index: 9999;
  transition: bottom 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.5);
}

#install-prompt.visible {
  bottom: 24px;
}

#install-prompt-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #b8c1ec;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  opacity: 0.7;
}

#install-prompt-close:hover {
  opacity: 1;
}

#install-prompt-text {
  color: #fffffe;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  margin: 0 28px 10px 0;
}

#install-prompt-text strong {
  color: #eebbc3;
}

#ios-share-icon {
  width: 15px;
  height: 15px;
  fill: #eebbc3;
  vertical-align: middle;
  display: inline-block;
  margin: 0 2px -2px;
}

#ios-prompt-arrow {
  text-align: center;
  color: #eebbc3;
  font-size: 16px;
  animation: ios-bounce 1.6s ease-in-out infinite;
}

@keyframes ios-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(5px); }
}

