:root {
  color-scheme: light;
  --bg: #f8f6f1;
  --paper: #fffdfa;
  --ink: #29242e;
  --muted: #6f6572;
  --line: #e8e0e6;
  --plum: #49334f;
  --plum-deep: #32233c;
  --lilac: #efe8f3;
  --sage: #e6ede3;
  --peach: #f6e7dd;
  --danger: #912f3d;
  --max: 43rem;
  --bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, a { -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
a { color: inherit; }
:focus-visible { outline: 2px solid #845e98; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 6vw, 2.4rem); line-height: 1.2; letter-spacing: -.045em; }
h2 { font-size: 1.08rem; letter-spacing: -.025em; }
svg.icon { width: 1.2rem; height: 1.2rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.top { padding: env(safe-area-inset-top, 0px) max(1.15rem, env(safe-area-inset-right)) 0 max(1.15rem, env(safe-area-inset-left)); border-bottom: 1px solid #eee7e9; }
.top-inner { max-width: var(--max); margin: auto; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.brand { display: flex; align-items: center; gap: .67rem; padding: 0; background: transparent; border: 0; text-align: left; }
.brand img { border-radius: 13px; }
.brand b { display: block; font-size: 1.37rem; letter-spacing: -.06em; line-height: 1; }
.brand-dot { color: #986c9b; }
.brand small { display: block; margin-top: .32rem; font-size: .68rem; font-weight: 600; color: var(--muted); letter-spacing: .08em; }
.top-link, .text-button { min-height: 44px; border: 0; background: transparent; color: var(--plum); display: inline-flex; gap: .35rem; align-items: center; font-size: .85rem; font-weight: 650; padding: .25rem .12rem; white-space: nowrap; }
.top-link { border: 1px solid var(--line); border-radius: 100px; padding: .3rem .7rem; background: var(--paper); }
.top-link[aria-current] { background: var(--lilac); }
.text-button .icon { width: .95rem; }
.shell { max-width: calc(var(--max) + 2.3rem); margin: auto; padding: 1.6rem max(1.15rem, env(safe-area-inset-right)) calc(6rem + var(--bottom)) max(1.15rem, env(safe-area-inset-left)); }
.page-date { font-weight: 650; font-size: .75rem; letter-spacing: .055em; color: var(--muted); margin-bottom: .45rem; }
.page-title { display: flex; gap: .55rem; justify-content: space-between; align-items: center; margin-bottom: 1.13rem; }
.status-chip { display: inline-flex; align-items: center; gap: .38rem; padding: .38rem .55rem; border-radius: 99px; background: #ede8e9; font-size: .68rem; color: var(--muted); white-space: nowrap; }
.status-chip::before { content: ''; width: .37rem; height: .37rem; border-radius: 50%; background: #887e89; }
.status-chip.ready { background: var(--sage); color: #3a5740; }
.status-chip.ready::before { background: #567758; }
.hero { position: relative; overflow: hidden; border-radius: 23px; background: var(--plum-deep); color: #fff8f4; min-height: 203px; padding: 1.2rem 1.15rem; }
.hero-content { position: relative; z-index: 1; }
.hero-kicker { color: #e5c5b9; font-size: .72rem; font-weight: 700; letter-spacing: .13em; margin-bottom: .45rem; }
.hero h2 { font-size: clamp(1.65rem, 6vw, 2.15rem); line-height: 1.18; }
.hero p:not(.hero-kicker) { margin-top: .37rem; font-size: .81rem; color: #e9dbeb; }
.hero-art { position: absolute; pointer-events: none; color: #e9bfd8; width: min(57%, 235px); right: -1.05rem; top: 50%; transform: translateY(-50%); }
.hero-art svg { display: block; width: 100%; }
.button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem .95rem; border-radius: 13px; border: 1px solid transparent; font-weight: 700; line-height: 1.2; text-decoration: none; text-align: center; }
.hero-button { background: #f3cfba; color: #37263c; margin-top: 1rem; }
.primary { background: var(--plum); color: #fff; }
.secondary { background: var(--lilac); color: var(--plum); }
.danger { background: #fae9e9; color: var(--danger); }
.wide { width: 100%; min-height: 50px; }
.compact { padding-inline: .7rem; font-size: .85rem; }
button:not(:disabled):active, .button:active { filter: brightness(.94); }
.metrics { margin-top: .85rem; display: grid; grid-template-columns: 1fr 1fr 1.23fr; gap: .48rem; }
.metric { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 15px; padding: .7rem .57rem; }
.metric.interval { background: #f0edf3; border-color: #e9e1ed; }
.metric span, .metric small { display: block; font-size: .69rem; color: var(--muted); line-height: 1.35; }
.metric strong { display: block; font-size: 1.65rem; font-weight: 720; line-height: 1.2; margin: .24rem 0 .2rem; font-variant-numeric: tabular-nums; }
.metric.interval strong { font-size: clamp(.93rem, 4vw, 1.3rem); min-height: 1.98rem; display: flex; align-items: center; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .45rem; margin: 1rem 0 .34rem; }
.section-head.flush { margin: 0 0 .7rem; }
.section-head .subtle { margin-top: .2rem; }
.subtle { font-size: .81rem; color: var(--muted); line-height: 1.6; }
.empty { border: 1px dashed #d9cedb; border-radius: 16px; padding: 1.15rem; background: #fbf9f7; text-align: center; }
.empty .tile { margin: 0 auto .55rem; }
.empty p { margin-top: .35rem; }
.tile { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--lilac); color: var(--plum); }
.tint-food, .tint-peach { background: var(--peach); color: #70462f; }
.tint-yellow { background: #f5edce; color: #6f5419; }
.tint-foam { background: #e8edf3; color: #465770; }
.tint-hair, .tint-sage { background: var(--sage); color: #3d5b42; }
.tint-other { background: var(--lilac); }
.backup-strip { display: flex; align-items: center; gap: .68rem; width: 100%; background: transparent; border: 0; padding: .8rem 0; margin-top: .65rem; text-align: left; }
.backup-strip b, .backup-strip small { display: block; }
.backup-strip b { font-size: .83rem; }
.backup-strip small { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.backup-strip > .icon:last-child { margin-left: auto; color: var(--muted); width: 1rem; }
.bottom-nav { position: fixed; z-index: 2; left: 0; right: 0; bottom: 0; padding: .35rem 0 calc(.32rem + var(--bottom)); background: #fffdfa; border-top: 1px solid var(--line); }
.nav-inner { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 30rem; margin: auto; gap: .45rem; padding: 0 1.1rem; }
.nav-inner button { display: flex; flex-direction: column; gap: .18rem; min-height: 47px; align-items: center; justify-content: center; background: transparent; border: 0; border-radius: 13px; color: var(--muted); font-size: .7rem; font-weight: 650; }
.nav-inner button[aria-current] { background: var(--lilac); color: var(--plum-deep); }
.record-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .42rem; }
.record-row { display: flex; width: 100%; text-align: left; align-items: center; gap: .62rem; background: var(--paper); border: 1px solid var(--line); border-radius: 13px; padding: .58rem; }
.record-row .tile { font-size: .83rem; font-weight: 700; }
.record-label { display: grid; gap: .28rem; min-width: 0; flex: 1; }
.record-label b { font-size: .9rem; }
.record-label small, .record-extra { font-size: .71rem; color: var(--muted); }
.record-extra { display: inline-flex; align-items: center; gap: .2rem; white-space: nowrap; }
.record-extra .icon, .record-row > .icon { width: .94rem; color: var(--muted); }
.history-filter { display: flex; align-items: center; justify-content: space-between; gap: .65rem; background: var(--lilac); border-radius: 13px; padding: .1rem .7rem; font-size: .9rem; }
#history-count { margin: .48rem 0 .65rem; }
.day-heading { font-size: .81rem; margin: .95rem 0 .4rem; color: var(--muted); }
.more { width: 100%; margin-top: 1rem; }
.panel { background: var(--paper); border: 1px solid var(--line); padding: .9rem; border-radius: 17px; margin-bottom: .7rem; }
.segments { display: flex; padding: .15rem; gap: .15rem; border-radius: 13px; background: var(--lilac); flex: none; }
.segments button { background: transparent; border: 0; border-radius: 11px; padding: .25rem .55rem; min-height: 44px; font-size: .78rem; white-space: nowrap; }
.segments button[aria-pressed="true"] { background: var(--plum); color: white; }
.trend-summary { color: var(--plum); font-size: .92rem; font-weight: 700; }
.trend-svg { width: 100%; height: 116px; display: block; margin-top: .65rem; }
.trend-svg rect { fill: #9f7cae; }
.trend-svg rect:last-of-type { fill: #5c3f66; }
.trend-svg line { stroke: #dad0de; vector-effect: non-scaling-stroke; }
.chart-labels { display: flex; justify-content: space-between; margin-top: .35rem; font-size: .7rem; color: var(--muted); }
.chart-details { font-size: .78rem; margin-top: .55rem; color: var(--muted); }
.chart-details summary { min-height: 44px; display: list-item; padding-top: .7rem; cursor: pointer; }
.chart-details ul { margin: 0; padding-left: 1.15rem; line-height: 1.65; }
.type-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .18rem .5rem; margin: .68rem 0; font-size: .81rem; }
.type-item span:last-of-type { color: var(--muted); font-variant-numeric: tabular-nums; }
.type-item progress { grid-column: 1 / -1; appearance: none; width: 100%; height: 7px; border: 0; border-radius: 10px; background: var(--lilac); accent-color: var(--plum); }
.type-item progress::-webkit-progress-bar { border-radius: 10px; background: var(--lilac); }
.type-item progress::-webkit-progress-value { border-radius: 10px; background: #9372a1; }
.type-item progress::-moz-progress-bar { border-radius: 10px; background: #9372a1; }
.month-nav { display: flex; align-items: center; gap: .18rem; font-size: .78rem; white-space: nowrap; }
.icon-button { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; border: 0; border-radius: 12px; background: var(--lilac); color: var(--plum); padding: .2rem; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .2rem; text-align: center; align-items: stretch; }
.weekday { font-size: .7rem; color: var(--muted); padding: .2rem; }
.day { min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; font-size: .77rem; padding: .1rem; background: #f7f3f4; }
.day.has-events { color: var(--plum-deep); background: var(--lilac); font-weight: 700; }
.day small { font-size: .62rem; color: var(--plum); }
.day.is-today { border-color: #9f7cae; }
.calendar-note { margin-top: .6rem; }
.notice { display: flex; align-items: flex-start; gap: .65rem; padding: .88rem; border-radius: 16px; background: var(--sage); margin-bottom: .72rem; color: #354f39; }
.notice .icon { margin-top: .06rem; }
.notice p, .data-card p, .setup p { margin-top: .48rem; font-size: .86rem; line-height: 1.65; }
.data-card p, .setup p { color: var(--muted); }
.data-card .button { margin-top: .65rem; }
.data-message:empty { display: none; }
.data-message { margin: .55rem 0; overflow-wrap: anywhere; }
.setup summary { cursor: pointer; font-weight: 700; padding-block: .22rem; }
.error { background: #fbe8e7; color: var(--danger); border-radius: 10px; padding: .55rem .65rem; font-size: .81rem; line-height: 1.5; overflow-wrap: anywhere; }
#db-error { margin-bottom: .65rem; }
.toast { position: fixed; bottom: calc(4.3rem + var(--bottom)); left: 50%; transform: translateX(-50%); z-index: 3; width: max-content; max-width: calc(100% - 2rem); border-radius: 12px; background: var(--plum-deep); color: white; padding: .6rem .9rem; font-size: .84rem; box-shadow: 0 6px 24px #34244032; }
dialog { width: min(100%, 36rem); max-width: 100%; max-height: min(94vh, 46rem); max-height: min(94dvh, 46rem); padding: 0; border: 0; border-radius: 22px; background: var(--paper); color: var(--ink); box-shadow: 0 18px 80px #231b3359; overflow: hidden; }
dialog::backdrop { background: #231b336f; }
body:has(dialog[open]) { overflow: hidden; }
.sheet { max-height: min(94vh, 46rem); max-height: min(94dvh, 46rem); display: flex; flex-direction: column; }
.sheet-top, .sheet-foot { flex: none; padding: .68rem .95rem; background: var(--paper); }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: .65rem; border-bottom: 1px solid var(--line); }
.sheet-top h2 { font-size: 1.28rem; }
.sheet-top .page-date { margin-bottom: .19rem; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding: .78rem .95rem; }
.sheet-foot { border-top: 1px solid var(--line); }
.sheet-foot .error { margin-bottom: .45rem; }
fieldset { min-width: 0; margin: 0 0 .8rem; border: 0; padding: 0; }
legend, .note-label { padding: 0; margin-bottom: .38rem; font-size: .88rem; font-weight: 720; }
.note-label { display: block; }
.date-fields { display: grid; grid-template-columns: 1.25fr 1fr; gap: .4rem; }
.date-fields label { min-width: 0; }
input[type="date"], input[type="time"], input[type="number"], textarea { min-height: 44px; width: 100%; min-width: 0; appearance: none; border: 1px solid var(--line); border-radius: 11px; background: #fbf8fa; font-size: 16px; padding: .44rem .55rem; }
input::-webkit-date-and-time-value { text-align: left; }
textarea { display: block; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: .34rem; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; width: 100%; height: 100%; inset: 0; margin: 0; cursor: pointer; }
.chip span { min-height: 44px; display: flex; align-items: center; padding: .3rem .6rem; background: #fbf8fa; border: 1px solid var(--line); border-radius: 10px; font-size: .8rem; }
.chip input:checked + span { background: var(--lilac); color: var(--plum-deep); border-color: #9d7aa7; font-weight: 700; }
.chip input:focus-visible + span { outline: 2px solid #845e98; outline-offset: 2px; }
.action-row { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.action-row p { font-size: .8rem; color: var(--muted); }
.stepper { flex: none; display: flex; align-items: center; gap: .2rem; border-radius: 11px; background: var(--lilac); }
.stepper button { width: 44px; height: 44px; display: grid; place-items: center; border: 0; color: var(--plum); background: transparent; padding: 0; }
.stepper input { background: var(--paper); border: 0; width: 3.1rem; min-height: 38px; padding: 0 .13rem; text-align: center; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.optional { font-size: .72rem; font-weight: 500; color: var(--muted); margin-left: .22rem; }
.photo-buttons { display: flex; gap: .45rem; }
.photo-buttons .button { font-size: .84rem; }
#photo-message:not(:empty) { margin-top: .4rem; }
.photos:not(:empty) { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; margin: .3rem 0 .56rem; }
.photo-tile { position: relative; min-width: 0; }
.photo-thumb { display: block; padding: 0; width: 100%; aspect-ratio: 1.2; background: var(--lilac); border: 0; border-radius: 10px; overflow: hidden; }
.photo-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-remove { min-width: 44px; min-height: 44px; border: 0; color: white; background: #32233cdd; position: absolute; right: 0; top: 0; border-radius: 0 10px 0 10px; display: grid; place-items: center; }
.photo-view { background: #25202a; display: grid; place-items: center; }
.photo-view img { width: 100%; max-height: 72vh; object-fit: contain; }
.detail-title { margin: 0 0 .6rem; font-size: 1.26rem; }
.detail-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 0 0 .8rem; }
.detail-fields div { padding: .6rem; border-radius: 11px; background: #f5eff6; min-width: 0; }
.detail-fields dt { font-size: .74rem; color: var(--muted); margin-bottom: .22rem; }
.detail-fields dd { font-size: .91rem; font-weight: 650; margin: 0; }
.detail-note { white-space: pre-wrap; overflow-wrap: anywhere; margin: .38rem 0 .75rem; font-size: .91rem; line-height: 1.6; }
.detail-actions, .export-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.detail-actions .primary, .export-actions .primary { flex: 1; }
.detail-actions .error { width: 100%; }
.restore-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; margin: .72rem 0; }
.restore-summary span { text-align: center; background: var(--lilac); padding: .48rem .15rem; border-radius: 10px; font-size: .8rem; }
.restore-summary b { display: block; font-size: 1.25rem; margin-bottom: .15rem; }
.restore-list { padding: 0; margin: .6rem 0; list-style: none; }
.restore-list li { display: flex; justify-content: space-between; gap: .35rem; padding: .52rem 0; border-bottom: 1px solid var(--line); font-size: .79rem; }
.restore-list li span:last-child { flex: none; color: var(--muted); }
.file-name { font-weight: 700; margin-bottom: .32rem; overflow-wrap: anywhere; }
#export-error { margin-top: .4rem; }

@media (max-width: 599px) {
  dialog { margin: auto auto 0; width: 100%; border-radius: 20px 20px 0 0; }
  .sheet-foot { padding-bottom: calc(.66rem + var(--bottom)); }
  #photo-viewer .sheet-body { padding-bottom: calc(.78rem + var(--bottom)); }
}
@media (min-width: 600px) {
  .shell { padding-top: 2rem; }
  .hero { padding: 1.45rem 1.6rem; }
  .hero-art { right: 1.5rem; }
  .metrics { gap: .75rem; }
  .metric { padding: .8rem .9rem; }
  .panel { padding: 1.15rem; }
  .sheet-top, .sheet-foot, .sheet-body { padding-inline: 1.2rem; }
}
@media (max-width: 350px) {
  .shell { padding-inline: .7rem; }
  .top { padding-inline: .7rem; }
  .metric { padding-inline: .37rem; }
}
