/* ==========================================================================
   DESIGN TOKENS & CSS VARIABLES
   ========================================================================== */
:root {
  color-scheme: dark;

  /* Color Palette - Laboratory Dark Mode */
  --bg-primary: #0a0d0e;
  --bg-secondary: #12181a;
  --bg-card: rgba(18, 25, 28, 0.75);
  --bg-card-hover: rgba(24, 34, 38, 0.85);
  --border-color: rgba(45, 68, 62, 0.4);
  --border-highlight: rgba(57, 255, 120, 0.35);

  /* Vibrant Accent Hues */
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --bright-green: #39ff78;
  --bright-green-glow: rgba(57, 255, 120, 0.3);
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.25);
  --amber: #f59e0b;
  --rose: #f43f5e;
  --purple: #a855f7;

  /* Typography Colors */
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  /* Fonts */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout & Transitions */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: dark;
  background-color: #0a0d0e;
  scrollbar-color: #2d443e #0a0d0e;
}

body {
  color-scheme: dark;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.glow-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: 
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 25%, rgba(6, 182, 212, 0.07) 0%, transparent 45%),
    radial-gradient(circle at 50% 85%, rgba(168, 85, 247, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.mono {
  font-family: var(--font-mono);
}

/* ==========================================================================
   CONTAINER & LAYOUT
   ========================================================================== */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* ==========================================================================
   HEADER & NAVIGATION
   ========================================================================== */
.app-header {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.brand h1 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 30%, var(--bright-green) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.2rem;
  font-weight: 400;
}

.voltage-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--bright-green);
  border: 1px solid rgba(57, 255, 120, 0.25);
  margin-bottom: 0.4rem;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bright-green);
  box-shadow: 0 0 8px var(--bright-green);
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
}

.header-meta {
  display: flex;
  gap: 0.5rem;
}

.tag {
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tag.accent {
  background: rgba(6, 182, 212, 0.1);
  color: var(--cyan);
  border-color: rgba(6, 182, 212, 0.25);
}

/* Tabs */
.nav-tabs {
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 0.85rem;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: #ffffff;
  background: rgba(16, 185, 129, 0.15);
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.35);
}

/* ==========================================================================
   CARDS & GRIDS
   ========================================================================== */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.grid-layout {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-highlight);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.card-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.step-badge {
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   INPUTS, SLIDERS & CONTROLS
   ========================================================================== */
.input-group {
  margin-bottom: 1.4rem;
}

.input-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.vol-input-box {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.custom-number-input {
  width: 96px;
  background: rgba(10, 14, 16, 0.9);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--bright-green);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  text-align: right;
  transition: var(--transition);
  outline: none;
}

.custom-number-input:hover {
  border-color: rgba(57, 255, 120, 0.4);
}

.custom-number-input:focus {
  border-color: var(--bright-green);
  box-shadow: 0 0 0 2px var(--bright-green-glow);
  background: rgba(18, 25, 28, 0.95);
}

.unit-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.val-badge {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.val-badge.accent {
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan);
  border-color: rgba(6, 182, 212, 0.3);
}

.val-badge.secondary-badge {
  background: rgba(16, 185, 129, 0.1);
  color: var(--bright-green);
  border-color: rgba(16, 185, 129, 0.25);
  font-size: 0.8rem;
  opacity: 0.85;
}


/* Risk badge for high-concentration state */
.val-badge.danger-badge {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.35);
}

/* Concentration slider mark positions (5 marks across 0.05–0.50 range = 0%, 25%, 50%, 75%, 100%) */
#conc-slider-marks .mark-item:nth-child(1) {
  left: 10px;
}
#conc-slider-marks .mark-item:nth-child(1) .mark-label {
  transform: translateX(16px);
}
#conc-slider-marks .mark-item:nth-child(2) {
  left: calc(10px + (100% - 20px) * 0.237); /* ratio 0.156 on 0.05–0.50 scale */
}
#conc-slider-marks .mark-item:nth-child(3) {
  left: calc(10px + (100% - 20px) * 0.444); /* ratio 0.25 */
}
#conc-slider-marks .mark-item:nth-child(4) {
  left: calc(10px + (100% - 20px) * 0.667); /* ratio 0.35 */
}
#conc-slider-marks .mark-item:nth-child(5) {
  left: calc(100% - 10px);
}
#conc-slider-marks .mark-item:nth-child(5) .mark-label {
  transform: translateX(-20px);
}

.helper-text {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  line-height: 1.4;
}

/* Select */
.custom-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(10, 14, 16, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.custom-select:focus {
  border-color: var(--bright-green);
  box-shadow: 0 0 0 3px var(--bright-green-glow);
}

/* Sliders */
.custom-range {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
  margin: 0.5rem 0;
}

.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bright-green);
  box-shadow: 0 0 10px var(--bright-green-glow);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.custom-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider-marks {
  position: relative;
  width: 100%;
  height: 28px;
  margin-top: 0.25rem;
}

.slider-marks .mark-item {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.slider-marks .mark-tick {
  width: 2px;
  height: 6px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 1px;
  margin-bottom: 4px;
  transition: var(--transition);
}

.slider-marks .mark-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
  transition: var(--transition);
}

.slider-marks .mark-item:hover .mark-label {
  color: var(--text-main);
}
.slider-marks .mark-item:hover .mark-tick {
  background: var(--bright-green);
}

.slider-marks .mark-item.active .mark-label {
  color: var(--bright-green);
  font-weight: 700;
}
.slider-marks .mark-item.active .mark-tick {
  background: var(--bright-green);
  height: 8px;
  box-shadow: 0 0 6px var(--bright-green);
}

.slider-marks .mark-item:nth-child(1) {
  left: 10px;
}
.slider-marks .mark-item:nth-child(1) .mark-label {
  transform: translateX(18px);
}

.slider-marks .mark-item:nth-child(2) {
  left: calc(10px + (100% - 20px) * 0.25);
}

.slider-marks .mark-item:nth-child(3) {
  left: 50%;
}

.slider-marks .mark-item:nth-child(4) {
  left: calc(10px + (100% - 20px) * 0.75);
}

.slider-marks .mark-item:nth-child(5) {
  left: calc(100% - 10px);
}
.slider-marks .mark-item:nth-child(5) .mark-label {
  transform: translateX(-18px);
}

/* Preset Buttons */
.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  transition: var(--transition);
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.preset-btn.active {
  background: rgba(16, 185, 129, 0.18);
  color: var(--bright-green);
  border-color: rgba(57, 255, 120, 0.35);
}

/* Notice Badges */
.chelation-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: #a7f3d0;
  margin-top: 0.6rem;
}

.mode-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 1rem;
}

.mode-badge.liquid {
  background: rgba(6, 182, 212, 0.1);
  color: var(--cyan);
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.mode-badge.dry {
  background: rgba(245, 158, 11, 0.1);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* ==========================================================================
   SCALE TABLE & CHECKLIST
   ========================================================================== */
.scale-actions {
  display: flex;
  gap: 0.4rem;
}

.btn-sm {
  background: rgba(16, 185, 129, 0.15);
  color: var(--bright-green);
  border: 1px solid rgba(57, 255, 120, 0.3);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-sm:hover {
  background: rgba(16, 185, 129, 0.25);
}

.btn-sm.secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border-color: rgba(255, 255, 255, 0.1);
}

.btn-sm.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.table-responsive {
  overflow-x: auto;
}

.scale-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.scale-table th {
  text-align: left;
  padding: 0.75rem 0.85rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.scale-table td {
  padding: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: var(--transition);
}

.scale-table tr.completed td {
  opacity: 0.45;
  background: rgba(0, 0, 0, 0.15);
}

.scale-table tr.completed td.ing-name {
  text-decoration: line-through;
}

.text-right {
  text-align: right;
}

.ing-name {
  font-weight: 600;
  color: var(--text-main);
}

.ing-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.comp-weight {
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.cum-weight {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--bright-green);
  font-size: 1.05rem;
}

.custom-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--emerald);
}

/* Instructions */
.instructions-box {
  margin-top: 1.5rem;
  background: rgba(10, 14, 16, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.instructions-box h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.instructions-box ol {
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.instructions-box li {
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

/* ==========================================================================
   DILUTION & ELEMENTAL CARDS
   ========================================================================== */
.elemental-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.element-card {
  background: rgba(10, 14, 16, 0.7);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.element-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
}

.element-card.mg::before { background: var(--emerald); }
.element-card.k::before { background: var(--purple); }
.element-card.na::before { background: var(--cyan); }

.element-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.element-symbol {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: #ffffff;
}

.element-name {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.element-val {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.element-footer {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.2rem;
}

.compound-tag {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.rda-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--emerald);
}

.math-callout {
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.math-callout h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.mono-formula {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cyan);
  background: rgba(6, 182, 212, 0.08);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
}

.math-subtext {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
}

.osmolarity-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1rem;
}

.osmo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.osmo-pill {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.osmo-pill.optimal {
  background: rgba(16, 185, 129, 0.2);
  color: var(--emerald);
}

.osmo-pill.hypertonic {
  background: rgba(244, 63, 94, 0.2);
  color: var(--rose);
}

.osmo-pill.flush-danger {
  background: #ef4444 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.6) !important;
}

.osmolarity-box.flush-danger {
  border-color: rgba(239, 68, 68, 0.7) !important;
  background: rgba(239, 68, 68, 0.14) !important;
}

.card.flush-danger {
  border-color: rgba(239, 68, 68, 0.75) !important;
  background: rgba(239, 68, 68, 0.08) !important;
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.28), inset 0 0 15px rgba(239, 68, 68, 0.08) !important;
  animation: pulse-flush 2.5s infinite ease-in-out;
  transition: all 0.3s ease;
}

@keyframes pulse-flush {
  0%, 100% {
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.2);
  }
  50% {
    border-color: rgba(239, 68, 68, 0.95);
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.38);
  }
}

#osmo-description {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.hover-term {
  position: relative;
  display: inline-block;
  color: var(--amber);
  border-bottom: 1px dashed var(--amber);
  cursor: help;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.hover-term:hover,
.hover-term:focus {
  color: #fcd34d;
  border-bottom-style: solid;
}

.hover-term .term-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #0f172a;
  border: 1px solid rgba(245, 158, 11, 0.4);
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.8), 0 0 16px rgba(245, 158, 11, 0.2);
  color: #f8fafc;
  padding: 0.75rem 0.95rem;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: normal;
  width: 320px;
  max-width: min(320px, 90vw);
  z-index: 9999;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  font-family: var(--font-sans);
  text-align: left;
}

.hover-term .term-tooltip strong {
  color: #fbbf24;
  display: block;
  margin-bottom: 0.25rem;
}

.hover-term .term-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #0f172a transparent transparent transparent;
}

.hover-term:hover .term-tooltip,
.hover-term:focus .term-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.osmo-pill.hover-term {
  border-bottom: none !important;
  color: #ffffff !important;
  cursor: help;
  position: relative;
}

.osmo-pill.hover-term:hover,
.osmo-pill.hover-term:focus {
  color: #ffffff !important;
  border-bottom-style: none !important;
}

.osmo-pill .term-tooltip {
  right: 0;
  left: auto;
  bottom: calc(100% + 12px);
  transform: translateY(4px);
  width: 320px;
  max-width: min(320px, 85vw);
}

.osmo-pill:hover .term-tooltip,
.osmo-pill:focus .term-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.osmo-pill .term-tooltip::after {
  right: 24px;
  left: auto;
  transform: none;
}

/* ==========================================================================
   BIOCHEMISTRY & SOURCING TAB
   ========================================================================= */
.science-filter-bar {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.5);
  border-radius: var(--radius-md);
  backdrop-filter: blur(8px);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(71, 85, 105, 0.4);
  color: var(--text-muted);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.filter-pill:hover {
  color: #ffffff;
  border-color: rgba(148, 163, 184, 0.6);
  background: rgba(51, 65, 85, 0.6);
  transform: translateY(-1px);
}

.filter-pill .pill-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.filter-pill.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.25);
}

.filter-pill.active .pill-count {
  background: var(--accent);
  color: #0f172a;
  font-weight: 700;
}

.filter-pill.safety.active {
  background: rgba(244, 63, 94, 0.18);
  border-color: var(--rose);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.3);
}

.filter-pill.safety.active .pill-count {
  background: var(--rose);
  color: #ffffff;
}

.filter-pill.physiology.active {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--bright-green);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.3);
}

.filter-pill.physiology.active .pill-count {
  background: var(--bright-green);
  color: #0f172a;
}

.filter-pill.physics.active {
  background: rgba(6, 182, 212, 0.18);
  border-color: var(--cyan);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.3);
}

.filter-pill.physics.active .pill-count {
  background: var(--cyan);
  color: #0f172a;
}

.category-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.category-tag.safety {
  background: rgba(244, 63, 94, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.category-tag.physiology {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.category-tag.physics {
  background: rgba(6, 182, 212, 0.15);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.info-card.filtered-out {
  display: none !important;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 1.5rem;
}

@media (max-width: 600px) {
  .info-grid {
    grid-template-columns: 1fr;
  }
}

.info-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: #ffffff;
}

.info-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.info-list, .safety-list {
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.info-list li, .safety-list li {
  margin-bottom: 0.5rem;
}

.danger-card {
  border-color: rgba(244, 63, 94, 0.3);
  background: rgba(244, 63, 94, 0.05);
}

.danger-card h3 {
  color: #fca5a5;
}

.amber-card {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.05);
}

.amber-card h3 {
  color: #fcd34d;
}

.emerald-card {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}

.emerald-card h3 {
  color: #6ee7b7;
}

.cyan-card {
  border-color: rgba(6, 182, 212, 0.3);
  background: rgba(6, 182, 212, 0.05);
}

.cyan-card h3 {
  color: #67e8f9;
}

.comparison-table-wrap {
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.comparison-table th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.comparison-table td {
  padding: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.app-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 1.5rem 0 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.footer-badge-wrap {
  margin-bottom: 0.25rem;
}

.app-footer .disclaimer {
  font-size: 0.75rem;
}
