@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #08080A;
  --surface: #141416;
  --surface2: #1C1C1F;
  --border: rgba(255,255,255,0.06);
  --text: #F5F5F7;
  --text2: #71717A;
  --cal: #FF6B35;
  --cal-dim: rgba(255,107,53,0.15);
  --prot: #34D399;
  --prot-dim: rgba(52,211,153,0.15);
  --water: #60A5FA;
  --water-dim: rgba(96,165,250,0.15);
  --train: #FBBF24;
  --train-dim: rgba(251,191,36,0.15);
  --xp: #A78BFA;
  --xp-dim: rgba(167,139,250,0.15);
  --success: #10B981;
  --danger: #F87171;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); overflow: hidden; }
body { display: flex; flex-direction: column; }
#app { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ONBOARDING */
.onboarding { position: fixed; inset: 0; background: var(--bg); z-index: 10000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 40px 32px; opacity: 1; transition: opacity 0.6s ease, transform 0.6s ease; }
.onboarding.hidden { opacity: 0; pointer-events: none; transform: scale(0.95); }
.onboarding-emoji { font-size: 80px; animation: onboardBounce 1.5s ease infinite; }
@keyframes onboardBounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.onboarding h1 { font-size: 28px; font-weight: 800; text-align: center; background: linear-gradient(135deg, var(--cal), var(--train)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.onboarding p { font-size: 15px; color: var(--text2); text-align: center; line-height: 1.5; max-width: 280px; }
.onboarding-btn { background: linear-gradient(135deg, var(--cal), #FF8F5E); color: #fff; border: none; padding: 16px 48px; border-radius: 16px; font-size: 16px; font-weight: 700; cursor: pointer; letter-spacing: 0.3px; transition: transform 0.2s, box-shadow 0.2s; }
.onboarding-btn:active { transform: scale(0.96); }

/* LOADING */
.loading-screen { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 9999; }
.loading-screen.hidden { display: none; }
.loading-spinner { width: 36px; height: 36px; border: 3px solid rgba(255,255,255,0.06); border-top-color: var(--cal); border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: var(--text2); }

/* PARTICLES CANVAS (behind everything) */
#particlesBg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* R6: SINGLE SCROLL CONTAINER (replaces tab system) */
.scroll-container { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; position: relative; z-index: 1; }

/* R6: PET HEADER (compact, always at top) */
.pet-header { display: flex; align-items: center; gap: 10px; padding: 6px 16px 2px; }
.ph-emoji { font-size: 28px; }
.ph-info { flex: 1; min-width: 0; }
.ph-name { font-size: 15px; font-weight: 800; }
.ph-status { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ph-streak { font-size: 13px; font-weight: 700; color: var(--train); }
.ph-xp { display: flex; align-items: center; gap: 4px; }
.ph-xp-bar { width: 40px; height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; }
.ph-xp-fill { height: 100%; background: linear-gradient(90deg, var(--xp), #C4B5FD); border-radius: 2px; width: 0%; transition: width 0.5s ease; }
.ph-xp-text { font-size: 9px; color: var(--text2); font-weight: 600; }

/* R6: MACRO CARD */
.macro-card { margin: 0 16px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 16px; }
.macro-row { display: flex; justify-content: space-around; }
.macro-item { text-align: center; }
.macro-item.cal .macro-pct { color: var(--cal); }
.macro-item.prot .macro-pct { color: var(--prot); }
.macro-item.water .macro-pct { color: var(--water); }
.macro-pct { font-size: 22px; font-weight: 800; }
.macro-lbl { font-size: 9px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 1px; }
.macro-sub { display: flex; justify-content: space-between; padding-top: 8px; margin-top: 8px; border-top: 1px solid rgba(255,255,255,0.03); }
.macro-sub span { flex: 1; text-align: center; font-size: 10px; color: var(--text2); font-weight: 500; }

/* R6: DASHBOARD DIVIDER (collapsible toggle) */
.dash-divider { display: flex; align-items: center; gap: 8px; padding: 16px 16px 8px; cursor: pointer; user-select: none; -webkit-user-select: none; }
.dash-divider-line { flex: 1; height: 1px; background: var(--border); }
.dash-divider-text { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.dash-divider-arrow { font-size: 12px; color: var(--text2); transition: transform 0.2s; }
.dash-divider-arrow.open { transform: rotate(90deg); }
.dash-section { padding: 0 16px 16px; }

/* PET TAB (legacy compat) */
.pet-tab { padding: 8px 16px 110px 16px; }

/* Triple Rings */
.rings-container { display: flex; justify-content: center; margin-bottom: 6px; position: relative; transition: filter 0.3s ease; }
.rings-wrap { position: relative; width: 280px; height: 280px; }
.rings-svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke-width: 8; }
.ring-progress { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.8s cubic-bezier(0.4,0,0.2,1); }
#cv { position: absolute; top: 30px; left: 30px; width: 220px; height: 220px; background: transparent; border-radius: 50%; }

/* R2: Ring completion glow */
.ring-complete { filter: drop-shadow(0 0 6px currentColor); }
.ring-complete[data-ring-type="cal"] { filter: drop-shadow(0 0 8px rgba(255,107,53,0.6)); }
.ring-complete[data-ring-type="prot"] { filter: drop-shadow(0 0 8px rgba(52,211,153,0.6)); }
.ring-complete[data-ring-type="water"] { filter: drop-shadow(0 0 8px rgba(96,165,250,0.6)); }
.ring-pulse { animation: ringPulse 1.5s ease-out; }
@keyframes ringPulse {
  0% { stroke-width: 8; filter: drop-shadow(0 0 4px currentColor); }
  30% { stroke-width: 12; filter: drop-shadow(0 0 20px currentColor); }
  60% { stroke-width: 9; filter: drop-shadow(0 0 12px currentColor); }
  100% { stroke-width: 8; }
}

/* Ring labels */
.ring-labels { display: flex; justify-content: center; gap: 20px; margin-bottom: 8px; }
.ring-label { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; }
.ring-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Pet info */
.pet-name-section { text-align: center; margin-bottom: 8px; }
.pet-name { font-size: 22px; font-weight: 800; }
.pet-mood-text { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* Stats chips */
.stats-row { display: flex; gap: 8px; margin-bottom: 12px; }
.stat-chip { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 8px; text-align: center; position: relative; overflow: hidden; }
.stat-chip::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.stat-chip.cal::before { background: var(--cal); }
.stat-chip.prot::before { background: var(--prot); }
.stat-chip.streak::before { background: var(--train); }
.stat-label { display: block; font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-bottom: 4px; }
.stat-value { display: block; font-size: 18px; font-weight: 800; }
.stat-value.cal-color { color: var(--cal); }
.stat-value.prot-color { color: var(--prot); }
.stat-value.streak-color { color: var(--train); }

/* Level badge */
.level-badge { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 20px; }
.level-pill { display: flex; align-items: center; gap: 6px; background: var(--xp-dim); border: 1px solid rgba(167,139,250,0.2); border-radius: 20px; padding: 6px 14px; }
.level-icon { font-size: 16px; }
.level-text { font-size: 12px; font-weight: 700; color: var(--xp); }
.xp-bar-wrap { flex: 1; max-width: 120px; height: 6px; background: var(--xp-dim); border-radius: 3px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--xp), #C4B5FD); border-radius: 3px; transition: width 0.6s ease; }

/* Feeding */
.feeding-section { margin-top: 4px; margin-bottom: 16px; }
.section-label { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px; padding: 0 2px; }
.feeding-queue { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 8px 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.feeding-queue::-webkit-scrollbar { display: none; }
.food-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: grab; transition: all 0.15s ease; position: relative; overflow: hidden; flex-shrink: 0; min-width: 90px; touch-action: none; user-select: none; -webkit-user-select: none; }
.food-card.dragging { opacity: 0.5; transform: scale(0.9); }
.food-card::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, var(--cal-dim), transparent); opacity: 0; transition: opacity 0.15s; }
.food-card:active::before { opacity: 1; }
.food-card-left { display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; z-index: 1; }
.food-emoji { font-size: 32px; }
.food-name { font-size: 11px; font-weight: 600; color: var(--text); text-align: center; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.food-calories { font-size: 10px; color: var(--text2); text-align: center; }
.food-action { font-size: 9px; color: var(--cal); font-weight: 700; background: var(--cal-dim); padding: 3px 8px; border-radius: 6px; position: relative; z-index: 1; letter-spacing: 0.5px; }
.empty-state { text-align: center; color: var(--text2); font-size: 13px; padding: 16px; }
.empty-state-emoji { font-size: 32px; margin-bottom: 8px; display: block; }

/* Food notification bubble on pet */
.food-bubble { position: absolute; top: 8px; right: 8px; background: var(--cal); color: #fff; border-radius: 20px; padding: 4px 10px; font-size: 11px; font-weight: 700; display: none; align-items: center; gap: 4px; animation: bubblePulse 2s ease infinite; z-index: 5; box-shadow: 0 2px 12px rgba(255,107,53,0.4); }
.food-bubble.visible { display: flex; }
@keyframes bubblePulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* Drag ghost */
.drag-ghost { position: fixed; pointer-events: none; z-index: 9999; font-size: 48px; transform: translate(-50%, -50%); filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3)); transition: none; }

/* R4: Pet bounce when dragging food near (reused by #ringsContainer.drop-active) */
@keyframes petBounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ACHIEVEMENTS BAR */
.achievements-bar { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-bottom: 16px; }
.achievements-bar::-webkit-scrollbar { display: none; }
.badge { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; border: 2px solid transparent; position: relative; transition: transform 0.2s; }
.badge:active { transform: scale(0.9); }
.badge.earned { background: var(--surface); border-color: var(--train); box-shadow: 0 0 12px rgba(251,191,36,0.2); }
.badge.locked { background: var(--surface); border-color: var(--border); opacity: 0.35; filter: grayscale(1); }
.badge-new { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; background: var(--danger); border-radius: 50%; border: 2px solid var(--bg); }

/* LOG TAB */
.log-tab { padding: 16px 16px 110px 16px; }
.log-header { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.log-subtitle { font-size: 13px; color: var(--text2); margin-bottom: 20px; }
.log-modes { display: flex; gap: 8px; margin-bottom: 20px; }
.log-mode-btn { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; color: var(--text2); font-size: 12px; font-weight: 600; transition: all 0.2s; font-family: inherit; }
.log-mode-btn.active { border-color: var(--cal); color: var(--cal); background: var(--cal-dim); }
.log-mode-icon { font-size: 24px; }
.log-input-area { margin-bottom: 20px; }
.log-input-wrap { display: flex; gap: 8px; margin-bottom: 12px; }
.log-input { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; font-size: 15px; color: var(--text); font-family: inherit; outline: none; }
.log-input:focus { border-color: var(--cal); }
.log-send-btn { background: linear-gradient(135deg, var(--cal), #FF8F5E); color: #fff; border: none; border-radius: 14px; width: 52px; font-size: 20px; font-weight: 700; cursor: pointer; transition: transform 0.15s; font-family: inherit; }
.log-send-btn:active { transform: scale(0.93); }
.log-quick-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-tag { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 8px 14px; font-size: 12px; font-weight: 600; color: var(--text); cursor: pointer; transition: all 0.15s; font-family: inherit; white-space: nowrap; }
.quick-tag:active { transform: scale(0.95); background: var(--cal-dim); border-color: var(--cal); }
.voice-record-area { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 20px 0; }
.voice-btn { width: 120px; height: 120px; border-radius: 50%; background: var(--surface); border: 3px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; transition: all 0.2s; font-family: inherit; color: var(--text); }
.voice-btn:active, .voice-btn.recording { background: var(--cal-dim); border-color: var(--cal); transform: scale(1.05); }
.voice-btn.recording { animation: voicePulse 1s ease infinite; }
@keyframes voicePulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,53,0.3); } 50% { box-shadow: 0 0 0 20px rgba(255,107,53,0); } }
.voice-btn-icon { font-size: 36px; }
.voice-btn-text { font-size: 11px; font-weight: 600; color: var(--text2); }
.voice-transcript { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; font-size: 14px; color: var(--text); width: 100%; }
.photo-capture-area { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.photo-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--surface); border: 2px dashed var(--border); border-radius: 20px; padding: 32px; cursor: pointer; width: 100%; transition: all 0.2s; }
.photo-btn:active { border-color: var(--cal); background: var(--cal-dim); }
.photo-btn-icon { font-size: 48px; }
.photo-btn-text { font-size: 14px; font-weight: 600; color: var(--text2); }
.photo-preview { width: 100%; }
.photo-preview img { width: 100%; border-radius: 16px; margin-bottom: 12px; max-height: 200px; object-fit: cover; }
.photo-desc-wrap { display: flex; gap: 8px; }
.log-recent { margin-top: 16px; }

/* DASHBOARD TAB */
.dashboard-tab { padding: 16px 16px 110px 16px; }
.dash-header { font-size: 22px; font-weight: 800; margin-bottom: 16px; }

/* Metric cards - Apple Health style */
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.metric-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; position: relative; overflow: hidden; }
.metric-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.metric-card.cal-card::before { background: var(--cal); }
.metric-card.prot-card::before { background: var(--prot); }
.metric-card.water-card::before { background: var(--water); }
.metric-card.train-card::before { background: var(--train); }
.metric-icon-label { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.metric-emoji { font-size: 14px; }
.metric-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.metric-card.cal-card .metric-label { color: var(--cal); }
.metric-card.prot-card .metric-label { color: var(--prot); }
.metric-card.water-card .metric-label { color: var(--water); }
.metric-card.train-card .metric-label { color: var(--train); }
.metric-big { font-size: 28px; font-weight: 800; margin-bottom: 2px; }
.metric-sub { font-size: 12px; color: var(--text2); margin-bottom: 10px; }
.metric-bar { height: 5px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden; }
.metric-bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.metric-bar-fill.cal-fill { background: var(--cal); }
.metric-bar-fill.prot-fill { background: var(--prot); }
.metric-bar-fill.water-fill { background: var(--water); }
.metric-status { font-size: 11px; margin-top: 8px; font-weight: 600; }

/* Meals section */
.meals-section { margin-bottom: 20px; }
.meals-list { display: flex; flex-direction: column; gap: 8px; }
.meal-item { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; }
.meal-left { display: flex; align-items: center; gap: 10px; flex: 1; }
.meal-emoji { font-size: 24px; }
.meal-info { flex: 1; }
.meal-name { font-size: 13px; font-weight: 600; }
.meal-time { font-size: 11px; color: var(--text2); }
.meal-kcal { font-size: 14px; font-weight: 700; color: var(--cal); }

/* Weekly chart */
.chart-section { margin-bottom: 20px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.chart-title { font-size: 13px; font-weight: 700; color: var(--text2); margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
.chart-wrapper { display: flex; align-items: flex-end; gap: 6px; height: 120px; position: relative; margin-bottom: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart-bar { width: 100%; border-radius: 5px 5px 2px 2px; min-height: 3px; transition: height 0.4s ease; }
.chart-day { font-size: 10px; color: var(--text2); font-weight: 500; }
.chart-day.today { color: var(--cal); font-weight: 700; }
.chart-target { position: absolute; left: 0; right: 0; border-top: 1.5px dashed rgba(251,191,36,0.4); pointer-events: none; }
.chart-target-label { position: absolute; right: 4px; top: -14px; font-size: 9px; color: var(--train); font-weight: 600; }
.chart-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.chart-stat { font-size: 12px; color: var(--text2); }
.chart-stat strong { color: var(--text); }

/* Monthly */
.monthly-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.monthly-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.monthly-item { text-align: center; }
.monthly-value { font-size: 20px; font-weight: 800; }
.monthly-label { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* Section toggle */
.section-toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; cursor: pointer; user-select: none; -webkit-user-select: none; }
.section-toggle:active { opacity: 0.7; }
.section-toggle-title { font-size: 14px; font-weight: 700; }
.section-toggle-arrow { font-size: 12px; color: var(--text2); transition: transform 0.3s; }
.section-toggle-arrow.open { transform: rotate(90deg); }
.section-content { display: none; }
.section-content.expanded { display: block; }

/* TAB NAV */
.tab-nav { position: fixed; bottom: 0; left: 0; right: 0; height: calc(72px + var(--safe-bottom)); background: rgba(20,20,22,0.92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--border); display: flex; justify-content: space-around; align-items: flex-start; padding-top: 8px; padding-bottom: var(--safe-bottom); z-index: 100; }
.tab-button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 20px; background: none; border: none; color: var(--text2); font-size: 10px; font-weight: 600; cursor: pointer; position: relative; transition: color 0.2s; }
.tab-button.active { color: var(--cal); }
.tab-button-icon { font-size: 22px; transition: transform 0.2s; }
.tab-button.active .tab-button-icon { transform: scale(1.1); }
.tab-badge { position: absolute; top: -2px; right: 4px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg); }

/* ERROR */
.error-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; text-align: center; height: 100%; }
.error-icon { font-size: 48px; margin-bottom: 16px; }
.error-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.error-message { font-size: 13px; color: var(--text2); margin-bottom: 24px; line-height: 1.5; }
.error-button { background: linear-gradient(135deg, var(--cal), #FF8F5E); color: #fff; border: none; padding: 14px 28px; border-radius: 14px; font-weight: 700; cursor: pointer; font-size: 14px; }

/* XP POPUP */
.xp-popup { position: fixed; pointer-events: none; font-weight: 800; font-size: 22px; z-index: 500; }
@keyframes popupFloat { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-70px) scale(1.3); } }

/* CONFETTI */
.confetti-piece { position: fixed; pointer-events: none; z-index: 600; animation: confettiFall 2s ease-out forwards; }
@keyframes confettiFall { 0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); } 100% { opacity: 0; transform: translateY(100vh) rotate(720deg) scale(0.3); } }

/* SHAKE HINT */
.shake-hint { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 16px; font-size: 12px; color: var(--text2); z-index: 50; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.shake-hint.visible { opacity: 1; }

/* TOAST */
.toast { position: fixed; top: 40px; left: 50%; transform: translateX(-50%) translateY(-20px); background: var(--surface2); border: 1px solid var(--border); border-radius: 14px; padding: 10px 20px; font-size: 13px; font-weight: 600; z-index: 800; opacity: 0; transition: all 0.3s ease; pointer-events: none; white-space: nowrap; }
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* INSIGHT CARD */
.insight-card { background: var(--surface); border: 1px solid rgba(255,107,53,0.2); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; position: relative; overflow: hidden; }
.insight-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--cal), var(--prot), var(--water)); }
.insight-icon { font-size: 20px; margin-right: 8px; float: left; }
.insight-text { font-size: 13px; line-height: 1.5; color: var(--text); }
.insight-trend { display: inline-block; font-size: 11px; font-weight: 700; margin-top: 6px; padding: 2px 8px; border-radius: 6px; }
.insight-trend.up { background: rgba(16,185,129,0.15); color: var(--success); }
.insight-trend.down { background: rgba(248,113,113,0.15); color: var(--danger); }
.insight-trend.neutral { background: rgba(255,255,255,0.06); color: var(--text2); }

/* WATER SECTION */
.water-section { margin-bottom: 16px; }
.water-item { background: var(--water-dim); border: 1px solid rgba(96,165,250,0.15); border-radius: 14px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; }
.water-left { display: flex; align-items: center; gap: 8px; }
.water-amount { font-size: 14px; font-weight: 700; color: var(--water); }

/* DAILY CHALLENGE */
.challenge-card { background: linear-gradient(135deg, rgba(167,139,250,0.1), rgba(251,191,36,0.1)); border: 1px solid rgba(167,139,250,0.15); border-radius: 16px; padding: 14px 16px; margin: 0 16px 12px; display: flex; align-items: center; gap: 12px; }
.challenge-icon { font-size: 24px; }
.challenge-text { flex: 1; }
.challenge-title { font-size: 11px; font-weight: 700; color: var(--xp); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.challenge-desc { font-size: 13px; color: var(--text); }

/* BADGE PROGRESS */
.badge-progress { position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%); font-size: 8px; font-weight: 700; color: var(--text2); white-space: nowrap; }

/* SHAKE ACTIVATE BUTTON */
.shake-activate { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; font-size: 11px; color: var(--text2); cursor: pointer; margin-top: 6px; transition: all 0.2s; }
.shake-activate:active { background: var(--surface2); }
.shake-activate.activated { border-color: rgba(16,185,129,0.3); color: var(--success); }

/* HEART FLOAT (tap pet) */
.heart-float { position: fixed; pointer-events: none; font-size: 28px; z-index: 500; animation: heartUp 1.2s ease-out forwards; }
@keyframes heartUp { 0% { opacity: 1; transform: translateY(0) scale(0.5); } 50% { opacity: 1; transform: translateY(-40px) scale(1.2); } 100% { opacity: 0; transform: translateY(-80px) scale(0.8); } }

/* R3: STAR BURST */
.star-burst { position: fixed; pointer-events: none; font-size: 16px; z-index: 550; animation: starBurst 0.7s ease-out forwards; transform: translate(-50%, -50%); }
@keyframes starBurst {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.3); }
  50% { opacity: 1; transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(1.2); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px) * 1.3), calc(-50% + var(--dy, 0px) * 1.3)) scale(0.5); }
}

/* R4: ORBIT ITEMS */
.orbit-item {
  position: absolute;
  font-size: 32px;
  cursor: grab;
  transition: font-size 0.2s;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
  user-select: none;
  -webkit-user-select: none;
  z-index: 10;
  transform: translate(-50%, -50%);
}
.orbit-item:active { cursor: grabbing; font-size: 38px; }
.orbit-item.absorbed {
  font-size: 0 !important;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* R4: DRAG GHOST */
.drag-ghost {
  position: fixed;
  font-size: 44px;
  pointer-events: none;
  z-index: 600;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 16px rgba(255,107,53,0.5));
  transition: none;
}

/* R4: DROP ACTIVE (rings glow + pet bounce when drag near) */
#ringsContainer.drop-active {
  filter: drop-shadow(0 0 12px rgba(52,211,153,0.4));
  transition: filter 0.2s;
}
#ringsContainer.drop-active #cv {
  animation: petBounce 0.5s ease infinite;
}

/* R4: MINI FOOD CARDS (queue indicator below rings) */
.food-card-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 10px;
  margin: 3px;
  font-size: 12px;
}
.food-emoji-mini { font-size: 16px; }
.food-name-mini { color: var(--text2); font-size: 11px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* R4: FEEDING SECTION */
#feedingSection { margin-top: 8px; padding: 0 16px; }
#feedingQueue { display: flex; flex-wrap: wrap; justify-content: center; padding: 4px 0; }

/* R5: WHATSAPP INPUT BAR */
.input-bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; margin: 4px 16px 8px; position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 28px; }
.input-field { flex: 1; display: flex; align-items: center; background: var(--surface2); border: 1px solid rgba(255,255,255,0.04); border-radius: 22px; padding: 0 4px 0 14px; height: 40px; transition: border-color 0.2s; position: relative; }
.input-field:focus-within { border-color: rgba(255,107,53,0.3); }
.input-field input { flex: 1; background: none; border: none; outline: none; font-size: 14px; color: var(--text); font-family: inherit; height: 100%; }
.input-field input::placeholder { color: var(--text2); }
.input-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: background 0.15s, transform 0.15s; }
.input-icon:active { transform: scale(0.9); background: var(--cal-dim); }
.input-icon svg { width: 20px; height: 20px; }
.input-icon.recording { background: rgba(248,113,113,0.2); }
.input-icon.recording svg { stroke: var(--danger); }
.send-btn { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg, var(--cal), #FF8F5E); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.15s; box-shadow: 0 2px 12px rgba(255,107,53,0.3); }
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { opacity: 0.5; transform: none; }

/* R5: SMART AUTOCOMPLETE */
.autocomplete { position: absolute; top: calc(100% + 6px); left: 0; right: 60px; background: var(--surface2); border: 1px solid var(--border); border-radius: 16px; padding: 6px; display: none; z-index: 100; box-shadow: 0 4px 24px rgba(0,0,0,0.5); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); max-height: 220px; overflow-y: auto; }
.autocomplete.visible { display: block; animation: acIn 0.2s ease; }
@keyframes acIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.ac-header { font-size: 9px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; padding: 4px 8px 2px; display: flex; align-items: center; gap: 4px; }
.ac-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; cursor: pointer; transition: background 0.15s; }
.ac-item:active { background: var(--cal-dim); }
.ac-emoji { font-size: 22px; flex-shrink: 0; width: 30px; text-align: center; }
.ac-info { flex: 1; min-width: 0; }
.ac-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-meta { font-size: 10px; color: var(--text2); display: flex; gap: 6px; margin-top: 1px; }
.ac-freq { font-size: 9px; color: var(--cal); font-weight: 600; background: var(--cal-dim); padding: 2px 6px; border-radius: 4px; flex-shrink: 0; align-self: center; }

/* R5: ANALYZING BAR */
.analyzing-bar { display: none; align-items: center; gap: 8px; padding: 4px 16px; margin-bottom: 4px; }
.analyzing-bar.visible { display: flex; }
.analyzing-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cal); animation: anPulse 0.8s ease infinite; }
.analyzing-dot:nth-child(2) { animation-delay: 0.15s; }
.analyzing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes anPulse { 0%,100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } }
.analyzing-text { font-size: 11px; color: var(--text2); font-weight: 500; }

/* R5: QUICK TAGS (horizontal scroll) */
.qtags { display: flex; gap: 6px; padding: 0 16px; overflow-x: auto; margin-bottom: 8px; scrollbar-width: none; -ms-overflow-style: none; }
.qtags::-webkit-scrollbar { display: none; }
.qtag { flex-shrink: 0; display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 6px 12px; font-size: 12px; color: var(--text); cursor: pointer; transition: all 0.15s; font-family: inherit; }
.qtag:active { background: var(--cal-dim); border-color: var(--cal); transform: scale(0.95); }
.qtag-emoji { font-size: 14px; }

/* R5: VOICE RECORDING INLINE */
.voice-inline { display: none; align-items: center; gap: 8px; padding: 4px 16px; }
.voice-inline.visible { display: flex; }
.voice-wave { display: flex; align-items: center; gap: 3px; flex: 1; }
.voice-wave-bar { width: 3px; border-radius: 2px; background: var(--danger); animation: vWave 0.6s ease-in-out infinite; }
.voice-wave-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-wave-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-wave-bar:nth-child(4) { animation-delay: 0.3s; }
.voice-wave-bar:nth-child(5) { animation-delay: 0.15s; }
@keyframes vWave { 0%,100% { height: 8px; } 50% { height: 20px; } }
.voice-cancel { font-size: 12px; color: var(--text2); cursor: pointer; padding: 4px 8px; }
.voice-text { font-size: 12px; color: var(--danger); font-weight: 600; }

/* R5: PHOTO BOTTOM SHEET */
.photo-sheet { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface2); border-top: 1px solid var(--border); border-radius: 20px 20px 0 0; padding: 16px; padding-bottom: calc(16px + var(--safe-bottom)); z-index: 200; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.photo-sheet.visible { transform: translateY(0); }
.photo-sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }
.photo-sheet-actions { display: flex; gap: 12px; }
.photo-sheet-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; cursor: pointer; transition: background 0.15s; font-family: inherit; color: var(--text); }
.photo-sheet-btn:active { background: var(--cal-dim); }
.photo-sheet-icon { font-size: 28px; }
.photo-sheet-label { font-size: 12px; font-weight: 600; }
.photo-sheet-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 199; display: none; }
.photo-sheet-overlay.visible { display: block; }

/* R5: LOG TAB LAYOUT */
.log-tab { padding: 16px 0 20px; }
.log-header-r5 { font-size: 18px; font-weight: 800; padding: 0 16px; margin-bottom: 4px; }
.log-subtitle-r5 { font-size: 12px; color: var(--text2); padding: 0 16px; margin-bottom: 12px; }

@media (max-width: 380px) {
  .pet-tab, .dashboard-tab { padding-left: 12px; padding-right: 12px; }
  .stat-value { font-size: 16px; }
  .metric-big { font-size: 24px; }
}
