:root {
  --ink: #273d4c;
  --muted: #7c8e98;
  --line: #e7edef;
  --cream: #f8f7f2;
  --mint: #dff3ea;
  --green: #4eae8e;
  --blue: #5daac7;
  --card: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: "Noto Sans TC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }

.app-shell { max-width: 900px; min-height: 100vh; margin: 0 auto; padding: 42px 48px 112px; }
.topbar, .section-heading, .medicine-card, .metric-heading { display: flex; align-items: center; justify-content: space-between; }
.eyebrow, .date, .section-kicker, .medicine-info p, .metric-note { margin: 0; color: var(--muted); }
.eyebrow, .section-kicker { font-size: 14px; font-weight: 600; letter-spacing: .04em; }
.day-care-quote { max-width: 620px; margin: 4px 0 7px; color: #39775f; font-size: 14px; font-weight: 700; line-height: 1.5; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 4px 0; font-size: clamp(26px, 4vw, 34px); letter-spacing: -.04em; }
.date { font-size: 14px; }
#today-time { margin-top: 2px; font-variant-numeric: tabular-nums; }
.avatar { width: 48px; height: 48px; border: 0; border-radius: 50%; color: #39775f; background: #ccebdc; font-weight: 700; }

.greeting-card { display: flex; justify-content: space-between; align-items: center; margin: 30px 0 36px; padding: 25px 28px; border-radius: 22px; background: var(--mint); }
.greeting-card p { margin-bottom: 5px; color: #4a806e; font-size: 14px; }
.greeting-card .greeting-status { margin: 0 0 5px; color: var(--ink); font-size: 16px; font-weight: 700; }
.greeting-card h2 { margin: 0; font-size: clamp(18px, 2.5vw, 23px); letter-spacing: -.025em; }
.greeting-icon { font-size: 45px; }

.section-block { margin-top: 32px; }
.section-heading { margin-bottom: 15px; }
.section-heading h2 { margin: 2px 0 0; font-size: 22px; letter-spacing: -.03em; }
.text-button, .link-button { border: 0; background: transparent; color: var(--green); font-size: 14px; font-weight: 700; }
.medicine-summary { color: var(--green); font-size: 14px; font-weight: 700; }
.medicine-card { min-height: 82px; margin-top: 10px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); gap: 14px; }
.medicine-time { min-width: 69px; border-right: 1px solid var(--line); }
.medicine-time span, .medicine-info h3 { display: block; font-size: 16px; font-weight: 700; }
.medicine-time small { color: var(--muted); font-size: 12px; }
.medicine-info { display: flex; align-items: center; gap: 11px; flex: 1; }
.medicine-info h3 { margin: 0 0 2px; }
.medicine-info p { font-size: 13px; }
.pill-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; background: #fff4e7; font-size: 19px; }
.check-button, .circle-button { width: 29px; height: 29px; border-radius: 50%; }
.check-button { border: 0; background: var(--green); color: white; font-weight: 700; }
.circle-button { border: 2px solid #c9d4d8; background: transparent; }
.muted-card { opacity: .78; }
.medicine-card.completed { background: #fcfffd; }
.home-medicine-empty { margin: 10px 0 0; padding: 20px; border: 1px dashed #cfdbdf; border-radius: 16px; color: var(--muted); text-align: center; background: rgba(255,255,255,.55); font-size: 14px; }
.today-medicine-actions { display: flex; align-items: center; gap: 9px; }
.today-delete-button { padding: 7px 9px; border: 0; border-radius: 9px; color: #b36b67; background: #fff0ef; font-size: 12px; font-weight: 700; }
.reminder-stack { position: fixed; z-index: 10; top: 18px; right: max(18px, calc((100% - 900px) / 2 + 18px)); display: grid; gap: 9px; width: min(340px, calc(100% - 36px)); pointer-events: none; }
.medicine-reminder { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px 11px 16px; border: 1px solid #f0ce85; border-radius: 13px; color: #77541a; background: #fff8e7; box-shadow: 0 8px 22px rgba(96, 74, 24, .13); font-size: 14px; font-weight: 700; pointer-events: auto; }
.reminder-taken-button { flex: 0 0 auto; padding: 7px 10px; border: 0; border-radius: 9px; color: #fff; background: #4eae8e; font-size: 13px; font-weight: 700; }
.water-reminder { border-color: #b9dfea; color: #347a95; background: #effaff; box-shadow: 0 8px 22px rgba(52, 122, 149, .13); }
.water-reminder-stack { top: 18px; }

.metrics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 31px; }
.metric-card { min-height: 206px; padding: 20px; border-radius: 20px; }
.water-card { background: #e6f5fa; }
.sleep-card { background: #f0edff; }
.sleep-card .metric-value { margin: 10px 0 5px; }
.sleep-card .metric-note { min-height: 20px; margin-bottom: 10px; }
.sleep-form { display: grid; gap: 9px; }
.sleep-time-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.sleep-field { display: grid; gap: 4px; color: #526a77; font-size: 12px; font-weight: 700; }
.sleep-field input { width: 100%; min-width: 0; padding: 8px 9px; border: 1px solid #d6d3e8; border-radius: 9px; color: var(--ink); background: rgba(255,255,255,.75); font: inherit; font-size: 13px; }
.sleep-field input:focus { outline: 2px solid #c8bff1; outline-offset: 1px; }
.sleep-save { margin-top: 0; }
.sleep-feedback { min-height: 1.2em; margin: 0; color: #7564b5; font-size: 12px; }
.settings-card { padding: 23px; border: 1px solid var(--line); border-radius: 20px; background: #fff; }
.settings-card .section-heading { margin-bottom: 12px; }
.settings-row { display: flex; align-items: flex-start; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.settings-icon { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border-radius: 12px; background: #effaf5; font-size: 20px; }
.settings-row h3 { margin: 0 0 3px; font-size: 15px; }
.settings-row p, .settings-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.settings-link { display: flex; align-items: center; gap: 11px; padding: 13px 2px; border-top: 1px solid var(--line); color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none; }
.settings-link span:nth-child(2) { flex: 1; }
.settings-link span:first-child { font-size: 19px; }
.settings-link span:last-child { color: var(--muted); font-size: 22px; }
.metric-heading { justify-content: flex-start; gap: 8px; color: #526a77; font-size: 14px; font-weight: 700; }
.metric-icon { font-size: 20px; }
.metric-value { margin: 18px 0 12px; }
.metric-value strong { font-size: 34px; line-height: 1; letter-spacing: -.05em; }
.metric-value span { margin-left: 5px; color: var(--muted); font-size: 14px; }
.progress-track { width: 100%; height: 8px; overflow: hidden; border-radius: 8px; background: #c6e4ee; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--blue); transition: width .25s ease; }
.add-water { width: 100%; margin-top: 18px; padding: 9px; border: 1px solid #b9dfea; border-radius: 10px; color: #347a95; background: rgba(255,255,255,.6); font-size: 13px; font-weight: 700; }
.add-water:disabled { cursor: default; color: #5c8d9e; background: rgba(255,255,255,.42); }
.metric-note { margin: 0 0 14px; font-size: 13px; }
.link-button { padding: 0; color: #7564b5; }
.link-button span { font-size: 22px; vertical-align: -2px; }

.condition-section { padding: 23px; border-radius: 20px; background: #fff; border: 1px solid var(--line); }
.condition-section .section-heading { margin-bottom: 9px; }
.daily-care-message { margin: 0 0 16px; padding: 14px 16px; border-radius: 13px; color: #39775f; background: #effaf5; font-size: 15px; font-weight: 700; }
.condition-prompt { margin-bottom: 17px; color: var(--muted); font-size: 14px; }
.mood-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.mood-button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 5px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: white; font-size: 13px; transition: .18s ease; }
.mood-button span { font-size: 24px; }
.mood-button.selected { border-color: #95d5bd; color: #39775f; background: #effaf5; box-shadow: inset 0 0 0 1px #95d5bd; }

.assistant-section { padding: 23px; border: 1px solid var(--line); border-radius: 20px; background: #fff; }
.assistant-section .section-heading { margin-bottom: 14px; }
.assistant-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 14px; background: #effaf5; font-size: 23px; }
.assistant-messages { display: grid; gap: 10px; max-height: 280px; overflow-y: auto; padding: 14px; border-radius: 14px; background: #f7faf9; }
.assistant-message { width: fit-content; max-width: 88%; margin: 0; padding: 10px 13px; border-radius: 13px; color: #526a77; background: #fff; font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-message.assistant-user { justify-self: end; color: #39775f; background: #e8f7f0; }
.assistant-note { margin: 11px 0; color: var(--muted); font-size: 12px; }
.assistant-form { display: flex; gap: 9px; }
.assistant-form input { min-width: 0; flex: 1; padding: 11px 13px; border: 1px solid #d6e0e3; border-radius: 11px; outline: none; color: var(--ink); background: #fcfdfd; font: inherit; font-size: 14px; }
.assistant-form input:focus { border-color: #86cdb1; box-shadow: 0 0 0 3px #e8f7f0; }
.assistant-send { padding: 10px 17px; border: 0; border-radius: 11px; color: #fff; background: var(--green); font-size: 14px; font-weight: 700; }

.bottom-nav { position: fixed; z-index: 2; bottom: 0; left: 50%; display: flex; align-items: center; justify-content: space-around; gap: 2px; width: min(900px, 100%); height: 78px; padding: 0 6px; transform: translateX(-50%); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.nav-item { display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; border: 0; color: #91a0a6; background: transparent; font-size: 11px; white-space: nowrap; }
.nav-item { text-decoration: none; }
.nav-item span { font-size: 23px; line-height: 20px; }
.nav-item.active { color: var(--green); font-weight: 700; }
.nav-add { display: grid; width: 45px; height: 45px; place-items: center; border-radius: 50%; color: white; background: var(--green); box-shadow: 0 5px 12px rgba(78,174,142,.32); font-size: 31px; line-height: 1; transform: translateY(-16px); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* 用藥管理頁：延續首頁的圓角卡片與薄荷綠重點色。 */
.management-header { margin-bottom: 30px; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--green); font-size: 14px; font-weight: 700; text-decoration: none; }
.header-pill { width: 52px; height: 52px; font-size: 24px; }
.form-card { padding: 25px 27px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); }
.form-grid { display: grid; grid-template-columns: 1.65fr 1fr; gap: 16px; }
.field-label { display: block; margin-bottom: 16px; color: #526a77; font-size: 14px; font-weight: 700; }
.field-label span { color: var(--muted); font-weight: 400; }
.field-label input, .field-label textarea { display: block; width: 100%; margin-top: 7px; padding: 11px 13px; border: 1px solid #d6e0e3; border-radius: 11px; outline: none; color: var(--ink); background: #fcfdfd; font: inherit; font-size: 15px; transition: border-color .18s, box-shadow .18s; }
.field-label textarea { resize: vertical; min-height: 82px; }
.field-label input:focus, .field-label textarea:focus { border-color: #86cdb1; box-shadow: 0 0 0 3px #e8f7f0; }
.primary-button { padding: 11px 17px; border: 0; border-radius: 11px; color: #fff; background: var(--green); box-shadow: 0 4px 10px rgba(78,174,142,.22); font-size: 14px; font-weight: 700; }
.medicine-list-section { margin-top: 31px; }
.management-list { display: grid; gap: 10px; }
.management-medicine-card { display: grid; grid-template-columns: 79px 1fr auto; align-items: center; gap: 15px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.management-medicine-card.completed { background: #fcfffd; }
.list-time { padding-right: 14px; border-right: 1px solid var(--line); color: var(--ink); font-size: 16px; font-weight: 700; }
.medicine-actions { display: flex; align-items: center; gap: 10px; }
.status-toggle, .delete-button { padding: 8px 11px; border-radius: 9px; font-size: 13px; font-weight: 700; }
.status-toggle { min-width: 76px; border: 1px solid #c8d5d8; color: #6e818a; background: #fff; }
.status-toggle.taken { border-color: var(--green); color: #fff; background: var(--green); }
.delete-button { border: 0; color: #b36b67; background: #fff0ef; }
.empty-state { padding: 38px 20px; border: 1px dashed #cfdbdf; border-radius: 17px; color: var(--muted); text-align: center; background: rgba(255,255,255,.55); }
.empty-state span { font-size: 31px; }
.empty-state p { margin: 7px 0 3px; color: #526a77; font-weight: 700; }
.empty-state small { font-size: 13px; }
.record-card { padding-bottom: 18px; }
.record-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.record-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px; }
.record-row time, .record-row strong { flex: 0 0 150px; color: #526a77; font-size: 13px; font-weight: 700; }
.record-row span { color: var(--muted); text-align: right; line-height: 1.5; }
.record-empty { padding: 12px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.record-manage-link { display: inline-block; margin-top: 14px; padding: 0; text-decoration: none; }

@media (max-width: 600px) {
  .app-shell { padding: 28px 20px 100px; }
  .greeting-card { margin: 22px 0 28px; padding: 20px; }
  .metrics-grid { grid-template-columns: 1fr; gap: 12px; }
  .metric-card { min-height: 180px; }
  .mood-list { gap: 7px; }
  .mood-button { font-size: 11px; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .form-card { padding: 20px; }
  .assistant-section { padding: 18px; }
  .assistant-form { gap: 7px; }
  .assistant-send { padding: 10px 13px; }
  .management-medicine-card { grid-template-columns: 60px 1fr; gap: 12px; }
  .medicine-actions { grid-column: 1 / -1; justify-content: flex-end; padding-top: 5px; }
  .list-time { padding-right: 10px; }
  .reminder-stack { top: 12px; right: 18px; }
  .bottom-nav { height: 72px; padding: 0 3px; }
  .nav-item { font-size: 10px; }
  .nav-item span { font-size: 21px; }
  .record-row { flex-direction: column; gap: 4px; }
  .record-row time, .record-row strong { flex-basis: auto; }
  .record-row span { text-align: left; }
}

/* 喝水提醒固定在頁面下方，避免同時出現時蓋住右上角的服藥提醒。 */
.water-reminder-stack { top: auto; bottom: 90px; }

/* Day 28 家人朋友：僅呈現尚未連接後端的介面狀態。 */
.friend-feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 32px; }
.friend-feature-grid .section-block { margin-top: 0; }
.section-heading .feature-status { flex: 0 0 auto; }
.feature-status { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; color: #75868d; background: #f1f4f4; font-size: 11px; font-weight: 700; white-space: nowrap; }
.friend-id-box { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1px dashed #cfdbdf; border-radius: 14px; background: #fbfcfc; }
.friend-id-box h3, .friend-empty-state h3 { margin: 1px 0 4px; font-size: 15px; }
.friend-id-box p, .friend-empty-state p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.qr-placeholder { display: grid; width: 132px; height: 132px; margin: 4px auto 15px; place-items: center; border: 1px dashed #cbd8dc; border-radius: 14px; color: #9eafb4; background: #f8faf9; }
.qr-placeholder span { font-size: 42px; }
.friend-feature-card .settings-note { margin-top: 10px; }
.friend-id-field { margin: 5px 0 0; }
.friend-disabled-button { margin-top: 12px; }
.friend-disabled-button:disabled, .friend-secondary-button:disabled, .chat-disabled-form button:disabled { cursor: not-allowed; opacity: .58; }
.friend-empty-state { display: grid; justify-items: center; padding: 24px 16px; border-top: 1px solid var(--line); text-align: center; }
.friend-empty-state > span, .chat-empty-state > span { margin-bottom: 8px; font-size: 29px; }
.friend-empty-state h3 { margin-bottom: 4px; }
.friend-empty-state .settings-note { margin: 10px 0 0; }
.compact-empty-state { padding-bottom: 12px; }
.friend-actions { display: flex; gap: 9px; margin-top: 13px; }
.friend-secondary-button { padding: 8px 14px; border: 1px solid #d9e2e4; border-radius: 9px; color: var(--muted); background: #f7f9f9; font-size: 13px; font-weight: 700; }
.chat-preview { padding: 12px; border-radius: 15px; background: #f7faf9; }
.chat-empty-state { display: grid; justify-items: center; min-height: 130px; align-content: center; padding: 16px; text-align: center; }
.chat-empty-state p { margin: 0 0 4px; color: #526a77; font-size: 14px; font-weight: 600; }
.chat-empty-state small { color: var(--muted); font-size: 12px; }
.chat-disabled-form { margin-top: 8px; }
.chat-disabled-form input:disabled { cursor: not-allowed; color: var(--muted); background: #eef2f2; }
.chat-disabled-form button:disabled { cursor: not-allowed; }

@media (max-width: 600px) {
  .friend-feature-grid { grid-template-columns: 1fr; gap: 0; }
  .friend-feature-grid .section-block { margin-top: 22px; }
  .friend-feature-card { padding: 20px; }
  .section-heading .feature-status { font-size: 10px; }
}

/* Supabase 登入與實際好友資料狀態。 */
.auth-form { display: grid; gap: 2px; }
.auth-form .field-label { margin-bottom: 12px; }
.auth-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.auth-actions button:disabled { cursor: progress; opacity: .65; }
.auth-message { min-height: 1.5em; margin: 6px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.auth-message[data-tone="success"] { color: #39775f; }
.auth-message[data-tone="error"] { color: #a65353; }
.account-id { display: block; margin-top: 6px; color: #526a77; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; user-select: all; }
.auth-signout { margin-top: 13px; }
.friends-login-link { display: inline-block; margin-top: 10px; text-decoration: none; }
.copy-id-button { margin-top: 8px; }
.subsection-heading { margin: 14px 0 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.subsection-heading h3 { margin: 0; color: #526a77; font-size: 14px; }
.friend-data-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.friend-data-row > strong { min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.friend-data-row > span { color: var(--muted); font-size: 12px; text-align: right; overflow-wrap: anywhere; }
.friend-data-row .friend-actions { grid-column: 1 / -1; margin-top: 2px; }
.friend-contact { align-items: start; }
.privacy-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 12px 0 4px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #fbfcfc; }
.privacy-toggle-row span { display: grid; gap: 3px; }
.privacy-toggle-row strong { font-size: 14px; }
.privacy-toggle-row small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.privacy-toggle-row input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--green); }
.privacy-toggle-row input:disabled { cursor: not-allowed; }

@media (max-width: 600px) {
  .friend-data-row { grid-template-columns: 1fr; }
  .friend-data-row > span { text-align: left; }
  .auth-actions button { flex: 1 1 auto; }
}
