:root {
  --ink: #273126;
  --muted: #677064;
  --paper: #f8f6ef;
  --card: #fffefa;
  --line: #dddcd3;
  --leaf: #526a4d;
  --leaf-dark: #3d5339;
  --leaf-pale: #e4eadf;
  --peach: #f0d8c5;
  --rose: #9b584f;
  --shadow: 0 12px 40px rgba(45, 57, 42, .08);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(228, 234, 223, .9), transparent 28rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a { color: inherit; }

button, input, textarea, select { font: inherit; }

button, summary, .file-picker { -webkit-tap-highlight-color: transparent; }

.site-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: calc(12px + env(safe-area-inset-top)) max(22px, calc((100vw - 1120px) / 2)) 12px;
  background: rgba(248, 246, 239, .9);
  border-bottom: 1px solid rgba(221, 220, 211, .8);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.28rem;
  font-weight: 700;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--leaf);
  font-family: sans-serif;
}

nav { display: flex; align-items: center; gap: 22px; }
nav a, .link-button { color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 650; }
nav a:hover, .link-button:hover { color: var(--ink); }
nav form { margin: 0; }

.link-button, .delete-button {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.page-shell {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: 54px 0 70px;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.12; }
h1 { margin-bottom: 12px; font-size: clamp(2.05rem, 4vw, 3.4rem); letter-spacing: -.035em; }
h2 { margin-bottom: 14px; font-size: clamp(1.55rem, 3vw, 2rem); }

.eyebrow {
  margin-bottom: 9px;
  color: var(--leaf);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.muted { color: var(--muted); }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, .93);
  box-shadow: var(--shadow);
}

.flash-stack { display: grid; gap: 8px; margin: -28px 0 28px; }
.flash { padding: 12px 16px; border-radius: 12px; font-weight: 650; }
.flash-success { color: #355431; background: #e5efe2; border: 1px solid #ccdfc8; }
.flash-error { color: #733a35; background: #f6e7e4; border: 1px solid #e7c8c3; }

.welcome-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 30px;
}
.welcome-note { max-width: 340px; margin-bottom: 8px; color: var(--muted); }

.reminder-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 16px 18px;
  border: 1px solid #cedac8;
  border-radius: 16px;
  background: var(--leaf-pale);
}
.reminder-banner p { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 22px; }

.action-card { overflow: hidden; }
.action-card summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 20px;
  cursor: pointer;
  list-style: none;
}
.action-card summary::-webkit-details-marker { display: none; }
.action-card summary strong { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 1.3rem; }
.action-card summary small { color: var(--muted); }
.action-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; font-size: 1.35rem; }
.meal-icon { background: #f4e6d8; }
.feeling-icon { color: #7c4943; background: #f3dfdc; font-size: 1.9rem; }
.chevron { color: var(--muted); font-size: 1.4rem; transition: transform .2s; }
details[open] .chevron { transform: rotate(180deg); }

.entry-form, .stacked-form { display: grid; gap: 14px; }
.entry-form { padding: 5px 20px 22px; border-top: 1px solid var(--line); }
.entry-form > :first-child:not(input[type=hidden]) { margin-top: 17px; }

label, legend { font-size: .88rem; font-weight: 720; }
input, textarea, select {
  width: 100%;
  border: 1px solid #cfcfc5;
  border-radius: 12px;
  color: var(--ink);
  background: white;
  padding: 11px 12px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(82, 106, 77, .13); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-row > div { display: grid; gap: 7px; }
.file-picker {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px dashed #bcbdb2;
  border-radius: 12px;
  color: var(--muted);
  background: white;
  cursor: pointer;
  font-weight: 560;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

button, .button-link { min-height: 44px; }
.primary, .secondary, .quiet-button, .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}
.primary { border: 1px solid var(--leaf); color: white; background: var(--leaf); }
.primary:hover { background: var(--leaf-dark); }
.secondary { border: 1px solid var(--leaf); color: var(--leaf-dark); background: transparent; }
.secondary:hover { background: rgba(255,255,255,.55); }
.quiet-button { border: 1px solid var(--line); color: var(--muted); background: white; }
.full { width: 100%; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 8px; }
.choice-row { display: grid; gap: 7px; }
.wellbeing-choices { grid-template-columns: repeat(5, 1fr); }
.choice-chip, .level-chip { position: relative; cursor: pointer; }
.choice-chip input, .level-chip input { position: absolute; opacity: 0; pointer-events: none; }
.choice-chip {
  min-width: 0;
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 8px 2px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  text-align: center;
}
.choice-emoji { font-size: 1.42rem; }
.choice-chip small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: .64rem; white-space: nowrap; }
.choice-chip:has(input:checked), .level-chip:has(input:checked) { border-color: var(--leaf); background: var(--leaf-pale); box-shadow: 0 0 0 2px rgba(82, 106, 77, .1); }
.level-choices { grid-template-columns: repeat(5, 1fr); }
.level-chip { display: grid; place-items: center; min-height: 45px; padding: 7px 4px; border: 1px solid var(--line); border-radius: 10px; background: white; text-align: center; font-size: .72rem; }

.timeline-section { margin-top: 60px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 22px; }
.section-heading h1, .section-heading h2 { margin-bottom: 0; }
.timeline { position: relative; display: grid; gap: 15px; }
.timeline::before { content: ""; position: absolute; top: 12px; bottom: 12px; left: 8px; width: 1px; background: var(--line); }
.timeline-item { position: relative; padding-left: 31px; }
.timeline-dot { position: absolute; z-index: 1; top: 24px; left: 2px; width: 13px; height: 13px; border: 3px solid var(--paper); border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0 1px var(--leaf); }
.timeline-item.checkin .timeline-dot { background: var(--rose); box-shadow: 0 0 0 1px var(--rose); }
.timeline-card { padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.timeline-meta { display: flex; align-items: center; justify-content: space-between; gap: 18px; color: var(--muted); font-size: .78rem; }
.entry-type { color: var(--ink); font-weight: 760; }
.entry-description { margin: 12px 0 0; font-size: 1.06rem; white-space: pre-wrap; }
.entry-note { margin: 10px 0 0; color: var(--muted); white-space: pre-wrap; }
.meal-photo { display: block; width: min(100%, 560px); max-height: 420px; margin-top: 14px; border-radius: 13px; object-fit: cover; }
.feeling-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 11px; font-weight: 680; }
.symptom-level { padding: 4px 9px; border-radius: 999px; background: var(--leaf-pale); color: var(--leaf-dark); font-size: .78rem; }
.level-2 { background: #f3e9cf; color: #725d2c; }
.level-3, .level-4 { background: #f3dfdc; color: #7c4943; }
.delete-button { margin-top: 12px; color: #8b7672; font-size: .75rem; text-decoration: underline; }
.entry-actions { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.entry-actions form { margin: 0; }
.entry-actions .delete-button { margin-top: 0; }
.edit-link { color: var(--leaf-dark); font-size: .78rem; font-weight: 700; }

.empty-state { padding: 55px 20px; border: 1px dashed #c9c9bd; border-radius: var(--radius); color: var(--muted); text-align: center; }
.empty-state > span { display: block; margin-bottom: 8px; font-size: 2rem; }
.empty-state h3 { margin-bottom: 7px; color: var(--ink); font-size: 1.4rem; }
.empty-state p { margin-bottom: 0; }

.auth-wrap { min-height: calc(100vh - 230px); display: grid; grid-template-columns: 1.2fr .8fr; align-items: center; gap: clamp(40px, 9vw, 110px); }
.auth-intro p:last-child { max-width: 570px; color: var(--muted); font-size: 1.08rem; }
.auth-card { padding: 30px; display: grid; gap: 12px; }
.auth-card h2 { margin-bottom: 4px; }
.auth-card button { margin-top: 7px; }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 3px 0 -2px; color: var(--muted); font-size: .75rem; }
.login-divider::before, .login-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.face-id-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: fit-content;
  min-height: 46px;
  padding: 10px 17px;
  border: 1px solid #1f2820;
  border-radius: 12px;
  color: #1f2820;
  background: white;
  font-weight: 750;
  cursor: pointer;
}
.face-id-button:hover { background: #f4f5f1; }
.face-id-button.full { width: 100%; }
.face-id-button:disabled { opacity: .55; cursor: wait; }
.face-id-symbol { width: 24px; height: 24px; display: grid; place-items: center; border: 2px solid currentColor; border-radius: 7px; font-size: 1.05rem; line-height: 1; }
.inline-status { min-height: 1.25rem; margin: 0; color: var(--leaf-dark); font-size: .8rem; }
.inline-status.status-error { color: var(--rose); }

.narrow { width: min(680px, 100%); margin: 0 auto; }
.narrow > .card { padding: clamp(22px, 5vw, 38px); }
.settings-page { display: grid; gap: 20px; }
.settings-page > .card { padding: 25px; }
.toggle-line { display: flex; align-items: center; justify-content: space-between; gap: 25px; padding: 13px 0; }
.toggle-line span { display: grid; gap: 2px; }
.toggle-line small { color: var(--muted); font-weight: 500; }
.toggle-line input { width: 24px; height: 24px; accent-color: var(--leaf); }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; }
.notification-status { min-height: 1.5em; margin: 0; color: var(--muted); font-size: .88rem; }
.passkey-list { display: grid; border-top: 1px solid var(--line); }
.passkey-item { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.passkey-item > div { display: grid; gap: 2px; }
.passkey-item small { color: var(--muted); }
.passkey-item .delete-button { margin: 0; }
.check-line { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.check-line input { width: 20px; height: 20px; accent-color: var(--leaf); }
.edit-photo { margin-top: 0; }

footer { display: flex; justify-content: center; gap: 9px; padding: 24px 18px 36px; color: #7a8178; font-size: .78rem; }

.ios-install-dialog {
  width: min(430px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  margin: auto auto max(14px, env(safe-area-inset-bottom));
  padding: 27px 23px calc(23px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 28px;
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 22px 80px rgba(24, 31, 22, .3);
}
.ios-install-dialog::backdrop { background: rgba(25, 31, 24, .5); backdrop-filter: blur(3px); }
.ios-install-dialog h2 { margin-bottom: 9px; }
.ios-install-dialog > p:not(.eyebrow) { color: var(--muted); }
.dialog-close { position: absolute; top: 10px; right: 12px; width: 44px; height: 44px; border: 0; border-radius: 50%; color: var(--muted); background: transparent; font-size: 1.8rem; cursor: pointer; }
.install-icon { width: 68px; height: 68px; margin-bottom: 18px; overflow: hidden; border-radius: 16px; box-shadow: 0 5px 15px rgba(35, 47, 32, .18); }
.install-icon img { width: 100%; height: 100%; display: block; }
.install-steps { display: grid; gap: 11px; margin: 18px 0 23px; padding-left: 25px; }
.install-steps li { padding-left: 4px; }
.share-symbol { display: inline-block; color: #1677c8; font-size: 1.15rem; font-weight: 800; transform: translateY(-2px); }

@media (max-width: 760px) {
  body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .site-header { min-height: calc(62px + env(safe-area-inset-top)); padding: calc(12px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left)); }
  .site-header nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; min-height: calc(62px + env(safe-area-inset-bottom)); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgba(255, 254, 250, .96); box-shadow: 0 -8px 28px rgba(45, 57, 42, .08); backdrop-filter: blur(18px); }
  .site-header nav a, .site-header nav .link-button { min-height: 48px; display: grid; place-items: center; padding: 0 9px; border-radius: 12px; font-size: .78rem; }
  .site-header nav a:active, .site-header nav .link-button:active { background: var(--leaf-pale); }
  .site-header nav form { display: grid; }
  .page-shell { width: min(100% - 26px, 650px); padding-top: 34px; }
  .welcome-row, .auth-wrap { display: block; }
  .welcome-note { margin-top: 18px; }
  .quick-grid { grid-template-columns: 1fr; }
  .auth-intro { margin-bottom: 28px; }
  .auth-wrap { min-height: auto; display: flex; flex-direction: column; }
  .auth-wrap .auth-card { order: -1; width: 100%; margin-bottom: 30px; }
  .auth-wrap .auth-intro { margin-bottom: 0; }
  .form-row { grid-template-columns: 1fr; }
  .reminder-banner { align-items: flex-start; flex-direction: column; }
  .choice-chip small { display: none; }
  .timeline-section { margin-top: 45px; }
  input, textarea, select { font-size: 16px; }
  button, .button-link, .file-picker { min-height: 48px; }
}

@media (max-width: 430px) {
  .brand > span:last-child { display: none; }
  .wellbeing-choices, .level-choices { gap: 4px; }
  .level-chip { font-size: .63rem; }
  .timeline-card { padding: 16px; }
  .timeline-meta { align-items: flex-start; flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
