/* Mantou Care - Warm Cream & Oatmeal Healing Theme */
:root {
  --bg-outer: #EFE8DD;
  --bg: #FAF6F0;
  --surface: #FFFFFF;
  --surface-soft: #F4ECE1;
  --surface-warm: #FDF8F2;
  --border: #EDE3D5;
  --border-strong: #DFD1BE;

  --text: #3B302A;
  --text-sub: #6B5D53;
  --text-muted: #9A8B7E;

  --primary: #D87D56;
  --primary-dark: #BF6640;
  --primary-soft: #FCEFE8;

  --pink: #E58C9A;
  --pink-soft: #FDF0F2;

  --sage: #689B80;
  --sage-soft: #EAF4EE;

  --amber: #D8973C;
  --amber-soft: #FEF5E6;

  --coral: #D65D56;
  --coral-soft: #FDECEB;

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-pill: 999px;

  --shadow-card: 0 4px 18px rgba(88, 65, 45, 0.05);
  --shadow-float: 0 10px 28px rgba(180, 105, 68, 0.28);
  --shadow-sheet: 0 -8px 36px rgba(59, 48, 42, 0.16);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-outer);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

/* Mobile-first App Shell centered cleanly on Desktop */
.app-shell {
  max-width: 460px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 0 40px rgba(72, 54, 38, 0.08);
}

/* Top Sticky Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  background: rgba(250, 246, 240, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.brand-mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #FFF;
  box-shadow: 0 2px 6px rgba(59, 48, 42, 0.12);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.role-switch-btn:active {
  transform: scale(0.96);
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-sub);
  cursor: pointer;
}

.sync-pill.synced {
  background: var(--sage-soft);
  color: var(--sage);
  border-color: rgba(104, 155, 128, 0.25);
}

/* Main Content Area */
.page-content {
  padding: 6px 16px 24px;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero Cat Card */
.hero-card {
  background: linear-gradient(145deg, #FFFDF9 0%, #F7EFE4 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.hero-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hero-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}

.hero-avatar {
  width: 74px;
  height: 74px;
  border-radius: 22px;
  object-fit: cover;
  border: 3px solid #FFFFFF;
  box-shadow: 0 4px 14px rgba(88, 65, 45, 0.14);
}

.gender-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--pink-soft);
  border: 2px solid #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--pink);
  font-weight: 700;
}

.hero-info {
  flex: 1;
  min-width: 0;
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-name {
  font-size: 21px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-soft);
  color: var(--text-sub);
}

.tag-chip.pink { background: var(--pink-soft); color: #C96A7A; }
.tag-chip.sage { background: var(--sage-soft); color: var(--sage); }
.tag-chip.amber { background: var(--amber-soft); color: #B87920; }
.tag-chip.coral { background: var(--coral-soft); color: var(--coral); }
.tag-chip.primary { background: var(--primary-soft); color: var(--primary-dark); }

.hero-breed {
  font-size: 12.5px;
  color: var(--text-sub);
  margin: 4px 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-stats-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-stat {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 9px;
  font-size: 12px;
  color: var(--text-sub);
}

.mini-stat strong {
  color: var(--text);
  font-weight: 700;
}

/* Observing Symptom Alert Banner */
.alert-banner {
  background: var(--amber-soft);
  border: 1px solid rgba(216, 151, 60, 0.38);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-banner.urgent {
  background: var(--coral-soft);
  border-color: rgba(214, 93, 86, 0.35);
}

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

.alert-title {
  font-weight: 700;
  font-size: 13.5px;
  color: #9A6114;
}

.alert-banner.urgent .alert-title {
  color: var(--coral);
}

/* Quick Metric Strip (Weight + Food Open Days) */
.metric-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 13px 14px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.metric-card:active {
  transform: scale(0.98);
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin: 4px 0 2px;
}

.metric-sub {
  font-size: 11.5px;
  color: var(--text-sub);
}

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 2px 10px;
}

.section-title {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-link {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
}

/* Medical Cycle Cards */
.cycle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cycle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 13px 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cycle-card.overdue {
  border-color: rgba(214, 93, 86, 0.45);
  background: linear-gradient(to right, #FFF9F9, #FFFFFF);
}

.cycle-card.due-soon {
  border-color: rgba(216, 151, 60, 0.45);
}

.cycle-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1;
}

.cycle-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.cycle-body {
  min-width: 0;
  flex: 1;
}

.cycle-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cycle-title {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text);
}

.cycle-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cycle-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.checkin-btn {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(216, 125, 86, 0.35);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.checkin-btn:active {
  transform: scale(0.95);
}

/* Grooming Capsules */
.groom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.groom-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}

.groom-pill.overdue {
  border-color: rgba(216, 151, 60, 0.5);
  background: #FFFDF8;
}

.groom-info {
  min-width: 0;
}

.groom-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 5px;
}

.groom-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.groom-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-warm);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

/* Sub-segmented Tabs (inside Health & Food pages) */
.seg-tabs {
  display: flex;
  background: var(--surface-soft);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 14px;
  gap: 4px;
}

.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 6px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(59, 48, 42, 0.08);
}

/* Generic Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
}

/* Timeline Items */
.timeline {
  position: relative;
  padding-left: 18px;
  margin-top: 8px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border-strong);
  border-radius: 2px;
}

.tl-item {
  position: relative;
  margin-bottom: 12px;
}

.tl-dot {
  position: absolute;
  left: -18px;
  top: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2.5px solid var(--bg);
}

.tl-dot.food { background: var(--sage); }
.tl-dot.vet { background: var(--coral); }
.tl-dot.observing { background: var(--amber); }

/* Photo Grid in Records */
.record-photos {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.record-thumb {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
}

/* Bottom Navigation Bar with Center Floating Plus */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 460px;
  background: rgba(255, 253, 250, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr 68px 1fr 1fr;
  align-items: center;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
}

.nav-item {
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.nav-item .nav-icon {
  font-size: 20px;
  line-height: 1.15;
  transition: transform 0.15s ease;
}

.nav-item.active {
  color: var(--primary-dark);
  font-weight: 700;
}

.nav-item.active .nav-icon {
  transform: translateY(-1px);
}

.plus-fab-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.plus-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid #FFFDF9;
  background: linear-gradient(135deg, var(--primary) 0%, #E5936B 100%);
  color: #FFFFFF;
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -20px;
  box-shadow: var(--shadow-float);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.plus-fab:active {
  transform: scale(0.92);
}

/* Modal / Bottom Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42, 32, 25, 0.42);
  backdrop-filter: blur(3px);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeBackdrop 0.16s ease;
}

@keyframes fadeBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bottom-sheet {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 16px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-sheet);
  animation: slideUp 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 4px;
  background: var(--border-strong);
  margin: 0 auto 12px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-title {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
}

.close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--surface-soft);
  color: var(--text-sub);
  font-size: 16px;
  cursor: pointer;
}

/* Quick Action Grid inside Plus Sheet */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.quick-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}

.quick-tile:active {
  transform: scale(0.96);
  background: var(--primary-soft);
}

.quick-tile-icon {
  font-size: 26px;
}

.quick-tile-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.quick-tile-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Forms */
.form-group {
  margin-bottom: 13px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 5px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* Prevents iOS Safari zoom on focus */
  font-family: inherit;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(216, 125, 86, 0.15);
}

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

.tag-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.selectable-tag {
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-sub);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.selectable-tag.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.btn-primary {
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 14px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(216, 125, 86, 0.25);
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-secondary {
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger-ghost {
  background: none;
  border: none;
  color: var(--coral);
  font-size: 12px;
  padding: 4px 6px;
  cursor: pointer;
}

/* Empty State */
.empty-box {
  text-align: center;
  padding: 26px 16px;
  background: var(--surface-warm);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  font-size: 13px;
}

/* Toast Notification */
.toast {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(59, 48, 42, 0.92);
  color: #FFF;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  z-index: 90;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

/* Fullscreen Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 14, 0.92);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox img {
  max-width: 100%;
  max-height: 88vh;
  border-radius: 14px;
  object-fit: contain;
}
