:root {
  --primary: #42a5f5;
  --primary-soft: #d7ecff;
  --bg: #fff8f0;
  --card: #ffffff;
  --text: #2f2a27;
  --sub: #7b6c62;
  --ok: #a8e6cf;
  --warn: #ffb6c1;
  --alert: #ff6b6b;
  --shadow: 0 10px 25px rgba(66, 165, 245, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Nunito", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at -10% -20%, #fff2e4 10%, transparent 60%),
    radial-gradient(900px 500px at 110% -10%, #ffe5d1 5%, transparent 65%),
    var(--bg);
  min-height: 100dvh;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 140, 66, 0.07), transparent 28%, rgba(255, 182, 193, 0.1));
}

.app-shell {
  position: relative;
  width: min(460px, 100vw);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 14px 14px 96px;
}

h2,
h3,
h4,
p {
  margin: 0;
}

p {
  color: var(--sub);
  line-height: 1.45;
}

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

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

.cat-switch,
.theme-toggle,
.ai-entry,
.tab,
button {
  border: 0;
  background: none;
}

.cat-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

.top-actions {
  display: inline-flex;
  gap: 8px;
}

.theme-toggle,
.ai-entry {
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.theme-toggle {
  color: #6b5648;
  background: #fff2e7;
}

.ai-entry {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #58b6ff);
}

.content {
  display: grid;
}

.page {
  display: none;
  gap: 12px;
  animation: slideIn 280ms ease;
}

.page.active {
  display: grid;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.cat-card {
  display: flex;
  gap: 12px;
  align-items: center;
}

.cat-avatar {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  font-size: 26px;
  background: var(--primary-soft);
}

.cat-avatar.large {
  width: 64px;
  height: 64px;
  font-size: 30px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.section-head span {
  font-size: 12px;
  color: var(--sub);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tag {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 0;
}

.tag.ok {
  background: rgba(168, 230, 207, 0.5);
}

.tag.warn {
  background: rgba(255, 182, 193, 0.5);
}

.tag.alert {
  background: rgba(255, 107, 107, 0.2);
  color: #b63e3e;
}

.todo-list,
.food-list,
.danger-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.todo-list li,
.food-list li,
.danger-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff7f1;
  color: #5d4b40;
}

.danger {
  border: 1px solid rgba(255, 107, 107, 0.25);
  background: linear-gradient(160deg, #fff, #fff2f2);
}

.score-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.score-wrap ul {
  margin: 0;
  padding-left: 18px;
  color: #634f43;
}

.ring {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #193d5e;
  font-weight: 800;
  background: conic-gradient(var(--primary) 0 86%, #f0dfd3 86%);
}

.profile-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.action-row {
  display: grid;
  gap: 8px;
}

.ghost,
.primary,
.danger-btn,
.tile,
.mini {
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
}

.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #58b6ff);
}

.ghost,
.tile,
.mini {
  color: #6b5648;
  background: #fff2e7;
}

.danger-btn {
  color: #fff;
  background: #ff6b6b;
}

.kv {
  margin: 8px 0 0;
  display: grid;
  gap: 8px;
}

.kv div {
  display: flex;
  justify-content: space-between;
  background: #fff8f3;
  padding: 8px 10px;
  border-radius: 10px;
}

.kv dt {
  color: var(--sub);
}

.chips {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #f5eee9;
  color: #7a675d;
  cursor: pointer;
  border: 0;
}

.chip.active {
  background: var(--primary-soft);
  color: #32597a;
}

.timeline {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
  align-items: start;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 6px;
}

.dot.vaccine {
  background: #f2b56c;
}

.dot.deworming {
  background: #7ed0a6;
}

.dot.checkup {
  background: #5bb3ff;
}

.dot.illness,
.dot.behavior {
  background: #ff97a6;
}

.radar-placeholder {
  margin-top: 10px;
  border-radius: 12px;
  padding: 18px 14px;
  text-align: center;
  color: #6b5648;
  background: repeating-linear-gradient(45deg, #fff4ea 0 8px, #ffeada 8px 16px);
}

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

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

.tile {
  text-align: left;
  min-height: 64px;
}

.theme-modal,
.chat-modal,
.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(20, 14, 11, 0.28);
  padding: 16px;
  z-index: 1200;
}

.chat-modal {
  place-items: end center;
  padding: 12px;
}

.theme-modal.open,
.chat-modal.open,
.modal.open {
  display: grid;
}

.theme-dialog,
.modal-card {
  width: min(420px, 100%);
}

.theme-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.theme-head button {
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  padding: 8px 10px;
}

.palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--sw);
  outline: 2px solid transparent;
}

.swatch.active {
  outline-color: #222;
}

.chat-card {
  width: min(460px, 100%);
  max-height: 84vh;
  background: #fff;
  border-radius: 16px;
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.chat-card header,
.chat-card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chat-body {
  overflow: auto;
  display: grid;
  gap: 10px;
}

.bubble {
  padding: 10px 12px;
  border-radius: 12px;
  max-width: 92%;
}

.bubble.assistant {
  background: #fff2e7;
}

.bubble.user {
  background: #d9eeff;
  margin-left: auto;
}

.chat-card input,
.modal-card input,
.modal-card select,
.modal-card textarea {
  width: 100%;
  border: 1px solid #f0d8c5;
  border-radius: 10px;
  padding: 10px;
}

.chat-card footer button,
.chat-card header button,
.modal-card button {
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  padding: 8px 10px;
}

.modal-card {
  display: grid;
  gap: 10px;
}

.modal-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-card .grid {
  display: grid;
  gap: 8px;
}

.modal-card footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-card .light {
  color: #6b5648;
  background: #f6ebe2;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  bottom: 90px;
  background: #1f1a17;
  color: #fff;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 1500;
}

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

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(env(safe-area-inset-bottom), 0px);
  z-index: 1000;
  width: min(460px, 100vw);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: rgba(255, 248, 240, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid #f3dcc8;
  padding: 6px 8px 10px;
}

.tab {
  display: grid;
  place-items: center;
  gap: 2px;
  color: #9d8677;
  font-size: 15px;
}

.tab span {
  font-size: 11px;
}

.tab.active {
  color: var(--primary);
  font-weight: 800;
}

.tab:active,
button:active {
  transform: scale(0.96);
}

.reveal {
  animation: rise 260ms ease both;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(18px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 360px) {
  .dual-btn {
    grid-template-columns: 1fr;
  }

  .palette {
    grid-template-columns: repeat(3, 1fr);
  }
}
