:root {
  color-scheme: light;
  --ink: #443c3c; --muted: #78686c; --green: #985164;
  --cream: #fff8f4; --surface: #fffdfb; --line: #eadfdd;
  --accent-soft: #fbe9ed; --accent-border: #e8b9c5;
  --gutter: 16px; --control: 44px; --radius: 6px; --width: 760px;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--cream); color: var(--ink); font-family: system-ui,-apple-system,'Microsoft YaHei',sans-serif; line-height: 1.5; }
body[data-profile="2"] { --green: #526c87; --accent-soft: #eaf0f8; --accent-border: #b5c8df; }
button,input,textarea { font: inherit; }
button,summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; color: var(--green); transition: transform .15s ease,background-color .18s ease; }
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .6; cursor: wait; }
button:focus-visible,input:focus-visible,textarea:focus-visible,summary:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.hidden { display: none!important; }
.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; }
.shell { width: 100%; max-width: var(--width); margin: auto; padding: 12px var(--gutter) max(20px,env(safe-area-inset-bottom)); }
.text-button { min-height: var(--control); border: 0; border-radius: var(--radius); padding: 8px 12px; background: transparent; color: var(--green); font-size: 13px; white-space: nowrap; }
.primary { min-height: var(--control); width: 100%; padding: 10px 16px; border: 0; border-radius: 8px; background: var(--green); color: white; font-size: 15px; font-weight: 600; }
.profile-pages { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #f4eeec; }
.profile-pages button { flex: 1; min-width: 0; min-height: var(--control); border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font-size: 15px; }
.profile-pages button.active,.profile-pages button[aria-current="page"] { border-color: var(--accent-border); background: var(--surface); color: var(--green); font-weight: 600; }
.profile-pages button::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: #df91a3; vertical-align: 1px; }
.profile-pages button[data-profile="2"]::before { background: #91a9c4; }
.calendar { margin: 8px 0 0; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.calendar-controls { display: flex; align-items: center; gap: 0; min-height: var(--control); }
#month-toggle { order: -1; padding-left: 0; color: var(--ink); font-size: 15px; font-weight: 600; }
#today { margin-left: auto; padding-right: 0; font-size: 12px; }
.week-navigation { display: flex; align-items: center; justify-content: space-between; gap: 0; font-size: 14px; color: var(--muted); }
.week-navigation button { width: var(--control); min-height: var(--control); flex-shrink: 0; padding: 0; border: 0; border-radius: var(--radius); background: transparent; font-size: 24px; line-height: 1; }
.date-grid,.weekday-labels { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 4px; }
.date-cell { min-width: 0; min-height: var(--control); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 0; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--ink); font-size: 16px; font-weight: 600; }
#week-days .date-cell { min-height: 60px; }
.date-cell .weekday { font-size: 12px; font-weight: 400; color: var(--muted); }
.date-cell.is-today { border: 1px dashed var(--accent-border); background: var(--accent-soft); }
.date-cell.selected { border: 1px solid var(--green); background: var(--green); color: white; }
.date-cell.selected .weekday { color: white; }
.record-dot { width: 4px; height: 4px; border-radius: 50%; background: transparent; }
.recorded .record-dot { background: var(--green); }
.selected.recorded .record-dot { background: white; }
.weekday-labels { padding: 4px 0 8px; text-align: center; color: var(--muted); font-size: 12px; }
#month-panel { padding: 0; }
.meals { display: flex; flex-direction: column; gap: 0; }
.meal { min-width: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.empty-meal { padding: 4px 0; }
.meal-head { display: flex; align-items: center; gap: 8px; min-height: var(--control); }
.meal-head h3 { display: flex; align-items: center; gap: 8px; margin: 0 auto 0 0; font-size: 15px; font-weight: 600; }
.meal-badge { display: inline-grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; border-radius: 4px; background: #fff2da; font-size: 17px; font-weight: 400; }
.meal[data-meal="lunch"] .meal-badge { background: #edf2e3; }
.meal[data-meal="dinner"] .meal-badge { background: #f5e9e5; }
.meal[data-meal="snacks"] .meal-badge { background: #eeeafa; }
.edit-meal { order: 2; min-width: 64px; flex-shrink: 0; padding: 8px 12px; background: var(--accent-soft); font-size: 12px; }
.meal-content { display: block; width: 100%; border: 0; padding: 0; background: transparent; text-align: left; color: var(--ink); cursor: text; }
.meal-content:active { transform: none; }
.food-list { list-style: none; margin: 0; padding: 0; }
.food-list li { position: relative; padding: 5px 0 5px 14px; font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.food-list li::before { content: ''; position: absolute; left: 0; top: 16px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent-border); }
.food-list li+li { border-top: 1px dashed var(--line); }
.previous-details { margin: 0; }
.previous-details summary { display: flex; align-items: center; gap: 6px; min-height: var(--control); padding: 8px 0; list-style: none; font-size: 12px; color: var(--muted); cursor: pointer; }
.previous-details summary::-webkit-details-marker { display: none; }
.previous-details summary::before { content: '›'; font-size: 19px; transition: transform .18s ease; }
.previous-details[open] summary::before { transform: rotate(90deg); }
.previous { padding: 8px 12px; border-left: 2px solid var(--accent-border); background: #f8f1ed; color: var(--muted); font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.status { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.status:empty,.error:empty { display: none; }
.meal-head .status { order: 1; max-width: 100px; font-size: 11px; }
.status.error,.error { color: #a34230; }
.meal>.status.error,#editor-status>.status.error { margin-top: 8px; padding: 10px 12px; border-left: 2px solid #c77b68; background: #fff0e9; }
.status button { min-height: var(--control); margin: 8px 8px 0 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 12px; }
.notice { margin: 12px 0; padding: 10px 12px; border-left: 2px solid #c77b68; background: #fff0e9; color: #a34230; font-size: 14px; }
.error,.hint { font-size: 14px; }
.login { width: 100%; max-width: 380px; margin: 24px auto; }
.login form { display: grid; gap: 16px; }
.login label { display: grid; gap: 8px; color: var(--muted); font-size: 14px; }
.login input { width: 100%; min-width: 0; min-height: var(--control); padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-size: 16px; }
.login .error { margin: 0; }
.editing { overflow: hidden; }
#editor { position: fixed; inset: auto 0 0; width: 100%; max-width: var(--width); max-height: 85vh; max-height: 85dvh; margin: 0 auto; padding: 0; border: 0; border-radius: 12px 12px 0 0; background: var(--surface); color: var(--ink); overflow: auto; overscroll-behavior: contain; }
#editor[open] { animation: sheet-in .2s ease-out; }
#editor::backdrop { background: #40313a55; backdrop-filter: blur(2px); }
.editor-header { position: sticky; top: 0; z-index: 1; display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 8px; padding: 12px var(--gutter); border-bottom: 1px solid var(--line); background: var(--surface); }
.editor-header>div { grid-column: 1; grid-row: 1; min-width: 0; }
.editor-header h2 { margin: 0; font-size: 18px; line-height: 1.5; }
.editor-header p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.editor-header .primary { grid-column: 3; grid-row: 1; width: auto; min-width: 64px; font-size: 14px; }
.editor-header .status { grid-column: 2; grid-row: 1; max-width: 96px; font-size: 11px; }
.editor-body { padding: 12px var(--gutter) max(20px,env(safe-area-inset-bottom)); }
#editor-text { display: block; width: 100%; min-height: 150px; resize: none; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fffaf5; color: var(--ink); font-size: 16px; line-height: 1.8; caret-color: var(--green); }
#editor-text::placeholder { color: #8e7d79; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media(hover:hover) { .text-button:hover,.week-navigation button:hover,.date-cell:not(.selected):hover { background: var(--accent-soft); } .profile-pages button:not(.active):hover { background: var(--surface); } .meal-content:hover { color: var(--green); } }
@media(max-width:360px) { :root { --gutter: 12px; } .date-grid,.weekday-labels { gap: 2px; } .calendar-controls .text-button { font-size: 12px; } }
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { animation: none!important; transition: none!important; } button:active:not(:disabled) { transform: none!important; } }

/* A quiet notebook palette, shared by the calendar, entries and editor. */
:root { --ink: #463b3e; --muted: #8b777d; --green: #a14f69; --cream: #fffaf7; --surface: #fffefd; --line: #eee4e1; --accent-soft: #f9eaf0; --accent-border: #deb3bf; }
body[data-profile="2"] { --green: #607f9c; --accent-soft: #eaf1f7; --accent-border: #bbcedd; }
body, .primary, .text-button, .date-cell, .meal-badge, .profile-pages button, #editor-text { transition: color .2s ease, background-color .2s ease, border-color .2s ease, transform .15s ease; }
button:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.profile-pages { gap: 10px; padding: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.profile-pages button { position: relative; display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 48px; border: 0; border-radius: 8px 8px 0 0; color: #ae7b89; }
.profile-pages button[data-profile="2"] { color: #849caf; }
.profile-pages button::before { display: none; }
.profile-pages button.active,.profile-pages button[aria-current="page"] { border: 0; background: var(--accent-soft); color: var(--green); }
.profile-pages button.active::after,.profile-pages button[aria-current="page"]::after { content: ''; position: absolute; bottom: -1px; width: 32px; height: 2px; border-radius: 2px; background: var(--green); }
.profile-icon { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.calendar { margin-top: 6px; padding-bottom: 9px; }
#month-toggle { letter-spacing: .02em; }
.week-navigation button { color: var(--muted); font-size: 22px; }
.date-cell { gap: 3px; border: 0; border-radius: 7px; font-size: 15px; }
#week-days .date-cell { min-height: 58px; }
.date-cell .weekday { font-size: 11px; }
.date-cell.is-today { border: 0; background: var(--accent-soft); color: var(--green); }
.date-cell.selected { border: 0; background: var(--green); color: white; }
.date-cell.selected .weekday { color: #fff; }
.record-dot { width: 4px; height: 4px; }
.meal { padding: 7px 0; }
.empty-meal { padding: 3px 0; }
.meal-head h3 { gap: 9px; letter-spacing: .02em; }
.meal-badge { width: 27px; height: 27px; border-radius: 50%; background: #fbf0db; color: #b88b4f; }
.meal-badge svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.meal[data-meal="lunch"] .meal-badge { background: #edf2e8; color: #84966f; }
.meal[data-meal="dinner"] .meal-badge { background: #edf0f8; color: #818eae; }
.meal[data-meal="snacks"] .meal-badge { background: #f8eceb; color: #ba8990; }
.edit-meal { border-radius: 6px; }
.food-list li { padding: 5px 0 5px 15px; }
.food-list li+li { border-top: 1px solid #f5efec; }
.previous { background: var(--accent-soft); }
.login input:focus, #editor-text:focus { border-color: var(--accent-border); }
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { animation: none!important; transition: none!important; } button:active:not(:disabled) { transform: none!important; } }
