:root {
  color-scheme: light;
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --surface-soft: #F3F6F4;
  --ink: #1E2926;
  --muted: #5A6B66;
  --line: #E2E8E4;
  --pine: #1B6B5A;
  --pine-soft: #E9F4F1;
  --persimmon: #E87A30;
  --persimmon-soft: #FFF2E8;
  --honey: #F4B942;
  --honey-soft: #FFF9E6;
  --danger: #C23B2B;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  min-height: 44px;
  padding: 0 14px;
  font-weight: 600;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(27, 107, 90, 0.28);
  outline-offset: 2px;
}

button.primary {
  background: var(--pine);
  border-color: var(--pine);
  color: #fff;
}

button.warm {
  background: var(--persimmon);
  border-color: var(--persimmon);
  color: #fff;
}

button.soft {
  background: var(--pine-soft);
  border-color: #C7E3DB;
  color: var(--pine);
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

button.danger {
  background: #FFF5F4;
  border-color: #F4CBC6;
  color: var(--danger);
}

button.small {
  min-height: 36px;
  padding: 0 11px;
  font-size: 14px;
}

input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

/* Sticky Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(250, 250, 247, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--pine);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.identity-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 15px;
  font-weight: 700;
}

/* Main Workspace */
.main-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px 14px 24px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

.section-sub {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
}

.panel-soft {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
}

/* ===== Living Room Pet Windowsill Stage ===== */
.pet-stage {
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid #DCE7DF;
  background: linear-gradient(180deg, #E8F6F2 0%, #FDF8EB 68%, #F4E6CE 68%, #EAD6B5 100%);
  padding: 18px 16px 16px;
  margin-bottom: 14px;
  position: relative;
}

.pet-stage.is-hungry {
  background: linear-gradient(180deg, #F1F4F6 0%, #FBF5EA 68%, #EFE2CC 68%, #E6D5B8 100%);
}

.pet-stage.is-droopy {
  background: linear-gradient(180deg, #E7ECEF 0%, #F2F0EC 68%, #E4DACB 68%, #D9CDBB 100%);
}

.pet-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.pet-name-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(30, 41, 38, 0.08);
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 800;
  font-size: 15px;
}

.pet-level-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--pine);
  background: var(--pine-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.pet-speech {
  background: #fff;
  border: 1px solid #DFEAE4;
  border-radius: 16px;
  padding: 10px 14px;
  margin: 12px auto 4px;
  max-width: 440px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}

.pet-figure-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 168px;
  cursor: pointer;
}

.pet-svg {
  width: 156px;
  height: 156px;
  transition: transform 180ms ease;
}

.pet-svg.bounce {
  animation: petHop 460ms ease;
}

@keyframes petHop {
  0% { transform: scale(1) translateY(0); }
  35% { transform: scale(1.08, 0.94) translateY(-12px); }
  70% { transform: scale(0.97, 1.03) translateY(2px); }
  100% { transform: scale(1) translateY(0); }
}

.pet-meters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.meter-box {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  padding: 9px 11px;
  border: 1px solid rgba(30, 41, 38, 0.07);
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}

.meter-track {
  height: 9px;
  border-radius: 999px;
  background: #E8ECE9;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--pine);
  transition: width 320ms ease;
}

.meter-fill.warm {
  background: var(--persimmon);
}

.pet-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.pet-action-btn {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #D7E2DC;
  border-radius: 12px;
  min-height: 46px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.pet-action-btn.highlight {
  background: var(--pine);
  border-color: var(--pine);
  color: #fff;
}

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.feed-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}

.feed-item:last-child {
  border-bottom: 0;
}

.feed-time {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ===== Mood Weather Board ===== */
.weather-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.weather-opt {
  min-height: 58px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 13.5px;
}

.weather-opt .w-ico {
  font-size: 22px;
  line-height: 1.1;
}

.weather-opt.selected {
  border-color: var(--pine);
  background: var(--pine-soft);
  color: var(--pine);
}

.rain-alert {
  background: var(--persimmon-soft);
  border: 1px solid #F4C7A6;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  color: #8A3F12;
  font-size: 15px;
  font-weight: 600;
}

.weather-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 680px) {
  .weather-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.mood-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
}

.mood-card.rainy {
  border-color: #C7D7E8;
  background: #F6FAFE;
}

.mood-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.member-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 16px;
}

.avatar-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}

.mood-note {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--ink);
}

.mood-week-strip {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  overflow-x: auto;
}

.day-chip {
  flex: 1;
  min-width: 40px;
  text-align: center;
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 4px 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.day-chip strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.cheer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

/* ===== Dining Wheel & Menu ===== */
.wheel-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
}

.wheel-stage {
  position: relative;
  width: min(300px, 82vw);
  height: min(300px, 82vw);
}

.wheel-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 22px solid var(--persimmon);
  z-index: 3;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

#dishWheelCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.wheel-result {
  min-height: 28px;
  font-size: 17px;
  font-weight: 800;
  color: var(--pine);
  text-align: center;
}

.dish-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.dish-item:last-child {
  border-bottom: 0;
}

.dish-meta {
  font-size: 13px;
  color: var(--muted);
}

.grocery-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.grocery-row.done label {
  text-decoration: line-through;
  color: var(--muted);
}

.grocery-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  flex: 1;
  cursor: pointer;
}

.grocery-check input {
  width: 22px;
  height: 22px;
  accent-color: var(--pine);
}

/* ===== Birthdays & Secret Wish List ===== */
.bday-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  margin-bottom: 10px;
}

.bday-card.soon {
  border-color: #F2C97D;
  background: var(--honey-soft);
}

.bday-days {
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.bday-days strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
  color: var(--pine);
}

.bday-card.soon .bday-days strong {
  color: var(--persimmon);
}

.wish-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px;
  margin-bottom: 10px;
  background: var(--surface);
}

.wish-card.fulfilled {
  opacity: 0.65;
}

.secret-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--pine-soft);
  color: var(--pine);
}

.secret-badge.owner {
  background: var(--surface-soft);
  color: var(--muted);
}

/* ===== Timeline Photo Album ===== */
.tag-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.tag-chip {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.tag-chip.active {
  background: var(--pine);
  border-color: var(--pine);
  color: #fff;
}

.timeline-rail {
  border-left: 2px solid #D5E2DC;
  padding-left: 14px;
  margin-left: 6px;
}

.memory-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 16px;
}

.memory-card::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 20px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pine);
  border: 2px solid var(--bg);
}

.memory-photo {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  border-radius: 12px;
  margin: 10px 0;
  display: block;
  cursor: zoom-in;
  background: var(--surface-soft);
}

.react-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.react-btn {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 14px;
  background: var(--surface-soft);
  border-color: transparent;
}

.react-btn.active {
  background: var(--persimmon-soft);
  border-color: #F4C7A6;
  color: #A64810;
}

.comment-box {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.comment-line {
  font-size: 14px;
  margin-bottom: 6px;
}

/* ===== Kids Face-Swap Mini-Games ===== */
.face-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 10px;
}

.face-card {
  flex: 0 0 auto;
  width: 96px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
}

.face-card.selected {
  border-color: var(--persimmon);
  background: var(--persimmon-soft);
}

.face-thumb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 6px;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: #FFF3D6;
  border: 2px solid #F4B942;
  font-size: 28px;
  overflow: hidden;
}

.face-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.face-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.game-tab-btn {
  min-height: 54px;
  padding: 6px 8px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.25;
}

.game-tab-btn.active {
  background: var(--pine);
  border-color: var(--pine);
  color: #fff;
}

.game-canvas-shell {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid #D7E5DE;
  background: #EAF6FB;
  touch-action: none;
  user-select: none;
}

#kidsGameCanvas {
  width: 100%;
  max-width: 440px;
  aspect-ratio: 3 / 4;
  display: block;
  margin: 0 auto;
  touch-action: none;
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.crop-preview-wrap {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--persimmon);
  margin: 10px auto;
  background: #F4F7F5;
  position: relative;
}

#faceCropCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== Bottom Mobile Nav ===== */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-inner {
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
}

.nav-btn {
  min-height: 60px;
  border: 0;
  border-radius: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}

.nav-btn .nav-ico {
  font-size: 21px;
  line-height: 1.1;
}

.nav-btn.active {
  color: var(--pine);
}

/* ===== Modals & Toast ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 30, 27, 0.62);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border-radius: 20px;
  max-width: 460px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 20px;
  border: 1px solid var(--line);
}

.modal-box h3 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
}

.form-row {
  margin-bottom: 12px;
}

.form-row label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--muted);
}

.inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(16px);
  background: #1E2926;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 120;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.lightbox-img {
  max-width: 94vw;
  max-height: 86vh;
  border-radius: 14px;
  object-fit: contain;
}

.muted-text {
  color: var(--muted);
  font-size: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
