/* health_tracker — 青綠健康主題, mobile-first PWA
   [claude code] 2026-07-05 建檔 */
:root {
  --teal: #14b8a6;
  --emerald: #10b981;
  --emerald-d: #059669;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg1: #ecfdf5;
  --bg2: #f0fdfa;
  --card: #ffffff;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --violet: #8b5cf6;
  --shadow: 0 6px 20px rgba(15, 23, 42, .08);
  --radius: 16px;
  --nav-h: 62px;
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  min-height: 100vh;
  overscroll-behavior-y: none;
}
#app { min-height: 100vh; }

.boot {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--emerald-d); font-weight: 700;
}

/* ───────── layout ───────── */
.screen {
  max-width: 560px; margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + 28px);
  min-height: 100vh;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--teal), var(--emerald));
  color: #fff; margin: 0 -16px 16px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 16px;
  border-radius: 0 0 22px 22px; box-shadow: var(--shadow);
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.topbar .sub { margin-top: 3px; font-size: 13px; opacity: .92; }

/* ───────── card ───────── */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card h2 .ico { font-size: 19px; }
.section-title { font-size: 13px; color: var(--muted); font-weight: 700; margin: 18px 4px 8px; }

/* ───────── todo / home ───────── */
.todo-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 13px; margin-bottom: 9px;
  background: #f8fafc; border: 1.5px solid var(--line);
  cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.todo-row:active { transform: scale(.98); }
.todo-row.done { background: #ecfdf5; border-color: #a7f3d0; }
.todo-row .tico {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.todo-row .tmain { flex: 1; min-width: 0; }
.todo-row .tmain .t1 { font-weight: 700; font-size: 15px; }
.todo-row .tmain .t2 { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.todo-row .tcheck { font-size: 22px; }
.todo-row.done .tcheck { color: var(--emerald); }
.todo-row .tcheck.go { color: var(--muted); font-size: 26px; font-weight: 300; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.stat {
  background: #f8fafc; border: 1.5px solid var(--line); border-radius: 13px;
  padding: 13px; text-align: center;
}
.stat .v { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat .v small { font-size: 13px; font-weight: 700; color: var(--muted); }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat .d-up { color: var(--red); } .stat .d-down { color: var(--emerald); }

/* ───────── buttons ───────── */
.btn {
  appearance: none; border: none; border-radius: 13px; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 700; padding: 13px 18px;
  background: linear-gradient(135deg, var(--teal), var(--emerald)); color: #fff;
  transition: transform .12s, opacity .15s; width: 100%;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.btn.ghost { background: #fff; color: var(--emerald-d); border: 1.5px solid #a7f3d0; }
.btn.gray { background: #f1f5f9; color: var(--ink); }
.btn.danger { background: #fef2f2; color: var(--red); border: 1.5px solid #fecaca; }
.btn.sm { padding: 9px 14px; font-size: 13.5px; width: auto; }
.btn-row { display: flex; gap: 10px; }

/* ───────── forms ───────── */
label.fld { display: block; margin-bottom: 12px; }
label.fld .lab { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 5px; display: block; }
input, select, textarea {
  font-family: inherit; font-size: 16px; width: 100%; padding: 12px 13px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--emerald); }
textarea { resize: vertical; min-height: 60px; }
.big-num { font-size: 30px; font-weight: 800; text-align: center; letter-spacing: 1px; padding: 16px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 9px 15px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .12s;
}
.chip.on { background: var(--emerald); color: #fff; border-color: var(--emerald); }
.chip:active { transform: scale(.95); }

/* ───────── list items ───────── */
.item {
  display: flex; align-items: center; gap: 12px; padding: 11px 2px;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }
.item .ib { font-size: 22px; width: 34px; text-align: center; flex: 0 0 auto; }
.item .im { flex: 1; min-width: 0; }
.item .im .i1 { font-weight: 700; font-size: 14.5px; }
.item .im .i2 { font-size: 12.5px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.item .iv { font-weight: 800; font-size: 15px; white-space: nowrap; }
.item .del { color: var(--red); background: none; border: none; font-size: 18px; padding: 6px; cursor: pointer; opacity: .7; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14px; }

/* ───────── workout hub ───────── */
.hub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hub-card {
  border-radius: var(--radius); padding: 18px 14px; color: #fff; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .12s; text-align: left;
}
.hub-card:active { transform: scale(.97); }
.hub-card .he { font-size: 30px; }
.hub-card .ht { font-weight: 800; font-size: 16px; margin-top: 6px; }
.hub-card .hs { font-size: 12px; opacity: .9; margin-top: 2px; }
.hub-tabata { background: linear-gradient(140deg, #f43f5e, #ec4899); }
.hub-jog    { background: linear-gradient(140deg, #14b8a6, #10b981); }
.hub-aero   { background: linear-gradient(140deg, #3b82f6, #06b6d4); }
.hub-core   { background: linear-gradient(140deg, #8b5cf6, #6366f1); }

/* ───────── SVG trend ───────── */
.trend { width: 100%; height: 170px; display: block; }
.trend .grid-l { stroke: var(--line); stroke-width: 1; }
.trend .line { fill: none; stroke: var(--emerald); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.trend .area { fill: rgba(16,185,129,.12); }
.trend .dot { fill: var(--emerald); }
.trend .lbl { fill: var(--muted); font-size: 10px; }
.trend .tgt { stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 4 3; }

/* ───────── bottom nav ───────── */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 14px rgba(15,23,42,.06);
}
.nav button {
  flex: 1; background: none; border: none; cursor: pointer; font-family: inherit;
  padding: 8px 0 9px; color: var(--muted); display: flex; flex-direction: column;
  align-items: center; gap: 3px; height: var(--nav-h);
}
.nav button .ne { font-size: 22px; transition: transform .15s; }
.nav button .nl { font-size: 11px; font-weight: 600; }
.nav button.on { color: var(--emerald-d); }
.nav button.on .ne { transform: translateY(-2px) scale(1.12); }

/* ───────── modal / sheet ───────── */
.mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  background: #fff; width: 100%; max-width: 560px;
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 90vh; overflow-y: auto; animation: slideup .24s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes slideup { from { transform: translateY(100%); } }
.sheet h3 { margin: 0 0 15px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.sheet .close { position: absolute; }

/* ───────── TABATA fullscreen timer ───────── */
.timer-full {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #fff; text-align: center;
  transition: background .3s;
}
.timer-full.prep { background: linear-gradient(160deg,#475569,#334155); }
.timer-full.work { background: linear-gradient(160deg,#f43f5e,#e11d48); }
.timer-full.rest { background: linear-gradient(160deg,#10b981,#059669); }
.timer-full.done { background: linear-gradient(160deg,#14b8a6,#10b981); }
.timer-phase { font-size: 26px; font-weight: 800; letter-spacing: 3px; }
.timer-count { font-size: 108px; font-weight: 900; line-height: 1; margin: 8px 0; font-variant-numeric: tabular-nums; }
.timer-round { font-size: 18px; opacity: .9; font-weight: 700; }
.timer-full .tbtns { position: absolute; bottom: calc(34px + env(safe-area-inset-bottom)); display: flex; gap: 14px; }
.timer-full .tbtns button {
  background: rgba(255,255,255,.22); color: #fff; border: 2px solid rgba(255,255,255,.5);
  border-radius: 14px; padding: 13px 26px; font-size: 16px; font-weight: 700; cursor: pointer;
}
.pulse-ring { animation: pring 1s ease-in-out infinite alternate; }
@keyframes pring { to { transform: scale(1.06); } }

/* ───────── misc ───────── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 18px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 80; box-shadow: var(--shadow);
  animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } }
.spinner {
  width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--emerald);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.guest { background: #fef3c7; color: #b45309; }
.badge.bound { background: #d1fae5; color: #047857; }
.foot { text-align: center; color: var(--muted); font-size: 11.5px; padding: 14px 0 4px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ───────── auth gate (未綁定登入閘門) ───────── */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 18px; }
.gate-card {
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  padding: 30px 22px 22px; width: 100%; max-width: 400px; text-align: center; position: relative;
}
.gate-back {
  position: absolute; top: 14px; left: 14px; background: none; border: none;
  color: var(--muted); font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; padding: 4px 6px;
}
.gate-back:active { color: var(--emerald-d); }
.gate-logo { font-size: 54px; line-height: 1; }
.gate-title { margin: 8px 0 3px; font-size: 25px; font-weight: 800; }
.gate-sub { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.gate-seg { display: flex; background: #f1f5f9; border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.gate-seg button {
  flex: 1; border: none; background: none; padding: 10px; border-radius: 9px;
  font-family: inherit; font-size: 15px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.gate-seg button.on { background: #fff; color: var(--emerald-d); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.gate-card .fld { text-align: left; }
.gate-ver { margin-top: 18px; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
