/* Kingsfoil Wellness — style.css（配色沿用 jenniferacupuncture.com） */
@font-face { font-family: 'Cormorant Garamond'; font-style: normal; font-weight: 500 700; font-display: swap; src: url(/fonts/cormorant-var.woff2) format('woff2'); }
@font-face { font-family: 'Lato'; font-style: normal; font-weight: 300; font-display: swap; src: url(/fonts/lato-300.woff2) format('woff2'); }
@font-face { font-family: 'Lato'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/lato-400.woff2) format('woff2'); }
@font-face { font-family: 'Lato'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/lato-700.woff2) format('woff2'); }

:root {
  --primary: #2d6b5a;
  --primary-lt: #3d8b73;
  --primary-dk: #1e4a3e;
  --accent: #c9a96e;
  --accent-dk: #8a6a2f;
  --bg: #faf9f6;
  --cream: #f3efe8;
  --white: #ffffff;
  --text: #2a2a2a;
  --muted: #5f6670;
  --border: #e5e1d8;
  --period: #c2410c;
  --period-bg: #fde7dc;
  --fertile: #2d6b5a;
  --fertile-bg: #dcefe7;
  --ov: #7c3aed;
  --danger: #b42318;
  --shadow: 0 4px 24px rgba(0,0,0,0.07);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --radius: 16px;
  --serif: 'Cormorant Garamond', Georgia, 'Songti SC', serif;
  --sans: 'Lato', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans); font-weight: 400; color: var(--text); background: var(--bg);
  line-height: 1.6; min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px);
  -webkit-tap-highlight-color: transparent;
}
html[lang="zh"] body { font-weight: 400; }
img { max-width: 100%; display: block; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.muted { color: var(--muted); }
small { font-size: 0.85rem; }

/* ---- 无障碍 ---- */
.skip-link {
  position: absolute; top: -60px; left: 16px; z-index: 9999;
  background: var(--primary); color: var(--white); padding: 10px 18px;
  border-radius: 0 0 8px 8px; font-weight: 700; text-decoration: none; transition: top .2s;
}
.skip-link:focus { top: 0; }
*:focus-visible { outline: 3px solid var(--accent-dk); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }

/* ---- 顶栏 ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 18px 10px;
  background: rgba(250,249,246,0.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--primary-dk); transition: opacity .3s; }
.logo a:hover { opacity: .8; }
.brand { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; line-height: 1.1; }
.brand-sub { display: block; font-size: 0.75rem; color: var(--muted); letter-spacing: .04em; }
.lang-btn {
  border: 1px solid var(--border); background: var(--white); border-radius: 999px;
  padding: 6px 14px; font-size: 0.9rem; font-weight: 700; color: var(--primary-dk); cursor: pointer; min-height: 40px;
}

main { max-width: 640px; margin: 0 auto; padding: 18px 16px 8px; }
.view { animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
h2 { font-family: var(--serif); font-size: 2rem; font-weight: 600; color: var(--primary-dk); line-height: 1.15; margin-bottom: 14px; }
h3 { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; color: var(--primary-dk); margin-bottom: 8px; line-height: 1.2; }
html[lang="zh"] h2, html[lang="zh"] h3 { font-family: var(--sans); font-weight: 700; letter-spacing: .02em; }
html[lang="zh"] h2 { font-size: 1.7rem; }
html[lang="zh"] h3 { font-size: 1.15rem; }
.greet { margin-bottom: 2px; }
.date-line { color: var(--muted); margin-bottom: 18px; }

/* ---- 卡片 ---- */
.card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card p + p { margin-top: 8px; }
.welcome { background: linear-gradient(135deg, #fff 0%, var(--cream) 100%); }
.privacy-note { background: var(--fertile-bg); color: var(--primary-dk); padding: 10px 14px; border-radius: 12px; font-size: 0.95rem; margin: 12px 0; }
.install { border-color: var(--accent); }

/* ---- 按钮 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 20px; border-radius: 999px; border: 2px solid transparent;
  font-weight: 700; font-size: 1rem; cursor: pointer; text-decoration: none; text-align: center;
  transition: background .2s, transform .1s, box-shadow .2s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: var(--white); box-shadow: 0 4px 14px rgba(45,107,90,.28); }
.btn-primary:hover { background: var(--primary-dk); }
.btn-outline { background: var(--white); color: var(--primary-dk); border-color: var(--primary); }
.btn-outline:hover { background: var(--fertile-bg); }
.btn-ghost { background: transparent; color: var(--primary-dk); text-decoration: underline; text-underline-offset: 3px; }
.btn-danger { background: var(--white); color: var(--danger); border-color: var(--danger); }
.btn-lg { min-height: 54px; padding: 12px 32px; font-size: 1.1rem; min-width: 140px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.btn-row.center { justify-content: center; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--white); font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--primary-dk); }
.file-btn { position: relative; overflow: hidden; }

/* ---- 表单 ---- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; color: var(--primary-dk); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #c9c3b6; border-radius: 12px; background: var(--white); font-size: 1rem;
}
.field textarea { min-height: 70px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; cursor: pointer; }
.switch-row input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.switch-row.big { font-weight: 700; font-size: 1.05rem; }
fieldset.chips-field { border: 0; margin: 4px 0 16px; }
fieldset.chips-field legend { font-weight: 700; font-size: 0.95rem; color: var(--primary-dk); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 8px 16px; border: 1px solid #c9c3b6; border-radius: 999px; background: var(--white); font-size: 0.95rem; min-height: 40px; line-height: 22px; }
.chip input:checked + span { background: var(--primary); color: var(--white); border-color: var(--primary); }
.chip input:focus-visible + span { outline: 3px solid var(--accent-dk); outline-offset: 2px; }
.form-error { color: var(--danger); font-weight: 700; min-height: 1em; }

/* 选择列表（呼吸方式/引导） */
.pattern-list { display: grid; gap: 8px; }
.opt { position: relative; display: block; cursor: pointer; }
.opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.opt .opt-box { display: block; padding: 12px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--white); transition: border-color .2s, background .2s; }
.opt .opt-title { display: block; font-weight: 700; }
.opt .opt-desc { display: block; font-size: 0.9rem; color: var(--muted); }
.opt input:checked + .opt-box { border: 2px solid var(--primary); background: var(--fertile-bg); padding: 11px 15px; }
.opt input:focus-visible + .opt-box { outline: 3px solid var(--accent-dk); outline-offset: 2px; }

.seg { display: flex; background: var(--cream); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.seg label { flex: 1; position: relative; text-align: center; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 10px 8px; border-radius: 999px; font-weight: 700; color: var(--muted); }
.seg input:checked + span { background: var(--white); color: var(--primary-dk); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 3px solid var(--accent-dk); }

/* ---- 今天 ---- */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.quick {
  display: flex; flex-direction: column; gap: 4px; padding: 18px 16px; border-radius: var(--radius);
  text-decoration: none; color: var(--white); min-height: 150px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.quick:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.quick-breathe { background: linear-gradient(140deg, #2d6b5a, #3d8b73); }
.quick-med { background: linear-gradient(140deg, #6b5532, #a88a50); }
.quick-title { font-weight: 700; font-size: 1.08rem; margin-top: auto; }
.quick-sub { font-size: 0.88rem; opacity: .92; }
.quick-icon { width: 44px; height: 44px; position: relative; font-size: 2rem; line-height: 44px; }
.quick-icon .ring { position: absolute; inset: 0; border: 2px solid rgba(255,255,255,.8); border-radius: 50%; animation: pulse 4s ease-in-out infinite; }
.quick-icon .r2 { animation-delay: 2s; }
@keyframes pulse { 0%,100% { transform: scale(.55); opacity: .9; } 50% { transform: scale(1); opacity: .3; } }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--white); border: 1px solid var(--border); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { display: block; font-family: var(--serif); font-size: 1.9rem; color: var(--primary); line-height: 1.1; }
.stat span { font-size: 0.82rem; color: var(--muted); }

.clinic { padding: 0; overflow: hidden; }
.clinic img { width: 100%; height: 190px; object-fit: cover; transition: transform .5s; }
.clinic:hover img { transform: scale(1.03); }
.clinic-body { padding: 18px 20px 20px; }
.clinic-addr { font-size: 0.95rem; }

/* 状态卡（周期/孕期） */
.status-card { position: relative; overflow: hidden; background: linear-gradient(150deg, #fff 0%, var(--cream) 100%); }
.status-top { display: flex; align-items: center; gap: 16px; }
.status-ring { width: 92px; height: 92px; flex-shrink: 0; position: relative; }
.status-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.status-ring .bg { fill: none; stroke: var(--border); stroke-width: 9; }
.status-ring .fg { fill: none; stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.status-ring .num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.status-ring .num b { font-family: var(--serif); font-size: 1.9rem; color: var(--primary-dk); }
.status-ring .num small { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }
.status-phase { font-family: var(--serif); font-size: 1.45rem; font-weight: 600; line-height: 1.15; color: var(--primary-dk); }
html[lang="zh"] .status-phase { font-family: var(--sans); font-weight: 700; font-size: 1.2rem; }
.status-lines { margin-top: 12px; display: grid; gap: 4px; font-size: 0.95rem; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; margin-top: 6px; }
.badge.high { background: var(--fertile); color: #fff; }
.badge.medium { background: var(--fertile-bg); color: var(--primary-dk); }
.badge.low { background: var(--cream); color: var(--muted); }
.ph-period .fg { stroke: var(--period); }
.ph-fertile .fg, .ph-ovulation .fg { stroke: var(--fertile); }
.ph-luteal .fg, .ph-follicular .fg { stroke: var(--accent); }
.ph-late .fg { stroke: var(--period); }
.ph-preg .fg { stroke: var(--primary-lt); }
.preg-bar { height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 12px 0 6px; }
.preg-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary-lt), var(--accent)); border-radius: 999px; }
.tip { background: var(--white); border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: 0 12px 12px 0; margin-top: 12px; }
.safety { background: #fff4ed; color: #7a2e0b; border-radius: 12px; padding: 12px 14px; margin-top: 12px; font-size: 0.93rem; }

/* ---- 呼吸 ---- */
.breath-stage { text-align: center; padding: 8px 0 12px; }
.breath-circle-wrap { position: relative; width: min(78vw, 320px); height: min(78vw, 320px); margin: 10px auto 8px; }
.breath-circle, .breath-halo { position: absolute; inset: 0; border-radius: 50%; transform: scale(.55); transition-property: transform; transition-timing-function: ease-in-out; }
.breath-circle { background: radial-gradient(circle at 35% 30%, #5fb096 0%, var(--primary) 55%, var(--primary-dk) 100%); box-shadow: 0 20px 60px rgba(45,107,90,.35); }
.breath-halo { background: radial-gradient(circle, rgba(201,169,110,.35) 0%, rgba(201,169,110,0) 70%); transform: scale(.7); }
.breath-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--white); pointer-events: none; padding: 0 18%; }
.breath-phase { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; text-shadow: 0 1px 6px rgba(0,0,0,.25); line-height: 1.15; }
html[lang="zh"] .breath-phase { font-family: var(--sans); font-weight: 700; font-size: 1.35rem; }
.breath-count { font-size: 2.6rem; font-weight: 300; margin-top: 4px; text-shadow: 0 1px 6px rgba(0,0,0,.25); min-height: 1.2em; }
.breath-remaining { color: var(--muted); min-height: 1.6em; }
.breath-stage .switch-row { justify-content: center; }
body.practicing .breath-setup, body.practicing #medSetup { display: none; }

/* ---- 冥想 ---- */
.med-stage { text-align: center; padding: 6px 0 16px; }
.med-ring-wrap { position: relative; width: min(70vw, 260px); height: min(70vw, 260px); margin: 6px auto 10px; }
.med-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.med-ring-bg { fill: none; stroke: var(--border); stroke-width: 6; }
.med-ring-fg { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 565.49; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear; }
.med-time { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 3.4rem; font-weight: 500; color: var(--primary-dk); font-variant-numeric: tabular-nums; }
.med-prompt { min-height: 4.8em; max-width: 30em; margin: 0 auto; font-size: 1.12rem; color: var(--primary-dk); transition: opacity .8s; padding: 0 8px; }
.med-prompt.fade { opacity: 0; }
.track { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--border); }
.track:first-child { border-top: 0; }
.track audio { width: 100%; }

/* ---- 日历 ---- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h3 { margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow div { text-align: center; font-size: 0.78rem; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day {
  position: relative; aspect-ratio: 1; border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  font-size: 0.95rem; display: flex; align-items: center; justify-content: center; color: var(--text); min-height: 40px;
}
.cal-day.out { visibility: hidden; }
.cal-day.p-logged { background: var(--period); color: #fff; font-weight: 700; }
.cal-day.p-predicted { background: var(--period-bg); color: #8a2c08; border: 2px dashed #e7a283; }
.cal-day.fertile { background: var(--fertile-bg); color: var(--primary-dk); }
.cal-day.ov { background: var(--fertile); color: #fff; font-weight: 700; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--text); }
.cal-day.logged::after { content: ''; position: absolute; bottom: 4px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent-dk); }
.cal-day.p-logged.logged::after, .cal-day.ov.logged::after { background: #fff; }
.cal-day.future { opacity: .9; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; font-size: 0.85rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; margin-right: 5px; }
.lg-period { background: var(--period); }
.lg-pred { background: var(--period-bg); border: 2px dashed #e7a283; }
.lg-fertile { background: var(--fertile-bg); border: 1px solid #a9d3c3; }
.lg-ov { background: var(--fertile); }
.lg-log { background: var(--accent-dk); width: 7px !important; height: 7px !important; }

.bbt svg { width: 100%; height: auto; display: block; }
.history-list { list-style: none; }
.history-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.history-list li:last-child { border-bottom: 0; }
.disclaimer { font-size: 0.85rem; color: var(--muted); margin: 8px 4px 16px; }

/* ---- 设置 ---- */
.rem-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rem-row label.switch-row { flex: 1; padding: 6px 0; }
.rem-row input[type=time] { min-height: 42px; border: 1px solid #c9c3b6; border-radius: 10px; padding: 6px 8px; background: var(--white); }
.rem-status { font-size: 0.95rem; color: var(--muted); margin-bottom: 8px; }

/* ---- 弹层 ---- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20,30,26,.45); z-index: 200; animation: fadeIn .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 210; max-height: 90vh; overflow-y: auto;
  background: var(--white); border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + var(--safe-b));
  box-shadow: 0 -10px 40px rgba(0,0,0,.2); max-width: 640px; margin: 0 auto; animation: slideUp .28s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.done-sheet { text-align: center; padding-top: 34px; }
.done-glow { width: 90px; height: 90px; margin: 0 auto 14px; border-radius: 50%; background: radial-gradient(circle, var(--accent) 0%, rgba(201,169,110,0) 70%); animation: pulse 3s ease-in-out infinite; }
.done-sheet p { margin: 6px 0 18px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); transform: translateX(-50%) translateY(20px);
  background: var(--primary-dk); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 0.95rem;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 300; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- 底部导航 ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.tabbar .tab-ic { font-size: 1.35rem; line-height: 1; }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tabbar a[aria-current="page"] .tab-ic { transform: scale(1.12); }

.site-footer { max-width: 640px; margin: 8px auto 0; padding: 16px 16px 20px; text-align: center; font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--border); }
.site-footer p { margin: 4px 0; }
.site-footer a { color: var(--primary-dk); }
.footer-partner a { color: var(--accent-dk); text-decoration: none; }

/* 无障碍插件按钮让出底部导航的位置 */
#a11y-btn { bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px) !important; }
#a11y-widget { bottom: calc(var(--tabbar-h) + var(--safe-b) + 76px) !important; }

@media (min-width: 720px) {
  main { padding-top: 28px; }
  h2 { font-size: 2.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .quick-icon .ring { animation: none; }
}

/* ---- 打印（看诊时给 Jennifer 看） ---- */
.print-only { display: none; }
@media print {
  body { padding: 0; background: #fff; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; padding: 24px; font-size: 12pt; }
  #printArea h1 { font-family: var(--serif); font-size: 20pt; margin-bottom: 4px; }
  #printArea table { width: 100%; border-collapse: collapse; margin: 12px 0; }
  #printArea th, #printArea td { border: 1px solid #999; padding: 4px 6px; text-align: left; font-size: 10pt; }
}
