:root {
  --bg: #080d18;
  --bg-soft: #0e1626;
  --surface: rgba(20, 30, 49, 0.92);
  --surface-strong: #172236;
  --surface-light: #1e2d45;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f6f8fc;
  --muted: #9aa8ba;
  --muted-2: #748399;
  --accent: #8df0bd;
  --accent-strong: #57dda1;
  --accent-dark: #063724;
  --warning: #ffc66d;
  --danger: #ff8b91;
  --blue: #85b9ff;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 15% -10%, rgba(87, 221, 161, 0.16), transparent 34%),
    radial-gradient(circle at 110% 25%, rgba(133, 185, 255, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--accent); }

.app-shell { width: min(100%, 760px); margin: 0 auto; min-height: 100dvh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(72px + var(--safe-top));
  padding: calc(12px + var(--safe-top)) 20px 12px;
  background: linear-gradient(180deg, rgba(8, 13, 24, 0.97) 68%, rgba(8, 13, 24, 0));
  backdrop-filter: blur(18px);
}
.brand-row { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px;
  background: var(--accent); color: var(--accent-dark); font-weight: 900; letter-spacing: -0.04em;
  box-shadow: 0 10px 26px rgba(87, 221, 161, 0.22);
}
.topbar h1 { margin: 1px 0 0; font-size: 20px; line-height: 1; letter-spacing: .04em; }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.icon-button {
  width: 44px; height: 44px; border: 1px solid var(--line-strong); border-radius: 15px; background: rgba(255,255,255,.04);
  font-size: 24px; line-height: 1; cursor: pointer;
}

#app-main { padding: 6px 16px calc(104px + var(--safe-bottom)); }
.view { display: none; animation: viewIn .24s ease; }
.view.is-active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.hero-card {
  display: grid; grid-template-columns: 1fr 112px; gap: 14px; align-items: center;
  min-height: 190px; padding: 24px; border: 1px solid rgba(141, 240, 189, 0.18); border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(30, 53, 65, .98), rgba(14, 22, 38, .98)); box-shadow: var(--shadow); overflow: hidden;
}
.hero-card h2 { margin: 8px 0 10px; font-size: clamp(27px, 7vw, 38px); line-height: 1.08; letter-spacing: -.04em; }
.hero-copy { margin: 0; color: #c5cfdb; font-size: 14px; line-height: 1.65; }
.phase-ring { position: relative; width: 112px; height: 112px; }
.phase-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.phase-ring circle { fill: none; stroke-width: 9; }
.ring-bg { stroke: rgba(255,255,255,.08); }
.ring-value { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 301.59; stroke-dashoffset: 301.59; transition: stroke-dashoffset .6s ease; }
.phase-ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.phase-ring-label strong { font-size: 30px; line-height: 1; }
.phase-ring-label span { color: var(--muted); font-size: 11px; margin-top: 4px; }

.priority-strip { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding: 14px 2px 2px; }
.priority-strip::-webkit-scrollbar { display: none; }
.priority-strip span { flex: 0 0 auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.035); color: #b9c4d2; font-size: 11px; font-weight: 700; }

.card {
  margin-top: 16px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(23,34,54,.96), rgba(15,24,40,.96)); box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.compact-card { padding: 18px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading.compact { margin: 0 0 12px; }
.section-heading h2, .card > h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.025em; }
.status-pill { display: inline-flex; align-items: center; min-height: 29px; padding: 5px 10px; border-radius: 999px; background: rgba(141,240,189,.12); color: var(--accent); font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-pill.neutral { background: rgba(255,255,255,.06); color: var(--muted); }
.status-pill.warn { background: rgba(255,198,109,.12); color: var(--warning); }
.status-pill.good { background: rgba(141,240,189,.12); color: var(--accent); }

.form-grid { display: grid; gap: 13px; }
.form-grid.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-width { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; min-width: 0; }
.field label, .field legend { color: #cbd4df; font-size: 12px; font-weight: 750; }
.field label span, .field legend span { color: var(--muted-2); font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 14px; outline: none;
  background: rgba(5, 10, 20, .44); color: var(--text); padding: 12px 13px; font-size: 16px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
textarea { resize: vertical; min-height: 92px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-strong); box-shadow: 0 0 0 3px rgba(87,221,161,.12); background: rgba(5,10,20,.64); }
input::placeholder, textarea::placeholder { color: #59687b; }
.no-border { border: 0; padding: 0; margin: 16px 0 0; }
.segmented { display: grid; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 16px; background: rgba(2,7,14,.35); }
.segmented-three { grid-template-columns: repeat(3, 1fr); }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; opacity: 0; pointer-events: none; clip: rect(0 0 0 0); clip-path: inset(50%); }
.segmented span { display: grid; place-items: center; min-height: 42px; border-radius: 11px; color: var(--muted); font-size: 13px; font-weight: 750; }
.segmented input:checked + span { background: var(--surface-light); color: var(--text); box-shadow: 0 5px 16px rgba(0,0,0,.22); }
.details-block { margin: 15px 0 0; border-top: 1px solid var(--line); }
.details-block summary { list-style: none; padding: 17px 2px 2px; color: var(--blue); font-size: 13px; font-weight: 750; cursor: pointer; }
.details-block summary::-webkit-details-marker { display: none; }
.details-block summary::after { content: "＋"; float: right; }
.details-block[open] summary::after { content: "−"; }
.details-content { padding-top: 15px; }
.form-actions { display: flex; gap: 9px; margin-top: 18px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 12px 17px; border: 1px solid transparent;
  border-radius: 14px; font-size: 14px; font-weight: 800; cursor: pointer; text-decoration: none; transition: transform .12s ease, opacity .12s ease;
}
.button:active { transform: scale(.985); }
.button.primary { flex: 1; background: var(--accent); color: var(--accent-dark); }
.button.secondary { background: rgba(133,185,255,.13); border-color: rgba(133,185,255,.2); color: #bcd8ff; }
.button.ghost { background: rgba(255,255,255,.045); border-color: var(--line-strong); color: var(--text); }
.button.danger { background: rgba(255,139,145,.1); border-color: rgba(255,139,145,.24); color: var(--danger); }
.form-message { min-height: 18px; margin: 11px 2px 0; color: var(--accent); font-size: 12px; }
.is-hidden { display: none !important; }

.score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.score-grid > div { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.score-grid span { display: block; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-grid strong { display: block; margin-top: 7px; font-size: 15px; }
.big-score { color: var(--accent); font-size: 27px; letter-spacing: -.04em; }

.page-intro { padding: 12px 6px 4px; }
.page-intro h2 { margin: 6px 0 8px; font-size: 34px; letter-spacing: -.045em; }
.page-intro p:last-child { margin: 0; max-width: 580px; color: var(--muted); line-height: 1.65; font-size: 14px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 14px; }
.metric-card { min-height: 102px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(23,34,54,.88); }
.metric-card.featured { background: linear-gradient(145deg, var(--accent), #64dca5); color: var(--accent-dark); }
.metric-card span { display: block; color: var(--muted); font-size: 10px; font-weight: 700; }
.metric-card.featured span, .metric-card.featured small { color: rgba(6,55,36,.74); }
.metric-card strong { display: inline-block; margin-top: 12px; font-size: 24px; letter-spacing: -.04em; }
.metric-card small { margin-left: 3px; color: var(--muted-2); font-size: 10px; }
.chart-wrap { position: relative; min-height: 250px; }
#weight-chart { display: block; width: 100%; height: 250px; }
.chart-legend { color: var(--muted); font-size: 10px; white-space: nowrap; }
.dot { display: inline-block; width: 14px; height: 2px; margin: 0 4px 2px 8px; background: var(--accent); }
.dot.dashed { background: repeating-linear-gradient(90deg, var(--blue) 0 3px, transparent 3px 6px); }
.empty-state { margin: 16px 0 0; color: var(--muted-2); text-align: center; font-size: 12px; }
.review-lead { margin: 0; color: #d3dbe5; line-height: 1.65; }
.review-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.review-facts > div { padding: 11px; border-radius: 13px; background: rgba(255,255,255,.035); }
.review-facts span { display: block; color: var(--muted); font-size: 9px; }
.review-facts strong { display: block; margin-top: 6px; font-size: 14px; }
.recommendation { padding: 14px; border-left: 3px solid var(--accent); border-radius: 4px 13px 13px 4px; background: rgba(141,240,189,.07); color: #d8e8df; font-size: 13px; line-height: 1.65; }
.history-list { display: grid; gap: 9px; }
.history-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.025); }
.history-date { width: 45px; text-align: center; }
.history-date strong { display: block; font-size: 18px; }
.history-date span { color: var(--muted); font-size: 9px; }
.history-main strong { font-size: 16px; }
.history-main p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.history-actions { display: flex; gap: 4px; }
.mini-button { min-width: 36px; min-height: 36px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.04); color: var(--muted); cursor: pointer; }
.text-button { border: 0; background: none; color: var(--blue); font-size: 12px; font-weight: 750; cursor: pointer; padding: 4px; }

.goal-banner { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 16px; overflow: hidden; border: 1px solid rgba(141,240,189,.2); border-radius: 20px; background: rgba(141,240,189,.18); }
.goal-banner > div { padding: 17px; background: #11251f; }
.goal-banner span { display: block; color: #85aa9b; font-size: 10px; }
.goal-banner strong { display: block; margin-top: 7px; color: var(--accent); font-size: 18px; }
.projection-card { background: linear-gradient(145deg, rgba(25,44,58,.98), rgba(14,22,38,.98)); }
.projection-main h2 { margin: 6px 0 8px; font-size: 22px; }
.projection-main p:last-child { margin: 0; color: #c9d3df; line-height: 1.65; font-size: 13px; }
.projection-values { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.projection-values > div { padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(0,0,0,.13); }
.projection-values span { display: block; color: var(--muted); font-size: 10px; }
.projection-values strong { display: block; margin-top: 6px; }
.caution { margin: 14px 0 0; padding: 12px; border-radius: 12px; background: rgba(255,198,109,.08); color: #e9d2aa; font-size: 11px; line-height: 1.65; }
.roadmap { display: grid; gap: 11px; margin-top: 16px; }
.roadmap-week { position: relative; display: grid; grid-template-columns: 56px 1fr; gap: 14px; padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: rgba(23,34,54,.78); overflow: hidden; }
.roadmap-week.is-current { border-color: rgba(141,240,189,.35); background: linear-gradient(135deg, rgba(26,52,51,.96), rgba(20,31,49,.96)); }
.roadmap-week.is-complete { opacity: .72; }
.week-index { display: grid; align-content: start; justify-items: center; }
.week-index span { color: var(--muted); font-size: 9px; }
.week-index strong { margin-top: 3px; font-size: 27px; }
.week-copy h3 { margin: 0; font-size: 16px; }
.week-copy p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.week-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.week-tags span { padding: 5px 7px; border-radius: 999px; background: rgba(255,255,255,.055); color: #b9c5d4; font-size: 9px; }
.week-state { position: absolute; top: 12px; right: 12px; padding: 4px 7px; border-radius: 999px; background: rgba(141,240,189,.1); color: var(--accent); font-size: 9px; font-weight: 800; }
.rule-list { display: grid; gap: 9px; margin-top: 15px; }
.rule-list article { padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.rule-list strong { color: var(--accent); font-size: 13px; }
.rule-list p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

.recommended-badge { align-self: flex-start; padding: 6px 9px; border-radius: 999px; background: var(--accent); color: var(--accent-dark); font-size: 10px; font-weight: 900; }
.mode-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 15px; background: rgba(0,0,0,.15); }
.mode-selector button { min-height: 43px; padding: 7px 5px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 750; cursor: pointer; }
.mode-selector button.is-selected { background: var(--surface-light); color: var(--text); }
.mode-description { min-height: 44px; margin: 14px 2px 0; color: #c7d1dd; font-size: 12px; line-height: 1.6; }
.macro-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 15px; }
.macro-grid article { padding: 11px 8px; border: 1px solid var(--line); border-radius: 14px; text-align: center; background: rgba(255,255,255,.026); }
.macro-grid span { display: block; min-height: 25px; color: var(--muted); font-size: 8px; line-height: 1.3; }
.macro-grid strong { display: block; font-size: 19px; }
.macro-grid small { display: block; margin-top: 2px; color: var(--muted-2); font-size: 8px; }
.micro-copy { margin: 13px 0 0; color: var(--muted-2); font-size: 10px; line-height: 1.65; }
.meal-timeline { display: grid; gap: 0; margin-top: 14px; }
.meal-timeline article { display: grid; grid-template-columns: 46px 1fr; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.meal-timeline article:last-child { border-bottom: 0; padding-bottom: 0; }
.meal-timeline article > span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: rgba(141,240,189,.09); color: var(--accent); font-size: 12px; font-weight: 850; }
.meal-timeline strong { font-size: 13px; }
.meal-timeline p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.swap-list { display: grid; gap: 8px; margin-top: 14px; }
.swap-list article { display: grid; grid-template-columns: 1fr 26px 1.25fr; align-items: center; gap: 4px; min-height: 62px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; }
.swap-before { color: #d7b1b4; font-size: 11px; text-decoration: line-through; text-decoration-color: rgba(255,139,145,.55); }
.arrow { color: var(--muted-2); text-align: center; }
.swap-after { color: #cfe4d8; font-size: 11px; font-weight: 700; line-height: 1.45; }
.numbered-steps { display: grid; gap: 13px; list-style: none; padding: 0; margin: 15px 0 0; }
.numbered-steps li { display: grid; grid-template-columns: 35px 1fr; gap: 11px; }
.numbered-steps li > span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(141,240,189,.3); color: var(--accent); font-size: 12px; font-weight: 900; }
.numbered-steps strong { font-size: 13px; }
.numbered-steps p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

.divider { height: 1px; border: 0; background: var(--line); margin: 22px 0; }
.estimate-box { margin-bottom: 13px; padding: 12px; border-radius: 13px; background: rgba(133,185,255,.07); color: #c3d8f4; font-size: 11px; line-height: 1.6; }
.data-actions { display: grid; gap: 9px; margin-top: 15px; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.reference-list { display: grid; gap: 9px; margin: 14px 0 0; padding-left: 18px; }
.reference-list li { color: var(--muted); font-size: 11px; }
.reference-list a { line-height: 1.45; text-underline-offset: 3px; }
.medical-note { margin: 16px 0; padding: 17px; border: 1px solid rgba(255,198,109,.18); border-radius: 18px; background: rgba(255,198,109,.06); }
.medical-note strong { color: var(--warning); font-size: 12px; }
.medical-note p { margin: 7px 0 0; color: #d1c2aa; font-size: 10px; line-height: 1.7; }

.bottom-nav {
  position: fixed; left: 50%; bottom: 0; z-index: 30; transform: translateX(-50%); display: grid; grid-template-columns: repeat(5, 1fr);
  width: min(100%, 760px); min-height: calc(68px + var(--safe-bottom)); padding: 7px 9px calc(7px + var(--safe-bottom));
  border-top: 1px solid var(--line); background: rgba(10,16,28,.94); backdrop-filter: blur(22px);
}
.nav-item { min-height: 53px; border: 0; border-radius: 14px; background: transparent; color: var(--muted-2); font-size: 10px; font-weight: 750; cursor: pointer; }
.nav-item span { display: block; }
.nav-icon { min-height: 24px; font-size: 17px; line-height: 1.2; }
.nav-item.is-active { background: rgba(141,240,189,.09); color: var(--accent); }

#install-dialog { width: min(92%, 430px); border: 0; padding: 0; border-radius: 24px; background: transparent; color: var(--text); }
#install-dialog::backdrop { background: rgba(0,0,0,.67); backdrop-filter: blur(5px); }
.dialog-card { position: relative; padding: 25px; border: 1px solid var(--line-strong); border-radius: 24px; background: #121d2f; box-shadow: var(--shadow); }
.dialog-card h2 { margin: 6px 0 12px; }
.dialog-card ol { padding-left: 22px; color: #d7dfe9; font-size: 13px; line-height: 1.9; }
.dialog-card p:last-of-type { color: var(--muted); font-size: 11px; line-height: 1.65; }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border: 0; border-radius: 12px; background: rgba(255,255,255,.05); color: var(--muted); font-size: 22px; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-bottom)); z-index: 50; transform: translate(-50%, 18px); max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 999px; background: #e9fff4; color: #073b28; font-size: 12px; font-weight: 800; opacity: 0; pointer-events: none; transition: .22s ease; box-shadow: 0 10px 30px rgba(0,0,0,.28); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 460px) {
  .hero-card { grid-template-columns: 1fr 92px; min-height: 174px; padding: 20px; }
  .phase-ring { width: 92px; height: 92px; }
  .hero-card h2 { font-size: 27px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .macro-grid { grid-template-columns: repeat(2, 1fr); }
  .macro-grid span { min-height: auto; }
  .review-facts { grid-template-columns: 1fr; }
}

@media (min-width: 640px) {
  #app-main { padding-left: 24px; padding-right: 24px; }
  .card { padding: 24px; }
  .roadmap { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 116px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
