/* =====================================================
   DESIGN TOKENS
   ===================================================== */
:root {
  --mp-bg:          #faf9f7;
  --mp-surface:     #ffffff;
  --mp-text:        #1a1a1a;
  --mp-muted:       #8a8a8a;
  --mp-accent:      #b45309;
  --mp-border:      #e5e2dc;
  --mp-border-lt:   #eeebe6;
  --mp-dopamine:    #f59e0b;
  --mp-serotonin:   #8b5cf6;
  --mp-endorphins:  #ec4899;
  --mp-oxytocin:    #ef4444;
  --mp-total:       #22c55e;
  --mp-damaged:     #dc2626;
  --mp-radius:      8px;
  --mp-shadow:      0 2px 12px rgba(0,0,0,.08);
  --mp-transition:  0.2s ease;
}

/* =====================================================
   BASE
   ===================================================== */
.mp-app { font-family: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif; color: var(--mp-text); max-width: 720px; margin: 0 auto; padding-bottom: 72px; background: var(--mp-bg); min-height: calc(100vh - 120px); }
.mp-app *, .mp-app *::before, .mp-app *::after { box-sizing: border-box; }

/* =====================================================
   APP HEADER
   ===================================================== */
.mp-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--mp-surface);
  border-bottom: 1px solid var(--mp-border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.mp-mito-name { font-family: 'Playfair Display', Georgia, serif; font-size: 1.15rem; font-weight: 600; color: var(--mp-accent); }
.mp-ivm-display { font-size: 0.9rem; color: var(--mp-muted); display: flex; align-items: center; gap: 0.4rem; }
.mp-ivm-display span#ivm-value { font-weight: 700; font-size: 1.1rem; color: var(--mp-text); }
.mp-badge { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.15rem 0.5rem; border: 1px solid currentColor; border-radius: 100px; }
.mp-mute-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 0.25rem; border-radius: var(--mp-radius); transition: opacity var(--mp-transition); }
.mp-mute-btn:hover { opacity: 0.7; }
.mp-mute-btn:focus-visible { outline: 2px solid var(--mp-accent); }

/* =====================================================
   SCREENS
   ===================================================== */
.mp-screen { display: none; padding: 1rem 1rem 0.5rem; }
.mp-screen.active { display: block; }

/* =====================================================
   MITO STAGE
   ===================================================== */
.mp-mito-stage { display: flex; justify-content: center; padding: 0.5rem 0 0.25rem; position: relative; }
.mp-mito-wrapper { display: inline-block; position: relative; cursor: default; transition: filter var(--mp-transition); }

/* =====================================================
   SVG — DEFAULT BODY STYLES
   ===================================================== */
.mito-body     { fill: #4ade80; stroke: #16a34a; stroke-width: 2; }
.mito-highlight { fill: white; }
.mito-iris     { fill: #15803d; }
.mito-eyelid   { fill: #4ade80; stroke: none; }
.mouth-yawn    { fill: #15803d; }
.deco-smoke circle { fill: #9ca3af; }

/* =====================================================
   SVG — VISIBILITY DEFAULTS (hide non-default elements)
   ===================================================== */
.eyes-stars, .eyes-tired, .eyes-closed { display: none; }
.mouth-frown, .mouth-flat, .mouth-yawn { display: none; }
.deco-smoke { display: none; }

/* =====================================================
   SVG — STATE: LEGENDARY
   ===================================================== */
[data-state="legendary"] .mito-body { fill: #ffd700; stroke: #b8860b; }
[data-state="legendary"] .mito-iris { fill: #b8860b; }
[data-state="legendary"] .mito-eyelid { fill: #ffd700; }
[data-state="legendary"] .mouth-yawn { fill: #b8860b; }
[data-state="legendary"] .eyes-stars { display: block; }
[data-state="legendary"] .deco-sparkles { display: block; }

/* =====================================================
   SVG — STATE: HAPPY (default, no overrides needed for visibility)
   ===================================================== */
/* mito-body defaults are happy colors */

/* =====================================================
   SVG — STATE: TIRED
   ===================================================== */
[data-state="tired"] .mito-body { fill: #9ca3af; stroke: #6b7280; }
[data-state="tired"] .mito-iris { fill: #6b7280; }
[data-state="tired"] .mito-eyelid { fill: #9ca3af; }
[data-state="tired"] .mouth-yawn { fill: #6b7280; }
[data-state="tired"] .eyes-open { display: none; }
[data-state="tired"] .eyes-tired { display: block; }
[data-state="tired"] .mouth-smile { display: none; }
[data-state="tired"] .mouth-frown { display: block; }
[data-state="tired"] .deco-atps { display: none; }
[data-state="tired"] .mouth-yawn { display: block; }

/* =====================================================
   SVG — STATE: HIBERNATING
   ===================================================== */
[data-state="hibernating"] .mito-body { fill: #4b5563; stroke: #374151; }
[data-state="hibernating"] .mito-iris { fill: #374151; }
[data-state="hibernating"] .deco-smoke circle { fill: #6b7280; }
[data-state="hibernating"] .eyes-open { display: none; }
[data-state="hibernating"] .eyes-closed { display: block; }
[data-state="hibernating"] .mouth-smile { display: none; }
[data-state="hibernating"] .mouth-flat { display: block; }
[data-state="hibernating"] .deco-atps { display: none; }
[data-state="hibernating"] .deco-smoke { display: block; }

/* =====================================================
   KEYFRAME ANIMATIONS
   ===================================================== */
@keyframes mitoFloat    { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-14px)} }
@keyframes mitoBounce   { 0%,100%{transform:translateY(0) scaleY(1)} 30%{transform:translateY(-11px) scaleY(1.05)} 60%{transform:translateY(0) scaleY(0.97)} }
@keyframes mitoSway     { 0%,100%{transform:rotate(0deg)} 25%{transform:rotate(2.5deg)} 75%{transform:rotate(-2.5deg)} }
@keyframes mitoPulse    { 0%,100%{opacity:.72} 50%{opacity:1} }
@keyframes mitoActionPop{ 0%{transform:scale(1)} 30%{transform:scale(1.18) translateY(-9px)} 65%{transform:scale(.96)} 100%{transform:scale(1)} }
@keyframes atpRise      { 0%{opacity:0;transform:translateY(0)} 20%{opacity:.85} 100%{opacity:0;transform:translateY(-32px)} }
@keyframes sparkleAnim  { 0%,100%{opacity:0;transform:scale(.5) rotate(0deg)} 50%{opacity:1;transform:scale(1.25) rotate(30deg)} }
@keyframes smokeRise    { 0%{opacity:.35;transform:translateY(0) scale(1)} 100%{opacity:0;transform:translateY(-22px) scale(1.6)} }
@keyframes yawnCycle    { 0%,60%,100%{opacity:0} 70%,90%{opacity:1} }
@keyframes confettiFall { 0%{transform:translateY(0) rotate(0deg);opacity:1} 100%{transform:translateY(130px) rotate(720deg);opacity:0} }
@keyframes feedbackFly  { 0%{transform:translateY(0) scale(1);opacity:1} 100%{transform:translateY(-65px) scale(1.4);opacity:0} }
@keyframes ringFlash    { 0%,100%{opacity:0;r:70} 30%{opacity:.6;r:88} }

/* =====================================================
   STATE ANIMATIONS
   ===================================================== */
[data-state="legendary"] #mito-svg { animation: mitoFloat 3s ease-in-out infinite; }
[data-state="legendary"] .sp       { animation: sparkleAnim 1.5s ease-in-out infinite; }
[data-state="legendary"] .s1 { animation-delay: 0s; }
[data-state="legendary"] .s2 { animation-delay: .3s; }
[data-state="legendary"] .s3 { animation-delay: .6s; }
[data-state="legendary"] .s4 { animation-delay: .9s; }
[data-state="legendary"] .s5 { animation-delay:1.2s; }

[data-state="happy"] #mito-svg  { animation: mitoBounce 2s ease-in-out infinite; }
[data-state="happy"] .mito-atp  { animation: atpRise 2.5s ease-out infinite; }
[data-state="happy"] .atp-a     { animation-delay: 0s; }
[data-state="happy"] .atp-b     { animation-delay: .85s; }
[data-state="happy"] .atp-c     { animation-delay:1.7s; }

[data-state="tired"] #mito-svg  { animation: mitoSway 4s ease-in-out infinite; }
[data-state="tired"] .mouth-yawn { animation: yawnCycle 8s ease-in-out infinite; }

[data-state="hibernating"] #mito-svg { animation: mitoPulse 5s ease-in-out infinite; }
[data-state="hibernating"] .mito-smk { animation: smokeRise 3s ease-out infinite; }
[data-state="hibernating"] .smk-a { animation-delay: 0s; }
[data-state="hibernating"] .smk-b { animation-delay: 1s; }
[data-state="hibernating"] .smk-c { animation-delay: 2s; }

.mito-pop #mito-svg { animation: mitoActionPop 0.4s ease-out forwards !important; }

/* =====================================================
   GAUGES
   ===================================================== */
.mp-gauges { padding: 0.5rem 0 0.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.mp-gauge-row { display: flex; align-items: center; gap: 0.6rem; }
.mp-gauge-label { font-size: 0.78rem; font-weight: 600; color: var(--mp-muted); text-transform: uppercase; letter-spacing: .07em; width: 72px; flex-shrink: 0; }
.mp-gauge-bar { flex: 1; height: 10px; background: var(--mp-border); border-radius: 100px; overflow: hidden; }
.mp-gauge-fill { height: 100%; border-radius: 100px; transition: width 0.5s ease; }
.mp-gauge-fill--total   { background: linear-gradient(90deg, #16a34a, var(--mp-total)); }
.mp-gauge-fill--damaged { background: linear-gradient(90deg, #b91c1c, var(--mp-damaged)); }
.mp-gauge-pct { font-size: 0.82rem; font-weight: 600; width: 36px; text-align: right; flex-shrink: 0; }

/* =====================================================
   MOLECULE CIRCLES
   ===================================================== */
.mp-molecules { display: flex; justify-content: space-around; padding: 0.75rem 0 0.5rem; }
.mp-mol-item { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.mp-mol-svg { display: block; }
.mp-mol-track { fill: none; stroke: var(--mp-border); stroke-width: 4; }
.mp-mol-ring  { fill: none; stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }
.mp-mol-text  { font-size: 10px; font-weight: 600; fill: var(--mp-text); text-anchor: middle; font-family: 'Source Sans 3', sans-serif; }
.mp-mol-label { font-size: 0.7rem; font-weight: 600; color: var(--mp-muted); }

/* =====================================================
   QUEST
   ===================================================== */
.mp-quest { background: var(--mp-surface); border: 1px solid var(--mp-border-lt); border-radius: var(--mp-radius); padding: 0.75rem 1rem; margin: 0.5rem 0; }
.mp-quest-header { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.5rem; }
.mp-quest-icon { font-size: 1rem; }
.mp-quest-text { font-size: 0.88rem; font-weight: 500; }
.mp-quest-bar-wrap { display: flex; align-items: center; gap: 0.6rem; }
.mp-quest-bar-bg { flex: 1; height: 8px; background: var(--mp-border); border-radius: 100px; overflow: hidden; }
.mp-quest-bar-fill { height: 100%; background: linear-gradient(90deg, var(--mp-accent), var(--mp-dopamine)); border-radius: 100px; transition: width 0.5s ease; }
.mp-quest-progress { font-size: 0.8rem; font-weight: 600; color: var(--mp-muted); white-space: nowrap; }

/* =====================================================
   ACTIONS
   ===================================================== */
.mp-actions-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; padding: 0.25rem 0 0.75rem; }
.mp-filter-pill { background: none; border: 1px solid var(--mp-border); border-radius: 100px; padding: 0.3rem 0.85rem; font-size: 0.8rem; font-weight: 500; color: var(--mp-muted); cursor: pointer; transition: all var(--mp-transition); font-family: inherit; }
.mp-filter-pill:hover { color: var(--mp-text); border-color: var(--mp-text); }
.mp-filter-pill.active { background: var(--mp-text); color: var(--mp-bg); border-color: var(--mp-text); }
.mp-filter-pill:focus-visible { outline: 2px solid var(--mp-accent); }
.mp-actions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.65rem; margin-bottom: 0.5rem; }
.mp-card { background: var(--mp-surface); border: 1px solid var(--mp-border-lt); border-radius: var(--mp-radius); padding: 0.85rem; display: flex; flex-direction: column; gap: 0.3rem; box-shadow: var(--mp-shadow); transition: transform var(--mp-transition), box-shadow var(--mp-transition); }
.mp-card:not(.mp-card--disabled):hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.mp-card--disabled { opacity: 0.45; pointer-events: none; }
.mp-card--neg { background: #fff8f8; border-color: #fecaca; }
.mp-card-icon { font-size: 1.5rem; }
.mp-card-name { font-size: 0.88rem; font-weight: 600; line-height: 1.3; }
.mp-card-effects { font-size: 0.72rem; color: var(--mp-muted); line-height: 1.4; }
.mp-card-count { font-size: 0.72rem; font-weight: 600; color: var(--mp-accent); }
.mp-card-btn { margin-top: 0.25rem; background: var(--mp-text); color: var(--mp-bg); border: none; border-radius: var(--mp-radius); padding: 0.4rem 0.7rem; font-size: 0.8rem; font-weight: 600; cursor: pointer; font-family: inherit; transition: opacity var(--mp-transition); }
.mp-card-btn:hover { opacity: 0.82; }
.mp-card-btn:focus-visible { outline: 2px solid var(--mp-accent); outline-offset: 2px; }
.mp-card-btn--neg { background: #dc2626; }
.mp-neg-title { font-size: 0.8rem; font-weight: 600; color: var(--mp-muted); text-transform: uppercase; letter-spacing: .1em; margin: 1rem 0 0.5rem; }
.mp-neg-grid .mp-card { opacity: 0.85; }

/* =====================================================
   HISTORY
   ===================================================== */
.mp-streak { font-size: 1rem; font-weight: 600; text-align: center; padding: 0.75rem 0 0.25rem; }
.mp-week-view { padding: 0.5rem 0 0.75rem; }
.mp-week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.3rem; }
.mp-week-day { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0.4rem 0.2rem; border-radius: var(--mp-radius); background: var(--mp-border-lt); font-size: 0.7rem; }
.mp-week-day--active { background: #dcfce7; }
.mp-week-day--goal   { background: #fef9c3; }
.mp-week-label { font-size: 0.65rem; font-weight: 600; color: var(--mp-muted); text-transform: uppercase; }
.mp-week-dot   { font-size: 0.85rem; }
.mp-week-count { font-size: 0.7rem; font-weight: 700; }
.mp-log-list { margin-top: 0.25rem; }
.mp-log-group { margin-bottom: 1rem; }
.mp-log-date { font-size: 0.78rem; font-weight: 600; color: var(--mp-accent); text-transform: capitalize; padding: 0.3rem 0; border-bottom: 1px solid var(--mp-border-lt); margin-bottom: 0.4rem; }
.mp-log-entry { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; padding: 0.3rem 0; border-bottom: 1px solid var(--mp-border-lt); flex-wrap: wrap; }
.mp-log-time { color: var(--mp-muted); font-size: 0.72rem; white-space: nowrap; }
.mp-log-name { font-weight: 500; }
.mp-empty { color: var(--mp-muted); font-size: 0.9rem; text-align: center; padding: 2rem; }

/* =====================================================
   INFO
   ===================================================== */
.mp-info-title { font-family: 'Playfair Display', Georgia, serif; font-size: 1.4rem; font-weight: 600; margin: 0 0 1rem; }
.mp-info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1.25rem; }
.mp-info-card { background: var(--mp-surface); border: 1px solid var(--mp-border-lt); border-radius: var(--mp-radius); padding: 1rem; }
.mp-info-icon { font-size: 1.5rem; margin-bottom: 0.4rem; }
.mp-info-card h3 { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.4rem; }
.mp-info-card p  { font-size: 0.82rem; color: var(--mp-muted); margin: 0; line-height: 1.5; }
.mp-info-section { margin-bottom: 1rem; }
.mp-info-section h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.4rem; }
.mp-info-section p  { font-size: 0.88rem; line-height: 1.6; margin: 0; color: var(--mp-muted); }
.mp-info-sources { padding-left: 1.2rem; margin: 0; }
.mp-info-sources li { font-size: 0.82rem; color: var(--mp-muted); margin-bottom: 0.25rem; }
.mp-info-disclaimer { background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--mp-radius); padding: 0.75rem 1rem; font-size: 0.82rem; color: #92400e; margin-top: 1rem; }

/* =====================================================
   NAVIGATION
   ===================================================== */
.mp-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 720px; display: flex; background: var(--mp-surface); border-top: 1px solid var(--mp-border); z-index: 20; }
.mp-nav-btn { flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0.55rem 0.25rem 0.45rem; cursor: pointer; color: var(--mp-muted); font-family: inherit; transition: color var(--mp-transition); }
.mp-nav-btn:hover, .mp-nav-btn.active { color: var(--mp-accent); }
.mp-nav-btn.active { border-top: 2px solid var(--mp-accent); }
.mp-nav-icon  { font-size: 1.15rem; line-height: 1; }
.mp-nav-label { font-size: 0.65rem; font-weight: 600; letter-spacing: .02em; }
.mp-nav-btn:focus-visible { outline: 2px solid var(--mp-accent); outline-offset: -2px; }

/* =====================================================
   FEEDBACK & CONFETTI
   ===================================================== */
.mp-mito-stage { position: relative; overflow: visible; }
.mp-feedback { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); font-size: 1.6rem; pointer-events: none; animation: feedbackFly 0.7s ease-out forwards; z-index: 5; }
.mp-confetti  { position: absolute; width: 9px; height: 9px; border-radius: 2px; pointer-events: none; animation: confettiFall 0.9s ease-out forwards; z-index: 5; }

/* =====================================================
   CHART
   ===================================================== */
.mp-chart-container { margin: 0.5rem 0 0.75rem; }
.mp-chart-title { font-size: 0.92rem; font-weight: 600; margin: 0 0 0.4rem; }
.mp-chart-wrap { position: relative; }
.mp-chart-svg { width: 100%; display: block; }
.mp-chart-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; font-size: 0.71rem; padding: 0.25rem 0 0; }
.mp-leg-item { display: flex; align-items: center; gap: 0.28rem; color: var(--mp-muted); }
.mp-leg-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.mp-leg-line { width: 18px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.mp-leg-area { width: 14px; height: 10px; background: var(--mp-damaged); opacity: 0.35; border-radius: 2px; flex-shrink: 0; }
.mp-chart-tip { position: absolute; top: 8%; background: var(--mp-surface); border: 1px solid var(--mp-border); border-radius: var(--mp-radius); padding: 0.45rem 0.65rem; font-size: 0.76rem; line-height: 1.55; box-shadow: var(--mp-shadow); max-width: 200px; z-index: 10; pointer-events: none; transform: translateX(-50%); white-space: nowrap; }
.mp-chart-hover { cursor: crosshair; }
.mp-chart-hover:focus-visible { outline: 2px solid var(--mp-accent); }

/* =====================================================
   FOCUS & ACCESSIBILITY
   ===================================================== */
:focus-visible { outline: 2px solid var(--mp-accent); outline-offset: 2px; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 600px) {
  .mp-app-header { padding: 0.6rem 0.75rem; }
  .mp-screen { padding: 0.75rem 0.75rem 0; }
  .mp-actions-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .mp-info-grid { grid-template-columns: 1fr; }
  .mp-molecules { gap: 0.25rem; }
  .mp-mol-svg { width: 58px; height: 58px; }
  .mp-mito-name { font-size: 1rem; }
  #mito-svg { width: 145px; height: 145px; }
}
@media (min-width: 601px) {
  .mp-actions-grid { grid-template-columns: repeat(3, 1fr); }
}
