/* Visual Snow Syndrome Next-Gen Simulator Stylesheet */
:root {
  --bg-dark: #0a0c10;
  --panel-bg: rgba(13, 17, 23, 0.90);
  --panel-border: rgba(56, 139, 253, 0.25);
  --panel-hover: rgba(56, 139, 253, 0.4);
  --accent-cyan: #38bdf8;
  --accent-cyan-glow: rgba(56, 189, 248, 0.35);
  --accent-emerald: #10b981;
  --accent-purple: #a855f7;
  --accent-rose: #f43f5e;
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --text-sub: #c9d1d9;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-sans);
  color: var(--text-main);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Viewport Canvas Layering */
#canvas-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: crosshair;
}

#gl-canvas, #particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#particle-canvas {
  pointer-events: none;
  z-index: 2;
}

/* Comparison Split Slider */
#split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan-glow), 0 0 24px var(--accent-cyan);
  z-index: 10;
  cursor: ew-resize;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

#split-handle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0f172a;
  border: 2px solid var(--accent-cyan);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  font-size: 14px;
  pointer-events: none;
}

.split-label {
  position: absolute;
  top: 24px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  z-index: 9;
}

#label-normal {
  left: 24px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
}

#label-vss {
  right: 24px;
  background: rgba(30, 27, 75, 0.85);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #c084fc;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.25);
}

/* Top Navigation Bar */
#top-bar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 6px 16px;
  border-radius: 30px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  max-width: 96vw;
}

.logo-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
}

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

@keyframes pulse-dot {
  0%, 100% { opacity: 0.6; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); box-shadow: 0 0 12px var(--accent-cyan); }
}

.top-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-sub);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.top-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: var(--text-main);
}

.top-btn.active {
  background: var(--accent-cyan);
  color: #04101c;
  border-color: var(--accent-cyan);
  font-weight: 600;
}

/* Language Toggle Button */
.lang-toggle-btn {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--accent-cyan);
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 14px;
  font-size: 11.5px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.lang-toggle-btn:hover {
  background: rgba(56, 189, 248, 0.22);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

/* Floating Control Drawer / HUD Panel */
#hud-panel {
  position: absolute;
  top: 74px;
  right: 20px;
  width: 400px;
  max-height: calc(100vh - 96px - var(--safe-bottom));
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  z-index: 25;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

#hud-panel.collapsed {
  transform: translateX(calc(100% + 30px));
  opacity: 0;
  pointer-events: none;
}

#hud-header {
  padding: 13px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hud-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
}

.hud-toggle-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 6px;
}

.hud-toggle-close:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

/* Tabs inside HUD */
.hud-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
  flex: 1;
  padding: 9px 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-sub);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.05);
}

/* HUD Content Scrollable Body */
.hud-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.hud-body::-webkit-scrollbar {
  width: 5px;
}
.hud-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* Control Groups with Master Toggles */
.control-section {
  margin-bottom: 22px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 12px 14px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.section-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-content {
  transition: opacity 0.25s ease, filter 0.25s ease;
}

.section-content.disabled {
  opacity: 0.32;
  pointer-events: none;
  filter: grayscale(0.7);
}

.control-row {
  margin-bottom: 14px;
}
.control-row:last-child {
  margin-bottom: 4px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
}

.control-title {
  color: var(--text-sub);
  font-weight: 500;
}

.indicator-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
}

/* Qualitative Clinical Badges */
.badge-tier {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.tier-off {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.2);
}

.tier-subtle {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
}

.tier-moderate {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}

.tier-pronounced {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.35);
}

.tier-severe {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.35);
}

/* Custom Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  transition: background 0.2s;
  cursor: pointer;
}

input[type="range"]:hover {
  background: rgba(255, 255, 255, 0.2);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
  cursor: pointer;
  border: 2px solid #0f172a;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
  cursor: pointer;
  border: 2px solid #0f172a;
}

/* Custom Select & Form Invariants */
select, input[type="file"], input[type="text"] {
  font-size: 16px !important; /* Invariant: Prevent iOS auto-zoom */
}

.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select {
  width: 100%;
  padding: 8px 36px 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 12.5px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.custom-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  width: 14px;
  height: 14px;
  fill: var(--text-muted);
}

/* Toggle Switches */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.3s;
  border-radius: 20px;
}

.slider-toggle:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider-toggle {
  background-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

input:checked + .slider-toggle:before {
  transform: translateX(18px);
  background-color: #0f172a;
}

/* Presets Grid */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 8px;
  border-radius: 8px;
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preset-btn:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent-cyan);
  color: var(--text-main);
  transform: translateY(-1px);
}

.preset-desc {
  font-size: 9.5px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Environment Cards */
.env-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.env-card {
  position: relative;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-sub);
}

.env-card:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  color: var(--text-main);
}

.env-card.active {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
  font-weight: 700;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.env-icon {
  font-size: 18px;
  display: block;
  margin-bottom: 4px;
}

.env-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 2px;
}

.env-symptom-tag {
  display: inline-block;
  font-size: 9px;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 4px;
  padding: 1px 5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* File Upload Button */
.upload-btn-wrapper {
  margin-top: 10px;
}

.upload-btn {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: var(--text-sub);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  display: block;
}

.upload-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.05);
}

/* Floating HUD Open Trigger */
#hud-open-btn {
  position: absolute;
  top: 74px;
  right: 20px;
  z-index: 24;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--accent-cyan);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

#hud-open-btn:hover {
  background: rgba(56, 189, 248, 0.15);
}

/* Action Buttons / Share / Reset */
.btn-action {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.btn-primary {
  background: var(--accent-cyan);
  color: #04101c;
}
.btn-primary:hover {
  background: #7dd3fc;
  box-shadow: 0 0 16px var(--accent-cyan-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Toast Notification */
#toast {
  position: absolute;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  border: 1px solid var(--accent-cyan);
  color: var(--text-main);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  z-index: 100;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

#toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Info Modal */
#info-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px;
}

#info-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #0d1117;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  width: 100%;
  max-width: 660px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-sub);
}

.modal-body h3 {
  color: var(--accent-cyan);
  font-size: 15.5px;
  margin-top: 18px;
  margin-bottom: 8px;
}
.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body ul, .modal-body ol {
  padding-left: 20px;
  margin-bottom: 14px;
}

.modal-body li {
  margin-bottom: 6px;
}

.modal-body strong {
  color: var(--text-main);
}

/* Responsive Rules */
@media (max-width: 768px) {
  #top-bar {
    top: 8px;
    padding: 6px 10px;
    gap: 6px;
  }
  .logo-tag span {
    display: none;
  }
  #hud-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 72vh;
    border-radius: 20px 20px 0 0;
    padding-bottom: var(--safe-bottom);
  }
  #hud-panel.collapsed {
    transform: translateY(100%);
  }
  #hud-open-btn {
    top: auto;
    bottom: calc(20px + var(--safe-bottom));
    right: 20px;
  }
  .split-label {
    top: 56px;
    font-size: 10px;
    padding: 4px 10px;
  }
}
