:root {
  --teal: #208f82;
  --teal-soft: #e7f5f2;
  --coral: #e87355;
  --coral-soft: #fff0eb;
  --blue: #397bb5;
  --ink: #17211f;
  --muted: #687774;
  --line: #e3e9e7;
  --surface: rgba(255, 255, 255, .9);
  --bg: #f3f6f5;
  --shadow: 0 10px 28px rgba(32, 72, 66, .08);
}

* { box-sizing: border-box; }
html { background: #dce5e2; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.app-shell { width: min(100%, 860px); min-height: 100vh; margin: 0 auto; background: var(--bg); box-shadow: 0 0 50px rgba(20, 45, 41, .12); }
#app { min-height: 100vh; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }

.page-header {
  min-height: 142px;
  padding: 30px 24px 54px;
  color: #fff;
  background: #208f82;
}
.page-header.coral { background: #df765a; }
.page-header.blue { background: #397bb5; }
.page-header h1 { margin: 0 0 7px; font-size: 27px; line-height: 1.25; }
.page-header p { margin: 0; color: rgba(255,255,255,.84); font-size: 14px; }
.content { padding: 0 16px 28px; margin-top: -32px; }
.section { margin-bottom: 28px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 14px; font-size: 18px; font-weight: 700; }
.section-note { color: var(--muted); font-size: 12px; font-weight: 500; }
.card, .panel, .list-shell {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.panel { padding: 20px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

.hero {
  position: relative;
  min-height: 214px;
  overflow: hidden;
  padding: 32px 28px;
  color: #fff;
  background: #208f82;
}
.hero::after { content: ""; position: absolute; width: 190px; height: 190px; right: -42px; top: 20px; border-radius: 50%; background: rgba(255,255,255,.12); }
.hero-icon { position: relative; z-index: 1; width: 72px; height: 72px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.94); font-size: 36px; box-shadow: 0 10px 24px rgba(0,0,0,.12); }
.hero-icon img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.hero h1 { position: relative; z-index: 1; margin: 25px 0 6px; font-size: 28px; }
.hero p { position: relative; z-index: 1; margin: 0; color: rgba(255,255,255,.82); }
.hero-dots { position: absolute; z-index: 2; left: 28px; bottom: 17px; display: flex; gap: 6px; }
.hero-dot { width: 6px; height: 6px; border: 0; padding: 0; border-radius: 50%; background: rgba(255,255,255,.42); }
.hero-dot.active { width: 18px; border-radius: 3px; background: #fff; }
.home-content { padding: 22px 16px 28px; }
.entry-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.entry-card { min-width: 0; padding: 18px 10px; text-align: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 8px 18px rgba(24,62,57,.05); }
.entry-icon { width: 52px; height: 52px; margin: 0 auto 11px; display: grid; place-items: center; border-radius: 50%; font-size: 25px; }
.entry-card strong { display: block; font-size: 14px; line-height: 1.35; }
.entry-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }

.article-card, .tip-card, .exercise-card, .device-card, .plan-card, .profile-row { overflow: hidden; margin-bottom: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.article-head, .tip-head, .plan-head, .device-head { width: 100%; display: flex; align-items: center; gap: 13px; padding: 16px; border: 0; text-align: left; color: inherit; background: transparent; }
.round-icon { width: 46px; height: 46px; flex: 0 0 46px; display: grid; place-items: center; border-radius: 50%; font-size: 23px; }
.item-copy { flex: 1; min-width: 0; }
.item-copy strong { display: block; margin-bottom: 4px; font-size: 15px; }
.item-copy span { display: block; color: var(--muted); font-size: 12px; line-height: 1.45; }
.chevron { color: #a2aca9; transform: rotate(0); transition: transform .2s ease; }
.open .chevron { transform: rotate(180deg); }
.expand-body { padding: 0 16px 16px 75px; color: #52615e; font-size: 13px; line-height: 1.7; }
.expand-body h4 { margin: 12px 0 3px; color: var(--ink); font-size: 14px; }
.source-box, .warning { padding: 15px; color: #5b6966; background: #edf2f0; border-radius: 8px; font-size: 12px; line-height: 1.6; }
.warning { color: #8e4939; background: var(--coral-soft); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat { padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 8px; font-size: 27px; font-variant-numeric: tabular-nums; }
.stat small { margin-left: 3px; color: var(--muted); font-size: 12px; }
.segmented { display: flex; gap: 7px; overflow-x: auto; padding: 4px; margin-bottom: 16px; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segment { flex: 0 0 auto; min-height: 38px; padding: 0 15px; border: 1px solid var(--line); border-radius: 19px; color: var(--muted); background: #fff; }
.segment.active { border-color: var(--teal); color: #fff; background: var(--teal); }
.exercise-card { width: 100%; display: flex; align-items: center; gap: 13px; padding: 15px; text-align: left; color: inherit; }
.exercise-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; color: var(--muted); font-size: 11px; }
.tag { padding: 3px 7px; color: var(--teal); border-radius: 4px; background: var(--teal-soft); }
.detail-back { margin: 0 0 14px; padding: 8px 0; border: 0; color: #fff; background: transparent; }
.steps { counter-reset: steps; margin: 0; padding: 0; list-style: none; }
.steps li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; margin-bottom: 14px; color: #4e5e5b; line-height: 1.6; }
.steps li::before { counter-increment: steps; content: counter(steps); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--teal); background: var(--teal-soft); font-weight: 700; }

.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(110px,1fr); gap: 4px; overflow-x: auto; padding: 5px; margin-bottom: 16px; background: rgba(255,255,255,.8); border-radius: 8px; box-shadow: var(--shadow); scrollbar-width: none; }
.tab { min-height: 42px; padding: 0 12px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; white-space: nowrap; }
.tab.active { color: #fff; background: var(--teal); }
.posture-page .tab.active { background: var(--coral); }
.features { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.feature { padding: 12px; border-radius: 6px; background: #f5f7f6; font-size: 12px; }
.feature strong { display: block; margin: 4px 0; }
.device-icon { width: 62px; height: 62px; flex: 0 0 62px; display: grid; place-items: center; border-radius: 8px; background: var(--coral-soft); font-size: 30px; user-select: none; }
.device-status { display: inline-flex !important; width: fit-content; margin-top: 5px; padding: 3px 7px; border-radius: 4px; color: var(--teal) !important; background: var(--teal-soft); }
.device-body { padding: 0 16px 16px; }
.usage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.usage-cell { padding: 12px; border-radius: 6px; background: #fff7f4; }
.usage-cell span { display: block; color: var(--muted); font-size: 11px; }
.usage-cell strong { display: block; margin-top: 5px; font-size: 15px; }
.settings-row, .form-row { min-height: 50px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.settings-row label, .form-row label { min-width: 100px; color: #4e5c59; font-size: 13px; }
.settings-row input[type="range"] { flex: 1; accent-color: var(--coral); }
.editor { margin: 14px 0; padding: 14px; border-radius: 8px; background: #fff7f4; }
.editor h3 { margin: 0 0 7px; font-size: 15px; color: #a4513d; }

.form-row input, .form-row select { min-width: 0; flex: 1; height: 42px; padding: 0 10px; border: 0; outline: 0; text-align: right; color: var(--ink); background: transparent; }
.form-row input:focus { box-shadow: inset 0 -2px var(--teal); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #eef2f1; border-radius: 8px; }
.auth-tab { min-height: 40px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; }
.auth-tab.active { color: var(--teal); background: #fff; box-shadow: 0 4px 12px rgba(32,72,66,.08); font-weight: 700; }
.code-wrap { display: flex; min-width: 0; flex: 1; align-items: center; }
.code-wrap input { width: 100%; }
.code-btn { flex: 0 0 105px; min-height: 34px; border: 0; border-radius: 6px; color: var(--teal); background: var(--teal-soft); font-size: 12px; }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.btn { min-height: 43px; padding: 0 18px; border: 0; border-radius: 7px; color: #fff; background: var(--teal); font-weight: 650; white-space: nowrap; }
.btn.secondary { color: var(--muted); background: #edf1f0; }
.btn.coral { background: var(--coral); }
.btn.full { width: 100%; }
.actions .btn { flex: 1; }
.text-btn { padding: 7px; border: 0; color: var(--teal); background: transparent; }
.profile-card { display: flex; align-items: center; gap: 14px; }
.avatar { width: 58px; height: 58px; flex: 0 0 58px; display: grid; place-items: center; border-radius: 50%; background: var(--teal-soft); font-size: 27px; }
.profile-row { position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding: 12px 14px; touch-action: pan-y; }
.profile-row small { display: block; margin-top: 4px; color: var(--muted); }
.delete-btn { border: 0; padding: 9px 13px; border-radius: 6px; color: #a64230; background: var(--coral-soft); }
.profile-row .delete-btn { display: none; }
.profile-row.revealed .delete-btn { display: block; }
.menu-row { width: 100%; min-height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border: 0; border-bottom: 1px solid var(--line); color: inherit; text-align: left; background: #fff; }
.menu-row:last-child { border-bottom: 0; }
.menu-row span:last-child { margin-left: auto; color: #a1aaa8; }

.option-group { margin-bottom: 20px; }
.option-group h3 { margin: 0 0 10px; font-size: 15px; }
.options { display: flex; flex-wrap: wrap; gap: 8px; }
.option { min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 19px; color: var(--muted); background: #fff; }
.option.active { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.food-tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.food-tag { padding: 5px 9px; border-radius: 4px; color: var(--teal); background: var(--teal-soft); font-size: 12px; }
.food-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.food { padding: 14px 8px; border-radius: 7px; text-align: center; background: #f1f6f4; font-size: 12px; }
.food span { display: block; margin-bottom: 7px; font-size: 25px; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: 0; width: min(100%,860px); min-height: 70px; display: grid; grid-template-columns: repeat(5,1fr); padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); transform: translateX(-50%); border-top: 1px solid rgba(221,230,227,.9); background: rgba(255,255,255,.94); backdrop-filter: blur(18px); }
.nav-item { min-width: 0; border: 0; color: #7b8885; background: transparent; font-size: 10px; }
.nav-item span { display: block; height: 25px; font-size: 21px; line-height: 25px; }
.nav-item.active { color: var(--teal); font-weight: 700; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 94px; max-width: calc(100% - 40px); padding: 10px 16px; transform: translate(-50%, 20px); border-radius: 7px; color: #fff; background: rgba(18,28,26,.9); opacity: 0; pointer-events: none; transition: .2s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.modal-backdrop { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(15,28,25,.42); }
.modal { width: min(100%,420px); max-height: 80vh; overflow: auto; padding: 22px; border-radius: 8px; background: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.2); }
.modal h2 { margin: 0 0 10px; font-size: 20px; }
.modal p { color: var(--muted); line-height: 1.65; white-space: pre-line; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

@media (max-width: 430px) {
  .entry-grid { gap: 7px; }
  .entry-card { padding-inline: 6px; }
  .entry-card strong { font-size: 12px; }
  .expand-body { padding-left: 16px; }
  .page-header { padding-inline: 19px; }
  .content { padding-inline: 12px; }
  .form-row label { min-width: 76px; }
  .code-btn { flex-basis: 90px; font-size: 11px; }
  .actions .btn { padding-inline: 10px; font-size: 14px; }
}

@media (min-width: 720px) {
  .home-content, .content { padding-left: 26px; padding-right: 26px; }
  .entry-grid { gap: 16px; }
  .exercise-list, .article-list, .tip-list, .device-list, .plan-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .article-card, .tip-card, .exercise-card, .device-card, .plan-card { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
