:root {
  --accent: #e76f51;
  --primary: #f4a261;
  --secondary: #264653;
  --mat-a: #f4e7d3;
  --mat-b: #dce8d6;
  --ink: #264653;
  --muted: #8a9188;
  --card: #fffdf7;
  --shadow: 0 6px 18px rgba(38, 70, 83, 0.14);
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--mat-a), var(--mat-b));
  overflow-x: hidden;
}

.mat {
  position: relative;
  min-height: 100vh;
  padding: calc(16px + var(--sat)) 16px calc(96px + var(--sab));
  background-image:
    radial-gradient(circle at 15% 22%, rgba(38,70,83,0.05) 8px, transparent 9px),
    radial-gradient(circle at 82% 15%, rgba(38,70,83,0.05) 7px, transparent 8px),
    radial-gradient(circle at 68% 42%, rgba(38,70,83,0.045) 9px, transparent 10px),
    radial-gradient(circle at 25% 55%, rgba(38,70,83,0.045) 6px, transparent 7px),
    radial-gradient(circle at 90% 68%, rgba(38,70,83,0.05) 8px, transparent 9px),
    radial-gradient(circle at 40% 82%, rgba(38,70,83,0.045) 7px, transparent 8px);
  background-attachment: fixed;
}

/* ribbed edge */
.mat::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  border: 10px solid transparent;
  border-image: repeating-linear-gradient(45deg, rgba(38,70,83,0.10) 0 12px, transparent 12px 24px) 10;
}

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

.logo {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0;
  color: var(--secondary);
}

.active-filter {
  background: var(--secondary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
}

/* ---------- Bowls ---------- */
.bowls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 6px 0 18px;
}

.bowl {
  border-radius: 22px;
  padding: 10px;
  background: linear-gradient(145deg, #e8e9ea, #c8cbcf);
  box-shadow: var(--shadow), inset 0 2px 3px rgba(255,255,255,0.7);
}

.bowl-inner {
  position: relative;
  border-radius: 16px;
  height: 120px;
  background: linear-gradient(180deg, #dfe1e3, #b9bdc2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bowl-top {
  position: absolute;
  inset: auto 0 18px 0;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(180deg, #d2d5d9, #aeb3b9);
  box-shadow: inset 0 -4px 8px rgba(0,0,0,0.15);
}

.bowl-silhouette {
  position: relative;
  z-index: 2;
}

.bowl-silhouette.kibble {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #f5c07a 2px, transparent 3px),
    radial-gradient(circle at 60% 25%, #efb36b 2px, transparent 3px),
    radial-gradient(circle at 42% 45%, #f2bb72 2px, transparent 3px),
    radial-gradient(circle at 68% 48%, #f5c07a 2px, transparent 3px),
    radial-gradient(circle at 25% 55%, #efb36b 2px, transparent 3px),
    radial-gradient(circle at 55% 62%, #f2bb72 2px, transparent 3px),
    radial-gradient(circle at 40% 72%, #f5c07a 2px, transparent 3px),
    radial-gradient(circle at 62% 20%, #efb36b 2px, transparent 3px),
    radial-gradient(circle at 30% 36%, #f8d39a 2px, transparent 3px),
    radial-gradient(circle at 58% 75%, #f8d39a 2px, transparent 3px);
}

.bowl-silhouette.water {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 30% 35%, rgba(120,180,255,0.85) 3px, transparent 4px),
    radial-gradient(ellipse at 70% 40%, rgba(120,180,255,0.85) 3px, transparent 4px),
    radial-gradient(ellipse at 40% 60%, rgba(120,180,255,0.85) 3px, transparent 4px),
    radial-gradient(ellipse at 60% 55%, rgba(120,180,255,0.85) 3px, transparent 4px),
    radial-gradient(ellipse at 50% 78%, rgba(140,190,255,0.9) 3px, transparent 4px);
}

.bowl-number {
  position: absolute;
  z-index: 3;
  bottom: 26px;
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.25), 0 0 1px rgba(0,0,0,0.4);
}

/* ---------- Quick grid ---------- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.quick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 6px;
  border: none;
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.quick:active { transform: scale(0.95); }

.quick .qi { font-size: 22px; }

/* ---------- Sections ---------- */
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 4px 0 10px;
}

/* ---------- Paw stickers ---------- */
.paw-list { display: flex; flex-direction: column; gap: 10px; }

.paw {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border-radius: 18px;
  color: #fff;
  box-shadow: var(--shadow);
  animation: stamp 0.28s ease;
  min-height: 62px;
}

.paw.past {
  box-shadow: 0 2px 4px rgba(38,70,83,0.25), inset 0 2px 3px rgba(0,0,0,0.18);
  filter: saturate(0.82) brightness(0.97);
}

.paw .paw-icon {
  font-size: 24px;
  width: 34px;
  text-align: center;
  flex-shrink: 0;
}

.paw.today .paw-icon {
  position: relative;
}

.paw.today .paw-icon::after {
  content: "";
  position: absolute;
  top: 2px; left: 4px;
  width: 16px; height: 9px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%, rgba(255,255,255,0.75), transparent 70%);
  transform: rotate(-20deg);
}

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

.paw .paw-name { font-weight: 700; font-size: 15px; }

.paw .paw-time {
  font-size: 12px;
  opacity: 0.85;
}

.paw .paw-notes {
  font-size: 12px;
  opacity: 0.9;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paw .paw-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.paw .paw-btn {
  border: none;
  background: rgba(255,255,255,0.22);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* care type colours */
.paw[data-care="feeding"] { background: var(--primary); }
.paw[data-care="walk"] { background: #5a9bd5; }
.paw[data-care="medication"] { background: #6bbf76; }
.paw[data-care="grooming"] { background: #9b7fc4; }
.paw[data-care="other"] { background: #9b7fc4; }

@keyframes stamp {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Form ---------- */
.entry-form, .log-controls, .settings-card {
  background: var(--card);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.form-title { margin: 0 0 12px; font-size: 18px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field input, .field select, .field textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  border: 1.5px solid #d8d4c8;
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  width: 100%;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(244,162,97,0.25);
}

.field small { color: var(--muted); font-weight: 400; }

.form-actions { display: flex; gap: 10px; }

.btn {
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease;
  flex: 1;
}

.btn:active { transform: scale(0.97); }

.btn.primary { background: var(--secondary); color: #fff; }
.btn.primary:active { background: #1d3945; }

.btn.ghost { background: #eef0ec; color: var(--ink); }
.btn.danger { background: var(--accent); color: #fff; }
.btn.small { padding: 8px 12px; font-size: 13px; flex: none; }

/* ---------- Log controls ---------- */
.log-controls { display: flex; flex-direction: column; gap: 10px; }

.search, .range {
  font-family: inherit;
  font-size: 15px;
  border: 1.5px solid #d8d4c8;
  border-radius: 12px;
  padding: 11px 12px;
  width: 100%;
  background: #fff;
}

.date-range { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.date-range .range { flex: 1; }

/* ---------- Pets ---------- */
.pet-cards { display: flex; flex-direction: column; gap: 12px; }

.pet-card {
  background: var(--card);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.pet-card.filtered { border-color: var(--accent); }

.pet-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--secondary);
  color: #fff;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pet-info { flex: 1; }
.pet-name { font-weight: 700; font-size: 16px; }
.pet-meta { font-size: 13px; color: var(--muted); }

.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 30px;
  margin-top: 6px;
}

.sparkline .bar {
  width: 6px;
  border-radius: 3px;
  background: var(--primary);
  min-height: 2px;
}

.pet-filter-badge {
  font-size: 11px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  padding: 4px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* ---------- Settings ---------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #eeeae0;
}

.setting-name { display: block; font-weight: 600; font-size: 15px; }
.setting-desc { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.danger-row { border-bottom: none; }

.switch { position: relative; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: #d8d4c8;
  border-radius: 999px;
  transition: background 0.2s;
}
.switch .slider::before {
  content: "";
  position: absolute;
  height: 22px; width: 22px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .slider { background: var(--secondary); }
.switch input:checked + .slider::before { transform: translateX(22px); }

.about {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-top: 8px;
  color: var(--muted);
}
.about .app-name { font-weight: 800; font-size: 18px; color: var(--secondary); }
.about .version { font-size: 12px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 30px 20px;
  color: var(--muted);
}

.empty-paw {
  width: 96px;
  height: 96px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 2px dashed rgba(38,70,83,0.25);
  position: relative;
}
.empty-paw::before {
  content: "\1F43E";
  position: absolute;
  inset: 0;
  font-size: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
}

.empty-msg { font-size: 15px; line-height: 1.5; }

/* ---------- Tab bar (bones) ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + var(--sab));
  background: rgba(38,70,83,0.06);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(38,70,83,0.08);
}

.bone {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 0 2px;
  font-family: inherit;
}

.bone-spine {
  width: 44px;
  height: 16px;
  border-radius: 50%;
  background: #b9b9b6;
  position: relative;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.bone-spine::before, .bone-spine::after {
  content: "";
  position: absolute;
  top: 1px;
  width: 15px;
  height: 14px;
  border-radius: 50%;
  background: inherit;
}
.bone-spine::before { left: -8px; }
.bone-spine::after { right: -8px; }

.bone-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.bone.active .bone-spine {
  transform: translateY(-6px);
  background: var(--secondary);
  box-shadow: 0 4px 8px rgba(38,70,83,0.3);
}

.bone.active .bone-spine::before,
.bone.active .bone-spine::after {
  background: var(--secondary);
}

.bone.active .bone-spine::after {
  background: var(--accent);
}

.bone.active .bone-label { color: var(--secondary); font-weight: 700; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
}

.modal {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  width: 100%;
  max-width: 320px;
  box-shadow: var(--shadow);
  text-align: center;
}
.modal h3 { margin: 0 0 6px; }
.modal p { margin: 0 0 16px; font-size: 14px; color: var(--muted); }
.modal-actions { display: flex; gap: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--sab));
  transform: translateX(-50%) translateY(20px);
  background: var(--secondary);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }