/* ============================================
   PawAfterglow - Warm Orange Companion Theme
   Mobile-first PWA styles
   WCAG 2.1 AA compliant (contrast ratios verified)
   ============================================ */

/* === CSS Custom Properties === */
:root {
  --primary: #FF9B50;
  --primary-dark: #E8833A;
  --primary-light: #FFB87A;
  --bg: #FFF8F0;
  --bg-warm: #FFFCF7;
  --bg-card: #FFFFFF;
  --text: #5D4037;
  --text-light: #8D6E63;
  --text-muted: #A1887F;
  --green: #4CAF50;
  --gold: #FFC107;
  --red: #E57373;
  --white: #FFFFFF;
  --shadow: rgba(93, 64, 55, 0.08);
  --shadow-md: rgba(93, 64, 55, 0.12);
  --shadow-lg: rgba(93, 64, 55, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  z-index: 10000;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  top: 16px;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 700;
  line-height: 1.3;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
p { margin-bottom: 1rem; }
a {
  color: var(--primary-dark);
  text-decoration: none;
  transition: var(--transition);
}
a:hover { color: var(--primary); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  min-height: 48px; /* WCAG touch target */
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px rgba(255,155,80,0.35);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 20px rgba(255,155,80,0.45); }
.btn-secondary {
  background: white;
  color: var(--primary-dark);
  border: 2px solid var(--primary);
}
.btn-secondary:hover { background: #FFF3E8; }
.btn-ghost {
  background: transparent;
  color: var(--text-light);
}
.btn-ghost:hover { color: var(--primary); background: rgba(255,155,80,0.08); }
.btn-lg { padding: 18px 36px; font-size: 1.1rem; }
.btn-sm { padding: 10px 20px; font-size: 0.9rem; min-height: 40px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Cards === */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 2px 12px var(--shadow);
  margin-bottom: 16px;
}
.card-warm {
  background: linear-gradient(135deg, #FFF3E8, #FFFCF7);
  border: 1px solid rgba(255,155,80,0.15);
}

/* === Landing Page (index.html) === */
.landing {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #FFFCF7 0%, #FFF3E8 50%, #FFE8D6 100%);
  padding-top: var(--safe-top);
}
.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
}
.landing-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.landing-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}
.landing-hero-svg {
  width: 220px;
  height: 220px;
  margin-bottom: 24px;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.landing-hero h1 {
  font-size: 2.5rem;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.landing-tagline {
  font-size: 1.1rem;
  color: var(--text-light);
  font-style: italic;
  margin-bottom: 32px;
}
.landing-cta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}
.landing-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 24px 40px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}
.feature-chip {
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  border: 1px solid rgba(255,155,80,0.1);
}
.feature-chip .icon {
  font-size: 1.5rem;
  display: block;
  margin-bottom: 4px;
}

/* === Dual Track Entry === */
.entry-tracks {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 360px;
  margin-bottom: 24px;
}
.track-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 20px var(--shadow);
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  text-align: left;
  width: 100%;
}
.track-card:hover, .track-card:focus {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--shadow-md);
}
.track-card.companion {
  border-color: var(--primary);
  background: linear-gradient(135deg, #FFF8F0, #FFF3E8);
}
.track-card h3 { margin-bottom: 6px; }
.track-card p { font-size: 0.9rem; color: var(--text-light); margin: 0; }
.track-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.track-badge.coming-soon {
  background: var(--text-muted);
}

/* === Adopt Page (adopt.html) === */
.adopt-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 24px 20px calc(80px + var(--safe-bottom));
  max-width: 500px;
  margin: 0 auto;
}
.adopt-header { text-align: center; margin-bottom: 32px; }
.adopt-header h1 { margin-bottom: 8px; }
.adopt-header p { color: var(--text-light); }
.plan-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px var(--shadow);
  border: 2px solid transparent;
  position: relative;
  transition: var(--transition);
}
.plan-card.featured {
  border-color: var(--primary);
  background: linear-gradient(135deg, #FFFCF7, #FFF3E8);
}
.plan-card.popular::before {
  content: 'Most Loved 🧡';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 16px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.plan-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.plan-price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 4px;
}
.plan-price span { font-size: 0.9rem; font-weight: 400; color: var(--text-light); }
.plan-desc { color: var(--text-light); font-size: 0.9rem; margin-bottom: 16px; }
.plan-features { list-style: none; margin-bottom: 20px; }
.plan-features li {
  padding: 6px 0;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.plan-features li::before { content: '✓'; color: var(--green); font-weight: 700; flex-shrink: 0; }
.plan-collapsed { display: none; }
.plan-card.collapsed .plan-collapsed { display: none; }
.plan-card.expanded .plan-collapsed { display: block; }
.toggle-plans {
  text-align: center;
  margin: 16px 0;
}
.free-updates {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 8px;
}
.activate-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid rgba(255,155,80,0.2);
}
.activate-section h3 { margin-bottom: 12px; text-align: center; }
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #E0D5CC;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  background: white;
  color: var(--text);
  transition: var(--transition);
  min-height: 48px;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,155,80,0.15);
}
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1.4;
}
.checkbox-label input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
}
.legal-links {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 16px;
  line-height: 1.5;
}
.legal-links a { color: var(--text-light); text-decoration: underline; }

/* === Companion Page (PWA Main) === */
.companion-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-top: var(--safe-top);
  padding-bottom: calc(72px + var(--safe-bottom));
}

/* Top Bar */
.companion-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(255,252,247,0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,155,80,0.08);
}
.pet-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pet-name-display {
  font-weight: 700;
  font-size: 1.15rem;
}
.days-ring {
  width: 36px;
  height: 36px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.days-ring svg { position: absolute; top: 0; left: 0; }
.days-count {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--primary-dark);
}
.quiet-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.quiet-btn:hover { background: rgba(255,155,80,0.1); }

/* Stats Bar */
.stats-bar {
  display: flex;
  justify-content: space-around;
  padding: 12px 20px;
  gap: 8px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-bar-bg {
  width: 100%;
  max-width: 80px;
  height: 6px;
  background: rgba(255,155,80,0.15);
  border-radius: 3px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.stat-bar-fill.hunger { background: var(--gold); }
.stat-bar-fill.energy { background: var(--green); }
.stat-bar-fill.happiness { background: var(--primary); }
.stat-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
}

/* Pet Display Area */
.pet-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}
.pet-container {
  width: 280px;
  height: 280px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pet-svg {
  width: 100%;
  height: 100%;
  transition: transform 0.3s ease;
}
/* Pet Animations */
.pet-svg.breathing { animation: breathe 3s ease-in-out infinite; }
.pet-svg.wagging { animation: wag 0.5s ease-in-out infinite; }
.pet-svg.playing { animation: bounce 0.6s ease-in-out infinite; }
.pet-svg.eating { animation: eat 0.8s ease-in-out infinite; }
.pet-svg.sleeping { animation: sleep 4s ease-in-out infinite; }
.pet-svg.happy { animation: happy-jump 1s ease-in-out; }
.pet-svg.being-petted { animation: pet-wiggle 1.5s ease-in-out; }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}
@keyframes wag {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-3deg); }
  75% { transform: rotate(3deg); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}
@keyframes eat {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(5px) rotate(-2deg); }
  75% { transform: translateY(5px) rotate(2deg); }
}
@keyframes sleep {
  0%, 100% { transform: scale(1) translateY(0); opacity: 0.9; }
  50% { transform: scale(0.98) translateY(4px); opacity: 0.85; }
}
@keyframes happy-jump {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-30px) scale(1.05); }
  50% { transform: translateY(-25px) scale(1.05); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes pet-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2deg) translateX(-4px); }
  75% { transform: rotate(2deg) translateX(4px); }
}
/* Blinking */
.pet-eyes .eye { transition: opacity 0.15s; }
.blink .pet-eyes .eye { opacity: 0; }

/* Emotion bubble */
.emotion-bubble {
  position: absolute;
  top: -10px;
  right: 10px;
  background: white;
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-size: 0.85rem;
  box-shadow: 0 4px 12px var(--shadow);
  display: flex;
  align-items: center;
  gap: 6px;
  animation: pop-in 0.4s ease;
}
@keyframes pop-in {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* Floating particles for interactions */
.particle {
  position: absolute;
  font-size: 1.5rem;
  pointer-events: none;
  animation: float-up 1.5s ease-out forwards;
}
@keyframes float-up {
  0% { transform: translateY(0) scale(0.5); opacity: 1; }
  100% { transform: translateY(-80px) scale(1.2); opacity: 0; }
}

/* Zzz indicator for sleeping */
.zzz-indicator {
  position: absolute;
  top: 10px;
  right: 30px;
  font-size: 1.2rem;
  opacity: 0;
  animation: zzz 2s ease-in-out infinite;
}
@keyframes zzz {
  0% { opacity: 0; transform: translateY(10px); }
  50% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-20px); }
}
.sleeping .zzz-indicator { display: block; }

/* Interaction Buttons */
.interaction-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px 20px;
}
.action-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 1.5rem;
  background: white;
  box-shadow: 0 4px 12px var(--shadow);
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.action-btn:active { transform: scale(0.9); }
.action-btn:hover { box-shadow: 0 6px 20px var(--shadow-md); }
.action-btn.feed { background: linear-gradient(135deg, #FFF3E0, #FFE0B2); }
.action-btn.play { background: linear-gradient(135deg, #E8F5E9, #C8E6C9); }
.action-btn.pet { background: linear-gradient(135deg, #FFF8F0, #FFE8D6); }
.action-btn.sleep { background: linear-gradient(135deg, #E8EAF6, #C5CAE9); }
.action-btn-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Bottom Tab Bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  display: flex;
  border-top: 1px solid rgba(255,155,80,0.1);
  z-index: 200;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
}
.tab-item.active { color: var(--primary); }
.tab-icon { font-size: 1.4rem; margin-bottom: 2px; }

/* Tab Content */
.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}
.tab-content.active { display: block; }
.tab-content.home-tab { padding: 0; }

/* Chat Tab */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px - var(--safe-bottom));
  max-height: 70vh;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-msg {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 6px;
}
.chat-msg.pet {
  align-self: flex-start;
  background: white;
  color: var(--text);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px var(--shadow);
}
.chat-msg.system {
  align-self: center;
  background: rgba(255,155,80,0.1);
  color: var(--text-light);
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: var(--radius-full);
}
.ai-disclaimer {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
}
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid rgba(255,155,80,0.1);
}
.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #E0D5CC;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-family: var(--font);
  background: white;
  min-height: 44px;
}
.chat-input:focus {
  outline: none;
  border-color: var(--primary);
}
.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-send:active { transform: scale(0.9); }
.chat-upgrade {
  text-align: center;
  padding: 40px 20px;
}
.chat-upgrade h3 { margin-bottom: 8px; }
.chat-upgrade p { color: var(--text-light); font-size: 0.95rem; margin-bottom: 20px; }
.chat-token-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  padding: 4px 4px 0;
}
.chat-locked {
  opacity: 0.5;
  pointer-events: none;
}

/* Memory Gallery Tab */
.memory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.memory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.memory-card {
  background: white;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  cursor: pointer;
  transition: var(--transition);
}
.memory-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px var(--shadow-md); }
.memory-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #FFF3E8, #FFE8D6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.memory-info { padding: 10px; }
.memory-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 2px; }
.memory-date { font-size: 0.7rem; color: var(--text-muted); }
.memory-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.memory-tag {
  font-size: 0.65rem;
  background: rgba(255,155,80,0.1);
  color: var(--primary-dark);
  padding: 2px 6px;
  border-radius: 4px;
}
.add-memory-btn {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,155,80,0.4);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.add-memory-btn:active { transform: scale(0.9); }

/* Profile Tab */
.profile-section { margin-bottom: 24px; }
.profile-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 0 4px;
}
.profile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: white;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.profile-item-label { font-weight: 500; font-size: 0.95rem; }
.profile-item-value { color: var(--text-light); font-size: 0.9rem; }
.profile-item-arrow { color: var(--text-muted); font-size: 1.2rem; }
.profile-badge {
  background: var(--green);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}
.profile-badge.inactive { background: var(--text-muted); }

/* === Birth Ceremony Overlay === */
.ceremony-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, #FFFCF7, #FFF3E8);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.ceremony-step { display: none; text-align: center; width: 100%; max-width: 400px; }
.ceremony-step.active { display: flex; flex-direction: column; align-items: center; }
.ceremony-progress {
  width: 200px;
  height: 4px;
  background: rgba(255,155,80,0.2);
  border-radius: 2px;
  margin-bottom: 32px;
  overflow: hidden;
}
.ceremony-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
}
.ceremony-emoji { font-size: 4rem; margin-bottom: 20px; animation: float 2s ease-in-out infinite; }
.ceremony-title { font-size: 1.5rem; margin-bottom: 8px; }
.ceremony-text { color: var(--text-light); margin-bottom: 24px; }
.ceremony-name-input {
  width: 100%;
  max-width: 280px;
  padding: 16px 20px;
  font-size: 1.3rem;
  text-align: center;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font-family: var(--font);
  background: white;
  margin-bottom: 16px;
}
.ceremony-name-input:focus { outline: none; box-shadow: 0 0 0 4px rgba(255,155,80,0.15); }
.personality-grid, .breed-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  margin-bottom: 20px;
}
.choice-chip {
  padding: 14px 10px;
  border: 2px solid #E0D5CC;
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  text-align: center;
}
.choice-chip:hover { border-color: var(--primary-light); }
.choice-chip.selected {
  border-color: var(--primary);
  background: #FFF3E8;
  color: var(--primary-dark);
}
.choice-chip .emoji { font-size: 1.5rem; display: block; margin-bottom: 4px; }
.pet-reveal {
  width: 200px;
  height: 200px;
  margin-bottom: 24px;
}
.pet-reveal svg { width: 100%; height: 100%; }
.pet-reveal.revealing { animation: reveal-pet 3s ease forwards; }
@keyframes reveal-pet {
  0% { opacity: 0; filter: blur(20px); transform: scale(0.8); }
  60% { opacity: 0.7; filter: blur(8px); transform: scale(0.95); }
  100% { opacity: 1; filter: blur(0); transform: scale(1); }
}
.pet-reveal.jump { animation: happy-jump 1s ease; }
.welcome-message {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-top: 16px;
  animation: pop-in 0.6s ease 3s both;
}

/* Age Gate */
.age-gate {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}
.age-gate h2 { margin-bottom: 16px; }
.age-gate p { color: var(--text-light); margin-bottom: 24px; max-width: 320px; }

/* Install prompt */
.install-banner {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 32px var(--shadow-lg);
  z-index: 300;
  display: none;
  align-items: center;
  gap: 12px;
}
.install-banner.show { display: flex; }
.install-banner-text { flex: 1; font-size: 0.9rem; }
.install-banner-text strong { display: block; margin-bottom: 2px; }

/* Offline indicator */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--gold);
  color: var(--text);
  text-align: center;
  padding: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 500;
  display: none;
}
.offline-banner.show { display: block; }

/* Toast notifications */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 10000;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(93,64,55,0.5);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal h3 { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* Loading spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,155,80,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Responsive === */
@media (min-width: 768px) {
  .companion-page, .adopt-page { max-width: 500px; margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,0.05); }
  .tab-bar { max-width: 500px; left: 50%; transform: translateX(-50%); border-radius: 20px 20px 0 0; }
  .landing-hero h1 { font-size: 3rem; }
}

/* Dark mode support (subtle) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2D1F14;
    --bg-warm: #3A2A1C;
    --bg-card: #3A2A1C;
    --text: #F5E6D3;
    --text-light: #C4A882;
    --text-muted: #8B7355;
    --shadow: rgba(0,0,0,0.3);
    --shadow-md: rgba(0,0,0,0.4);
    --shadow-lg: rgba(0,0,0,0.5);
  }
  .landing { background: linear-gradient(180deg, #2D1F14, #3A2A1C, #4A3525); }
  .card, .plan-card, .chat-msg.pet, .action-btn, .modal, .profile-item, .install-banner, .memory-card {
    background: #3A2A1C;
  }
  .track-card { background: #3A2A1C; }
  .form-input, .chat-input { background: #2D1F14; color: #F5E6D3; border-color: #5D4037; }
  .companion-topbar, .tab-bar { background: rgba(58,42,28,0.95); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* =====================================================
   PawAfterglow - Talking Pet / Translation Bubble Styles
   Warm orange palette: #FF9B50 / #FFF8F0 / #5D4037
   ===================================================== */

/* ---------- Chat tab as full pet stage ---------- */
.talking-pet-stage {
  display: flex !important;
  flex-direction: column;
  height: calc(100vh - 140px - var(--safe-bottom, 0px));
  max-height: none;
  position: relative;
  background: linear-gradient(180deg, #FFF8F0 0%, #FFEEDD 100%);
  border-radius: 20px;
  overflow: hidden;
}

/* Hide old chat header h2/p slightly for immersive feel on chat tab */
#tab-chat > h2 { display: none; }
#tab-chat > p { display: none; }

/* Bubbles area: floats above the pet, scrollable */
.talk-bubbles-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 200px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  position: relative;
  z-index: 2;
  pointer-events: none; /* let clicks pass through to pet/input */
}
.talk-bubbles-area > * { pointer-events: auto; }

/* ---------- Pet slot (centered, behind bubbles) ---------- */
.chat-pet-slot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
  z-index: 1;
}

.chat-pet-stage {
  width: 260px;
  height: 260px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-pet-loader {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-pet-svg {
  width: 100%;
  height: 100%;
  transition: transform 0.3s ease;
  transform-origin: center bottom;
  will-change: transform;
}

.chat-pet-name {
  margin-top: 6px;
  background: white;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #5D4037;
  box-shadow: 0 2px 8px rgba(93,64,55,0.12);
}

/* Chat-tab pet breathing (gentler, more alert than home idle) */
.chat-pet-svg.chat-breathing {
  animation: chat-breathe 3s ease-in-out infinite;
}
@keyframes chat-breathe {
  0%, 100% { transform: scale(1) translateY(0); }
  50%      { transform: scale(1.015) translateY(-2px); }
}

/* Listening: ears-perk / head-tilt */
.chat-pet-svg.chat-listen {
  animation: chat-listen-anim 0.9s ease-out;
}
@keyframes chat-listen-anim {
  0%   { transform: rotate(0deg) scale(1); }
  30%  { transform: rotate(-8deg) scale(1.03) translateX(-4px); }
  60%  { transform: rotate(6deg) scale(1.03) translateX(4px); }
  100% { transform: rotate(0deg) scale(1); }
}

/* Talking: small bounce + wobble while typing */
.chat-pet-svg.chat-bounce-talk {
  animation: chat-talk-bounce 0.5s ease-in-out infinite;
}
@keyframes chat-talk-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-6px) scale(1.02); }
}

/* Head tilt (curious / first greeting) */
.chat-pet-svg.chat-headtilt {
  animation: chat-headtilt-anim 1.4s ease-in-out;
}
@keyframes chat-headtilt-anim {
  0%   { transform: rotate(0); }
  20%  { transform: rotate(-12deg) translateX(-6px); }
  50%  { transform: rotate(-12deg) translateX(-6px); }
  80%  { transform: rotate(4deg) translateX(2px); }
  100% { transform: rotate(0); }
}

/* Happy jump (first awakening) */
.chat-pet-svg.chat-happy-jump {
  animation: chat-happy-anim 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes chat-happy-anim {
  0%   { transform: translateY(0) scale(1); }
  35%  { transform: translateY(-40px) scale(1.08); }
  55%  { transform: translateY(-30px) scale(1.08); }
  80%  { transform: translateY(4px) scale(0.98); }
  100% { transform: translateY(0) scale(1); }
}

/* ---------- Translation cloud bubbles (comic speech bubble) ---------- */
.talk-cloud {
  position: relative;
  max-width: 78%;
  padding: 14px 18px;
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
  opacity: 0;
  transform: scale(0.3) translateY(10px);
  transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform, opacity;
  filter: drop-shadow(0 4px 10px rgba(255, 155, 80, 0.18));
}

.talk-cloud.popped {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.talk-cloud.fading {
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.25s, transform 0.25s;
}

/* Pet translation bubble (cloud shape, warm cream with orange stroke) */
.talk-cloud.pet-bubble {
  align-self: flex-start;
  margin-left: 8px;
  background: #FFFDF8;
  color: #5D4037;
  border: 2.5px solid #FFB077;
  border-radius: 28px;
  /* Cloud shape: extra lobe circles using box-shadow trick */
  box-shadow:
    -8px -2px 0 -2px #FFFDF8,
    -8px -2px 0 0 #FFB077,
     8px -4px 0 -2px #FFFDF8,
     8px -4px 0 0 #FFB077,
     0 4px 14px rgba(255, 155, 80, 0.18);
  margin-top: 6px;
  margin-bottom: 10px;
}

/* Speech tail (pointing down to pet) — CSS triangle + circle for cloud-tail */
.talk-cloud.pet-bubble::after {
  content: '';
  position: absolute;
  left: 28px;
  bottom: -14px;
  width: 22px;
  height: 22px;
  background: #FFFDF8;
  border: 2.5px solid #FFB077;
  border-radius: 50%;
  box-shadow: -4px 4px 0 -2px #FFFDF8, -4px 4px 0 0 #FFB077;
  clip-path: polygon(0 0, 100% 0, 100% 50%, 60% 100%, 0 60%);
}
.talk-cloud.pet-bubble::before {
  content: '';
  position: absolute;
  left: 22px;
  bottom: -26px;
  width: 14px;
  height: 14px;
  background: #FFFDF8;
  border: 2.5px solid #FFB077;
  border-radius: 50%;
  z-index: -1;
}

/* First bubble — emphasize with warm orange gradient fill */
.talk-cloud.pet-bubble.first-bubble {
  background: linear-gradient(135deg, #FFE0C2 0%, #FFFDF8 60%);
  animation: first-bubble-glow 2s ease-in-out 0.6s 2;
}
@keyframes first-bubble-glow {
  0%, 100% { box-shadow: -8px -2px 0 -2px #FFE0C2, -8px -2px 0 0 #FFB077, 8px -4px 0 -2px #FFE0C2, 8px -4px 0 0 #FFB077, 0 4px 14px rgba(255, 155, 80, 0.18); }
  50%      { box-shadow: -8px -2px 0 -2px #FFE0C2, -8px -2px 0 0 #FFB077, 8px -4px 0 -2px #FFE0C2, 8px -4px 0 0 #FFB077, 0 4px 24px rgba(255, 155, 80, 0.45); }
}

/* Thinking bubble (small "..." cloud) */
.talk-cloud.thinking-cloud {
  align-self: flex-start;
  margin-left: 20px;
  background: white;
  border: 2px solid #E8D5C2;
  border-radius: 20px;
  padding: 10px 14px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.think-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #C4A892;
  animation: think-dot-bounce 1s ease-in-out infinite;
}
@keyframes think-dot-bounce {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50%      { transform: translateY(-4px); opacity: 1; }
}
.talk-cloud.thinking-cloud::after {
  content: '';
  position: absolute;
  left: 12px;
  bottom: -10px;
  width: 12px;
  height: 12px;
  background: white;
  border: 2px solid #E8D5C2;
  border-radius: 50%;
}
.talk-cloud.thinking-cloud::before {
  content: '';
  position: absolute;
  left: 4px;
  bottom: -20px;
  width: 8px;
  height: 8px;
  background: white;
  border: 2px solid #E8D5C2;
  border-radius: 50%;
}

/* User bubble (smaller, right side, warm orange) */
.talk-cloud.user-bubble {
  align-self: flex-end;
  margin-right: 8px;
  background: #FF9B50;
  color: white;
  border: none;
  border-radius: 22px 22px 6px 22px;
  padding: 10px 16px;
  font-size: 0.9rem;
  box-shadow: 0 3px 10px rgba(255, 155, 80, 0.3);
  max-width: 70%;
}

/* System / notification bubble (small, centered) */
.talk-cloud.system-bubble {
  align-self: center;
  background: rgba(255, 248, 240, 0.9);
  color: #8D6E63;
  border: 1px dashed #FFB077;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.8rem;
  max-width: 90%;
  text-align: center;
  box-shadow: none;
  filter: none;
}
.talk-cloud.system-bubble::after,
.talk-cloud.system-bubble::before {
  display: none;
}

/* Bubble disclaimer text */
.bubble-disclaimer {
  font-size: 0.65rem;
  color: #A1887F;
  margin-top: 4px;
  text-align: right;
  font-style: italic;
}

/* ---------- Awakening hint text ---------- */
.awakening-hint {
  align-self: center;
  text-align: center;
  font-size: 0.9rem;
  color: #8D6E63;
  font-style: italic;
  padding: 10px 18px;
  background: rgba(255,255,255,0.7);
  border-radius: 999px;
  margin: 10px 0;
  animation: hint-float 2s ease-in-out infinite;
  transition: opacity 0.5s;
}
@keyframes hint-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

/* Sparkles during awakening */
.talk-sparkle {
  position: absolute;
  font-size: 1.4rem;
  pointer-events: none;
  animation: sparkle-burst 1.4s ease-out forwards;
  z-index: 3;
}
@keyframes sparkle-burst {
  0%   { opacity: 0; transform: scale(0.3) translateY(0) rotate(0deg); }
  30%  { opacity: 1; transform: scale(1.2) translateY(-20px) rotate(90deg); }
  100% { opacity: 0; transform: scale(0.5) translateY(-60px) rotate(180deg); }
}

/* ---------- Upgrade CTA inside talking stage ---------- */
.talking-upgrade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,248,240,0.95) 0%, rgba(255,238,221,0.97) 100%);
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  z-index: 10;
  backdrop-filter: blur(4px);
}

/* ---------- Input bar restyling in chat tab ---------- */
#tab-chat .chat-input-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 14px calc(10px + var(--safe-bottom, 0px));
  background: linear-gradient(180deg, rgba(255,248,240,0) 0%, #FFF8F0 30%);
  border-top: none;
  display: flex;
  gap: 8px;
  z-index: 5;
}

#tab-chat .chat-input {
  background: white;
  border: 2px solid #FFD8B5;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 0.95rem;
  box-shadow: 0 2px 12px rgba(93,64,55,0.08);
}
#tab-chat .chat-input:focus {
  border-color: #FF9B50;
  box-shadow: 0 2px 16px rgba(255,155,80,0.28);
}

#tab-chat .chat-send {
  background: linear-gradient(135deg, #FF9B50 0%, #FF7E2E 100%);
  box-shadow: 0 4px 12px rgba(255,126,46,0.35);
  width: 46px;
  height: 46px;
}

#tab-chat .chat-token-info {
  position: absolute;
  top: 8px;
  right: 14px;
  background: rgba(255,255,255,0.8);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  z-index: 4;
}

#tab-chat #chat-ai-disclaimer {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  color: #A1887F;
  white-space: nowrap;
  z-index: 4;
  background: rgba(255,255,255,0.6);
  padding: 3px 10px;
  border-radius: 999px;
}

/* ---------- Responsive adjustments ---------- */
@media (max-height: 640px) {
  .chat-pet-stage { width: 200px; height: 200px; }
  .talking-pet-stage { height: calc(100vh - 120px - var(--safe-bottom, 0px)); }
  .talk-bubbles-area { padding: 12px 12px 170px; }
}

@media (min-width: 768px) {
  .talk-cloud.pet-bubble { max-width: 60%; }
  .talk-cloud.user-bubble { max-width: 50%; }
  .chat-pet-stage { width: 300px; height: 300px; }
}

/* ---------- Dark mode adjustments ---------- */
@media (prefers-color-scheme: dark) {
  .talking-pet-stage {
    background: linear-gradient(180deg, #3E2A1C 0%, #2D1F14 100%);
  }
  .talk-cloud.pet-bubble {
    background: #4A3526;
    color: #F5E6D3;
    border-color: #FF9B50;
    box-shadow:
      -8px -2px 0 -2px #4A3526, -8px -2px 0 0 #FF9B50,
       8px -4px 0 -2px #4A3526,  8px -4px 0 0 #FF9B50,
       0 4px 14px rgba(0,0,0,0.4);
  }
  .talk-cloud.pet-bubble::after { background: #4A3526; border-color: #FF9B50; box-shadow: -4px 4px 0 -2px #4A3526, -4px 4px 0 0 #FF9B50; }
  .talk-cloud.pet-bubble::before { background: #4A3526; border-color: #FF9B50; }
  .chat-pet-name { background: #4A3526; color: #F5E6D3; }
  #tab-chat .chat-input-bar { background: linear-gradient(180deg, rgba(62,42,28,0) 0%, #3E2A1C 30%); }
  #tab-chat .chat-input { background: #4A3526; color: #F5E6D3; border-color: #6D4C34; }
  .talk-cloud.user-bubble { background: #FF9B50; }
  .talk-cloud.system-bubble { background: rgba(74,53,38,0.8); color: #D7BEA8; border-color: #6D4C34; }
  .awakening-hint { background: rgba(74,53,38,0.8); color: #D7BEA8; }
  .talk-cloud.thinking-cloud { background: #4A3526; border-color: #6D4C34; }
  .talk-cloud.thinking-cloud::after, .talk-cloud.thinking-cloud::before { background: #4A3526; border-color: #6D4C34; }
  .think-dot { background: #C4A892; }
}
