:root {
  --ink: #3f3530;
  --muted: #8b7d75;
  --paper: #fffaf4;
  --card: #ffffff;
  --line: #eee1d5;
  --primary: #a65b51;
  --primary-dark: #85473f;
  --green: #497766;
  --shadow: 0 12px 32px rgba(95, 62, 41, .09);
  font-family: "Noto Sans TC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: #f7efe7;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; }
.landing { display: grid; place-items: center; padding: 24px; background: linear-gradient(140deg, #f9eee4, #edf4ee); }
.landing-card { width: min(680px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 28px; background: rgba(255,255,255,.88); box-shadow: var(--shadow); }
.eyebrow { color: var(--primary); font-size: 12px; letter-spacing: .16em; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 10px 0 12px; font-size: clamp(30px, 6vw, 48px); }
h2 { margin-bottom: 5px; font-size: 24px; }
h3 { margin-bottom: 14px; font-size: 17px; }
.muted, .hint, small { color: var(--muted); }
.role-links { display: grid; gap: 14px; margin: 28px 0; }
.role-card { display: flex; align-items: center; gap: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); transition: transform .15s, box-shadow .15s; }
.role-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.role-card strong, .role-card small { display: block; }
.role-card small { margin-top: 4px; font-size: 13px; }
.role-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: #f8e6d8; font-size: 24px; }
.test-note { margin: 0; font-size: 13px; }
.app-shell { min-height: 100vh; }
.topbar { position: static; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px max(16px, calc((100vw - 1100px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,250,244,.94); }
.brand { display: inline-flex; align-items: center; color: var(--primary-dark); }
.brand-banner { display: block; width: min(620px, calc(100vw - 32px)); height: auto; object-fit: contain; }
.brand-wordmark { justify-content: center; min-height: 52px; font-size: 25px; font-weight: 900; letter-spacing: .16em; }
.topbar nav { display: flex; gap: 8px; font-size: 13px; }
.nav-link { padding: 8px 12px; border-radius: 10px; color: var(--muted); }
.nav-link:hover { background: #f5e8de; color: var(--ink); }
.page { width: min(1100px, 100%); margin: 0 auto; padding: 28px 20px 60px; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-header p { margin-bottom: 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 5px 18px rgba(95, 62, 41, .04); }
.profile-card { border-color: #d9c4a7; background: linear-gradient(135deg, #fffdf8, #f8f4ea); }
.profile-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 14px; border-radius: 12px; background: rgba(255,255,255,.72); }
.profile-summary strong { font-size: 18px; }
.profile-summary span { color: var(--muted); }
.profile-summary small { flex-basis: 100%; }
.profile-note { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.profile-action { align-content: end; }
.profile-form { display: grid; gap: 18px; }
.profile-subsection { padding-top: 16px; border-top: 1px solid var(--line); }
.profile-subsection h4 { margin: 0 0 8px; font-size: 15px; }
.profile-health-details { margin-top: 16px; border-top: 1px solid var(--line); }
.profile-health-details summary { padding: 16px 0 8px; color: var(--primary-dark); font-weight: 800; cursor: pointer; list-style-position: inside; }
.profile-health-details[open] summary { margin-bottom: 2px; }
.collapsible-card { padding: 0; overflow: hidden; }
.collapsible-card summary { padding: 20px; color: var(--primary-dark); font-size: 17px; font-weight: 800; cursor: pointer; list-style-position: inside; }
.collapsible-card[open] summary { border-bottom: 1px solid var(--line); }
.collapsible-body { padding: 0 20px 20px; }
.body-condition-body { display: grid; gap: 0; }
.period-details { margin-top: 14px; border-top: 1px solid var(--line); }
.period-details summary { padding: 14px 0 8px; color: var(--primary-dark); font-weight: 800; cursor: pointer; list-style-position: inside; }
.period-details[open] summary { margin-bottom: 8px; }
.period-details-body { padding-bottom: 4px; }
.site-copyright { padding: 18px 20px 34px; color: var(--muted); font-size: 13px; line-height: 1.7; text-align: center; }
.site-copyright a { color: var(--primary-dark); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.profile-actions { display: flex; justify-content: flex-end; }
.medication-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1.3fr auto; align-items: end; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.medication-row:first-child { border-top: 0; }
.share-options { display: grid; gap: 12px; margin-bottom: 12px; }
.share-option { display: grid; gap: 8px; }
.share-options label { color: var(--muted); font-size: 15px; font-weight: 700; }
.share-card .hint, .share-version-hint { font-size: 15px; line-height: 1.7; }
.share-version-hint { margin: 0; color: var(--ink); }
.share-options select { max-width: 520px; }
.share-preview { display: grid; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.share-preview img { display: block; width: min(360px, 100%); max-height: 620px; object-fit: contain; object-position: top; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.share-pages { display: grid; gap: 18px; }
.share-page { display: grid; gap: 8px; }
.share-page-label { color: var(--muted); font-size: 13px; font-weight: 800; }
.share-page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.calendar-card { margin-bottom: 18px; }
.calendar-heading { display: flex; align-items: center; justify-content: flex-start; gap: 16px; }
.calendar-controls { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.calendar-controls strong { white-space: nowrap; text-align: left; }
.calendar-heading > .hint { margin: 0; }
.calendar-controls .button { min-width: 40px; padding: 7px 11px; }
.calendar-grid, .calendar-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.calendar-weekdays { margin: 14px 0 8px; color: var(--muted); font-size: 12px; text-align: center; }
.calendar-day { position: relative; min-height: 48px; padding: 10px 6px; border: 1px solid transparent; border-radius: 12px; color: var(--ink); background: #faf4ed; cursor: pointer; text-align: center; }
.calendar-day.has-record::after { position: absolute; bottom: 5px; left: 50%; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); content: ""; transform: translateX(-50%); }
.calendar-day.selected.has-record::after { background: #fff; }
.calendar-day:hover { border-color: #cc8a78; }
.calendar-day.muted { color: #c9bcb3; background: #fffdfb; cursor: default; }
.calendar-day.selected { border-color: var(--primary); color: white; background: var(--primary); font-weight: 800; }
.stat { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stat strong { display: block; font-size: 25px; color: var(--primary-dark); }
.stat span { color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.daily-status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.daily-status-grid .field { min-width: 0; }
.field { display: grid; gap: 6px; }
.field label { color: var(--muted); font-size: 15px; font-weight: 700; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.section-heading h3 { margin-bottom: 4px; }
.meal-section-heading { align-items: flex-start; }
.hint { margin: 0 0 12px; font-size: 14px; line-height: 1.65; }
.treat-inline-check { margin-top: 0; white-space: nowrap; }
.treat-inline-message { margin-top: -4px; margin-bottom: 4px; }
.inline-input { display: grid; grid-template-columns: minmax(0, 1fr) 58px; gap: 8px; align-items: center; }
.unit-suffix { display: grid; place-items: center; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #fff8f1; font-weight: 700; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fffdfb; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #cc8a78; box-shadow: 0 0 0 3px rgba(204, 138, 120, .15); }
textarea { min-height: 92px; resize: vertical; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 15px; border: 0; border-radius: 10px; color: white; background: var(--primary); font-weight: 800; }
.button:hover { background: var(--primary-dark); }
.button.secondary { color: var(--ink); background: #f4e8dd; }
.button.green { background: var(--green); }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.meal { display: grid; grid-template-columns: 130px 1fr; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.meal:first-of-type { border-top: 0; }
.meal-title { font-weight: 800; }
.meal small { display: block; margin-top: 5px; }
.meal-fields { display: grid; gap: 12px; }
.photo-preview { display: grid; place-items: center; min-height: 84px; overflow: hidden; border: 1px dashed #d8bca9; border-radius: 12px; color: var(--muted); background: #fffaf5; font-size: 12px; }
.photo-preview img { width: 100%; height: 110px; object-fit: cover; }
.photo-gallery { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.photo-item { position: relative; width: 100px; height: 100px; overflow: hidden; border-radius: 12px; background: #fffaf5; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-remove { position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 50%; color: white; background: rgba(63,53,48,.78); cursor: pointer; }
.photo-add { display: grid; place-items: center; width: 100px; height: 100px; padding: 8px; border: 1px dashed #d8bca9; border-radius: 12px; color: var(--muted); background: #fffaf5; text-align: center; font-size: 13px; cursor: pointer; }
.photo-add:hover { border-color: var(--primary); color: var(--primary-dark); }
.habit-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.check-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; background: #faf4ed; font-size: 14px; }
.check input { width: auto; }
.treat-check { margin-top: 14px; background: #fff3dc; }
.dynamic-row { display: grid; grid-template-columns: 1fr 1fr 1.3fr auto; align-items: end; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.dynamic-row:first-child { border-top: 0; }
.text-button { padding: 8px 0; border: 0; color: var(--primary-dark); background: transparent; cursor: pointer; font-weight: 700; }
.text-button.danger { color: #a45045; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.chart-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 3px; background: var(--primary); }
.chart-legend span:nth-child(2)::before { background: var(--green); }
.chart-legend span:nth-child(3)::before { background: #d49752; }
.chart-bars { display: flex; align-items: end; gap: 10px; min-height: 180px; overflow-x: auto; padding: 14px 4px 0; border-bottom: 1px solid var(--line); }
.chart-day { display: grid; gap: 6px; min-width: 44px; text-align: center; }
.bars { display: flex; align-items: end; justify-content: center; gap: 3px; height: 140px; }
.bar { display: block; width: 10px; min-height: 4px; border-radius: 5px 5px 0 0; }
.bar.water { background: var(--primary); }
.bar.weight { background: var(--green); }
.bar.waist { background: #d49752; }
.chart-empty { color: var(--muted); }
.empty { padding: 28px; border: 1px dashed #d8bca9; border-radius: 14px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 5; padding: 12px 16px; border-radius: 10px; color: #fff; background: #3f3530; box-shadow: var(--shadow); }
.photo-editor-modal { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; color: #fff; background: #171917; }
.photo-editor-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; background: rgba(0,0,0,.76); }
.photo-editor-header button { padding: 9px 12px; border: 0; border-radius: 10px; color: #fff; background: rgba(255,255,255,.13); cursor: pointer; }
.photo-editor-header .photo-editor-done { background: var(--primary); font-weight: 800; }
.photo-editor-stage { position: relative; flex: 1; min-height: 260px; overflow: hidden; touch-action: none; }
.photo-editor-image { position: absolute; max-width: none; user-select: none; pointer-events: none; }
.photo-editor-crop { position: absolute; z-index: 2; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.66); touch-action: none; }
.photo-editor-grid { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, transparent 32.8%, rgba(255,255,255,.5) 33%, transparent 33.4%, transparent 66.1%, rgba(255,255,255,.5) 66.3%, transparent 66.7%), linear-gradient(0deg, transparent 32.8%, rgba(255,255,255,.5) 33%, transparent 33.4%, transparent 66.1%, rgba(255,255,255,.5) 66.3%, transparent 66.7%); }
.photo-editor-move { position: absolute; inset: 0; cursor: move; }
.photo-editor-handle { position: absolute; z-index: 3; width: 28px; height: 28px; border: 3px solid #fff; border-radius: 50%; background: var(--primary); }
.photo-editor-handle.nw { top: -14px; left: -14px; cursor: nwse-resize; }
.photo-editor-handle.ne { top: -14px; right: -14px; cursor: nesw-resize; }
.photo-editor-handle.sw { bottom: -14px; left: -14px; cursor: nesw-resize; }
.photo-editor-handle.se { right: -14px; bottom: -14px; cursor: nwse-resize; }
.photo-editor-hint { margin: 0; padding: 10px 18px 14px; color: rgba(255,255,255,.72); background: rgba(0,0,0,.76); text-align: center; font-size: 13px; }
@media (max-width: 760px) {
  .landing-card { padding: 28px 22px; }
  .topbar { align-items: center; flex-direction: column; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .daily-status-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .daily-status-grid .field label { font-size: 13px; }
  .habit-list, .check-list { grid-template-columns: repeat(2, 1fr); }
  .meal { grid-template-columns: 1fr; }
  .dynamic-row { grid-template-columns: 1fr 1fr; }
  .calendar-heading { flex-wrap: wrap; gap: 10px 14px; }
  .calendar-heading > .hint { flex-basis: 100%; }
  .calendar-controls { justify-content: flex-start; }
  .dynamic-row .text-button { justify-self: start; }
}
