:root {
  --paper: #FFF6EC;
  --ink: #3A2416;
  --sea: #C45312;
  --citrus: #E8943A;
  --citrus-deep: #C45312;
  --card: #FFFFFF;
  --line: rgba(58, 36, 22, .12);
  --muted: #6B5344;
  --clay: #9C3B24;
  --serif: "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --sans: "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  --shadow: 0 10px 28px rgba(120, 64, 16, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(233, 138, 68, .08), transparent 50%),
    var(--paper);
  font: 17px/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
  overflow-x: clip;
}
body.has-nav { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
img, svg, canvas { max-width: 100%; }
a { color: var(--sea); }
button, input, select { font: inherit; color: inherit; }
h1, h2, .brand, .seal, .figure, .dial-copy strong {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: .01em;
}
h1 { font-size: 30px; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
main { max-width: 440px; margin: 0 auto; padding: 6px 20px 28px; }

.top {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px;
  padding: calc(6px + env(safe-area-inset-top)) 20px 6px;
  background: rgba(243, 240, 232, .9);
  backdrop-filter: blur(12px);
}
.brand {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--ink); text-decoration: none; font-size: 22px;
}
.top-meta { display: flex; align-items: center; gap: 2px; }
.top-date { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.settings-link {
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 0 2px 0 12px; color: var(--sea); text-decoration: none; font-weight: 600;
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex;
  background: rgba(255, 253, 250, .94);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(12px);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 58px; padding: 6px 0 8px;
  color: var(--muted); text-decoration: none; font-size: 12px;
}
.tabs svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--sea); font-weight: 700; }
.tabs a.on svg { transform: translateY(-1px); }

.kicker { margin: 4px 0 0; color: var(--citrus-deep); font-size: 13px; letter-spacing: .08em; }
.lede { color: var(--muted); margin-bottom: 16px; }
.fine { color: var(--muted); font-size: 13px; line-height: 1.55; }
.dayhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.dayhead h1 { flex: 1; }
.daynav { display: flex; gap: 8px; padding-bottom: 8px; }
.daynav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px;
  color: var(--sea); text-decoration: none; font-size: 14px; font-weight: 600; white-space: nowrap;
}

.ledger {
  background:
    radial-gradient(90% 80% at 100% 0%, rgba(233, 138, 68, .28), transparent 42%),
    var(--sea);
  color: var(--card);
  border-radius: 22px;
  padding: 12px 16px 8px;
  margin: 4px 0 6px;
  box-shadow: var(--shadow);
}
.dial { position: relative; width: 156px; height: 156px; margin: 0 auto; }
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial circle { fill: none; stroke-width: 8; }
.dial .track { stroke: rgba(255, 253, 250, .18); }
.dial .value {
  stroke: var(--citrus);
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: calc(326.73 * (1 - var(--p) / 100));
  animation: ring .9s ease;
}
.dial .value.is-empty { stroke: transparent; }
.dial-copy {
  position: absolute; inset: 32px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.dial-copy strong { font-size: 34px; line-height: 1; color: var(--card); }
.dial-copy small { font-size: 12px; color: rgba(255, 253, 250, .78); }
.dial-caption { text-align: center; margin: 6px 0 0; font-size: 15px; }
.eq { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 12px 0 4px; }
.eq span { font-size: 13px; color: rgba(255, 253, 250, .78); }
.eq b { color: var(--card); font-weight: 600; }
.eq i { font-style: normal; margin-left: 4px; color: #F6D3B0; font-size: 12px; }
@keyframes ring { from { stroke-dashoffset: 326.73; } }

.block, .card {
  background: var(--card);
  border-radius: 24px;
  padding: 18px 16px 16px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}
.card.slim { padding: 14px 16px; }
.card h2, .block h2 { font-size: 20px; }
.ruler { margin: 8px 0; }
.ruler-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.ruler-h b { font-size: 16px; font-variant-numeric: tabular-nums; }
.ruler-h small, .aside { color: var(--muted); font-weight: 500; }
.est {
  font-style: normal; font-size: 11px; letter-spacing: .04em;
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px; color: var(--muted);
}
.bar { height: 7px; margin-top: 6px; background: rgba(24, 60, 52, .08); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--sea); border-radius: 99px; transition: width .7s ease; }
.bar i.carb { background: #3E7A64; }
.bar i.fat { background: var(--citrus); }

.actions { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 2px; }
.actions .btn.primary, .actions-row .btn { width: 100%; }
.actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 16px; border-radius: 16px;
  border: 1px solid rgba(24, 60, 52, .18); background: var(--card); color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.btn.primary { background: var(--sea); border-color: var(--sea); color: #fff; }
.btn.big { width: 100%; min-height: 56px; font-size: 18px; border-radius: 18px; margin-top: 8px; }
.weigh-now input { font-size: 28px; text-align: center; min-height: 68px; border-radius: 20px; }
.calorie-line { font-size: 18px; }
.calorie-line b { font-size: 40px; line-height: 1; }
.goal-line { font-size: 17px; margin-top: 8px; }
.brand { font-size: 20px; }
.btn.small { min-height: 44px; padding: 8px 12px; font-size: 14px; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--sea); outline-offset: 2px;
}

.measure b, .num, .figure, .kpis b { font-variant-numeric: tabular-nums; }
.figure { font-size: 56px; line-height: 1; margin: 4px 0 6px; }
.figure small { font-size: 16px; margin-left: 6px; font-family: var(--sans); color: var(--muted); }
.note-text { font-size: 16px; }
.chart { position: relative; height: 220px; margin: 8px 0; }
.chart.short { height: 180px; }
.entry {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 8px 0;
  border-top: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.entry .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry small, .grow small { color: var(--muted); font-size: 13px; }
.mark, .thumb {
  width: 44px; height: 44px; flex: none; border-radius: 12px;
}
.mark {
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); font-family: var(--serif); color: var(--sea); background: var(--card);
}
.mark.alt { color: var(--citrus-deep); }
.thumb { object-fit: cover; background: #E7E2D6; }
.empty { color: var(--muted); padding: 8px 0 4px; }
.disclaimer, .coach { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 18px; }
.coach a { font-weight: 600; }

.why summary, .fold summary {
  min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--sea);
}
.why.on-dark { color: rgba(255, 253, 250, .82); font-size: 14px; }
.why.on-dark summary { color: rgba(255, 253, 250, .92); }
.why ul { margin: 6px 0 8px; padding-left: 18px; }
.fold { margin-top: 4px; }
.fold.inner { margin-left: 0; }

.toasts { margin: 8px 0; }
.flash {
  padding: 12px 14px; border-radius: 12px; background: #E7F0EB; color: var(--sea);
  animation: settle .35s ease;
}
.flash.warn { background: #F8EBE3; color: var(--clay); }
.flash.ok { background: #E7F0EB; }
@keyframes settle { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.slim { gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid rgba(24, 60, 52, .18); border-radius: 12px;
  background: var(--card); color: var(--ink); font-size: 16px;
}
.grid2, .grid3, .grid4 { display: grid; gap: 10px; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid4 { grid-template-columns: repeat(4, 1fr); }
.req { color: var(--citrus-deep); font-size: 11px; }
.inline { display: flex; gap: 8px; align-items: flex-end; }
.inline .grow, .inline select { flex: 1; }
.search { display: flex; gap: 8px; align-items: center; }
.search input { flex: 1; }
.search .btn { flex: none; }

fieldset.seg-set { border: 0; margin: 0; padding: 0; }
.seg-set legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.seg {
  display: flex; gap: 4px; padding: 4px; overflow-x: auto;
  background: rgba(24, 60, 52, .06); border-radius: 12px;
}
.seg.wrap { flex-wrap: wrap; overflow: visible; }
.seg-opt { position: relative; flex: 1 0 auto; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; }
.seg-opt span, .seg.range a {
  display: flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 10px; border-radius: 9px;
  font-size: 14px; white-space: nowrap; color: var(--muted); text-decoration: none;
}
.seg-opt input:checked + span, .seg.range a.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(24, 60, 52, .08); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--sea); }
.seg.range { margin: 4px 0 8px; }
.seg.range a { flex: 1; }

.picks { display: flex; flex-direction: column; }
.pick {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 8px 0; border: 0; border-top: 1px solid var(--line);
  background: transparent; text-align: left; cursor: pointer;
}
.pick-name { font-weight: 600; color: var(--ink); }
.pick-meta { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pick:active { background: rgba(36, 90, 73, .04); }
.picks.scroll, .scroll { max-height: 420px; overflow: auto; }
.tw-row {
  display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 6px 0; border-top: 1px solid var(--line);
}
.tw-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tw-row select { width: 72px; min-height: 44px; padding: 6px; }

.photo-pick {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 72px; padding: 12px; border: 1.5px dashed rgba(36, 90, 73, .35);
  border-radius: 14px; color: var(--sea); font-weight: 600; background: rgba(255, 253, 250, .7);
}
.photo-pick.small { min-height: 48px; flex: none; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.preview, .meal-photo { width: 100%; max-height: 320px; object-fit: cover; border-radius: 16px; background: #F6E7D6; display: block; }
.preview[hidden], img[hidden] { display: none !important; }
.shared-line {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.shared-text, .shared-kcal { color: var(--ink); text-decoration: none; font-weight: 600; white-space: nowrap; }
.shared-kcal { margin-left: auto; color: var(--sea); }
.diner-picker[open] { flex: 1 0 100%; }
.diner-picker { position: relative; }
.diner-picker summary {
  list-style: none; cursor: pointer; min-height: 44px; padding: 8px 14px;
  border-radius: 999px; background: #FFF1E4; color: var(--sea); font-weight: 700;
}
.diner-picker summary::-webkit-details-marker { display: none; }
.diner-picker form { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0 4px; }
.diner-picker button {
  min-height: 44px; min-width: 64px; padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.diner-picker button.on { background: var(--sea); color: #fff; border-color: var(--sea); }
.text-btn {
  min-width: 44px; min-height: 44px; padding: 8px 4px 8px 10px;
  border: 0; background: transparent; color: var(--sea); font-weight: 600; cursor: pointer;
}
.text-btn.danger { color: var(--clay); }
.end-action { margin: 12px 0 8px; }
.aside { float: right; color: var(--sea); font-family: var(--sans); font-size: 16px; }

.comp { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.comp div { background: var(--card); border-radius: 14px; padding: 12px; border: 1px solid var(--line); }
.comp span, .comp small, .kpis span, .kpis small { display: block; color: var(--muted); font-size: 12px; }
.comp b, .kpis b { font-size: 26px; font-family: var(--serif); font-weight: 600; }
.est-line { font-size: 14px; }
.est-line small { display: block; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.kpis div { padding: 8px 4px; }

label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; }
label.check input { width: 22px; min-height: 22px; }

.gate { min-height: 100vh; }
.gate main { padding-top: 12vh; }
.gate-sheet { max-width: 380px; }
.seal {
  width: 84px; height: 84px; margin: 0 0 18px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--sea); border-radius: 50%;
  color: var(--sea); font-size: 20px;
  animation: seal-in .6s ease;
}
@keyframes seal-in { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }

@media (min-width: 800px) {
  body {
    background:
      linear-gradient(90deg, transparent 0 28px, rgba(36, 90, 73, .14) 28px 29px, transparent 29px),
      radial-gradient(900px 420px at 80% -10%, rgba(233, 138, 68, .1), transparent 46%),
      var(--paper);
  }
}
@media (hover: hover) {
  .entry:hover { background: rgba(36, 90, 73, .035); }
  .pick:hover .pick-name { color: var(--sea); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
