:root {
  --bg: #fff8f0;
  --card-bg: #ffffff;
  --text: #3a2e26;
  --text-muted: #9c8d80;
  --border: #f3e6d8;
  --accent: #e0784f;
  --accent-rgb: 224, 120, 79;
  --eat: #ff9f5a;
  --eat-rgb: 255, 159, 90;
  --walk: #45b787;
  --walk-rgb: 69, 183, 135;
  --poop: #ad8558;
  --poop-rgb: 173, 133, 88;
  --pee: #4bb4d9;
  --pee-rgb: 75, 180, 217;
  --medicine: #a97fd6;
  --medicine-rgb: 169, 127, 214;
  --radius: 20px;
  --shadow-soft: 0 4px 14px rgba(224, 120, 79, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1712;
    --card-bg: #2a2019;
    --text: #f6ede4;
    --text-muted: #b3a294;
    --border: #3d2f25;
    --accent: #f0a479;
    --accent-rgb: 240, 164, 121;
    --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Quicksand", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  font-family: "Baloo 2", "Quicksand", sans-serif;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 20px) 16px 100px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px 20px;
}

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

.brand-badge {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--eat), var(--accent));
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.35);
}

.brand-badge::before,
.brand-badge::after {
  content: "";
  position: absolute;
  top: -30%;
  width: 42%;
  height: 55%;
  background: linear-gradient(160deg, var(--eat), var(--accent));
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  z-index: -1;
}

.brand-badge::before {
  left: -6%;
  transform: rotate(-18deg);
}

.brand-badge::after {
  right: -6%;
  transform: rotate(18deg);
}

.brand-centered .brand-badge {
  width: 56px;
  height: 56px;
  min-width: 56px;
  font-size: 24px;
}

.topbar h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dog-name {
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
  background: rgba(var(--accent-rgb), 0.12);
  padding: 5px 12px;
  border-radius: 999px;
}

.logout-btn {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.log-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 28px;
}

.log-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 4px;
  border: none;
  border-radius: var(--radius);
  font-family: "Baloo 2", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.log-btn:active { transform: scale(0.92) rotate(-1deg); }

.log-btn .icon { font-size: 26px; }

.log-btn.eat  { background: var(--eat);  box-shadow: 0 6px 14px rgba(var(--eat-rgb), 0.35); }
.log-btn.walk { background: var(--walk); box-shadow: 0 6px 14px rgba(var(--walk-rgb), 0.35); }
.log-btn.poop { background: var(--poop); box-shadow: 0 6px 14px rgba(var(--poop-rgb), 0.35); }
.log-btn.pee  { background: var(--pee);  box-shadow: 0 6px 14px rgba(var(--pee-rgb), 0.35); }
.log-btn.medicine { background: var(--medicine); box-shadow: 0 6px 14px rgba(var(--medicine-rgb), 0.35); }

.history-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.history-header h2 {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
}

.filter-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.filter-tab {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.filter-tab:active { transform: scale(0.95); }

.filter-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 3px 10px rgba(var(--accent-rgb), 0.35);
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
}

.entry .dot {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.entry.eat .dot  { background: rgba(var(--eat-rgb), 0.18); }
.entry.walk .dot { background: rgba(var(--walk-rgb), 0.18); }
.entry.poop .dot { background: rgba(var(--poop-rgb), 0.18); }
.entry.pee .dot  { background: rgba(var(--pee-rgb), 0.18); }
.entry.medicine .dot { background: rgba(var(--medicine-rgb), 0.18); }

.entry .content { flex: 1; min-width: 0; }

.entry .top-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.entry .type-label {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  text-transform: capitalize;
}

.entry .time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.entry .detail {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.entry .notes {
  font-size: 13px;
  margin-top: 4px;
}

.entry .delete-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
}

.empty-state {
  display: none;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 40px 20px;
}

.empty-state::before {
  content: "🐾";
  display: block;
  font-size: 36px;
  margin-bottom: 10px;
}

.settings-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(var(--accent-rgb), 0.4);
  transition: transform 0.12s ease;
}

.settings-btn:active { transform: scale(0.9); }

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

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

.modal {
  background: var(--card-bg);
  width: 100%;
  max-width: 480px;
  border-radius: 26px 26px 0 0;
  padding: 14px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
}

.modal::before {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 0 auto 6px;
}

.modal h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

.field-row {
  display: flex;
  gap: 10px;
}

.field-row .field {
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.field input, .field textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 11px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  resize: none;
  transition: border-color 0.15s ease;
}

.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.btn {
  flex: 1;
  padding: 13px;
  border-radius: 16px;
  border: none;
  font-family: "Baloo 2", sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease;
}

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

.btn.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 6px 16px rgba(var(--accent-rgb), 0.35);
}

.btn.secondary {
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
}
