/* 版面（母版共用）。顏色、圓角請改 theme.css */
:root {
  --brand: #0f766e; --brand-2: #134e4a; --brand-ink: #fff; --brand-soft: #ccfbf1; --accent: #10b981; --radius: 16px;
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --bg: #f1f5f9; --card: #fff; --danger: #dc2626;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 560px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 8px; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
p { margin: 0 0 12px; }
a { color: var(--brand); }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; padding: 48px 0; }
.small { font-size: 13px; }

.hero {
  position: relative; overflow: hidden; isolation: isolate;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); color: var(--brand-ink);
  margin: 0 -16px 16px; padding: 14px 16px 22px; border-radius: 0 0 28px 28px;
  box-shadow: 0 8px 24px -12px var(--brand-2);
}
/* 裝飾圓：右上大、左下小 */
.hero::before, .hero::after { content: ''; position: absolute; border-radius: 50%; z-index: -1; }
.hero::before { width: 240px; height: 240px; right: -70px; top: -110px; background: rgba(255,255,255,.10); }
.hero::after { width: 140px; height: 140px; left: -50px; bottom: -70px; background: var(--accent); opacity: .35; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brandline { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; letter-spacing: .5px; opacity: .92; }
.brandline img { width: 22px; height: 22px; border-radius: 7px; }
.hero-actions { display: flex; gap: 8px; }
.icon-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--brand-ink); text-decoration: none; font-size: 10px; opacity: .95; }
.icon-btn svg { width: 38px; height: 38px; padding: 9px; border-radius: 50%; background: rgba(255,255,255,.16); }
.icon-btn:active svg { background: rgba(255,255,255,.3); }
.hero-main { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.hero .avatar { width: 64px; height: 64px; flex-shrink: 0; border-radius: 50%; object-fit: cover; background: var(--brand-soft);
  border: 3px solid rgba(255,255,255,.9); box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.hero .who { min-width: 0; }
.hero .greet { font-size: 13px; opacity: .85; }
.hero .t { font-size: 22px; font-weight: 800; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.hero .pill { background: rgba(255,255,255,.18); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600;
  background: var(--brand); color: var(--brand-ink); cursor: pointer; text-decoration: none;
}
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input.code { text-transform: uppercase; letter-spacing: 2px; font-size: 20px; text-align: center; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--ink); font-size: 15px; }
.check input { width: auto; margin-top: 5px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tag.gray { background: var(--line); color: var(--muted); }
.tag.red { background: #fee2e2; color: var(--danger); }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 12px; }
.tabs button, .tabs a { flex: 1; white-space: nowrap; border: 0; background: var(--card); color: var(--muted); padding: 10px 8px; border-radius: 12px; font: inherit; font-weight: 600; text-align: center; text-decoration: none; font-size: 15px; }
.tabs button.on, .tabs a.on { background: var(--brand); color: var(--brand-ink); }

.consent { max-height: 50vh; overflow-y: auto; font-size: 14px; background: var(--bg); border-radius: 10px; padding: 12px; white-space: pre-wrap; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.mono { font-family: ui-monospace, Menlo, monospace; letter-spacing: 1px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(15,23,42,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); z-index: 10;
  pointer-events: none; /* 不擋住下面的按鈕 */
}

/* ---------- 學員畫面 ---------- */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.big { font-size: 24px; font-weight: 700; }
.notice { display: block; background: #fef3c7; color: #92400e; text-decoration: none; font-size: 14px; }
.bar { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: #60a5fa; border-radius: 999px; transition: width .3s; }
.seg button { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 10px 4px; border-radius: 10px; font: inherit; font-size: 14px; }
.seg button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
label.btn { margin: 0; font-size: 16px; }
label.btn.disabled { opacity: .6; pointer-events: none; }
.meal img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; background: var(--bg); display: block; }
.items { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.advice { background: var(--brand-soft); border-radius: 12px; padding: 10px 12px; margin-top: 10px; font-size: 15px; }
.chat #c-list { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.bubble { max-width: 85%; padding: 10px 12px; border-radius: 16px; font-size: 15px; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 4px; }
.bubble.typing { color: var(--muted); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { flex-shrink: 0; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14px; margin: 0; cursor: pointer; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.chat textarea { min-height: 44px; height: 44px; }
.link { border: 0; background: none; color: var(--brand); font: inherit; font-size: 13px; padding: 0 0 0 8px; text-decoration: underline; cursor: pointer; }
.warn { background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px; padding: 12px; margin-top: 12px; font-size: 14px; }
.warn p { margin: 6px 0; }
.photo { position: relative; aspect-ratio: 3 / 4; border: 1px dashed var(--line); border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; margin: 0; background: var(--bg); cursor: pointer; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo span { font-size: 13px; color: var(--muted); }
.photo small { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(15,23,42,.55); color: #fff; font-size: 11px; text-align: center; }
.scroll-x { overflow-x: auto; }
.chart { position: relative; height: 200px; }
.cmp { border-collapse: collapse; width: 100%; font-size: 14px; }
.cmp th, .cmp td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.cmp th:first-child, .cmp td:first-child { text-align: left; color: var(--muted); }

/* ---------- 教練後台 ---------- */
.student { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.student img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--brand-soft); flex-shrink: 0; }
.student .grow { min-width: 0; }
.stat { text-align: center; padding: 12px 8px; }
.stat .big { font-size: 20px; }
.card.medical { border-left: 4px solid var(--danger); }
.card.note { border-left: 4px solid var(--brand); }
.compare figure { margin: 0; }
.compare img, .compare .photo { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; display: flex; }
.compare figcaption { text-align: center; font-size: 13px; color: var(--muted); margin-top: 4px; }
img.thumb { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; display: block; }
details > summary { cursor: pointer; }

/* ---------- 健檢報告 ---------- */
.ritem { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.ritem.low { border-color: #f59e0b; background: #fffbeb; }
.ritem input, .ritem select { padding: 8px 10px; font-size: 15px; }
table.lab td { text-align: left; vertical-align: top; white-space: normal; }
table.lab td:first-child { color: var(--ink); width: 40%; }
table.lab tr.bad td:nth-child(2) b { color: var(--danger); }
.flag { font-size: 12px; font-weight: 700; }
.flag.up, .flag.down { color: var(--danger); }

/* ---------- LINE 設定 ---------- */
.rm { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.rm-img { width: 100%; border-radius: 8px; margin-top: 6px; display: block; background: var(--bg); }
.kwrow { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }

/* AI 填入的欄位：淡色底提醒學員確認 */
label.btn.scan { margin: 4px 0 4px; }
input.ai-filled { background: var(--brand-soft); border-color: var(--brand); }

/* 使用說明 */
.help-h { margin: 18px 4px 8px; font-size: 15px; color: var(--muted, #64748b); }
details.help { border-top: 1px solid var(--line); }
details.help:first-child { border-top: 0; }
details.help > summary { list-style: none; padding: 12px 0; font-weight: 600; display: flex; align-items: center; }
details.help > summary::-webkit-details-marker { display: none; }
details.help > summary::after { content: '›'; margin-left: auto; font-size: 20px; color: #94a3b8; transition: transform .2s; }
details.help[open] > summary::after { transform: rotate(90deg); }
.help-body { padding: 0 0 12px; font-size: 14px; line-height: 1.7; }
.help-body ul, .help-body ol { margin: 0 0 6px; padding-left: 20px; }
.help-body p { margin: 0 0 6px; }
.help-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; margin-right: 12px; }
.help-ico svg { width: 19px; height: 19px; }
.help-ico.teal { background: var(--brand-soft); color: var(--brand); }
.help-ico.green { background: #dcfce7; color: #15803d; }
.help-ico.amber { background: #fef3c7; color: #b45309; }
.help-ico.violet { background: #ede9fe; color: #6d28d9; }
.help-ico.sky { background: #e0f2fe; color: #0369a1; }
.help-ico.rose { background: #ffe4e6; color: #be123c; }
details.help > .help-body { padding-left: 46px; }
