:root {
  --ink: #20332b;
  --muted: #718078;
  --line: #dce7e1;
  --surface: #ffffff;
  --bg: #f4f8f6;
  --green: #2f7d5b;
  --green-dark: #225d45;
  --mint: #dff2e8;
  --coral: #f1856f;
  --coral-soft: #fff0ec;
  --blue: #4f7ea3;
  --blue-soft: #edf5fb;
  --yellow: #e8af45;
  --shadow: 0 12px 32px rgba(45, 78, 63, 0.1);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: #e8efeb; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); letter-spacing: 0; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-screen { width: min(100%, 480px); margin: 0 auto; background: var(--surface); }
.auth-visual { height: min(46vh, 390px); min-height: 300px; position: relative; overflow: hidden; }
.auth-visual img { width: 100%; height: 100%; object-fit: cover; object-position: center 58%; }
.auth-visual::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(18,43,32,.08), rgba(20,56,40,.68)); }
.auth-brand { position: absolute; z-index: 1; left: 24px; bottom: 28px; color: white; }
.auth-brand h1 { font-size: 35px; line-height: 1.1; margin: 12px 0 8px; font-weight: 760; }
.auth-brand p { margin: 0; font-size: 15px; opacity: .9; }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--green-dark); background: rgba(255,255,255,.92); }
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark.small { width: 31px; height: 31px; background: var(--mint); color: var(--green); }
.brand-mark.small svg { width: 18px; height: 18px; }
.auth-panel { position: relative; z-index: 2; min-height: calc(54vh + 18px); margin-top: -18px; padding: 22px 22px 40px; border-radius: 18px 18px 0 0; background: var(--surface); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 8px; background: #eef3f0; }
.segment { border: 0; border-radius: 6px; padding: 9px 12px; color: var(--muted); background: transparent; font-size: 14px; font-weight: 650; }
.segment.active { color: var(--ink); background: var(--surface); box-shadow: 0 2px 8px rgba(36,59,48,.08); }
.stack-form { display: grid; gap: 16px; margin-top: 22px; }
.stack-form label, .field-label { display: grid; gap: 7px; color: #526159; font-size: 13px; font-weight: 650; }
.stack-form small, .field-label small { color: #95a098; font-size: 11px; font-weight: 500; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 7px; outline: none; background: #fbfdfc; color: var(--ink); transition: border-color .2s, box-shadow .2s; }
input, select { height: 46px; padding: 0 13px; }
textarea { min-height: 84px; resize: vertical; padding: 12px 13px; }
input:focus, textarea:focus, select:focus { border-color: #79ae93; box-shadow: 0 0 0 3px rgba(47,125,91,.1); }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-grid.three input { padding: 0 8px; }
.primary-btn, .secondary-btn, .danger-btn, .text-btn { min-height: 46px; border: 0; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-weight: 700; }
.primary-btn { padding: 0 18px; color: white; background: var(--green); box-shadow: 0 8px 18px rgba(47,125,91,.2); }
.primary-btn:hover { background: var(--green-dark); }
.primary-btn svg, .secondary-btn svg { width: 18px; }
.secondary-btn { padding: 0 16px; color: var(--green-dark); background: var(--mint); }
.danger-btn { padding: 0 16px; color: #a14635; background: var(--coral-soft); }
.text-btn { min-height: 36px; padding: 0 8px; color: var(--green); background: transparent; font-size: 13px; }
.primary-btn:disabled, .secondary-btn:disabled { opacity: .55; cursor: not-allowed; }

.app-shell { width: min(100%, 480px); min-height: 100vh; margin: 0 auto; background: var(--bg); box-shadow: 0 0 60px rgba(33,62,48,.12); }
.topbar { position: sticky; top: 0; z-index: 30; height: 58px; padding: max(10px, env(safe-area-inset-top)) 18px 8px; display: flex; align-items: center; justify-content: space-between; background: rgba(247,250,248,.94); backdrop-filter: blur(14px); }
.wordmark { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; color: var(--ink); font-weight: 760; font-size: 17px; }
.icon-btn { width: 40px; height: 40px; position: relative; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); }
.icon-btn svg { width: 19px; }
.notification-dot { position: absolute; width: 8px; height: 8px; top: 7px; right: 7px; border: 2px solid white; border-radius: 50%; background: var(--coral); }
#main-content { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.page { display: none; min-height: calc(100vh - 145px); padding: 14px 18px 24px; animation: rise .24s ease; }
.page.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.bottom-nav { position: fixed; z-index: 40; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 480px); height: calc(70px + env(safe-area-inset-bottom)); padding: 8px 15px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; border-top: 1px solid rgba(212,225,217,.8); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); }
.nav-item { height: 52px; border: 0; display: grid; justify-items: center; align-content: center; gap: 3px; color: #849188; background: transparent; font-size: 10px; }
.nav-item svg { width: 20px; height: 20px; }
.nav-item.active { color: var(--green); font-weight: 700; }
.checkin-nav { width: 52px; height: 52px; justify-self: center; margin-top: -26px; display: grid; place-items: center; border: 5px solid var(--bg); border-radius: 50%; background: var(--green); color: white; box-shadow: 0 7px 16px rgba(47,125,91,.27); }
.checkin-nav svg { width: 23px; }

.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 11px; font-weight: 760; text-transform: uppercase; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.page-heading h2 { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 760; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 24px 0 11px; }
.section-head h3 { margin: 0; font-size: 16px; font-weight: 760; }
.section-head span { color: var(--muted); font-size: 12px; }
.card { border: 1px solid rgba(216,229,222,.95); border-radius: 8px; background: var(--surface); box-shadow: 0 4px 18px rgba(47,76,61,.055); }
.hero-stat { min-height: 195px; padding: 20px; position: relative; overflow: hidden; color: white; border-radius: 8px; background: #397e61; }
.hero-stat::after { content: ""; position: absolute; width: 175px; height: 175px; right: -76px; bottom: -75px; border: 33px solid rgba(255,255,255,.08); border-radius: 50%; }
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.hero-top p { margin: 0; font-size: 13px; opacity: .86; }
.streak-pill { display: inline-flex; gap: 5px; align-items: center; padding: 6px 9px; border-radius: 18px; color: #633c1b; background: #f9d992; font-size: 12px; font-weight: 740; }
.streak-pill svg { width: 15px; fill: currentColor; }
.weight-value { margin-top: 14px; font-size: 47px; line-height: 1; font-weight: 760; }
.weight-value small { font-size: 15px; font-weight: 600; opacity: .75; }
.hero-meta { margin-top: 12px; display: flex; gap: 18px; font-size: 12px; opacity: .9; }
.hero-progress { position: absolute; left: 20px; right: 20px; bottom: 19px; }
.hero-progress-line { height: 6px; overflow: hidden; border-radius: 4px; background: rgba(255,255,255,.22); }
.hero-progress-line i { display: block; height: 100%; border-radius: inherit; background: #f9d992; }
.hero-progress-label { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; opacity: .83; }
.today-card { margin-top: 13px; padding: 16px; display: flex; align-items: center; gap: 13px; }
.status-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: var(--mint); }
.status-icon.pending { color: var(--coral); background: var(--coral-soft); }
.status-icon svg { width: 21px; }
.today-copy { min-width: 0; flex: 1; }
.today-copy strong { display: block; font-size: 14px; }
.today-copy span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-btn { height: 34px; flex: 0 0 auto; padding: 0 11px; border: 0; border-radius: 6px; color: white; background: var(--green); font-size: 12px; font-weight: 700; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.mini-stat { min-height: 82px; padding: 12px; }
.mini-stat span { display: block; color: var(--muted); font-size: 11px; }
.mini-stat strong { display: block; margin-top: 6px; font-size: 20px; }
.mini-stat small { margin-left: 2px; color: var(--muted); font-size: 10px; }
.team-pulse { padding: 15px; }
.team-pulse-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.team-pulse-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.team-pulse-name span { min-width: 0; }
.team-pulse-name strong, .team-pulse-name small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-pulse-name small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.team-badge { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 7px; color: var(--blue); background: var(--blue-soft); }
.avatar-row { display: flex; align-items: center; margin-top: 14px; }
.avatar { width: 34px; height: 34px; flex: 0 0 auto; object-fit: cover; border: 2px solid white; border-radius: 50%; background: var(--mint); }
.avatar + .avatar { margin-left: -8px; }
.avatar-count { margin-left: 9px; color: var(--muted); font-size: 12px; }

.calendar-card { padding: 14px; }
.month-switch { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-switch strong { font-size: 15px; }
.month-switch button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); }
.month-switch svg { width: 18px; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 5px; }
.calendar .weekday { height: 25px; display: grid; place-items: center; color: #95a199; font-size: 10px; }
.calendar .day { aspect-ratio: 1; min-width: 0; display: grid; place-items: center; position: relative; border-radius: 6px; color: var(--ink); font-size: 12px; }
.calendar .day.muted { color: #bcc5bf; }
.calendar .day.checked { color: white; background: var(--green); font-weight: 700; }
.calendar .day.today:not(.checked) { outline: 1px solid var(--green); outline-offset: -1px; color: var(--green); font-weight: 700; }
.chart-card { height: 235px; padding: 16px 10px 10px; }
.record-list { display: grid; gap: 8px; }
.record-row { padding: 13px 14px; display: grid; grid-template-columns: 55px 1fr auto; align-items: center; gap: 10px; }
.record-date { color: var(--muted); font-size: 11px; }
.record-date strong { display: block; color: var(--ink); font-size: 15px; }
.record-note { min-width: 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-weight { font-size: 15px; font-weight: 740; }

.checkin-header { margin-bottom: 18px; display: flex; align-items: center; gap: 12px; }
.checkin-header .status-icon { color: white; background: var(--coral); }
.checkin-header h2 { margin: 0; font-size: 23px; }
.checkin-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.checkin-form { display: grid; gap: 14px; }
.form-section { padding: 16px; }
.form-section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 14px; }
.form-section-title svg { width: 18px; color: var(--green); }
.weight-input-wrap { display: grid; grid-template-columns: 36px 1fr 36px; gap: 9px; align-items: center; }
.weight-input-wrap button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--green); background: white; }
.weight-input-wrap input { height: 58px; border: 0; background: var(--bg); text-align: center; font-size: 28px; font-weight: 760; }
.mood-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.mood-option input { position: absolute; opacity: 0; pointer-events: none; }
.mood-option span { min-height: 58px; display: grid; place-items: center; align-content: center; gap: 3px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: white; font-size: 11px; }
.mood-option b { font-size: 19px; }
.mood-option input:checked + span { border-color: #79ae93; color: var(--green-dark); background: var(--mint); }
.meal-grid { display: grid; gap: 9px; }
.meal-input { display: grid; grid-template-columns: 47px 1fr; align-items: center; gap: 8px; }
.meal-input span { color: var(--muted); font-size: 12px; }
.upload-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.upload-tile, .preview-tile { aspect-ratio: 1; min-width: 0; overflow: hidden; border-radius: 7px; }
.upload-tile { display: grid; place-items: center; border: 1px dashed #a8bab0; color: var(--muted); background: var(--bg); }
.upload-tile input { display: none; }
.upload-tile svg { width: 22px; }
.preview-tile { position: relative; }
.preview-tile img { width: 100%; height: 100%; object-fit: cover; }
.preview-tile button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; display: grid; place-items: center; border: 0; border-radius: 50%; color: white; background: rgba(22,37,30,.72); }
.preview-tile button svg { width: 12px; }

.empty-state { padding: 34px 22px; text-align: center; }
.empty-art { width: 88px; height: 88px; margin: 0 auto 17px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: var(--blue-soft); }
.empty-art svg { width: 40px; height: 40px; }
.empty-state h3 { margin: 0 0 7px; font-size: 18px; }
.empty-state p { margin: 0 auto 19px; max-width: 260px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.button-row { display: flex; justify-content: center; gap: 9px; }
.team-hero { padding: 17px; color: white; background: #4f7189; }
.team-hero-top { display: flex; justify-content: space-between; gap: 12px; }
.team-hero h2 { margin: 0; font-size: 21px; }
.team-hero p { margin: 5px 0 0; opacity: .82; font-size: 12px; }
.team-hero .icon-btn { width: 36px; height: 36px; border-color: rgba(255,255,255,.25); color: white; background: rgba(255,255,255,.12); }
.completion { margin-top: 17px; }
.completion-copy { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 11px; opacity: .9; }
.completion-line { height: 7px; overflow: hidden; border-radius: 5px; background: rgba(255,255,255,.2); }
.completion-line i { display: block; height: 100%; border-radius: inherit; background: #f9d992; }
.board-tabs { margin-top: 12px; }
.member-list { display: grid; gap: 9px; }
.member-card { padding: 13px; display: grid; grid-template-columns: 42px 1fr auto; gap: 11px; align-items: center; }
.member-card .avatar { width: 42px; height: 42px; border: 0; }
.member-info { min-width: 0; }
.member-info strong { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.member-info strong em { padding: 2px 5px; border-radius: 3px; color: var(--blue); background: var(--blue-soft); font-size: 9px; font-style: normal; }
.member-info span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-action { display: grid; justify-items: end; gap: 5px; }
.status-label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; }
.status-label.done { color: var(--green); }
.status-label.waiting { color: var(--coral); }
.status-label svg { width: 13px; }
.nudge-btn { height: 28px; padding: 0 8px; border: 0; border-radius: 5px; color: #a44e3b; background: var(--coral-soft); font-size: 10px; font-weight: 700; }
.comment-btn { height: 28px; padding: 0 8px; border: 0; border-radius: 5px; color: var(--blue); background: var(--blue-soft); font-size: 10px; font-weight: 700; }
.rank-list { display: grid; gap: 8px; }
.rank-row { padding: 12px; display: grid; grid-template-columns: 24px 38px 1fr auto; gap: 9px; align-items: center; }
.rank-no { text-align: center; color: var(--muted); font-size: 13px; font-weight: 750; }
.rank-no.top { color: var(--yellow); font-size: 18px; }
.rank-row .avatar { width: 38px; height: 38px; border: 0; }
.rank-name strong, .rank-name span { display: block; }
.rank-name strong { font-size: 13px; }
.rank-name span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.rank-value { text-align: right; font-size: 14px; font-weight: 760; }
.rank-value small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 500; }
.rules-box { padding: 13px 15px; color: #526159; background: #fffdf7; border-color: #eee4cb; font-size: 12px; line-height: 1.65; }

.profile-head { padding: 8px 2px 18px; display: flex; align-items: center; gap: 13px; }
.profile-avatar { width: 62px; height: 62px; border: 3px solid white; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); }
.profile-head h2 { margin: 0; font-size: 21px; }
.profile-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.settings-form { display: grid; gap: 12px; }
.settings-card { padding: 16px; }
.settings-card h3 { margin: 0 0 14px; font-size: 14px; }
.toggle-row { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.toggle-row + .toggle-row { border-top: 1px solid #edf1ef; }
.toggle-copy strong, .toggle-copy span { display: block; }
.toggle-copy strong { font-size: 13px; }
.toggle-copy span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.switch { width: 43px; height: 25px; position: relative; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; }
.switch i { position: absolute; inset: 0; border-radius: 15px; background: #cbd5cf; transition: .2s; }
.switch i::after { content: ""; position: absolute; width: 19px; height: 19px; top: 3px; left: 3px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.18); transition: .2s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(18px); }

.modal-backdrop { position: fixed; z-index: 80; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 20px 0 0; background: rgba(22,38,30,.42); animation: fade .2s ease; }
.modal-sheet { width: min(100%, 480px); max-height: 88vh; overflow: auto; padding: 9px 20px calc(24px + env(safe-area-inset-bottom)); border-radius: 14px 14px 0 0; background: white; animation: slide .25s ease; }
.modal-handle { width: 38px; height: 4px; margin: 0 auto 12px; border-radius: 3px; background: #d7dfda; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-head .icon-btn { width: 34px; height: 34px; }
.modal-copy { color: var(--muted); font-size: 12px; line-height: 1.7; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateY(20px); } }
.invite-code { padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-radius: 7px; background: var(--bg); }
.invite-code code { min-width: 0; overflow: hidden; color: var(--ink); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.qr-wrap { width: 190px; height: 190px; margin: 16px auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: white; }
.notification-list, .comment-list { display: grid; gap: 8px; }
.notification-item, .comment-item { padding: 12px; display: grid; grid-template-columns: 36px 1fr; gap: 10px; background: var(--bg); border-radius: 7px; }
.notification-item.unread { background: var(--mint); }
.notification-item p, .comment-item p { margin: 0; font-size: 12px; line-height: 1.55; }
.notification-item time, .comment-item time { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.notification-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: white; }
.notification-icon svg { width: 17px; }
.comment-compose { position: sticky; bottom: -24px; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 0 0; background: white; }
.comment-compose button { width: 46px; }
.loading-state { min-height: 180px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.spinner { width: 25px; height: 25px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-root { position: fixed; z-index: 120; top: 18px; left: 50%; width: min(calc(100% - 36px), 430px); transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 11px 13px; display: flex; align-items: center; gap: 9px; border-radius: 7px; color: white; background: #263b31; box-shadow: var(--shadow); font-size: 12px; animation: toast-in .25s ease; }
.toast.error { background: #943f31; }
.toast svg { width: 17px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (min-width: 700px) {
  body { background: #e6eeea; }
  .app-shell, .auth-screen { min-height: 100vh; }
}

@media (max-width: 370px) {
  .page { padding-left: 13px; padding-right: 13px; }
  .form-grid.two { grid-template-columns: 1fr; }
  .form-grid.three { gap: 7px; }
  .stats-grid { gap: 6px; }
  .mini-stat { padding: 10px 8px; }
}
