*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --amber: #f59e0b; --amber-light: #fbbf24; --amber-dark: #d97706;
  --green: #22c55e; --red: #ef4444;
  --bg: #0a0a0a; --surface: rgba(18, 18, 18, 0.88);
  --text: #f5f5f5; --text-dim: #a3a3a3;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}

#app { position: relative; width: 100%; height: 100%; overflow: hidden; }

/* Camera */
#camera { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--bg); }
#capture { display: none; }

/* Top Bar */
#top-bar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
  z-index: 10;
}

#logo { display: flex; align-items: center; gap: 8px; color: var(--amber); font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
#paw-icon { filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }
#status { display: flex; align-items: center; gap: 8px; }
#status-text { font-size: 13px; color: var(--text-dim); font-weight: 500; }
#status-text.active { color: var(--green); }

/* Audio Bars */
#audio-bars { display: flex; align-items: flex-end; gap: 2px; height: 16px; }
#audio-bars .bar { display: block; width: 3px; height: 4px; background: var(--text-dim); border-radius: 2px; transition: height 0.1s ease, background 0.2s; }
#audio-bars.active .bar { background: var(--green); }
#audio-bars.bark .bar { background: var(--amber); }
#audio-bars.howl .bar { background: #8b5cf6; }
#audio-bars.whine .bar { background: #06b6d4; }
#audio-bars.growl .bar { background: var(--red); }
#audio-bars.yelp .bar { background: #f97316; }

/* Vocal badge */
.vocal-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  padding: 2px 7px; border-radius: 6px; text-transform: uppercase;
  animation: badge-pop 0.2s ease;
}
.vocal-badge.bark { background: rgba(245,158,11,0.25); color: var(--amber-light); }
.vocal-badge.howl { background: rgba(139,92,246,0.25); color: #a78bfa; }
.vocal-badge.whine { background: rgba(6,182,212,0.25); color: #22d3ee; }
.vocal-badge.growl { background: rgba(239,68,68,0.25); color: #f87171; }
.vocal-badge.yelp { background: rgba(249,115,22,0.25); color: #fb923c; }
.vocal-badge.vocalization { background: rgba(255,255,255,0.12); color: var(--text-dim); }
@keyframes badge-pop { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* Mini spectrogram */
#spectrogram { position: absolute; top: calc(52px + var(--safe-top)); right: 16px; border-radius: 4px; opacity: 0.6; background: rgba(0,0,0,0.3); z-index: 10; }

/* Translation Area */
#translation-area {
  position: absolute; bottom: 100px; left: 12px; right: 12px;
  z-index: 10; display: flex; flex-direction: column; align-items: center;
}

#translation-bubble {
  width: 100%; max-width: 400px;
  background: var(--surface); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(245, 158, 11, 0.15); border-radius: var(--radius);
  padding: 14px 18px;
  opacity: 1; transform: translateY(0);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
#translation-bubble.hidden { opacity: 0; transform: translateY(20px); pointer-events: none; }
#translation-bubble.updating { border-color: rgba(245, 158, 11, 0.5); box-shadow: 0 0 20px rgba(245, 158, 11, 0.1); }

#bubble-header { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }

#emotion-badge, #secondary-emotion {
  display: inline-block; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 3px 10px; border-radius: 20px;
}

#translation-text { font-size: 18px; line-height: 1.4; font-weight: 500; color: var(--text); }

/* Tail info row */
#tail-info {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; font-size: 12px; color: var(--green); opacity: 0.85;
}
#tail-icon { font-size: 14px; }
#tail-info .wag-anim {
  display: inline-block;
  animation: wag 0.4s ease-in-out infinite alternate;
  transform-origin: left center;
}
@keyframes wag { 0% { transform: rotate(-15deg); } 100% { transform: rotate(15deg); } }

/* Audio info row */
#audio-info {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px; font-size: 12px; color: var(--amber); opacity: 0.8;
}
#audio-icon { font-size: 14px; }

/* Confidence */
#confidence { margin-top: 10px; height: 3px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden; }
#confidence-fill { height: 100%; width: 0%; border-radius: 2px; transition: width 0.6s ease; }

/* Evidence toggle */
.evidence-toggle {
  display: block; width: 100%; margin-top: 8px; padding: 4px;
  font-size: 11px; color: var(--text-dim); background: none; border: none;
  cursor: pointer; text-align: center; opacity: 0.6;
  transition: opacity 0.2s;
}
.evidence-toggle:active { opacity: 1; }

/* Evidence panel */
#evidence-panel {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

#evidence-list {
  list-style: none; padding: 0; margin: 0 0 10px 0;
}
#evidence-list li {
  font-size: 11px; color: var(--text-dim); padding: 2px 0;
  line-height: 1.4;
}
#evidence-list li::before {
  content: '\25B8'; margin-right: 6px; color: var(--amber); font-size: 10px;
}

/* Emotion score bars */
.emo-bar-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.emo-bar-label { font-size: 10px; font-weight: 600; text-transform: uppercase; width: 70px; text-align: right; }
.emo-bar-track { flex: 1; height: 4px; background: rgba(255,255,255,0.06); border-radius: 2px; overflow: hidden; }
.emo-bar-fill { height: 100%; border-radius: 2px; transition: width 0.4s ease; }
.emo-bar-val { font-size: 10px; color: var(--text-dim); width: 16px; text-align: right; }

/* No dog / analyzing */
#no-dog-msg, #analyzing-msg {
  text-align: center; padding: 12px 24px;
  background: var(--surface); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: 24px; transition: all 0.3s ease;
}
#no-dog-msg.hidden, #analyzing-msg.hidden { opacity: 0; transform: scale(0.9); pointer-events: none; }
#no-dog-msg p, #analyzing-msg p { font-size: 14px; color: var(--text-dim); }

.dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 6px; }
.dots span { width: 8px; height: 8px; background: var(--amber); border-radius: 50%; animation: dot-pulse 1.2s ease-in-out infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

/* Controls */
#controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 24px;
  padding: 16px 24px calc(16px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  z-index: 10;
}

.ctrl-btn {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border: none; border-radius: 50%;
  background: rgba(255,255,255,0.12); color: var(--text);
  cursor: pointer; transition: all 0.2s;
}
.ctrl-btn:active { transform: scale(0.9); }
.ctrl-btn.primary { width: 64px; height: 64px; background: var(--amber); color: #000; box-shadow: 0 4px 16px rgba(245,158,11,0.3); }
.ctrl-btn.primary:active { background: var(--amber-dark); }
.ctrl-btn.primary.recording { background: var(--red); box-shadow: 0 4px 16px rgba(239,68,68,0.3); animation: pulse-ring 2s ease infinite; }

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  70% { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

.hidden { display: none !important; }

/* Overlays */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 10, 10, 0.95); z-index: 100; padding: 32px;
}
.overlay.hidden { display: none !important; }
.overlay-content { text-align: center; max-width: 360px; }
.big-paw { color: var(--amber); margin-bottom: 16px; filter: drop-shadow(0 4px 12px rgba(245,158,11,0.3)); }
.overlay-content h1 { font-size: 40px; font-weight: 800; letter-spacing: -1px; color: var(--amber); margin-bottom: 8px; }
.overlay-content h2 { font-size: 24px; font-weight: 700; margin-bottom: 12px; }
.tagline { font-size: 16px; color: var(--text-dim); margin-bottom: 16px; }
.desc { font-size: 14px; line-height: 1.5; color: var(--text-dim); margin-bottom: 32px; }
.action-btn {
  display: inline-block; padding: 14px 40px; font-size: 16px; font-weight: 600;
  color: #000; background: var(--amber); border: none; border-radius: 32px;
  cursor: pointer; transition: all 0.2s;
}
.action-btn:active { transform: scale(0.95); background: var(--amber-dark); }
.note { font-size: 12px; color: var(--text-dim); margin-top: 16px; opacity: 0.6; }

/* Bark flash */
#app.bark-flash::after {
  content: ''; position: absolute; inset: 0;
  border: 3px solid var(--amber); pointer-events: none; z-index: 50;
  animation: bark-border 0.5s ease-out forwards;
}
@keyframes bark-border { 0% { opacity: 1; } 100% { opacity: 0; } }
