@font-face {
  font-family: FamilyCare;
  src: url('/fonts/family-care.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-synthesis: none;
  color: #303832;
  background: #fff;
  --ink: #303832;
  --muted: #717972;
  --line: #e1e5e0;
  --green: #edf3ec;
  --green-ink: #637d69;
  --error: #8a493e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #fff; font-size: 16px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 500; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button, summary, .file-button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
summary:focus-visible, [role='button']:focus-visible { outline: 2px solid #7a8b7c; outline-offset: 3px; }
a { color: inherit; }
.small { font-size: 13px; line-height: 1.7; }
.muted { color: var(--muted); }
.error-text { color: var(--error); font-size: 13px; white-space: pre-wrap; }
.error-text:empty { display: none; }
.danger-text { color: var(--error); }
.eyebrow { font-size: 12px; font-weight: 400; color: #838c81; }

.app {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
}

.care-note {
  margin: 0 0 23px;
  font-family: FamilyCare, 'PingFang SC', sans-serif;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: .01em;
  color: #3d443e;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.date-heading { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.date-heading h1 { font-size: 17px; font-weight: 500; line-height: 1.5; color: #3c443e; }
.history-label { color: #7a8277; font-size: 12px; white-space: nowrap; }
.text-button { min-height: 44px; padding: 8px 0; border: 0; background: none; font-size: 14px; font-weight: 400; }
.return-today { margin-left: auto; color: #616e64; font-size: 13px; white-space: nowrap; }
.date-strip { display: grid; grid-template-columns: repeat(7, minmax(44px, 1fr)); gap: 3px; margin: 6px 0 20px; }
.week-day { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-width: 44px; min-height: 62px; padding: 0; border: 0; border-radius: 0; background: transparent; color: #646d65; }
.week-day .weekday { font-size: 11px; font-weight: 400; line-height: 1.3; color: #838b84; }
.week-day .week-number { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 9px; color: #5f6961; font-size: 16px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.week-day.selected .week-number, .week-day[aria-pressed='true'] .week-number { background: #39433c; color: #fff; }
.week-day.selected .weekday, .week-day[aria-pressed='true'] .weekday { color: #39433c; }
.day-summary { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; margin: -5px 0 18px; color: #697563; font-size: 13px; line-height: 1.7; }
.day-summary .unconfirmed, .day-summary .summary-unconfirmed { color: #7d8278; font-size: 12px; }
.retry-load { width: 100%; margin: 0 0 14px; padding: 10px 12px; background: #f7f8f5; border-radius: 10px; font-size: 13px; color: #6c7865; text-align: left; }
.conflict-button { margin-bottom: 15px; font-size: 14px; }

.timeline { display: grid; gap: 19px; }
.time-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; margin-bottom: 9px; }
.time-title { display: flex; align-items: baseline; gap: 9px; min-width: 0; font-size: 19px; font-weight: 500; line-height: 1.4; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.time-title h2 { font: inherit; }
.time-kind, .time-count { color: #7c857d; font-size: 12px; font-weight: 400; letter-spacing: 0; }
.time-count { white-space: nowrap; }
.time-heading > .text-button { min-height: 44px; padding: 3px 0; font-size: 12px; color: #7c857d; }
.time-group .dose-list, .time-group .medicine-list { display: grid; gap: 9px; }
.collapsed-group { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 49px; width: 100%; padding: 9px 1px 12px; border: 0; border-bottom: 1px solid #e7eae6; background: #fff; text-align: left; }
.collapsed-left { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 12px; }
.group-clock { color: #5a645c; font-size: 17px; font-weight: 400; font-variant-numeric: tabular-nums; }
.group-recorded { color: #65766a; font-size: 12px; }
.group-expand { color: #7c867e; font-size: 12px; white-space: nowrap; }

.dose.medicine-card {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 44px;
  column-gap: 8px;
  align-items: center;
  min-height: 98px;
  padding: 11px 10px 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.dose.medicine-card.future { background: #f7f8f6; border-color: #eef0eb; }
.dose.medicine-card.confirmed { background: #fff; border-color: #d9e2d8; }
.dose.medicine-card[role='button'] { cursor: pointer; }
.photo-sticker { display: block; flex-shrink: 0; width: 88px; height: 74px; object-fit: contain; filter: drop-shadow(0 1px 1px #25352a1f); }
.photo-placeholder { display: flex; align-items: center; justify-content: center; width: 88px; height: 74px; border-radius: 9px; background: #f6f8f4; color: #8c9586; font-size: 11px; line-height: 1.5; white-space: pre-line; text-align: center; }
.dose-info { min-width: 0; }
.dose-name { font-size: 16px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.dose-dosage { display: block; margin-top: 5px; color: #697269; font-size: 15px; font-weight: 400; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.dose-time { display: block; color: #737c6e; font-size: 13px; font-weight: 400; line-height: 1.5; }
.dose-caption { margin-top: 4px; color: #65776a; font-size: 11px; font-weight: 400; line-height: 1.5; overflow-wrap: anywhere; }
.dose-caption.pending-caption, .dose-caption.backfill { color: #7c857d; }
.check-button { display: flex; align-items: center; justify-content: center; width: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: #58675d; font-size: 13px; font-weight: 400; }
.check-icon { display: flex; align-items: center; justify-content: center; width: 29px; height: 29px; border: 1.4px solid #858f86; border-radius: 50%; background: #fff; color: #fff; font-size: 18px; font-weight: 400; line-height: 1; }
.check-button.confirmed .check-icon { background: #637d69; border-color: #637d69; }
.check-button.future { color: #949f94; opacity: 1; font-size: 23px; }
.check-button.future .check-icon { border-color: transparent; background: transparent; color: #949f94; font-size: 24px; }
.check-button.pending .check-icon { border-style: dashed; color: #7b897a; }
.check-button.backfill, .check-button.backfill-label { background: #f0f2ee; color: #59685c; }
.dose-highlight { outline: 2px solid #829585; outline-offset: 3px; }
.empty-state, .period-empty { padding: 17px 0; color: #7c857d; font-size: 14px; line-height: 1.8; }

.bottom-actions { display: grid; gap: 0; margin-top: 24px; padding-top: 9px; border-top: 1px solid #e8ebe6; }
.add-medicine { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 45px; padding: 6px 0; border: 0; background: transparent; color: #526157; font-size: 15px; font-weight: 400; text-align: left; }
.add-plus { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; font-size: 23px; font-weight: 300; line-height: 1; color: #66766c; }
.calendar-section { min-width: 0; }
.calendar-section > summary { display: flex; align-items: center; gap: 7px; min-height: 45px; padding: 6px 0; color: #7a867d; font-size: 13px; font-weight: 400; list-style: none; cursor: pointer; }
.calendar-section > summary::-webkit-details-marker { display: none; }
.calendar-section > summary::before { content: '›'; margin-left: auto; order: 1; color: #a1a798; font-size: 20px; line-height: 1; }
.calendar-section[open] > summary::before { transform: rotate(90deg); }
.calendar-heading { display: flex; align-items: center; justify-content: space-between; gap: 7px; min-height: 44px; }
.calendar-heading h2 { font-size: 16px; font-weight: 500; white-space: nowrap; }
.calendar-today { margin-left: auto; color: #7c857d; font-size: 11px; white-space: nowrap; }
.month-controls { display: flex; gap: 0; }
.icon-button { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: #838d7a; font-size: 24px; line-height: 1; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0; text-align: center; }
.calendar-weekdays { margin: 2px 0 4px; color: #969d90; font-size: 11px; }
.calendar-cell { position: relative; display: flex; align-items: flex-start; justify-content: center; width: 100%; min-width: 0; min-height: 44px; padding: 1px 0 0; border: 0; background: transparent; font-size: 15px; font-variant-numeric: tabular-nums; }
.calendar-cell .day-number { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; color: #66725d; line-height: 1; font-weight: 400; }
.calendar-cell.selected .day-number, .calendar-cell[aria-pressed='true'] .day-number { background: #39433c; color: #fff; }
.calendar-cell.today .day-number { font-weight: 600; color: #353f32; }
.calendar-cell.today::after { content: ''; position: absolute; top: 34px; left: calc(50% - 9px); width: 18px; border-bottom: 1px solid #9ca894; }
.calendar-cell.selected.today .day-number, .calendar-cell.today[aria-pressed='true'] .day-number { color: #fff; }
.day-dot { position: absolute; bottom: 3px; left: calc(50% - 2px); width: 4px; height: 4px; border: 1px solid #96a18b; border-radius: 50%; background: transparent; }
.day-dot.complete { background: #718c73; border-color: #718c73; }
.day-dot.no-plan { width: 7px; height: 1px; left: calc(50% - 3.5px); bottom: 5px; border: 0; border-radius: 0; background: #a6ad9d; }
.calendar-legend { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px; margin-top: 9px; color: #8d9785; font-size: 10px; line-height: 1.6; }
.calendar-legend span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-dot { width: 5px; height: 5px; border: 1px solid #96a18b; border-radius: 50%; }
.legend-dot.complete { background: #718c73; border-color: #718c73; }
.legend-dot.no-plan { width: 7px; height: 1px; border: 0; border-radius: 0; background: #a6ad9d; }
.calendar-caveat { margin-top: 8px; color: #929b89; font-size: 11px; line-height: 1.6; }
#calendar-error { margin-top: 9px; }

.button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 11px 15px; border: 1px solid #cbd4c5; border-radius: 10px; background: #fff; font-size: 16px; font-weight: 400; line-height: 1.5; text-align: center; }
.button-dark { background: #39433c; color: #fff; border-color: #39433c; }
.button:disabled { opacity: .55; }
.button-stack { display: grid; gap: 11px; margin: 19px 0; }
.file-button { position: relative; margin: 0; overflow: hidden; }
input[type='file'] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
label { display: block; margin: 19px 0 7px; font-size: 14px; font-weight: 500; }
input:not([type='file']):not([type='range']), textarea, select { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: 11px 12px; border: 1px solid #c8d0c2; border-radius: 9px; background: #fff; color: var(--ink); font-size: 16px; }
input::placeholder, textarea::placeholder { color: #9ba393; }
input[type='datetime-local'], input[type='time'] { appearance: none; -webkit-appearance: none; }
textarea { resize: vertical; }

.sheet { width: min(100%, 500px); max-width: 100%; max-height: 90vh; max-height: 90dvh; margin: auto auto 0; padding: 23px 21px calc(25px + env(safe-area-inset-bottom)); border: 1px solid #dfe5dd; border-bottom: 0; border-radius: 22px 22px 0 0; background: #fff; color: var(--ink); overflow: auto; overscroll-behavior: contain; }
.sheet::backdrop { background: #26322238; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 19px; }
.sheet-head h2 { margin-top: 3px; font-size: 23px; font-weight: 500; line-height: 1.4; }
.close-button { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: #f3f5f0; color: #7f8a76; font-size: 26px; line-height: 1; }
.sheet > p { margin-bottom: 18px; }
.sheet h3 { font-size: 18px; font-weight: 500; }
.dialog-management { margin-top: 20px; padding-top: 10px; border-top: 1px solid #e8ece3; }
.dialog-management .text-button { width: 100%; text-align: center; color: #63765c; }
.setting-section { margin-top: 25px; padding-top: 22px; border-top: 1px solid #e5eadf; }
.setting-section > p { margin-top: 10px; }
.setting-section > .button { margin-top: 15px; }
.install-help { margin-top: 15px; font-size: 13px; color: var(--muted); }
.install-help summary { min-height: 44px; padding: 10px 0; font-weight: 400; cursor: pointer; }
.install-help p { margin-top: 8px; line-height: 1.7; }
.logout-button { display: block; margin-top: 14px; color: #7d8875; }
.medicine-list-item { display: flex; align-items: center; gap: 10px; padding: 15px 0; border-top: 1px solid #e6ebdf; }
.medicine-list-item:first-child { padding-top: 0; border-top: 0; }
.medicine-list-item .photo-sticker { width: 48px; height: 58px; }
.medicine-list-item > div { flex: 1; min-width: 0; }
.medicine-list-item h3 { font-size: 16px; overflow-wrap: anywhere; }
.medicine-list-item p { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.medicine-list-item .text-button { flex-shrink: 0; font-size: 13px; }
.photo-area { margin-bottom: 20px; padding: 15px 11px; border: 1px solid #e0e6d9; border-radius: 14px; background: #f8faf5; text-align: center; }
.photo-area > img { display: block; width: 160px; height: 160px; margin: auto; object-fit: contain; filter: drop-shadow(0 2px 2px #2631262b); }
.photo-area p { margin-top: 12px; }
.photo-controls { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 15px; }
.photo-controls .text-button { font-size: 12px; }
.notice { margin: 15px 0; padding: 12px 13px; border-radius: 10px; background: #f3f6ef; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.error-notice { background: #faf2ee; }
.schedule-heading { display: flex; align-items: center; gap: 18px; margin-top: 23px; }
.schedule-heading label { margin: 0; }
.schedule-heading input { max-width: 83px; }
.schedule-row { margin-top: 13px; padding: 13px; border: 1px solid #d9e1d1; border-radius: 11px; }
.schedule-row-heading { margin-bottom: 7px; font-size: 13px; font-weight: 500; }
.schedule-row label { margin-top: 8px; font-size: 13px; }
#medicine-save { margin-top: 24px; }
#medicine-stop { width: 100%; margin-top: 15px; }
.crop-preview { position: relative; width: 100%; overflow: hidden; background: #f4f6f1; line-height: 0; }
.crop-preview img { width: 100%; max-height: 350px; object-fit: fill; }
.crop-preview #crop-box { position: absolute; inset: 0; border: 2px solid #6b875a; box-shadow: 0 0 0 400px #0004; pointer-events: none; }
.crop-sliders { margin-bottom: 20px; }
.crop-sliders label { display: flex; align-items: center; gap: 15px; font-size: 13px; }
.crop-sliders input { width: 100%; min-height: 44px; accent-color: #718667; }
#record-existing { white-space: pre-wrap; }
#record-form button[type='submit'], #stop-form button[type='submit'] { margin-top: 22px; }
.conflict-item { padding: 15px 0; border-top: 1px solid #e0e7d8; }
.conflict-item h3 { font-size: 17px; }
.conflict-item p { margin: 7px 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.conflict-item .button { min-height: 44px; margin-top: 10px; font-size: 14px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(25px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); padding: 12px 17px; border-radius: 11px; background: #39433c; color: #fff; box-shadow: 0 4px 16px #25302019; font-size: 14px; }

.login-view { max-width: 400px; margin: 0 auto; padding: calc(60px + env(safe-area-inset-top)) 27px 30px; }
.brand-mark { display: flex; align-items: center; justify-content: center; width: 50px; height: 50px; margin-bottom: 26px; border: 1px solid #d8e1d1; border-radius: 15px; background: var(--green); color: #637d69; font-size: 31px; }
.login-view h1 { margin-top: 6px; font-size: 40px; font-weight: 500; line-height: 1.3; }
.title-dot { color: #91a685; }
.login-intro { margin: 21px 0 24px; font-size: 21px; line-height: 1.6; }
.login-view form .button { margin-top: 16px; }
.login-view > p:last-child { margin-top: 28px; }

@media (max-width: 359px) {
  .app { padding-inline: 15px; }
  .date-strip { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; }
  .date-strip::-webkit-scrollbar { display: none; }
  .week-day { flex: 0 0 44px; }
  .dose.medicine-card { grid-template-columns: 76px minmax(0, 1fr) 44px; column-gap: 7px; padding-inline: 10px; }
  .photo-sticker, .photo-placeholder { width: 76px; height: 70px; }
  .dose-caption { font-size: 10px; }
  .date-heading { gap: 5px; }
  .date-heading h1 { font-size: 16px; }
  .history-label { font-size: 11px; }
  .calendar-today { font-size: 10px; }
  .calendar-grid, .calendar-weekdays { width: calc(100% + 30px); margin-inline: -15px; }
  .calendar-legend { font-size: 9px; gap: 5px; }
  .sheet { padding-inline: 18px; }
}

@media (min-width: 600px) {
  .app { padding-top: 30px; padding-bottom: 36px; }
  .sheet { margin: auto; border-bottom: 1px solid #dfe5dd; border-radius: 22px; max-height: 88vh; }
  .login-view { padding-top: 80px; }
}

@media (prefers-reduced-motion: no-preference) {
  .check-button:active, .button:active, .add-medicine:active { transform: translateY(1px); }
}
