:root {
  --bg: #0b1a2b;
  --bg-elevated: #112339;
  --text: #eaf2fb;
  --text-dim: #8fa6bf;
  --accent: #3fb8f0;
  --accent-dim: #1a8fd1;
  --danger: #ff6b6b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: calc(var(--safe-top) + 14px) 20px 12px;
  text-align: center;
  flex-shrink: 0;
}

.app-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.tab-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 4px 20px 12px;
  overflow-y: auto;
}

.tab-panel.active {
  display: flex;
}

/* ---- Water tab ---- */

.water-top {
  flex-shrink: 0;
  text-align: center;
  margin-bottom: 6px;
}

.goal-label {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.percent-label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-dim);
}

.goal-source {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-dim);
}

.glass-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}

.glass-svg {
  height: 100%;
  max-height: 32vh;
  width: auto;
}

.glass-outline {
  fill: rgba(255,255,255,0.03);
  stroke: rgba(255,255,255,0.35);
  stroke-width: 3;
}

.glass-rim {
  stroke: rgba(255,255,255,0.5);
  stroke-width: 3;
  stroke-linecap: round;
}

#water-rect {
  transition: y 0.6s cubic-bezier(.34,1.2,.4,1), height 0.6s cubic-bezier(.34,1.2,.4,1);
}

#wave-group {
  transition: transform 0.6s cubic-bezier(.34,1.2,.4,1);
}

.wave-path {
  animation: waveDrift 3.2s linear infinite;
}

@keyframes waveDrift {
  from { transform: translateX(0); }
  to { transform: translateX(-50px); }
}

.glass-wrap.filling .glass-svg {
  animation: glassBounce 0.4s ease;
}

@keyframes glassBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.tap-cup-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px auto 0;
  padding: 16px 28px;
  border: none;
  border-radius: 22px;
  background: var(--bg-elevated);
  color: var(--text);
  transition: transform 0.12s ease, background 0.12s ease;
}

.tap-cup-btn:active {
  transform: scale(0.95);
  background: var(--accent-dim);
}

.cup-icon {
  font-size: 28px;
}

.cup-label {
  font-size: 15px;
  color: var(--text-dim);
  font-weight: 600;
}

.tap-cup-btn:active .cup-label {
  color: white;
}

.undo-btn {
  flex-shrink: 0;
  align-self: center;
  margin-top: 2px;
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.undo-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.undo-btn:active {
  color: var(--danger);
}

/* ---- Pee color section ---- */

.pee-section {
  flex-shrink: 0;
  margin-top: 10px;
  padding: 14px 16px 16px;
  border-radius: 18px;
  background: var(--bg-elevated);
}

.pee-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
}

.info-btn {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 15px;
  padding: 2px 4px;
}

.info-btn:active {
  color: var(--accent);
}

.pee-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.pee-swatch {
  flex: 1;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--swatch-color);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.pee-swatch:active {
  transform: scale(0.9);
}

.pee-swatch.selected {
  border-color: var(--text);
}

.pee-scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

/* ---- Info panel ---- */

.info-panel {
  flex-shrink: 0;
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--bg-elevated);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

.info-panel p {
  margin: 0 0 10px;
}

.info-panel p:last-child {
  margin-bottom: 0;
}

.info-panel.hidden {
  display: none;
}

/* ---- floating "+ml" pop ---- */

.pop {
  position: absolute;
  left: 50%;
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  pointer-events: none;
  transform: translate(-50%, 0);
  animation: popUp 0.9s ease forwards;
}

@keyframes popUp {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
  20% { opacity: 1; transform: translate(-50%, -6px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

/* ---- Tab bar ---- */

.tab-bar {
  flex-shrink: 0;
  display: flex;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: var(--bg-elevated);
  padding-bottom: var(--safe-bottom);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  border: none;
  background: none;
  color: var(--text-dim);
}

.tab-btn.active {
  color: var(--accent);
}

.tab-icon {
  font-size: 22px;
}

.tab-text {
  font-size: 11px;
  font-weight: 600;
}
