/* Recovery Book: a quiet, paper-like space for everyday progress. */
:root { --paper: #f6f4ec; --ink: #293b31; --muted: #788075; --sage: #dce5d5; --green: #436448; --line: #e1e2d7; --white: #fffef9; --serif: Georgia, 'Times New Roman', serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: 'Segoe UI', Arial, sans-serif; font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-underline-offset: 4px; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled, input:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #9a783f; outline-offset: 4px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -.035em; line-height: 1.15; }
h1 { font-size: clamp(40px, 5vw, 64px); margin-bottom: 14px; }
h2 { font-size: 29px; margin-bottom: 10px; }
h3 { font-size: 13px; font-weight: 500; }
p { margin-bottom: 16px; }
input, select, textarea { border: 1px solid #ced3c6; border-radius: 10px; background: var(--white); font-size: 16px; padding: 13px 15px; width: 100%; max-width: 100%; }
textarea { resize: vertical; }
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 8px; }
.button, .btn { display: inline-flex; gap: 24px; align-items: center; justify-content: center; min-height: 48px; padding: 12px 25px; border: 1px solid var(--green); background: var(--green); color: #fffef5; border-radius: 9px; text-decoration: none; font-size: 14px; font-weight: 500; }
.button:hover, .btn:hover { background: #345438; }
.button-small { min-height: 42px; padding: 8px 20px; }
.text-button { min-height: 44px; background: transparent; border: 0; padding: 8px; text-decoration: underline; text-underline-offset: 4px; }
.muted { color: var(--muted); font-size: 13px; }
.eyebrow { font-size: 10px; letter-spacing: .18em; font-weight: 600; color: #78816f; margin-bottom: 16px; }
.site-header { max-width: 1280px; margin: auto; padding: 24px 48px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; font-size: 19px; letter-spacing: -.05em; font-weight: 600; text-decoration: none; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 38px; border-radius: 5px 10px 10px 5px; background: var(--sage); border-left: 3px solid #8b9d7d; font-family: var(--serif); font-size: 27px; line-height: 1; }
.brand-dot, .heading-dot { color: #94a482; }
.header-links { display: flex; gap: 24px; align-items: center; font-size: 12px; }
.header-links a { text-decoration: none; padding: 10px 0; }
.header-links .button { padding: 8px 20px; }
.page-shell { max-width: 1280px; margin: auto; padding: 42px 48px; }
.site-footer { display: flex; justify-content: center; gap: 20px; color: #89917f; font-size: 11px; padding: 28px 24px 34px; }
.site-footer span { color: #a0ad8a; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; background: white; padding: 14px; }
.skip-link:focus { top: 12px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.notice, .messages p { background: #e9ecdf; padding: 14px 18px; border-radius: 10px; font-size: 13px; border: 1px solid #dce2ce; }
.welcome { min-height: 620px; display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 60px; padding: 24px 24px 48px; }
.welcome h1 { font-size: clamp(52px, 6vw, 86px); line-height: 1.05; }
.welcome h1 em { color: #71876a; font-weight: 400; }
.welcome-description { max-width: 330px; color: #737d70; font-size: 16px; line-height: 1.9; margin: 28px 0; }
.welcome-note { max-width: 290px; margin-top: 18px; font-size: 11px; }
.welcome-art { position: relative; display: flex; justify-content: center; padding: 50px 0; }
.book-cover { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 310px; min-height: 410px; padding: 36px 20px; border-radius: 5px 20px 20px 5px; background: #dbe3cf; border-left: 12px solid #bac8a8; transform: rotate(7deg); box-shadow: 12px 20px 30px #39472f17, 5px 0 0 #f9f7e8, 9px 0 0 #d4d8c9; }
.book-cover p { text-align: center; font: 44px/1.1 var(--serif); margin: 20px 0; }
.book-cover p em { color: #67815f; }
.book-cover .eyebrow { font-size: 8px; }
.book-cover-bottom { font-size: 7px; letter-spacing: .18em; }
.paper-sticker { position: absolute; top: 10px; left: 5px; z-index: 1; background: #f0deb6; padding: 18px 23px; font: italic 18px/1.5 var(--serif); transform: rotate(-10deg); box-shadow: 0 8px 12px #34432b0a; }
.art-spark { position: absolute; bottom: 26px; right: 10px; font-size: 70px; color: #9eae8d; }
.book-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin: 0 0 32px; }
.book-heading h1 { font-size: 54px; margin-bottom: 10px; }
.book-heading .eyebrow { margin-bottom: 12px; }
.date-line { font-size: 13px; margin: 0; }
.date-line > span:last-child { color: var(--muted); }
.date-divider { color: #bec5b3; padding: 0 10px; }
.heading-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; font-size: 12px; min-width: 160px; }
.today-link { padding: 6px 0; }
.save-status { font-size: 11px; color: #6f8262; }
.save-status::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-right: 7px; vertical-align: middle; }
.save-status[data-state='error'], .save-status[data-state='conflict'] { color: #9b4d31; }
.book-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: stretch; }
.panel { min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; color: #7f8d71; }
.panel-title > span:last-child { font-size: 24px; line-height: 1; }
.section-number { font-size: 9px; font-weight: 600; letter-spacing: .14em; }
.calorie-panel { background: #e9eddf; }
.calorie-panel > .muted { margin-bottom: 20px; }
.calorie-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.calorie-summary .eyebrow { font-size: 9px; }
.remaining-number { font: 58px/1.15 var(--serif); letter-spacing: -.04em; margin: 8px 0 18px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.unit { font: 12px 'Segoe UI', sans-serif; letter-spacing: 0; color: #7c8970; padding-left: 8px; }
.goal-summary { text-align: right; font-size: 12px; line-height: 1.9; color: #78856d; }
.progress-track { height: 5px; width: 100%; overflow: hidden; background: #d5ddca; border-radius: 5px; margin: 0 0 22px; }
#calorie-progress { width: 0; height: 100%; background: #7f9c6f; transition: width .4s ease; }
.amount-wrap { position: relative; }
.amount-wrap input { padding-right: 62px; }
.amount-wrap > span { position: absolute; right: 16px; top: 14px; font-size: 12px; color: var(--muted); }
.field-hint { font-size: 10px; color: #7c8475; margin: 7px 0 18px; }
.entry-heading { display: flex; justify-content: space-between; border-top: 1px solid #d4dcc9; padding-top: 16px; margin-top: 24px; }
.entry-heading h3 { margin: 0; }
.entry-heading .muted { font-size: 11px; }
.calorie-entries { list-style: none; padding: 0; margin: 6px 0 0; max-height: 200px; overflow-y: auto; }
.calorie-entries li { display: flex; align-items: center; gap: 12px; font-size: 13px; min-height: 44px; border-bottom: 1px solid #dce2d2; }
.calorie-entries li span:first-child { flex: 1; }
.calorie-entries button { background: transparent; border: 0; color: #65795b; font-size: 11px; padding: 10px; min-height: 44px; text-decoration: underline; }
.completion { display: flex; align-items: center; gap: 12px; background: #dce6d0; border-radius: 10px; margin: 16px 0; padding: 10px 14px; }
.completion p { font-family: var(--serif); font-size: 20px; line-height: 1.3; margin: 0; }
.completion p span { font-family: 'Segoe UI', sans-serif; font-size: 11px; }
.good-panel { background: #fcf8eb; }
.thoughts-panel { background: #fffdf6; }
.writing-panel { display: flex; flex-direction: column; }
.diary-input { flex: 1; min-height: 230px; padding: 6px 0; border: 0; border-radius: 0; background: repeating-linear-gradient(transparent, transparent 35px, #dfe0d267 35px, #dfe0d267 36px); font-family: var(--serif); font-size: 18px; line-height: 36px; resize: vertical; }
.diary-input::placeholder { color: #a0a38f; opacity: 1; }
.diary-input:focus { outline-offset: 6px; }
.writing-footer { display: flex; justify-content: space-between; align-items: center; font: italic 13px var(--serif); color: #9a9f88; padding-top: 20px; margin: 0; }
.writing-footer span { font-size: 22px; }
.calendar-panel { background: #fdfcf6; }
.calendar-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 18px; }
.calendar-heading h2 { font-size: 27px; margin: 0; }
.month-controls { display: flex; gap: 5px; }
.month-controls button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 23px; }
.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.weekday-row { text-align: center; font-size: 10px; color: #929a85; margin: 0 0 10px; }
.calendar-day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: 1; border-radius: 9px; border: 1px solid transparent; text-decoration: none; font-size: 12px; gap: 0; }
.calendar-day:hover { background: #edf0e3; }
.calendar-day.is-today { color: var(--green); border-color: #9da98b; }
.calendar-day.selected { background: #dce5cf; color: #344d31; }
.calendar-day.future { color: #a5aa9d; }
.calendar-day img { width: 45%; height: 45%; max-width: 28px; max-height: 28px; object-fit: contain; }
.calendar-day.has-writing::after { content: ''; width: 3px; height: 3px; background: #a2a98e; border-radius: 50%; position: absolute; bottom: 4px; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; font-size: 9px; color: #848e77; }
.calendar-legend span { display: flex; align-items: center; gap: 5px; }
.calendar-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.legend-today { border: 1px solid #9da98b; }
.legend-writing { background: #a2a98e; width: 4px !important; height: 4px !important; }
.calendar-note { font: italic 13px var(--serif); color: #9a9f88; margin: 20px 0 0; }
.bottom-nav { display: none; }
.settings-page { max-width: 640px; margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: 32px; font-size: 12px; }
.settings-page h1 { font-size: 48px; }
.settings-form, .account-panel { margin-top: 28px; }
.settings-form select { margin-top: 0; }
.settings-form label { margin-top: 24px; }
.account-panel a { display: inline-block; margin-right: 22px; padding: 8px 0; font-size: 13px; }
.celebration { position: fixed; inset: 0; z-index: 50; background: #293b3177; backdrop-filter: blur(5px); display: grid; place-items: center; padding: 20px; }
.celebration-card { position: relative; z-index: 1; text-align: center; background: var(--paper); border-radius: 24px; padding: 32px; max-width: 380px; box-shadow: 0 20px 100px #21381f33; }
.celebration-card h2 { margin-top: 12px; font-size: 35px; }
.celebration-card p { color: var(--muted); font-size: 13px; }
.confetti { position: fixed; pointer-events: none; top: -20px; width: 9px; height: 16px; animation: confetti-fall 3s ease-in forwards; }
@keyframes confetti-fall { to { transform: translate(var(--drift), 110dvh) rotate(700deg); opacity: .2; } }
dialog { color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 28px; max-width: min(580px, calc(100% - 32px)); }
dialog::backdrop { background: #293b3177; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
/* Authentication templates inherit the same typography and controls. */
.page-shell > h1, .page-shell > form, .page-shell > p, .page-shell > div > form { max-width: 640px; }
.alert { padding: 14px; border-radius: 10px; background: #e9ecdf; }
.invalid-feedback, .errorlist { color: #9b4d31; }
.form-check { display: flex; align-items: center; gap: 10px; }
input[type='checkbox'] { width: 20px; height: 20px; }
.form-text { color: var(--muted); font-size: 12px; }
@media (min-width: 1000px) { .book-grid { grid-template-columns: 1fr 1fr 1fr; } .calorie-panel { grid-column: span 1; } .good-panel { grid-column: span 2; } .thoughts-panel { grid-column: span 2; } .calendar-panel { grid-column: span 1; } }
@media (max-width: 767px), (max-height: 500px) and (max-width: 950px) {
  .site-header { padding: 16px 20px; gap: 10px; }
  .brand { font-size: 17px; gap: 8px; }
  .brand-mark { width: 29px; height: 32px; font-size: 23px; }
  .header-links { gap: 14px; font-size: 11px; }
  .header-links.signed-in a:first-child, .header-links.signed-in a:last-child { display: none; }
  .page-shell { padding: 28px 20px; }
  .book-page .page-shell { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .book-page .site-footer { display: none; }
  .book-heading { align-items: flex-start; gap: 12px; margin-bottom: 22px; }
  .book-heading h1 { font-size: 42px; }
  .book-heading .eyebrow { font-size: 8px; letter-spacing: .12em; }
  .date-line { font-size: 11px; }
  .date-line > span { display: none; }
  .heading-actions { min-width: 0; max-width: 125px; font-size: 10px; gap: 8px; padding-top: 6px; }
  .save-status { font-size: 10px; }
  .book-grid { display: block; }
  .panel { padding: 23px 20px; border-radius: 14px; }
  .book-grid > .panel + .panel { margin-top: 20px; }
  .js .book-grid > .panel { margin-top: 0; }
  .js [data-panel]:not(.active-panel) { display: none; }
  h2 { font-size: 28px; }
  .remaining-number { font-size: 58px; }
  .diary-input { min-height: 300px; min-height: max(300px, calc(100dvh - 440px)); }
  .js .bottom-nav { position: fixed; z-index: 20; inset: auto 0 0; display: flex; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: #fffef9f5; backdrop-filter: blur(14px); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px #293b3105; }
  .bottom-nav a { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; min-height: 52px; text-decoration: none; color: #89917e; font-size: 10px; white-space: nowrap; }
  .bottom-nav a > span:first-child { font-size: 23px; line-height: 27px; width: 54px; text-align: center; border-radius: 20px; }
  .bottom-nav a[aria-current='page'] { color: #365433; font-weight: 600; }
  .bottom-nav a[aria-current='page'] > span:first-child { background: #e3ead9; }
  .keyboard-open .bottom-nav { display: none; }
  .calendar-heading h2 { font-size: 25px; }
  .calendar-day { min-height: 34px; }
  .calendar-legend { font-size: 9px; gap: 9px; }
  .welcome { grid-template-columns: 1fr; gap: 8px; min-height: 0; padding: 16px 0; }
  .welcome h1 { font-size: 60px; }
  .welcome-art { padding-top: 55px; margin-top: 10px; }
  .book-cover { width: 250px; min-height: 340px; }
  .book-cover p { font-size: 36px; }
  .book-cover img { width: 130px; height: 130px; }
  .paper-sticker { left: 5px; font-size: 16px; }
  .site-footer { flex-wrap: wrap; gap: 8px; font-size: 10px; }
  .settings-page h1 { font-size: 40px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
.auth-shell { max-width: 480px; margin: 36px auto; padding: 32px; }
.auth-shell h1 { font-size: 42px; }
.auth-shell form { margin: 24px 0; }
.auth-shell button[type='submit'] { margin-top: 20px; }
.auth-shell input[type='checkbox'] { display: inline-block; }
.auth-shell p { font-size: 13px; color: var(--muted); }
@media (max-width: 767px), (max-height: 500px) and (max-width: 950px) { .auth-shell { margin: 12px auto; padding: 24px 20px; } }
.calendar-grid.offset-0 > :first-child { grid-column-start: 1; }
.calendar-grid.offset-1 > :first-child { grid-column-start: 2; }
.calendar-grid.offset-2 > :first-child { grid-column-start: 3; }
.calendar-grid.offset-3 > :first-child { grid-column-start: 4; }
.calendar-grid.offset-4 > :first-child { grid-column-start: 5; }
.calendar-grid.offset-5 > :first-child { grid-column-start: 6; }
.calendar-grid.offset-6 > :first-child { grid-column-start: 7; }
@media (max-width: 767px), (max-height: 500px) and (max-width: 950px) { .calendar-day { min-height: 0; } }
@media (max-width: 360px) { .calendar-heading h2 { font-size: 19px; } .month-controls { gap: 2px; } }

/* A moment to keep: highlight and day emoji share a single diary panel. */
.highlight-panel { background: #f2eff5; grid-column: 1 / -1; grid-row: 3; }
.highlight-panel .diary-input { min-height: 180px; }
.heading-emoji { display: inline-block; margin-left: 10px; font-family: 'Segoe UI Emoji', sans-serif; font-size: .52em; vertical-align: middle; letter-spacing: 0; }
.emoji-picker { min-width: 0; border: 0; padding: 0; margin: 8px 0 0; }
.emoji-picker legend { padding: 0; margin-bottom: 12px; font-size: 13px; font-weight: 600; }
.emoji-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 8px; max-width: 560px; }
.emoji-option { min-width: 44px; min-height: 44px; padding: 6px; border: 1px solid #ded9e4; border-radius: 12px; background: #fffdfa; font-family: 'Segoe UI Emoji', sans-serif; font-size: 24px; line-height: 1; }
.emoji-option:hover { background: #e8e1ef; }
.emoji-option[aria-pressed='true'] { background: #dfe7d5; border-color: #6f8963; box-shadow: inset 0 0 0 1px #6f8963; }
.emoji-option:disabled { cursor: default; opacity: .65; }
.emoji-option:disabled[aria-pressed='true'] { opacity: 1; }
.clear-emoji { color: #7b786f; font-size: 20px; }
.calendar-day { line-height: 1.2; }
.calendar-markers { display: flex; align-items: center; justify-content: center; gap: 1px; height: 14px; width: 100%; }
.calendar-emoji { font-family: 'Segoe UI Emoji', sans-serif; font-size: 12px; line-height: 14px; }
.calendar-day .calendar-markers img { width: 14px; height: 14px; }
@media (min-width: 768px) { .calendar-panel { grid-column: 2; grid-row: 2; } }
@media (min-width: 1000px) { .calendar-panel { grid-column: 3; } }
@media (max-width: 767px), (max-height: 500px) and (max-width: 950px) {
  .bottom-nav a > span:first-child { width: min(44px, 100%); }
  .bottom-nav a { font-size: 9px; }
  .highlight-panel .diary-input { min-height: 200px; }
}

/* App preferences share the diary's paper and sage palette. */
.reminder-settings { border-top: 1px solid var(--line, #deded1); margin-top: 1.7rem; padding-top: 1.2rem; }
.reminder-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1.25rem; }
.reminder-row .reminder-switch { display: flex; align-items: center; gap: .6rem; margin: 0; }
.reminder-row input[type=checkbox] { width: 1.15rem; height: 1.15rem; accent-color: #63866a; flex-shrink: 0; }
.reminder-row input[type=time] { width: 8rem; min-width: 0; margin: 0; }
.app-settings { margin-top: 1.3rem; }
.app-actions { display: flex; flex-wrap: wrap; gap: .9rem; align-items: center; }
.app-actions .button { white-space: normal; }
@media (max-width: 380px) { .reminder-row { align-items: flex-start; flex-direction: column; } }
