:root {
  --paper: #f6f3eb;
  --paper-deep: #ece5d8;
  --ink: #27352f;
  --ink-soft: #657069;
  --moss: #4f725e;
  --moss-dark: #335443;
  --leaf: #a8bba6;
  --coral: #dc755f;
  --coral-soft: #f1c8ba;
  --sun: #e9be66;
  --line: rgba(39,53,47,.16);
  --white: #fffdf8;
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--font-sans); line-height: 1.6; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.grain { position: fixed; inset: 0; pointer-events: none; opacity: .035; z-index: 99; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E"); }

.lock-screen { min-height: 100svh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 24% 16%, rgba(233,190,102,.2), transparent 28%), radial-gradient(circle at 88% 84%, rgba(79,114,94,.18), transparent 34%), var(--paper); }
.lock-card { width: min(520px, 100%); text-align: center; padding: 48px 34px 42px; border: 1px solid var(--line); background: rgba(255,253,248,.75); backdrop-filter: blur(18px); box-shadow: 0 24px 70px rgba(51,84,67,.12); border-radius: 42% 42% 28px 28px / 10% 10% 28px 28px; }
.lock-mark { width: 92px; height: 92px; margin: 0 auto 28px; border-radius: 50%; border: 1px solid var(--moss); display: flex; align-items: end; justify-content: center; gap: 7px; padding-bottom: 21px; }
.lock-mark span { display: block; width: 7px; background: var(--moss); border-radius: 10px 10px 2px 2px; transform-origin: bottom; }
.lock-mark span:nth-child(1) { height: 25px; transform: rotate(-24deg); }
.lock-mark span:nth-child(2) { height: 42px; }
.lock-mark span:nth-child(3) { height: 31px; transform: rotate(22deg); }
.kicker, .date-line, .section-heading p, .dialog-head p { margin: 0; color: var(--moss); font-size: .83rem; letter-spacing: .08em; }
.lock-card h1 { font-family: var(--font-serif); font-size: clamp(2.7rem, 10vw, 4.3rem); font-weight: 500; letter-spacing: .12em; margin: 8px 0 4px; }
.lock-copy { margin: 0 auto 32px; color: var(--ink-soft); }
.unlock-form { text-align: left; }
.unlock-form label, label > span { display: block; font-size: .82rem; color: var(--ink-soft); margin-bottom: 7px; }
.input-row { display: grid; gap: 12px; }
.input-row input { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); padding: 13px 14px; outline: none; min-width: 0; letter-spacing: .15em; }
.input-row input:focus { border-color: var(--moss); box-shadow: 0 0 0 3px rgba(79,114,94,.1); }
.input-row button { border: 0; border-radius: var(--radius-sm); background: var(--moss-dark); color: var(--white); padding: 13px 18px; cursor: pointer; font-weight: 600; transition: transform .18s ease, opacity .18s ease; }
.input-row button:hover { transform: translateY(-1px); }
.input-row button:disabled { opacity: .64; cursor: wait; transform: none; }
.form-error { color: #a44137; font-size: .84rem; min-height: 1.4em; margin: 9px 0 0; font-weight: 500; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.topbar { min-height: 96px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-seal { display: grid; place-items: center; width: 43px; height: 43px; border: 1px solid var(--moss); border-radius: 50%; font-family: var(--font-serif); font-size: 1.2rem; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: var(--font-serif); letter-spacing: .12em; font-size: 1.12rem; }
.brand small { color: var(--ink-soft); font-size: .68rem; letter-spacing: .05em; }
.quiet-button, .delete-meal { border: 0; border-bottom: 1px solid var(--line); padding: 6px 0; background: transparent; color: var(--ink-soft); cursor: pointer; }

.hero { min-height: 520px; padding: 80px 0 64px; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .7fr); gap: 80px; align-items: center; position: relative; }
.hero::after { content: ""; position: absolute; width: 330px; height: 330px; right: 3%; top: 12%; border-radius: 47% 53% 58% 42%; border: 1px solid rgba(79,114,94,.13); transform: rotate(14deg); pointer-events: none; }
.hero-copy { position: relative; z-index: 1; }
.hero-copy h2 { font-family: var(--font-serif); font-size: clamp(3rem, 7vw, 6rem); line-height: 1.12; font-weight: 500; letter-spacing: -.03em; margin: 16px 0 24px; }
.hero-copy > p:last-child { max-width: 570px; color: var(--ink-soft); font-size: 1.02rem; }
.hero-actions { position: relative; z-index: 1; display: grid; gap: 14px; }
.primary-action, .secondary-action { min-height: 96px; border: 0; border-radius: var(--radius-md); padding: 20px 22px; display: flex; align-items: center; gap: 18px; text-align: left; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.primary-action:hover, .secondary-action:hover { transform: translateY(-2px); }
.primary-action { color: var(--white); background: var(--moss-dark); box-shadow: 0 16px 34px rgba(51,84,67,.18); }
.secondary-action { background: rgba(255,253,248,.72); border: 1px solid var(--line); }
.primary-action strong, .secondary-action strong, .primary-action small, .secondary-action small { display: block; }
.primary-action strong, .secondary-action strong { font-family: var(--font-serif); font-size: 1.3rem; font-weight: 500; }
.primary-action small, .secondary-action small { opacity: .72; font-size: .76rem; margin-top: 2px; }
.action-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.35); font-size: 1.8rem; font-weight: 200; }
.drop-icon { width: 38px; height: 46px; border-radius: 55% 55% 60% 60% / 70% 70% 35% 35%; background: var(--coral-soft); transform: rotate(45deg) scale(.75); position: relative; }

.curve-section, .journal-section { padding: 78px 0; border-top: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 34px; }
.section-heading h2 { font-family: var(--font-serif); font-size: clamp(2rem, 4vw, 3.2rem); font-weight: 500; margin: 3px 0 0; }
.ink-note { max-width: 380px; color: var(--ink-soft); font-family: var(--font-serif); font-style: italic; font-size: .9rem; text-align: right; }
.curve-frame { min-height: 300px; position: relative; background: rgba(255,253,248,.55); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
#glucoseChart { display: block; width: 100%; min-height: 290px; }
.empty-state { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; color: var(--ink-soft); }
.curve-legend { display: flex; justify-content: space-between; gap: 18px; margin-top: 14px; color: var(--ink-soft); font-size: .76rem; }
.dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; margin-right: 7px; }.dot.coral { background: var(--coral); }

.meal-list { display: grid; gap: 34px; }
.meal-entry { display: grid; grid-template-columns: 74px minmax(220px, .75fr) minmax(0, 1.35fr); gap: 24px; padding-bottom: 34px; border-bottom: 1px solid var(--line); }
.meal-date { text-align: center; padding-top: 4px; }.meal-date strong { display: block; font-family: var(--font-serif); font-size: 2.2rem; line-height: 1; font-weight: 500; }.meal-date span { color: var(--ink-soft); font-size: .74rem; }
.meal-photo-wrap { aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius-sm); background: var(--paper-deep); position: relative; }
.meal-photo { width: 100%; height: 100%; object-fit: cover; display: block; }.photo-placeholder { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--ink-soft); font-family: var(--font-serif); }
.meal-title-row { display: flex; justify-content: space-between; gap: 18px; align-items: start; }.meal-title-row h3 { font-family: var(--font-serif); font-size: 1.8rem; font-weight: 500; margin: 3px 0 0; }.meal-time { margin: 0; color: var(--moss); font-size: .75rem; }
.meal-note { color: var(--ink-soft); white-space: pre-wrap; margin: 14px 0 18px; }
.estimate-block { display: flex; align-items: baseline; gap: 14px; padding: 14px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); }.estimate-value { font-family: var(--font-serif); font-size: 1.5rem; }.estimate-meta { color: var(--ink-soft); font-size: .78rem; }
.reading-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }.reading-chip { font-size: .76rem; border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; background: rgba(255,253,248,.5); }
.empty-journal { text-align: center; padding: 60px 20px 20px; max-width: 600px; margin: auto; }.plate-illustration { width: 160px; height: 160px; border: 1px solid var(--leaf); border-radius: 50%; margin: 0 auto 28px; display: grid; place-items: center; }.plate-illustration span { width: 86px; height: 86px; border: 1px dashed var(--leaf); border-radius: 50%; }.empty-journal h3 { font-family: var(--font-serif); font-size: 1.8rem; font-weight: 500; margin: 0; }.empty-journal p { color: var(--ink-soft); }.empty-journal button { border: 0; border-bottom: 1px solid var(--ink); background: transparent; padding: 8px 0; cursor: pointer; }
footer { border-top: 1px solid var(--line); padding: 28px 0 70px; color: var(--ink-soft); font-size: .76rem; }

.sheet-dialog { width: min(700px, calc(100% - 28px)); max-height: 92svh; overflow-y: auto; padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--white); color: var(--ink); box-shadow: 0 30px 90px rgba(39,53,47,.24); }.sheet-dialog::backdrop { background: rgba(39,53,47,.48); backdrop-filter: blur(4px); }.sheet-dialog form { padding: 30px; }.sheet-dialog.compact { width: min(580px, calc(100% - 28px)); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 24px; }.dialog-head h2 { font-family: var(--font-serif); font-size: 2.2rem; font-weight: 500; margin: 0; }.dialog-head button { border: 0; background: transparent; font-size: 2rem; font-weight: 200; line-height: 1; cursor: pointer; }
.photo-picker { min-height: 250px; border: 1px dashed var(--leaf); border-radius: var(--radius-md); display: grid; place-items: center; overflow: hidden; background: var(--paper); cursor: pointer; margin-bottom: 22px; position: relative; }.photo-picker input { position: absolute; opacity: 0; pointer-events: none; }.photo-picker img { width: 100%; height: 100%; max-height: 380px; object-fit: cover; }.photo-picker > span { text-align: center; padding: 30px; }.photo-picker b, .photo-picker strong, .photo-picker small { display: block; }.photo-picker b { font-size: 2.2rem; font-weight: 200; }.photo-picker small { color: var(--ink-soft); margin-top: 4px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }.sheet-dialog label { display: block; margin: 14px 0; }.sheet-dialog input, .sheet-dialog textarea, .sheet-dialog select { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); padding: 12px 13px; color: var(--ink); outline: none; }.sheet-dialog input:focus, .sheet-dialog textarea:focus, .sheet-dialog select:focus { border-color: var(--moss); box-shadow: 0 0 0 3px rgba(79,114,94,.1); }.glucose-entry { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }.glucose-entry input { font-family: var(--font-serif); font-size: 2rem; }
.submit-button { width: 100%; border: 0; border-radius: var(--radius-sm); background: var(--moss-dark); color: var(--white); padding: 14px 18px; margin-top: 8px; cursor: pointer; font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 120px); background: var(--ink); color: var(--white); padding: 10px 16px; border-radius: 999px; font-size: .86rem; opacity: 0; transition: .25s ease; z-index: 120; }.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 780px) {
  main { width: min(100% - 28px, 640px); }
  .topbar { min-height: 78px; }
  .brand small { display: none; }
  .hero { min-height: auto; grid-template-columns: 1fr; gap: 38px; padding: 58px 0 52px; }
  .hero::after { width: 190px; height: 190px; top: 22px; right: -40px; }
  .hero-copy h2 { font-size: clamp(2.8rem, 13vw, 4.7rem); }
  .curve-section, .journal-section { padding: 54px 0; }
  .section-heading { align-items: start; }.ink-note { max-width: 140px; font-size: .75rem; }
  .curve-frame { min-height: 240px; margin-inline: -14px; border-left: 0; border-right: 0; border-radius: 0; } #glucoseChart { min-height: 240px; }
  .meal-entry { grid-template-columns: 52px minmax(0, 1fr); gap: 14px; }.meal-photo-wrap { grid-column: 2; }.meal-body { grid-column: 2; }.meal-date { grid-row: 1 / span 2; }.meal-date strong { font-size: 1.7rem; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }.sheet-dialog form { padding: 24px 20px; }
  .sheet-dialog { width: 100%; max-height: 94svh; margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .sheet-dialog.compact { width: 100%; }
}

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