/* ==========================================================================
   EATLABEL.COM DESIGN SYSTEM
   Brand Colors: Clean Leaf Green (#10B981), Deep Slate Navy (#0F172A)
   Status: Safe (#10B981), Caution (#F59E0B), Danger (#EF4444)
   ========================================================================== */

:root {
  --primary: #10B981;
  --primary-hover: #059669;
  --primary-light: #34D399;
  --primary-tint: #ECFDF5;
  --primary-border: #A7F3D0;
  
  --base: #0F172A;
  --base-muted: #1E293B;
  --base-card: #1E293B;
  
  --text-main: #0F172A;
  --text-sub: #475569;
  --text-muted: #94A3B8;
  --text-light: #F8FAFC;
  
  --bg-body: #F8FAFC;
  --bg-card: #FFFFFF;
  --border-light: #E2E8F0;
  --border-hover: #CBD5E1;
  
  --safe: #10B981;
  --safe-bg: #ECFDF5;
  --safe-text: #065F46;
  
  --caution: #F59E0B;
  --caution-bg: #FFFBEB;
  --caution-text: #92400E;
  
  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --danger-text: #991B1B;
  
  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #FFFFFF;
  box-shadow: 0 0 50px rgba(15, 23, 42, 0.08);
  transition: max-width 0.3s ease;
}

@media (min-width: 521px) and (max-width: 899px) {
  .app-container {
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
  }
}

@media (min-width: 900px) {
  .app-container {
    max-width: 1200px;
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
  }
}

/* Header (GNB) */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.brand-logo-img {
  height: 38px;
  width: auto;
  display: block;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-db-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--base);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.header-db-btn:hover {
  background: var(--primary-tint);
  border-color: var(--primary);
  color: var(--primary);
}

.header-db-btn svg {
  color: var(--primary);
  flex-shrink: 0;
}

.lang-toggle-btn {
  display: flex;
  align-items: center;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 3px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.lang-toggle-btn span {
  padding: 4px 8px;
  border-radius: var(--radius-full);
  transition: var(--transition);
  color: var(--text-muted);
}

.lang-toggle-btn span.active {
  background: var(--base);
  color: #FFFFFF;
}

.icon-btn {
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-sub);
  transition: var(--transition);
}

.icon-btn:hover {
  background: #FFFFFF;
  color: var(--primary);
  border-color: var(--primary);
}

.icon-btn.active {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: var(--primary);
}

/* ==========================================================================
   WORKSPACE GRID & RESPONSIVE LAYOUT
   ========================================================================== */
.workspace-grid {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.workspace-col-left {
  width: 100%;
}

.workspace-col-right {
  display: block;
  width: 100%;
  padding: 12px 16px 28px;
}

@media (max-width: 899px) {
  #desktop-deep-panel {
    display: none !important;
  }
}

#desktop-guide-panel {
  display: block;
}

@media (min-width: 900px) {
  .workspace-grid {
    display: grid;
    grid-template-columns: 460px 1fr;
    gap: 28px;
    padding: 24px 28px;
    align-items: start;
    background: var(--bg-body);
  }

  .workspace-col-left {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .workspace-col-left .scanner-viewport {
    border: none;
    background: transparent;
    box-shadow: none;
    height: auto;
    padding: 12px 0 4px;
  }

  .workspace-col-left .scanner-controls {
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
  }


  .workspace-col-left .result-card-container {
    padding: 20px;
    border-radius: var(--radius-xl);
  }

  .workspace-col-left .result-card {
    border-radius: var(--radius-xl);
  }

  .workspace-col-left .btn-expand-deep {
    display: none;
  }

  .workspace-col-right {
    display: block;
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    padding: 0 4px 0 0;
  }

  .workspace-col-right::-webkit-scrollbar {
    width: 6px;
  }
  .workspace-col-right::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: var(--radius-full);
  }

  #desktop-deep-panel {
    display: none;
  }
}

/* Panel & Guide Cards Common Styles (Mobile & Desktop) */
.desktop-panel-inner {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 20px 16px;
  box-shadow: var(--shadow-md);
}

@media (min-width: 640px) {
  .desktop-panel-inner {
    padding: 24px;
  }
}

.desktop-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.desktop-panel-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--base);
  margin-top: 4px;
  letter-spacing: -0.3px;
}

.desktop-reg-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-sub);
  background: var(--bg-body);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  white-space: nowrap;
}

.desktop-panel-desc {
  font-size: 0.82rem;
  color: var(--text-sub);
  line-height: 1.5;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.desktop-ingredients-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Guide Panel Cards */
.guide-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-card {
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.guide-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.guide-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.guide-country-flag {
  font-size: 1.15rem;
}

.guide-card-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--base);
}

.guide-card-desc {
  font-size: 0.8rem;
  color: var(--text-sub);
  line-height: 1.5;
  margin: 0;
}

.guide-card.highlight-scoring {
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.guide-card.highlight-scoring .guide-card-title {
  color: #065F46;
}

/* ==========================================================================
   VIEWFINDER & CAMERA WORKSPACE (Clean Floating Logo)
   ========================================================================== */
.scanner-viewport {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 280px;
  background: transparent;
  border-bottom: none;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 20px 12px;
  box-sizing: border-box;
}

@media (max-height: 750px) {
  .scanner-viewport {
    min-height: 240px;
    padding: 12px 20px 8px;
  }
}

.preview-img {
  width: 100%;
  max-height: 380px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  object-fit: cover;
  transition: opacity 0.3s ease;
}

.preview-img.hidden {
  display: none;
}

.viewfinder-placeholder {
  position: relative;
  width: 100%;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity 0.3s ease;
}

.scanner-logo-box {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  height: auto;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  filter: drop-shadow(0 10px 28px rgba(15, 23, 42, 0.12));
  padding: 4px;
}

.scanner-logo-box:hover {
  transform: scale(1.03);
  filter: drop-shadow(0 14px 36px rgba(16, 185, 129, 0.28));
}

.scanner-logo-box:active {
  transform: scale(0.98);
}

.scanner-logo-symbol {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Prompt Texts below scan box */
.scanner-text-group {
  text-align: center;
  width: 100%;
  padding: 0;
}

.scanner-hero-prompt {
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.3;
  color: var(--base);
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}

.scanner-hero-sub {
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--text-muted);
}

/* Scanning Laser Animation */
.laser-line {
  position: absolute;
  left: 4px;
  right: 4px;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--primary) 50%, transparent 100%);
  box-shadow: 0 0 14px 2px var(--primary);
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  z-index: 15;
}

.scanner-active .laser-line {
  opacity: 1;
  animation: laser-scan 1.8s infinite ease-in-out alternate;
}

@keyframes laser-scan {
  0% { top: 8px; }
  100% { top: calc(100% - 10px); }
}

@keyframes pulse-slow {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.05); opacity: 1; }
}

/* Camera Flash Screen Effect */
.camera-flash {
  position: absolute;
  inset: 0;
  background: #FFFFFF;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: opacity 0.15s ease-out;
}

.camera-flash.flash-active {
  opacity: 0.85;
}

/* ==========================================================================
   SCANNER CONTROLS & BOTTOM SHUTTER BAR
   ========================================================================== */
.scanner-controls {
  padding: 18px 20px;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-light);
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  max-width: 320px;
}

/* Shutter Button */
.shutter-btn {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: #FFFFFF;
  border: 4px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25), 0 8px 20px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.shutter-btn::after {
  content: '';
  width: 54px;
  height: 54px;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: var(--transition);
}

.shutter-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.35), 0 10px 25px rgba(16, 185, 129, 0.2);
}

.shutter-btn:active {
  transform: scale(0.94);
}

.shutter-btn:active::after {
  transform: scale(0.88);
  background: var(--primary-hover);
}

/* Secondary Action Buttons */
.sub-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.sub-action-btn .btn-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  transition: var(--transition);
}

.sub-action-btn:hover .btn-icon-wrap {
  background: #FFFFFF;
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px);
}


.dot-safe { background-color: var(--safe); }
.dot-caution { background-color: var(--caution); }
.dot-danger { background-color: var(--danger); }

/* Hidden File Inputs */
#camera-input,
#album-input,
#file-input {
  display: none !important;
}

/* ==========================================================================
   STAGE 1: 3-SECOND GLANCEABLE SUMMARY CARD (Bottom Sheet / Card)
   ========================================================================== */
@keyframes resultReveal {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-card-container {
  padding: 24px 20px;
  background: #94A3B8;
  transition: background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  animation: resultReveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.result-card-container.state-idle {
  background: #94A3B8;
}

.result-card-container.state-safe {
  background: #10B981;
}

.result-card-container.state-caution {
  background: #F59E0B;
}

.result-card-container.state-danger {
  background: #EF4444;
}

.result-card {
  background: #FFFFFF;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.result-card.state-safe {
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 14px 36px rgba(16, 185, 129, 0.12), 0 2px 6px rgba(15, 23, 42, 0.04);
}

.result-card.state-caution {
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 14px 36px rgba(245, 158, 11, 0.12), 0 2px 6px rgba(15, 23, 42, 0.04);
}

.result-card.state-danger {
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 14px 36px rgba(239, 68, 68, 0.14), 0 2px 6px rgba(15, 23, 42, 0.04);
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.product-meta {
  flex: 1;
  padding-right: 12px;
}

.product-badge-type {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-tint);
  border: 1px solid var(--primary-border);
  padding: 3px 9px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}

.product-badge-type svg {
  stroke-width: 3px;
  flex-shrink: 0;
}

.product-country-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.product-country-badge .country-flag-img {
  width: 18px;
  height: 13.5px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.product-country-badge .country-name {
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-sub);
}

.product-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--base);
  line-height: 1.25;
  letter-spacing: -0.4px;
}

.product-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Dynamic EatLabel Bite Score Badge */
.eatlabel-score-badge {
  flex-shrink: 0;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  filter: drop-shadow(0 6px 18px rgba(15, 23, 42, 0.18));
  transition: transform 0.25s ease, filter 0.25s ease;
  cursor: default;
}

.eatlabel-score-badge:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 8px 22px rgba(15, 23, 42, 0.22));
}

.score-badge-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.badge-body {
  transition: fill 0.3s ease;
}

/* Badge Body Fill Colors by Status */
.badge-safe .badge-body,
.state-safe .badge-body {
  fill: #10B981 !important;
}

.badge-caution .badge-body,
.state-caution .badge-body {
  fill: #F59E0B !important;
}

.badge-danger .badge-body,
.state-danger .badge-body {
  fill: #EF4444 !important;
}

/* Digits: Dark Navy fill with Crisp White outline */
.badge-digit {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  font-weight: 900;
  font-size: 20px;
  fill: #0F172A;
  stroke: #FFFFFF;
  stroke-width: 1.8px;
  stroke-linejoin: round;
  paint-order: stroke fill;
  text-anchor: middle;
  dominant-baseline: central;
  user-select: none;
}

.badge-digit.d-100 {
  font-size: 14px;
  stroke-width: 1.2px;
}

.badge-digit.hidden {
  display: none;
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* 3-Color Gauge Component */
.score-gauge-wrap {
  margin: 18px 0 16px;
  padding: 6px 2px;
}

.gauge-pin-track {
  position: relative;
  height: 15px;
  width: 100%;
  margin-bottom: 2px;
}

.gauge-pin {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.25));
  z-index: 5;
}

.gauge-pin-triangle {
  width: 14px;
  height: 11px;
  display: block;
}

.gauge-bar-track {
  height: 12px;
  border-radius: var(--radius-full);
  display: flex;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.gauge-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.seg-danger {
  width: 40%;
  background: #EF4444;
}

.seg-caution {
  width: 30%;
  background: #F59E0B;
}

.seg-safe {
  width: 30%;
  background: #10B981;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* 4 Core Fact-Check Grid */
.factcheck-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.fact-item {
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: var(--transition);
}

.fact-item:hover {
  background: #FFFFFF;
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.fact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fact-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-sub);
}

.fact-status-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.fact-status-safe {
  background: #D1FAE5;
  color: #065F46;
}

.fact-status-caution {
  background: #FEF3C7;
  color: #92400E;
}

.fact-status-danger {
  background: #FEE2E2;
  color: #991B1B;
}

.fact-desc {
  font-size: 0.78rem;
  color: var(--text-main);
  font-weight: 600;
  line-height: 1.35;
}

/* Actions in Card */
.card-cta-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-expand-deep {
  width: 100%;
  background: var(--base);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  padding: 13px 18px;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
}

.btn-expand-deep:hover {
  background: #1E293B;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.24);
}

.btn-reset-scan {
  width: 100%;
  background: transparent;
  color: var(--text-sub);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-reset-scan:hover {
  background: var(--bg-body);
  color: var(--text-main);
}

/* ==========================================================================
   STAGE 2: DEEP DIVE MODAL / BOTTOM SHEET
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  max-height: 88vh;
  background: #FFFFFF;
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.sheet-handle-bar {
  width: 44px;
  height: 5px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  margin: 10px auto 4px;
}

.sheet-header {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
}

.sheet-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--base);
}

.close-btn {
  background: var(--bg-body);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  cursor: pointer;
  transition: var(--transition);
}

.close-btn:hover {
  background: var(--border-light);
  color: var(--text-main);
}

.sheet-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Tabs inside Modal */
.modal-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 16px;
  padding-bottom: 8px;
}

.modal-tab-btn {
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.modal-tab-btn.active {
  background: var(--primary-tint);
  color: var(--primary);
}

/* Ingredients List in Deep Dive */
.ingredient-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 12px;
  background: #FFFFFF;
  transition: var(--transition);
}

.ingredient-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.ing-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ing-name-group {
  flex: 1;
}

.ing-name-ko {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--base);
}

.ing-name-en {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ing-risk-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.ing-plain-desc {
  font-size: 0.82rem;
  color: var(--text-sub);
  line-height: 1.45;
  margin-bottom: 10px;
  background: var(--bg-body);
  padding: 8px 10px;
  border-radius: var(--radius-md);
}

/* 3-Country Comparison Matrix */
.reg-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  margin-top: 6px;
}

.reg-matrix-table th,
.reg-matrix-table td {
  padding: 6px 8px;
  text-align: left;
  border-top: 1px solid var(--border-light);
}

.reg-matrix-table th {
  color: var(--text-muted);
  font-weight: 700;
  background: var(--bg-body);
}

.reg-status-pill {
  display: inline-block;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.reg-ok { background: #D1FAE5; color: #065F46; }
.reg-warn { background: #FEF3C7; color: #92400E; }
.reg-ban { background: #FEE2E2; color: #991B1B; }

/* ==========================================================================
   BELOW THE FOLD: ENCYCLOPEDIA & CONTENT (FlyBatt Style SEO)
   ========================================================================== */
.content-section {
  padding: 28px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-body);
}

.section-head {
  margin-bottom: 18px;
}

.section-tag {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--base);
  margin-top: 2px;
}

.section-desc {
  font-size: 0.82rem;
  color: var(--text-sub);
  margin-top: 4px;
}

/* Additive Encyclopedia Grid */
.additive-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 480px) {
  .additive-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 900px) {
  .additive-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.additive-card {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.additive-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.additive-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--base);
}

.additive-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.additive-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.7rem;
}

/* Top Philosophy Banner (Étiquette) */
.philosophy-banner {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  color: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin: 14px 20px 0;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.philosophy-badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.2);
  color: var(--primary-light);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.philosophy-heading {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 8px;
}

.philosophy-text {
  font-size: 0.8rem;
  color: #CBD5E1;
  line-height: 1.5;
}

/* ==========================================================================
   FOOTER (AdSense Essential Links)
   ========================================================================== */
.app-footer {
  background: #FFFFFF;
  border-top: 1px solid var(--border-light);
  padding: 24px 20px 32px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
}

.footer-nav a {
  color: var(--text-sub);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.footer-nav a:hover {
  color: var(--primary);
}

.footer-disclaimer {
  font-size: 0.7rem;
  line-height: 1.4;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.footer-copy {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Loading Spinner & Status */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  color: #FFFFFF;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 14px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.loading-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   ADDITIVE DETAIL PAGE (INGREDIENT ENCYCLOPEDIA)
   ========================================================================== */
.ingredient-article-wrap {
  padding: 24px 20px 60px;
  max-width: 840px;
  margin: 0 auto;
  width: 100%;
}

.ingredient-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.ingredient-breadcrumb a {
  color: var(--text-sub);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.ingredient-breadcrumb a:hover {
  color: var(--primary);
}

.ingredient-breadcrumb .sep {
  color: var(--border-hover);
  font-size: 0.75rem;
}

.ingredient-breadcrumb .curr {
  color: var(--text-main);
  font-weight: 700;
}

.ingredient-hero {
  margin-bottom: 22px;
}

.ingredient-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.ingredient-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--base);
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.ingredient-meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.ing-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-sub);
}

.ing-meta-chip.code-badge {
  background: var(--base);
  color: #FFFFFF;
  border-color: var(--base);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ing-meta-chip.category-badge {
  background: var(--primary-tint);
  color: var(--primary-hover);
  border-color: var(--primary-border);
  font-weight: 700;
}

/* Verdict & Risk Banner */
.ingredient-verdict-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  border: 1.5px solid;
  box-shadow: var(--shadow-sm);
}

.verdict-left-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.verdict-icon-box {
  font-size: 1.6rem;
  line-height: 1;
}

.verdict-text-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.verdict-label-sub {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.verdict-grade-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.verdict-score-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

/* Content Section Cards */
.ing-card-section {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.ing-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.ing-card-header h2 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--base);
  letter-spacing: -0.01em;
}

.ing-card-icon {
  font-size: 1.15rem;
}

.ing-card-desc {
  font-size: 0.94rem;
  line-height: 1.7;
  color: #334155;
  margin-bottom: 8px;
}

/* 3-Nation Regulatory Grid */
.ing-reg-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 680px) {
  .ing-reg-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.ing-reg-col {
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ing-reg-agency {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--base);
}

.ing-reg-flag {
  font-size: 1.3rem;
  line-height: 1;
}

.ing-reg-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 800;
  align-self: flex-start;
}

.reg-status-safe {
  background: var(--safe-bg);
  color: var(--safe-text);
  border: 1px solid var(--safe);
}

.reg-status-caution {
  background: var(--caution-bg);
  color: var(--caution-text);
  border: 1px solid var(--caution);
}

.reg-status-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger);
}

.ing-reg-note {
  font-size: 0.84rem;
  line-height: 1.55;
  color: #475569;
}

/* Chips wrap for common foods and alternatives */
.ing-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.food-item-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  color: #1E293B;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
}

.alt-item-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--safe-bg);
  border: 1px solid var(--primary-border);
  color: var(--safe-text);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
}

/* CTA Box */
.ingredient-cta-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(15, 23, 42, 0.03) 100%);
  border: 1.5px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-xl);
  padding: 36px 24px;
  text-align: center;
  margin-top: 36px;
  box-shadow: var(--shadow-sm);
}

.ingredient-cta-box h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--base);
  margin-bottom: 8px;
}

.ingredient-cta-box p {
  font-size: 0.9rem;
  color: var(--text-sub);
  max-width: 480px;
  margin: 0 auto;
}

.ingredient-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #FFFFFF !important;
  font-weight: 800;
  font-size: 0.98rem;
  padding: 13px 30px;
  border-radius: var(--radius-full);
  text-decoration: none;
  margin-top: 20px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: var(--transition);
}

.ingredient-cta-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.45);
}

/* Deep Dive Card Additive Deeplink */
.ing-card-footer {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.ing-detail-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--primary-tint);
  border: 1px solid var(--primary-border);
  transition: var(--transition);
}

.ing-detail-link:hover {
  background: var(--primary);
  color: #FFFFFF !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.ing-name-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.ing-name-link:hover {
  color: var(--primary);
  text-decoration: underline;
}
