:root {
  --green-950: #0c4026;
  --green-900: #14532d;
  --green-800: #176b3a;
  --green-700: #238248;
  --green-600: #36a85d;
  --green-500: #57bd71;
  --green-200: #cfead5;
  --green-100: #e8f6eb;
  --green-50: #f5fbf6;
  --cream: #fffdf7;
  --yellow: #f2b705;
  --orange: #a84a18;
  --red: #c94747;
  --blue: #2a78a6;
  --ink: #173427;
  --muted: #5d7165;
  --border: #cfe1d3;
  --shadow: 0 14px 34px rgba(22, 84, 48, 0.13);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --font-scale: 1;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(115, 203, 132, 0.22), transparent 32rem),
    linear-gradient(180deg, #edf8ef 0%, #f8fbf7 45%, #f2f7f1 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: calc(18px * var(--font-scale));
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.72; }
img { max-width: 100%; display: block; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; }

.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;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  left: 16px;
  top: -80px;
  padding: 12px 18px;
  border-radius: 12px;
  background: #fff;
  color: var(--green-900);
  box-shadow: var(--shadow);
}
.skip-link:focus { top: 12px; }

.app-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.74);
}

.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 12px 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--green-900), var(--green-700));
  box-shadow: 0 8px 22px rgba(18, 79, 44, 0.2);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 32px; }
.brand strong { display: block; font-size: 1.12rem; line-height: 1.2; }
.brand span:last-child { display: block; color: rgba(255,255,255,.92); font-size: .86rem; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-button {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,.12);
}
.icon-button:hover, .icon-button:focus-visible { background: rgba(255,255,255,.24); }
.points-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 50px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--green-950);
  background: #fff7cf;
}
.points-pill.large { min-width: 112px; justify-content: center; font-size: 1.15rem; }

main { padding: 22px 18px calc(108px + var(--safe-bottom)); }
.view { animation: view-in .24s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }

.hero-summary, .page-heading, .section-heading, .pet-profile-line, .analysis-score, .dish-line, .reward-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.hero-summary, .page-heading { margin-bottom: 18px; }
.welcome, .eyebrow { margin: 0; color: var(--green-700); font-weight: 800; letter-spacing: .02em; }
.eyebrow { display: block; font-size: .9rem; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.5rem, 5vw, 2.15rem); line-height: 1.22; }
h2 { margin-bottom: 0; font-size: 1.22rem; line-height: 1.3; }
h3 { margin: 0; font-size: 1.08rem; line-height: 1.35; }

.primary-button, .secondary-button {
  min-height: 54px;
  border-radius: 16px;
  border: 0;
  padding: 12px 20px;
  font-weight: 800;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--green-800), var(--green-700));
  box-shadow: 0 8px 18px rgba(36, 139, 73, .22);
}
.secondary-button { color: var(--green-900); background: var(--green-100); border: 1px solid var(--green-200); }
.primary-button:hover:not(:disabled), .secondary-button:hover:not(:disabled) { transform: translateY(-1px); }
.primary-button:active:not(:disabled), .secondary-button:active:not(:disabled) { transform: translateY(1px); }
.full-width { width: 100%; }

.pet-overview, .status-panel, .daily-panel, .camera-card, .analysis-result, .history-panel, .inventory-panel, .health-card, .achievement-card, .admin-card {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid rgba(163, 196, 169, .62);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow);
}
.pet-overview { padding: 18px; }
.pet-name-row { display: flex; align-items: baseline; gap: 10px; }
.pet-name-row h2 { font-size: 1.55rem; }
.level-label { color: var(--green-700); font-weight: 800; }
.exp-area { width: min(46%, 280px); font-size: .92rem; text-align: right; color: var(--muted); }
.progress-track { height: 10px; overflow: hidden; border-radius: 999px; background: #e3ebe4; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green-700), #8dcc58); transition: width .4s ease; }
.progress-track.large { height: 14px; margin: 14px 0 18px; }

.pet-stage {
  position: relative;
  isolation: isolate;
  width: min(100%, 620px);
  margin: 16px auto 18px;
  overflow: hidden;
  border-radius: 28px;
  background: linear-gradient(180deg, #dcebd5, #f4e5bd);
  box-shadow: inset 0 0 0 1px rgba(44, 107, 62, .12);
}
.pet-stage::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: auto 0 0;
  height: 26%;
  pointer-events: none;
  background: linear-gradient(transparent, rgba(18, 65, 35, .12));
}
.pet-stage img { width: 100%; aspect-ratio: 360 / 325; object-fit: cover; }
.pet-message {
  position: absolute;
  z-index: 6;
  top: 14px;
  left: 14px;
  max-width: 64%;
  padding: 11px 14px;
  border-radius: 17px 17px 17px 5px;
  color: var(--green-950);
  background: rgba(255,255,255,.96);
  box-shadow: 0 7px 18px rgba(22, 63, 35, .14);
  font-size: .96rem;
  font-weight: 700;
}
.house-label {
  position: absolute;
  z-index: 5;
  right: 12px;
  bottom: 12px;
  padding: 7px 11px;
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 83, 45, .88);
  font-size: .9rem;
  font-weight: 800;
}
.equipped-item {
  position: absolute;
  z-index: 7;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(42px, 11vw, 70px);
  filter: drop-shadow(0 4px 4px rgba(30,50,20,.18));
  pointer-events: none;
}

.pet-stage[data-appearance="hat"] .equipped-item { top: 5%; transform: translateX(-50%) rotate(-5deg); }
.pet-stage[data-appearance="glasses"] .equipped-item { top: 27%; font-size: clamp(38px, 10vw, 66px); }
.pet-stage[data-appearance="bow"] .equipped-item { top: 48%; font-size: clamp(34px, 9vw, 58px); }
.pet-stage[data-appearance="crown"] .equipped-item { top: 3%; font-size: clamp(42px, 11vw, 72px); }

.hotspot {
  position: absolute;
  z-index: 8;
  min-width: 48px;
  min-height: 50px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}
.hotspot:focus-visible { outline: 5px solid rgba(255, 255, 255, .95); box-shadow: 0 0 0 9px rgba(39, 139, 74, .78); }
.hotspot-head { top: 21%; left: 36%; width: 30%; height: 25%; }
.hotspot-paw { top: 58%; left: 28%; width: 43%; height: 19%; }
.hotspot-foot { top: 72%; left: 35%; width: 35%; height: 16%; }

.interaction-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.interaction-button {
  min-height: 94px;
  border: 1px solid var(--green-200);
  border-radius: 18px;
  color: var(--green-900);
  background: var(--green-50);
  font-weight: 800;
}
.interaction-button:hover, .interaction-button:focus-visible { background: #dbf2df; }
.interaction-icon { display: block; margin-bottom: 4px; font-size: 1.65rem; }

.status-list { display: grid; gap: 13px; margin-top: 18px; }
.status-row { display: grid; grid-template-columns: 82px 1fr 54px; align-items: center; gap: 10px; }
.status-row strong { font-size: 1rem; }
.status-row span:last-child { text-align: right; color: var(--muted); font-size: .9rem; }
.status-bar { height: 13px; overflow: hidden; border-radius: 999px; background: #e6ece6; }
.status-bar span { display: block; height: 100%; border-radius: inherit; transition: width .35s ease; }
.status-mood span { background: linear-gradient(90deg, #e2aa14, #f0cc53); }
.status-hunger span { background: linear-gradient(90deg, #df7e2e, #f3a657); }
.status-health span { background: linear-gradient(90deg, #2d9e57, #72c26d); }
.status-clean span { background: linear-gradient(90deg, #2684aa, #6dc5dc); }
.status-chip, .privacy-label, .admin-badge, .mode-label {
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--green-900);
  background: var(--green-100);
  font-size: .9rem;
  font-weight: 800;
}
.gentle-note, .helper-text { margin: 16px 0 0; color: var(--muted); font-size: .92rem; }

.task-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 10px 12px;
  border-radius: 15px;
  background: var(--green-50);
}
.task-check {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--green-700);
  background: #fff;
  border: 2px solid var(--green-200);
  font-weight: 900;
}
.task-item.is-done .task-check { color: #fff; background: var(--green-700); border-color: var(--green-700); }
.task-item strong { display: block; }
.task-item span:last-child { color: var(--muted); font-size: .9rem; }

.photo-drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 300px;
  overflow: hidden;
  border: 3px dashed #9ec8a7;
  border-radius: 24px;
  color: var(--green-900);
  background: linear-gradient(145deg, #f8fff9, #ebf7ed);
  text-align: center;
  cursor: pointer;
}
.photo-drop-zone:focus-within { outline: 4px solid rgba(36, 130, 72, .25); }
.photo-drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-placeholder { display: grid; gap: 8px; place-items: center; padding: 24px; }
.photo-placeholder span:last-child { color: var(--muted); font-size: .92rem; }
.camera-symbol { font-size: 3.2rem; }
#photo-preview { width: 100%; height: 100%; min-height: 300px; object-fit: cover; }
.file-meta { min-height: 30px; margin: 10px 0; color: var(--muted); font-size: .92rem; }
.analyze-progress { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; color: var(--green-800); font-weight: 700; }
.spinner { width: 24px; height: 24px; border: 3px solid var(--green-200); border-top-color: var(--green-700); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.analysis-result { background: linear-gradient(160deg, #ffffff, #f0faf2); }
.score-circle {
  display: grid;
  place-items: center;
  grid-template-columns: auto auto;
  width: 94px;
  height: 94px;
  border: 9px solid #81cb7e;
  border-radius: 50%;
  color: var(--green-900);
  background: #fff;
}
.score-circle strong { font-size: 2rem; line-height: 1; }
.score-circle span { align-self: end; margin-bottom: 22px; font-size: .88rem; }
.dish-line { margin: 18px 0; padding: 14px; border-radius: 16px; background: var(--green-50); }
.nutrition-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.nutrition-item { padding: 14px; border-radius: 16px; border: 1px solid var(--border); background: #fff; }
.nutrition-item span { display: block; color: var(--muted); font-size: .9rem; }
.nutrition-item strong { font-size: 1.2rem; }
.analysis-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.analysis-tag { padding: 8px 12px; border-radius: 999px; color: var(--green-900); background: #ddf3e1; font-weight: 700; font-size: .9rem; }
.suggestion { padding: 15px; border-left: 5px solid var(--green-600); border-radius: 0 14px 14px 0; background: #f7fbf7; }
.reward-line { padding-top: 14px; border-top: 1px solid var(--border); }
.reward-line strong { color: var(--orange); font-size: 1.12rem; }

.photo-history, .health-history { display: grid; gap: 12px; margin-top: 16px; }
.photo-record, .health-record {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: var(--green-50);
}
.photo-record img { width: 74px; height: 74px; object-fit: cover; border-radius: 14px; }
.record-meta strong { display: block; }
.record-meta span { display: block; color: var(--muted); font-size: .9rem; }
.record-points { color: var(--orange); font-weight: 900; }
.empty-state { padding: 22px; border-radius: 16px; color: var(--muted); background: var(--green-50); text-align: center; }

.shop-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 16px; padding: 6px; border-radius: 18px; background: #dfece1; }
.shop-tab { min-height: 52px; border: 0; border-radius: 14px; color: var(--muted); background: transparent; font-weight: 800; }
.shop-tab.is-active { color: var(--green-900); background: #fff; box-shadow: 0 5px 12px rgba(37,82,51,.09); }
.shop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.shop-item { display: flex; flex-direction: column; min-height: 270px; padding: 16px; border-radius: 22px; border: 1px solid var(--border); background: rgba(255,255,255,.95); box-shadow: 0 10px 22px rgba(23, 90, 48, .09); }
.shop-item-icon { display: grid; place-items: center; min-height: 98px; margin-bottom: 12px; border-radius: 18px; background: var(--green-50); font-size: 3.3rem; }
.shop-item h3 { margin: 0 0 4px; font-size: 1rem; }
.shop-item p { flex: 1; margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.price-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; color: var(--orange); font-weight: 900; }
.shop-action { width: 100%; min-height: 52px; border: 0; border-radius: 14px; color: #fff; background: var(--green-700); font-weight: 800; }
.shop-action.is-owned { color: var(--green-900); background: #dff1e2; }
.inventory-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.inventory-chip:disabled, .shop-action:disabled { opacity: .84; }
.inventory-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 50px; padding: 8px 12px; border-radius: 999px; background: var(--green-100); font-weight: 700; }

.health-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 18px; }
.health-form label { display: grid; gap: 7px; color: var(--green-950); font-weight: 700; }
.health-form input, .health-form select {
  width: 100%;
  min-height: 56px;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}
.health-form input:focus, .health-form select:focus { outline: 3px solid rgba(49, 155, 87, .2); border-color: var(--green-600); }
.health-form .primary-button { grid-column: 1 / -1; }
.health-record { grid-template-columns: 1fr auto; }

.achievement-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.achievement-item { padding: 15px; border-radius: 18px; text-align: center; background: var(--green-50); border: 1px solid var(--border); }
.achievement-item.is-locked { filter: grayscale(1); opacity: .6; }
.achievement-icon { display: block; font-size: 2.2rem; }
.achievement-item strong { display: block; margin-top: 7px; }
.achievement-item span:last-child { display: block; color: var(--muted); font-size: .9rem; }

.admin-heading { align-items: flex-start; }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.metric-card { padding: 16px; border-radius: 18px; background: var(--green-50); border: 1px solid var(--border); }
.metric-card span { display: block; color: var(--muted); font-size: .9rem; }
.metric-card strong { display: block; margin-top: 4px; font-size: 1.35rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; }
table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 13px 12px; border-bottom: 1px solid #e1ebe3; text-align: left; vertical-align: top; }
th { color: var(--green-950); background: var(--green-100); }
tbody tr:last-child td { border-bottom: 0; }


.ledger-list, .daily-usage-list { display: grid; gap: 10px; margin-top: 16px; }
.ledger-row, .daily-usage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 11px 13px;
  border-radius: 15px;
  background: var(--green-50);
}
.ledger-row strong, .daily-usage-row strong { display: block; }
.ledger-row span, .daily-usage-row span { display: block; color: var(--muted); font-size: .9rem; }
.ledger-amount { color: var(--green-800) !important; font-weight: 900; white-space: nowrap; }
.ledger-amount.is-negative { color: var(--orange) !important; }
.backend-status-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 16px 0 6px; }
.compact-button { min-height: 50px; padding: 8px 14px; }
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 8px 14px;
  border: 1px solid var(--green-200);
  border-radius: 14px;
  color: var(--green-900);
  background: var(--green-100);
  font-weight: 800;
  text-decoration: none;
}
.sync-ok { color: var(--green-950); background: #dff2e3; }
.sync-warning { color: #6a3a0b; background: #fff0d8; }
.daily-usage-panel { margin: 20px 0; padding: 16px; border-radius: 18px; background: #fbfefb; border: 1px solid var(--border); }

.pet-stage[data-house="house_forest"]::before,
.pet-stage[data-house="house_blue"]::before {
  position: absolute;
  z-index: 4;
  right: 4%;
  top: 8%;
  pointer-events: none;
  font-size: clamp(44px, 12vw, 78px);
  filter: drop-shadow(0 5px 6px rgba(20,60,30,.2));
}
.pet-stage[data-house="house_forest"]::before { content: "🌲"; }
.pet-stage[data-house="house_blue"]::before { content: "☁️"; }

.bottom-nav {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 1180px);
  min-height: calc(74px + var(--safe-bottom));
  padding: 7px 10px var(--safe-bottom);
  border-top: 1px solid #cfe0d1;
  background: rgba(255,255,255,.96);
  box-shadow: 0 -10px 26px rgba(20, 70, 40, .11);
  backdrop-filter: blur(15px);
}
.nav-button { min-height: 60px; border: 0; border-radius: 16px; color: var(--muted); background: transparent; font-weight: 800; }
.nav-button span { display: block; }
.nav-button span:first-child { font-size: 1.35rem; line-height: 1.15; }
.nav-button span:last-child { font-size: .9rem; }
.nav-button.is-active { color: var(--green-900); background: var(--green-100); }

.confirm-dialog { width: min(calc(100% - 32px), 460px); border: 0; border-radius: 28px; padding: 0; color: var(--ink); box-shadow: 0 22px 70px rgba(11, 50, 27, .3); }
.confirm-dialog::backdrop { background: rgba(9, 35, 20, .58); backdrop-filter: blur(4px); }
.confirm-dialog form { padding: 28px; text-align: center; }
.dialog-item-icon { font-size: 4rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(94px + var(--safe-bottom));
  transform: translate(-50%, 18px);
  width: min(calc(100% - 36px), 520px);
  padding: 14px 18px;
  border-radius: 16px;
  color: #fff;
  background: rgba(12, 64, 38, .96);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  text-align: center;
  font-weight: 700;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.pet-anim-head { animation: nod .55s ease; }
.pet-anim-paw { animation: paw .55s ease; }
.pet-anim-foot { animation: wiggle .55s ease; }
.pet-anim-play { animation: bounce .65s ease; }
@keyframes nod { 30% { transform: rotate(-2deg) translateY(4px); } 65% { transform: rotate(2deg) translateY(-3px); } }
@keyframes paw { 35% { transform: rotate(-2deg) translateX(-5px); } 70% { transform: rotate(2deg) translateX(5px); } }
@keyframes wiggle { 25% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } 75% { transform: rotate(-1deg); } }
@keyframes bounce { 35% { transform: translateY(-12px) scale(1.015); } 70% { transform: translateY(2px); } }

:focus-visible { outline: 4px solid rgba(32, 128, 67, .38); outline-offset: 3px; }
[hidden] { display: none !important; }

@media (min-width: 820px) {
  main { padding: 30px 32px 120px; }
  #home-view.is-active { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 18px; align-items: start; }
  #home-view .hero-summary { grid-column: 1 / -1; }
  #home-view .pet-overview { grid-row: span 2; }
  .shop-grid { grid-template-columns: repeat(3, 1fr); }
  .camera-card, .analysis-result, .history-panel { max-width: 820px; margin-left: auto; margin-right: auto; }
}

@media (max-width: 640px) {
  body { font-size: calc(17px * var(--font-scale)); }
  .topbar { min-height: 70px; padding: 10px 14px; }
  .brand span:last-child { display: none; }
  .brand-mark { font-size: 27px; }
  .topbar-actions { gap: 5px; }
  .icon-button { width: 48px; height: 48px; }
  .points-pill { min-height: 44px; padding-inline: 10px; }
  main { padding: 18px 12px calc(100px + var(--safe-bottom)); }
  .hero-summary, .page-heading { align-items: flex-start; }
  .hero-summary { flex-direction: column; }
  .hero-summary .secondary-button { width: 100%; }
  .page-heading { gap: 10px; }
  .privacy-label, .admin-badge { max-width: 42%; text-align: center; }
  .pet-overview, .status-panel, .daily-panel, .camera-card, .analysis-result, .history-panel, .inventory-panel, .health-card, .achievement-card, .admin-card { padding: 16px; border-radius: 23px; }
  .pet-profile-line { align-items: flex-end; }
  .interaction-grid { grid-template-columns: repeat(2, 1fr); }
  .interaction-button { min-height: 84px; }
  .nutrition-grid, .health-form { grid-template-columns: 1fr; }
  .health-form .primary-button { grid-column: auto; }
  .shop-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .shop-item { min-height: 252px; padding: 13px; }
  .shop-item-icon { min-height: 86px; font-size: 2.8rem; }
  .achievement-list { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-heading { flex-direction: column; }
  .backend-status-row > * { flex: 1 1 100%; }
  .export-actions { width: 100%; justify-content: stretch; }
  .export-actions button { flex: 1; }
  .photo-record { grid-template-columns: 64px 1fr; }
  .photo-record img { width: 64px; height: 64px; }
  .record-points { grid-column: 2; }
}

@media (max-width: 390px) {
  .brand strong { font-size: .98rem; }
  .points-pill { font-size: .9rem; }
  .shop-grid { grid-template-columns: 1fr; }
  .interaction-grid { gap: 8px; }
  .status-row { grid-template-columns: 70px 1fr 45px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ===== 2.0：成长、日记、提醒与家庭关怀 ===== */
button, input, select, textarea { font: inherit; }
textarea { resize: vertical; }

.home-dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.summary-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px 10px;
  min-height: 82px;
  padding: 13px 15px;
  border: 1px solid var(--green-200);
  border-radius: 20px;
  color: var(--green-950);
  background: rgba(255,255,255,.92);
  box-shadow: 0 8px 22px rgba(22,84,48,.08);
  text-align: left;
}
.summary-tile:hover, .summary-tile:focus-visible { background: #ecf8ee; }
.summary-icon { grid-row: 1 / span 2; font-size: 1.8rem; }
.summary-tile > span:not(.summary-icon) { color: var(--muted); font-size: .88rem; }
.summary-tile strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.04rem; }

.active-toy {
  position: absolute;
  z-index: 7;
  right: 13%;
  bottom: 13%;
  pointer-events: none;
  font-size: clamp(38px, 10vw, 64px);
  filter: drop-shadow(0 5px 5px rgba(30,50,20,.2));
}
.pet-stage[data-toy="toy_ball"] .active-toy { right: 11%; bottom: 9%; }
.pet-stage[data-toy="toy_bell"] .active-toy { right: 13%; bottom: 14%; }
.pet-stage[data-toy="toy_duck"] .active-toy { right: 10%; bottom: 12%; }
.pet-stage[data-toy="toy_book"] .active-toy { right: 8%; bottom: 10%; transform: rotate(-8deg); }

.journey-hero, .journey-card, .game-card, .diary-card, .settings-card, .reminder-card, .family-card {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid rgba(163, 196, 169, .62);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.95);
  box-shadow: var(--shadow);
}
.journey-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  align-items: center;
  gap: 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at 94% 8%, rgba(96,190,103,.22), transparent 14rem),
    linear-gradient(145deg, #ffffff, #eff9f1);
}
.journey-hero-copy p { margin: 10px 0 0; color: var(--muted); }
.journey-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.journey-stat-grid div {
  min-width: 0;
  padding: 14px 10px;
  border: 1px solid var(--green-200);
  border-radius: 17px;
  background: rgba(255,255,255,.86);
  text-align: center;
}
.journey-stat-grid span { display: block; color: var(--muted); font-size: .82rem; }
.journey-stat-grid strong { display: block; margin-top: 3px; color: var(--green-900); font-size: 1.12rem; }

.journey-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px;
  border: 1px solid var(--green-200);
  border-radius: 19px;
  background: rgba(255,255,255,.92);
}
.journey-tab {
  min-height: 54px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
}
.journey-tab.is-active { color: #fff; background: var(--green-800); box-shadow: 0 8px 16px rgba(27,117,62,.2); }

.week-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 17px;
}
.week-day {
  min-width: 0;
  padding: 10px 4px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--green-50);
  text-align: center;
}
.week-day span, .week-day small { display: block; color: var(--muted); font-size: .76rem; }
.week-day strong {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 5px auto;
  border-radius: 50%;
  color: var(--muted);
  background: #fff;
  border: 2px solid var(--green-200);
}
.week-day.is-active { border-color: #91c99c; background: #e7f6e9; }
.week-day.is-active strong { color: #fff; border-color: var(--green-700); background: var(--green-700); }
.week-day.is-today { box-shadow: inset 0 0 0 2px var(--green-700); }

.milestone-list, .journey-timeline, .diary-list, .reminder-list { display: grid; gap: 12px; margin-top: 17px; }
.milestone-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 72px;
  padding: 11px 13px;
  border-radius: 18px;
  background: var(--green-50);
}
.milestone-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; background: #fff; font-size: 1.65rem; }
.milestone-item strong, .timeline-item strong { display: block; }
.milestone-item span, .timeline-item span { display: block; color: var(--muted); font-size: .88rem; }
.milestone-state { color: var(--green-800) !important; font-weight: 850; white-space: nowrap; }
.milestone-item.is-locked { opacity: .72; }

.timeline-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border-radius: 17px;
  background: #fbfefb;
  border: 1px solid var(--border);
}
.timeline-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--green-100); }
.timeline-time { color: var(--muted); font-size: .82rem; white-space: nowrap; }

.game-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, .7fr); align-items: start; gap: 18px; }
.game-intro p { margin: 10px 0 0; color: var(--muted); }
.game-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.game-stats div { padding: 12px 8px; border: 1px solid var(--green-200); border-radius: 16px; background: var(--green-50); text-align: center; }
.game-stats span { display: block; color: var(--muted); font-size: .78rem; }
.game-stats strong { display: block; margin-top: 4px; color: var(--green-900); }
.game-status {
  min-height: 58px;
  margin: 18px 0 14px;
  padding: 14px 16px;
  border-radius: 16px;
  color: var(--green-950);
  background: #edf8ef;
  font-weight: 750;
  text-align: center;
}
.leaf-game-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: min(100%, 520px);
  margin: 0 auto;
}
.leaf-tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 78px;
  border: 2px solid var(--green-200);
  border-radius: 22px;
  color: var(--green-900);
  background: linear-gradient(145deg, #fff, #edf8ef);
  font-size: clamp(2rem, 8vw, 3.4rem);
  box-shadow: 0 8px 18px rgba(20,85,46,.08);
}
.leaf-tile:hover:not(:disabled), .leaf-tile:focus-visible { border-color: var(--green-700); background: #e2f4e5; }
.leaf-tile.is-wrong { background: #fff4df; border-color: #e0a43d; }
.leaf-tile.is-found { color: #fff; background: var(--green-700); border-color: var(--green-900); transform: scale(1.03); }
.game-actions, .family-actions, .reminder-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; }

.diary-form, .profile-form, .reminder-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.diary-form label, .profile-form label, .reminder-form label { display: grid; gap: 7px; color: var(--green-950); font-weight: 760; }
.diary-form input, .diary-form select, .diary-form textarea,
.profile-form input, .reminder-form input, .reminder-form select {
  width: 100%;
  min-height: 52px;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}
.diary-form textarea { min-height: 132px; line-height: 1.55; }
.diary-note-label, .preference-list, .profile-form > .primary-button { grid-column: 1 / -1; }
.diary-form > .primary-button { grid-column: 1 / -1; justify-self: start; min-width: 190px; }
.character-count { justify-self: end; color: var(--muted); font-size: .84rem; font-weight: 500; }

.diary-entry {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fbfefb;
}
.diary-mood-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; background: var(--green-100); font-size: 1.55rem; }
.diary-entry header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.diary-entry header span { color: var(--muted); font-size: .84rem; }
.diary-entry p { margin: 7px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.diary-entry .diary-tag { display: inline-block; margin-top: 8px; padding: 4px 9px; border-radius: 999px; color: var(--green-900); background: var(--green-100); font-size: .8rem; }
.icon-danger {
  min-width: 48px;
  min-height: 48px;
  border: 1px solid #ebc5c5;
  border-radius: 14px;
  color: #8f2f2f;
  background: #fff6f6;
  font-weight: 800;
}

.preference-list { display: grid; gap: 10px; }
.switch-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--green-50);
}
.switch-row span { min-width: 0; }
.switch-row strong, .switch-row small { display: block; }
.switch-row small { margin-top: 2px; color: var(--muted); font-weight: 500; }
.switch-row input { flex: 0 0 auto; width: 30px; height: 30px; min-height: 30px; accent-color: var(--green-700); }

.reminder-form { grid-template-columns: minmax(0, 1fr) minmax(150px, .45fr) auto; align-items: end; }
.reminder-form .primary-button { min-height: 52px; }
.reminder-actions { justify-content: flex-start; }
.reminder-actions .helper-text { margin: 0; flex: 1 1 260px; }
.reminder-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fbfefb;
}
.reminder-time { color: var(--green-900); font-size: 1.08rem; font-weight: 900; }
.reminder-item strong, .reminder-item span { display: block; }
.reminder-item span { color: var(--muted); font-size: .86rem; }
.reminder-buttons { display: flex; gap: 7px; }
.reminder-toggle, .reminder-delete {
  min-width: 50px;
  min-height: 48px;
  border: 1px solid var(--green-200);
  border-radius: 13px;
  color: var(--green-900);
  background: var(--green-100);
  font-weight: 800;
}
.reminder-delete { color: #8f2f2f; border-color: #ebc5c5; background: #fff6f6; }
.reminder-item.is-paused { opacity: .67; }

.family-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.family-summary-item { padding: 14px 10px; border-radius: 17px; background: var(--green-50); border: 1px solid var(--border); text-align: center; }
.family-summary-item span { display: block; color: var(--muted); font-size: .82rem; }
.family-summary-item strong { display: block; margin-top: 4px; color: var(--green-900); }
.family-actions { justify-content: flex-start; }

body.is-high-contrast {
  --ink: #071a0f;
  --muted: #2f4838;
  --border: #6e9678;
  --green-100: #dcefe0;
  --green-50: #f3faf4;
  background: #fff;
}
body.is-high-contrast .app-shell { background: #fff; }
body.is-high-contrast .pet-overview,
body.is-high-contrast .status-panel,
body.is-high-contrast .daily-panel,
body.is-high-contrast .camera-card,
body.is-high-contrast .analysis-result,
body.is-high-contrast .history-panel,
body.is-high-contrast .inventory-panel,
body.is-high-contrast .health-card,
body.is-high-contrast .achievement-card,
body.is-high-contrast .admin-card,
body.is-high-contrast .journey-hero,
body.is-high-contrast .journey-card,
body.is-high-contrast .game-card,
body.is-high-contrast .diary-card,
body.is-high-contrast .settings-card,
body.is-high-contrast .reminder-card,
body.is-high-contrast .family-card { border-width: 2px; box-shadow: none; }

html.reduce-motion { scroll-behavior: auto; }
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}

.bottom-nav { grid-template-columns: repeat(5, 1fr); }

@media (min-width: 820px) {
  #journey-view.is-active .journey-progress-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  #journey-view.is-active .journey-progress-panel .journey-card { margin-bottom: 0; }
  #journey-view.is-active .journey-progress-panel .journey-card:last-child { grid-column: 1 / -1; }
  #records-view.is-active { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
  #records-view .page-heading, #records-view .admin-card { grid-column: 1 / -1; }
  #records-view > section { margin-bottom: 0; }
}

@media (max-width: 720px) {
  .home-dashboard { grid-template-columns: 1fr; }
  .summary-tile { min-height: 68px; }
  .journey-hero, .game-intro { grid-template-columns: 1fr; }
  .journey-stat-grid, .game-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .family-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .diary-form, .profile-form, .reminder-form { grid-template-columns: 1fr; }
  .diary-note-label, .preference-list, .profile-form > .primary-button, .diary-form > .primary-button { grid-column: auto; }
  .diary-form > .primary-button { width: 100%; justify-self: stretch; }
  .reminder-form .primary-button { width: 100%; }
}

@media (max-width: 520px) {
  .journey-hero, .journey-card, .game-card, .diary-card, .settings-card, .reminder-card, .family-card { padding: 16px; border-radius: 23px; }
  .journey-tabs { gap: 4px; padding: 5px; }
  .journey-tab { min-height: 52px; padding: 8px 5px; font-size: .88rem; }
  .week-calendar { gap: 4px; }
  .week-day { padding: 8px 2px; border-radius: 13px; }
  .week-day strong { width: 32px; height: 32px; font-size: .82rem; }
  .week-day span, .week-day small { font-size: .66rem; }
  .milestone-item { grid-template-columns: 48px minmax(0, 1fr); }
  .milestone-state { grid-column: 2; }
  .timeline-item { grid-template-columns: 40px minmax(0, 1fr); }
  .timeline-time { grid-column: 2; }
  .leaf-game-grid { gap: 8px; }
  .leaf-tile { min-height: 72px; border-radius: 18px; }
  .diary-entry { grid-template-columns: 44px minmax(0, 1fr); }
  .diary-entry .icon-danger { grid-column: 2; justify-self: end; }
  .reminder-item { grid-template-columns: 52px minmax(0, 1fr); }
  .reminder-buttons { grid-column: 2; }
  .bottom-nav { padding-inline: 5px; }
  .nav-button { min-height: 62px; padding-inline: 2px; }
  .nav-button span:first-child { font-size: 1.22rem; }
  .nav-button span:last-child { font-size: .78rem; }
}

.task-copy { min-width: 0; flex: 1 1 auto; }
.task-action, .task-finished {
  flex: 0 0 auto;
  min-width: 76px;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 13px;
  font-weight: 800;
  text-align: center;
}
.task-action { border: 1px solid var(--green-200); color: var(--green-900); background: #fff; }
.task-action:hover, .task-action:focus-visible { background: #e5f5e8; }
.task-finished { display: grid; place-items: center; color: var(--green-800); background: transparent; font-size: .88rem; }
@media (max-width: 420px) {
  .task-item { flex-wrap: wrap; }
  .task-action, .task-finished { margin-left: 44px; flex: 1 1 calc(100% - 44px); }
}

.pet-stage[data-appearance="flower"] .equipped-item { top: 5%; font-size: clamp(40px, 10vw, 66px); transform: translateX(-50%) rotate(-4deg); }
.pet-stage[data-appearance="scarf"] .equipped-item { top: 50%; font-size: clamp(38px, 10vw, 64px); }
.pet-stage[data-house="house_courtyard"]::before,
.pet-stage[data-house="house_bamboo"]::before {
  position: absolute;
  z-index: 4;
  right: 4%;
  top: 8%;
  pointer-events: none;
  font-size: clamp(44px, 12vw, 78px);
  filter: drop-shadow(0 5px 6px rgba(20,60,30,.2));
}
.pet-stage[data-house="house_courtyard"]::before { content: "🍵"; }
.pet-stage[data-house="house_bamboo"]::before { content: "🎋"; }

@media (max-width: 720px) {
  .home-dashboard { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .summary-tile { display: block; min-height: 104px; padding: 10px 6px; text-align: center; }
  .summary-icon { display: block; margin-bottom: 3px; font-size: 1.45rem; }
  .summary-tile > span:not(.summary-icon) { display: block; font-size: .75rem; line-height: 1.25; }
  .summary-tile strong { display: block; margin-top: 3px; font-size: .9rem; white-space: normal; line-height: 1.25; }
}
