:root {
  color-scheme: light;
  --cream: #f6efe2;
  --paper: #fffaf1;
  --paper-strong: #fffdf8;
  --ink: #282621;
  --muted: #746f65;
  --line: #e4d8c6;
  --terracotta: #b85f45;
  --terracotta-dark: #934833;
  --terracotta-soft: #f0d3c5;
  --sesame: #3c3a35;
  --sage: #6f806e;
  --shadow: 0 18px 45px rgba(70, 54, 38, .09);
  font-family: ui-rounded, "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--cream); color: var(--ink); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 88% 0, rgba(184,95,69,.09), transparent 31rem), var(--cream); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:disabled { cursor: wait; opacity: .55; }
.quick-status { min-height: 1.4em; margin: 10px 2px 0; color: var(--muted); font-size: .8rem; }
button, select, input[type="file"] { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(184,95,69,.28); outline-offset: 2px; }

.site-header { position: sticky; z-index: 20; top: 0; border-bottom: 1px solid rgba(228,216,198,.8); background: rgba(246,239,226,.9); backdrop-filter: blur(16px); }
.header-inner, .app-shell { width: min(100% - 28px, 1080px); margin-inline: auto; }
.header-inner { min-height: 78px; display: flex; align-items: center; gap: 12px; }
.header-inner h1 { margin: 1px 0 0; font: 700 1.25rem/1.15 Georgia, "Songti SC", serif; }
.brand-mark { width: 46px; height: 46px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 16px; background: var(--terracotta-soft); }
.brand-mark svg { width: 36px; fill: var(--sesame); }
.eyebrow, .section-kicker { margin: 0; color: var(--terracotta-dark); font-size: .7rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.text-button { margin-left: auto; min-height: 44px; padding: 0 10px; border: 0; background: transparent; color: var(--muted); }

.app-shell { padding: 28px 0 70px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading.compact { align-items: center; }
.section-heading h2 { margin: 4px 0 0; font: 700 1.5rem/1.2 Georgia, "Songti SC", serif; }
.section-heading > span { color: var(--muted); font-size: .78rem; }
.soft-pill { padding: 7px 10px; border-radius: 999px; background: rgba(255,255,255,.55); border: 1px solid var(--line); white-space: nowrap; }

.overview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat-card { min-width: 0; padding: 16px 14px; border: 1px solid rgba(228,216,198,.8); border-radius: 22px; background: rgba(255,250,241,.86); box-shadow: 0 10px 30px rgba(70,54,38,.045); }
.stat-card > span:not(.stat-icon) { display: block; color: var(--muted); font-size: .78rem; }
.stat-icon { display: inline-grid; width: 28px; height: 28px; margin-bottom: 12px; place-items: center; border-radius: 10px; background: var(--terracotta-soft); color: var(--terracotta-dark); }
.stat-card strong { display: block; margin: 5px 0 3px; overflow: hidden; font-size: 1.12rem; text-overflow: ellipsis; white-space: nowrap; }
.stat-card small { display: block; min-height: 2.4em; color: var(--muted); font-size: .68rem; line-height: 1.35; }

.quick-section, .chart-card, .diary-section { margin-top: 34px; }
.quick-grid { display: grid; grid-template-columns: 1fr; gap: 11px; }
.capture-group { min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); }
.capture-group h3 { grid-column: 1 / -1; margin: 0 0 4px; font-size: .95rem; }
.capture-group .quick-action { min-height: 50px; justify-content: center; padding: 10px; border: 1px solid var(--line); border-radius: 14px; box-shadow: none; font-size: .86rem; font-weight: 700; }
.capture-group [data-capture] { grid-column: 1 / -1; color: white; background: var(--sesame); }
.feed-action [data-quick-feed] { grid-column: 1 / -1; }
.quick-wrap { display: flex; min-width: 0; flex-direction: column; border-radius: 22px; background: var(--sesame); box-shadow: var(--shadow); overflow: hidden; }
.quick-action { min-width: 0; min-height: 82px; display: flex; align-items: center; gap: 12px; padding: 14px; border: 0; border-radius: 22px; text-align: left; background: var(--paper-strong); box-shadow: var(--shadow); }
.quick-wrap .quick-action { flex: 1; color: white; border-radius: 22px 22px 0 0; background: transparent; box-shadow: none; }
.quick-action strong, .quick-action small { display: block; }
.quick-action strong { font-size: .96rem; }
.quick-action small { margin-top: 4px; color: var(--muted); font-size: .69rem; line-height: 1.35; }
.quick-wrap .quick-action small { color: #d7d2c8; }
.quick-symbol { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 14px; background: var(--terracotta-soft); color: var(--terracotta-dark); font-size: 1.1rem; }
.feed-action .quick-symbol { background: #e2ddc5; color: #6e663f; }
.weight-action .quick-symbol { background: #d9e1d7; color: #506351; }
.detail-button { min-height: 44px; border: 0; border-top: 1px solid rgba(255,255,255,.14); background: transparent; color: #eee7dc; font-size: .72rem; }

.trends-section { margin-top: 30px; }
.trend-window { margin: -4px 0 16px; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.trend-grid { display: grid; gap: 14px; }
.trend-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); }
.trend-card h3 { margin: 0; font-size: 1rem; }
.trend-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trend-heading select { max-width: 50%; min-height: 44px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-strong); font-size: .74rem; color: var(--ink); }
.trend-rule { min-height: 2.8em; margin: 8px 0; color: var(--muted); font-size: .75rem; line-height: 1.5; }
.trend-summary { min-height: 1.4em; margin: 8px 0; font-size: .84rem; font-weight: 700; }
.chart-empty { display: grid; min-height: 150px; place-items: center; margin: 0; color: var(--muted); font-size: .85rem; }
.chart-card { padding: 20px; border: 1px solid var(--line); border-radius: 26px; background: var(--paper); box-shadow: var(--shadow); }
.chart-canvas { min-height: 170px; overflow: hidden; }
.chart-canvas svg { display: block; width: 100%; height: 180px; }
.chart-grid { stroke: #eadfce; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--terracotta); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: rgba(184,95,69,.11); }
.chart-dot { fill: var(--paper-strong); stroke: var(--terracotta); stroke-width: 3; }
.chart-label { fill: var(--muted); font-size: 12px; }
.chart-bar { fill: var(--terracotta); }
#feed-chart .chart-bar { fill: #827547; }
.trend-data { margin-top: 4px; font-size: .75rem; }
.trend-data summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--terracotta-dark); }
.trend-data summary::before { content: '▸'; margin-right: 6px; }
.trend-data[open] summary::before { content: '▾'; }
.trend-data table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.trend-data caption { text-align: left; margin-bottom: 8px; color: var(--muted); }
.trend-data th, .trend-data td { padding: 7px 3px; border-bottom: 1px solid var(--line); text-align: left; overflow-wrap: anywhere; }
.trend-data th { width: 40%; font-weight: 500; }

.diary-list { position: relative; display: grid; gap: 13px; }
.diary-list::before { content: ""; position: absolute; top: 20px; bottom: 20px; left: 18px; width: 1px; background: var(--line); }
.entry-card { position: relative; min-width: 0; margin-left: 37px; padding: 17px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,250,241,.93); box-shadow: 0 9px 25px rgba(70,54,38,.045); }
.entry-card::before { content: ""; position: absolute; top: 21px; left: -25px; width: 11px; height: 11px; border: 4px solid var(--cream); border-radius: 50%; background: var(--terracotta); box-shadow: 0 0 0 1px var(--line); }
.entry-top { display: flex; align-items: flex-start; gap: 10px; }
.entry-title { margin: 0; font-size: 1rem; }
.entry-time { margin: 3px 0 0; color: var(--muted); font-size: .74rem; }
.entry-badge { margin-left: auto; padding: 5px 8px; border-radius: 999px; color: var(--terracotta-dark); background: var(--terracotta-soft); font-size: .68rem; white-space: nowrap; }
.entry-detail { margin: 13px 0 0; color: var(--ink); font-size: .86rem; line-height: 1.55; }
.entry-note { margin: 9px 0 0; padding: 10px 12px; border-radius: 13px; color: var(--muted); background: rgba(228,216,198,.28); font-size: .8rem; line-height: 1.55; white-space: pre-wrap; }
.entry-photo { width: 100%; max-height: 280px; margin-top: 13px; padding: 0; overflow: hidden; border: 0; border-radius: 16px; background: #e9dfd0; }
.entry-photo img { width: 100%; height: 180px; display: block; object-fit: cover; }
.entry-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 8px; }
.entry-actions button { min-width: 48px; min-height: 42px; padding: 0 8px; border: 0; border-radius: 12px; color: var(--muted); background: transparent; font-size: .76rem; }
.entry-actions button:hover { background: rgba(228,216,198,.35); }

.empty-state { padding: 28px 20px 34px; text-align: center; border: 1px dashed #d6c6b2; border-radius: 26px; background: rgba(255,250,241,.55); }
.empty-state svg { width: 150px; fill: none; stroke: var(--sesame); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .78; }
.empty-state h3 { margin: 2px 0 7px; font-family: Georgia, "Songti SC", serif; }
.empty-state p { max-width: 330px; margin: auto; color: var(--muted); font-size: .84rem; line-height: 1.6; }

dialog { padding: 0; border: 0; color: var(--ink); }
dialog::backdrop { background: rgba(36,32,28,.48); backdrop-filter: blur(3px); }
.entry-dialog { width: min(calc(100% - 24px), 540px); max-height: calc(100dvh - 24px); border-radius: 28px; background: transparent; }
.dialog-card { max-height: calc(100dvh - 24px); padding: 22px; overflow-y: auto; border-radius: 28px; background: var(--paper-strong); box-shadow: 0 30px 80px rgba(36,32,28,.24); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.dialog-heading h2 { margin: 4px 0 0; font: 700 1.45rem Georgia, "Songti SC", serif; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--cream); font-size: 1.5rem; }
.dialog-card label { display: block; margin: 14px 0 7px; font-size: .82rem; font-weight: 700; }
.dialog-card input:not([type="file"]), .dialog-card select, .dialog-card textarea { width: 100%; min-height: 48px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; background: white; color: var(--ink); }
.dialog-card textarea { min-height: 86px; resize: vertical; }
.dialog-card input[type="file"] { width: 100%; padding: 12px; border: 1px dashed #cebda8; border-radius: 14px; background: var(--cream); }
.dialog-card small { display: block; margin-top: 6px; color: var(--muted); font-size: .7rem; }
.field-group { display: contents; }
.dialog-actions { position: sticky; bottom: -22px; display: grid; grid-template-columns: 1fr 1.45fr; gap: 10px; margin: 22px -22px -22px; padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,253,248,.96); backdrop-filter: blur(12px); }
.primary-button, .secondary-button { min-height: 50px; padding: 0 18px; border-radius: 15px; font-weight: 800; }
.primary-button { border: 0; color: white; background: var(--terracotta); box-shadow: 0 9px 20px rgba(184,95,69,.2); }
.primary-button:hover { background: var(--terracotta-dark); }
.secondary-button { border: 1px solid var(--line); background: var(--paper-strong); }
.form-error { padding: 10px 12px; border-radius: 12px; color: #8c3328; background: #f9ddd7; font-size: .8rem; }

.lightbox { width: min(calc(100% - 20px), 980px); max-height: calc(100dvh - 20px); overflow: visible; border-radius: 20px; background: #171615; box-shadow: 0 30px 100px rgba(0,0,0,.4); }
.lightbox img { width: 100%; max-height: calc(100dvh - 20px); display: block; object-fit: contain; border-radius: 20px; }
.lightbox-close { position: absolute; z-index: 2; top: 10px; right: 10px; width: 44px; height: 44px; border: 0; border-radius: 50%; color: white; background: rgba(0,0,0,.58); font-size: 1.5rem; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 11px 16px; transform: translateX(-50%); border-radius: 999px; color: white; background: var(--sesame); box-shadow: var(--shadow); font-size: .82rem; }

.login-page { display: grid; min-height: 100dvh; place-items: center; padding: 20px; }
.login-shell { width: min(100%, 430px); }
.login-card { padding: 30px 26px; text-align: center; border: 1px solid rgba(228,216,198,.9); border-radius: 32px; background: rgba(255,250,241,.9); box-shadow: var(--shadow); }
.login-card h1 { margin: 5px 0 7px; font: 700 2rem Georgia, "Songti SC", serif; }
.login-intro { margin: 0 auto 24px; color: var(--muted); font-size: .88rem; }
.cat-portrait { width: 165px; height: 130px; margin: -12px auto 3px; }
.cat-portrait svg { width: 100%; height: 100%; overflow: visible; }
.cat-head, .cat-body { fill: var(--sesame); }
.cat-tail, .cat-stripe, .cat-mouth { fill: none; stroke: var(--sesame); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.cat-stripe, .cat-mouth { stroke: #b6a994; stroke-width: 4; }
.cat-eye { fill: #f8efe1; }.cat-nose { fill: var(--terracotta); }
.login-form { text-align: left; }
.login-form label { display: block; margin-bottom: 7px; font-size: .8rem; font-weight: 800; }
.login-form input { width: 100%; min-height: 50px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.login-form button { width: 100%; margin-top: 12px; }
.privacy-note { margin: 20px 0 0; color: var(--muted); font-size: .69rem; }
.error-home { display: inline-grid; min-width: 150px; place-items: center; text-decoration: none; }

@media (max-width: 640px) {
  .app-shell { padding-top: 22px; }
  .overview-grid { gap: 7px; }
  .stat-card { padding: 13px 10px; border-radius: 18px; }
  .stat-card strong { font-size: .98rem; }
  .quick-grid { grid-template-columns: 1fr; }
  .quick-wrap { grid-column: 1 / -1; }
  .quick-action { min-height: 76px; }
  .section-heading h2 { font-size: 1.34rem; }
}

@media (min-width: 1000px) {
  .trend-grid, .quick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quick-grid { align-items: stretch; }
  .diary-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .diary-list::before { display: none; }
  .entry-card { margin-left: 0; }
  .entry-card::before { display: none; }
  .entry-photo img { height: 240px; }
}

@media (prefers-reduced-motion: no-preference) {
  .quick-action, .primary-button, .entry-card { transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
  .quick-action:hover, .entry-card:hover { transform: translateY(-2px); }
}
