:root {
  --sand: #d2b48c;
  --sand-light: #e2cba4;
  --sand-dark: #b89a6e;
  --secondary: #8b5e3c;
  --accent: #00b4d8;
  --accent-dark: #0093b0;
  --ink: #0000cd;
  --grey: #9a9a9a;
  --text: #3a2d1f;
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--sand);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/><feColorMatrix type='saturate' values='0'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='0.5'/></svg>");
}

#app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Litter box top-down rim */
.litterbox {
  flex: 1;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,255,255,0.10) 0%, rgba(0,0,0,0.06) 70%);
  border-radius: 22px;
  margin: 8px;
  box-shadow: inset 0 0 0 10px #a98a5e, inset 0 0 24px rgba(0,0,0,0.35), 0 6px 18px rgba(0,0,0,0.3);
  overflow: hidden;
  position: relative;
}

/* Metal scoop sitting at right edge */
.edge-scoop {
  position: absolute;
  top: 14px;
  right: 8px;
  width: 30px;
  height: 34px;
  z-index: 5;
  pointer-events: none;
  filter: drop-shadow(1px 3px 4px rgba(0,0,0,0.3));
}

.scoop-bowl {
  width: 100%;
  height: 22px;
  background: linear-gradient(145deg, #e8e8e8, #b9b9b9, #dcdcdc);
  border-radius: 50% 50% 46% 46% / 70% 70% 30% 30%;
  border: 1px solid #8f8f8f;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.25);
  position: relative;
}

.scoop-bowl::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 3px;
  width: 12px;
  height: 7px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  transform: rotate(-15deg);
}

.scoop-handle {
  width: 30px;
  height: 10px;
  margin-top: -2px;
  border-radius: 3px;
  background: linear-gradient(180deg, #0ec4e6, #00b4d8);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.5);
}

/* Dashboard content */
main {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.screen-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: var(--secondary);
  margin: 4px 0 10px;
  text-transform: uppercase;
}

/* Hourglass */
.hourglass-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0 4px;
}

.hourglass {
  width: 110px;
  height: 150px;
  position: relative;
  filter: drop-shadow(0 5px 8px rgba(0,0,0,0.35));
}

.hg-top, .hg-bottom {
  width: 0;
  height: 0;
  margin: 0 auto;
}

.hg-top {
  border-left: 55px solid transparent;
  border-right: 55px solid transparent;
  border-bottom: 34px solid rgba(255,255,255,0.35);
}

.hg-bottom {
  border-left: 55px solid transparent;
  border-right: 55px solid transparent;
  border-top: 34px solid rgba(255,255,255,0.35);
}

.hg-neck {
  width: 14px;
  height: 12px;
  margin: -4px auto;
  background: rgba(255,255,255,0.35);
}

.hg-sand-top {
  position: absolute;
  left: 0;
  right: 0;
  top: 20px;
  height: 0;
  border-left: 48px solid transparent;
  border-right: 48px solid transparent;
  border-bottom: 40px solid var(--sand-dark);
  margin: 0 auto;
  width: 55px;
}

.hg-sand-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 20px;
  width: 90px;
  height: 26px;
  margin: 0 auto;
  background: var(--sand-dark);
  border-radius: 0 0 10px 10px;
  clip-path: polygon(0 0, 12% 100%, 20% 0, 32% 100%, 45% 0, 55% 100%, 68% 0, 80% 100%, 100% 0);
}

.hg-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 800;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 0 3px rgba(0,0,0,0.6), 0 1px 2px rgba(0,0,0,0.4);
  -webkit-text-stroke: 0.4px rgba(0,0,0,0.5);
}

.hg-label {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--secondary);
  margin-top: -2px;
}

/* Sand mound */
.mound-wrap {
  margin-top: 14px;
  text-align: center;
}

.mound {
  display: inline-block;
  position: relative;
  width: 130px;
  height: 60px;
}

.mound-hill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 46px;
  background: radial-gradient(circle at 50% 100%, var(--sand-dark), #c7a66f);
  border-radius: 50% 50% 30% 30% / 80% 80% 20% 20%;
  box-shadow: inset 0 -6px 10px rgba(0,0,0,0.15);
}

.mound-count {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 40px;
  font-weight: 900;
  color: rgba(139,94,60,0.85);
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

.mound-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--secondary);
  margin-top: 2px;
}

/* Log a Clean scoop button */
.scoop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 18px auto 4px;
  max-width: 230px;
  height: 46px;
  border: none;
  border-radius: 0 0 14px 14px;
  background: linear-gradient(180deg, #dcdcdc, #b9b9b9);
  box-shadow: 0 5px 0 #9a9a9a, inset 0 2px 2px rgba(255,255,255,0.6);
  cursor: pointer;
  position: relative;
}

.scoop-btn::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 0;
  right: 0;
  height: 14px;
  background: linear-gradient(180deg, #0ec4e6, #00b4d8);
  border-radius: 8px 8px 0 0;
}

.scoop-btn span {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

/* Log cards */
.log-card {
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.25), transparent 40%),
    linear-gradient(160deg, #e0c79b, #cbb084);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.2);
  position: relative;
  overflow: hidden;
}

.log-card::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80'><filter id='n2'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix type='saturate' values='0'/></filter><rect width='80' height='80' filter='url(%23n2)'/></svg>");
  pointer-events: none;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-cat {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
}

.date-stamp {
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(0,0,205,0.08);
  border: 1px solid rgba(0,0,205,0.5);
  padding: 2px 5px;
  transform: rotate(2deg);
  border-radius: 2px;
  box-shadow: inset 0 0 3px rgba(0,0,205,0.3);
}

.card-meta {
  font-size: 13px;
  color: var(--text);
  margin: 6px 0 2px;
  opacity: 0.85;
}

.card-paws {
  font-size: 15px;
  letter-spacing: 2px;
  margin: 4px 0 2px;
}

.paw {
  display: inline-block;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.35));
}

.paw.off {
  opacity: 0.22;
  filter: grayscale(1);
}

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

.card-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-edit {
  background: linear-gradient(180deg, #0ec4e6, #00b4d8);
  color: #fff;
}

.btn-del {
  background: linear-gradient(180deg, #c8b08c, #a98a5e);
  color: var(--text);
  border: 1px solid rgba(0,0,0,0.15) !important;
}

.empty-state {
  text-align: center;
  color: var(--secondary);
  padding: 30px 10px;
  font-size: 14px;
}

/* Form */
.form-wrap {
  padding: 4px 2px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 5px;
}

.field input[type="text"],
.field input[type="datetime-local"],
.field select {
  width: 100%;
  height: 44px;
  border: 2px solid #b89a6e;
  border-radius: 10px;
  padding: 0 10px;
  font-size: 15px;
  background: #f2e3c4;
  color: var(--text);
  outline: none;
}

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

.field input.invalid {
  border-color: #d9534f;
}

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

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #b89a6e, #8b5e3c);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(180deg, #0ec4e6, #00b4d8);
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  cursor: pointer;
}

.score-display {
  font-size: 18px;
  font-weight: 800;
  color: var(--secondary);
  min-width: 70px;
  text-align: center;
}

.form-submit {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #0ec4e6, #0093b0);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 4px 0 #007a94;
  cursor: pointer;
  margin-top: 6px;
}

.error-msg {
  color: #d9534f;
  font-size: 13px;
  margin: 4px 0 0;
  display: none;
}

.error-msg.show {
  display: block;
}

/* Search */
.search-box {
  width: 100%;
  height: 40px;
  border: 2px solid #b89a6e;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  background: #f2e3c4;
  margin-bottom: 12px;
  outline: none;
}

.search-box:focus {
  border-color: var(--accent);
}

/* Settings */
.version-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f2e3c4;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
  border: 2px solid #b89a6e;
}

.version-row strong {
  font-size: 15px;
}

.reset-btn {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #e0c79b, #cbb084);
  color: #a33;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 4px 0 #b89a6e;
  cursor: pointer;
}

.settings-paws {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  background-image: radial-gradient(circle at 20% 20%, #8b5e3c 3px, transparent 3px);
  background-size: 34px 34px;
}

/* Bottom tab bar */
.tabbar {
  display: flex;
  background: #a98a5e;
  padding: 4px 6px 4px;
  gap: 6px;
  box-shadow: 0 -3px 8px rgba(0,0,0,0.25);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 0;
  color: var(--text);
}

.tab .tab-label {
  font-size: 10px;
  font-weight: 700;
  margin-top: 1px;
}

.scoop-icon {
  width: 34px;
  height: 26px;
  position: relative;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.scoop-icon .s-body {
  width: 34px;
  height: 16px;
  border-radius: 50% 50% 46% 46% / 72% 72% 28% 28%;
  position: relative;
}

.scoop-icon .s-handle {
  width: 34px;
  height: 8px;
  border-radius: 3px;
  margin-top: -1px;
}

.scoop-icon .s-body::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 4px;
  width: 12px;
  height: 6px;
  background: rgba(255,255,255,0.45);
  border-radius: 50%;
  transform: rotate(-15deg);
}

/* Inactive - matte grey, flat */
.tab:not(.active) .s-body {
  background: linear-gradient(180deg, #b9b9b9, #9a9a9a);
  border: 1px solid #858585;
}
.tab:not(.active) .s-handle {
  background: linear-gradient(180deg, #b0b0b0, #909090);
}

/* Active - teal handle, metallic, lifted */
.tab.active .scoop-icon {
  transform: translateY(-6px);
  filter: drop-shadow(0 5px 5px rgba(0,0,0,0.35));
}
.tab.active .s-body {
  background: linear-gradient(160deg, #f2f2f2, #cfcfcf, #eaeaea);
  border: 1px solid #9a9a9a;
}
.tab.active .s-handle {
  background: linear-gradient(180deg, #26c8e6, #00b4d8);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.6);
}
.tab.active .tab-label {
  color: #00586b;
}