:root {
  --bg-color-1: #f1f5f9;
  --bg-color-2: #e2e8f0;
  --text-color: #1e293b;
  --glass-bg: rgba(255, 255, 255, 0.95);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-shadow: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.05);
  --accent-color: #fed7aa;
  /* Very light orange */
  --accent-hover: #ffedd5;
  --zodiac-wheel-bg: #ffffff;
  --grid-border: #f1f5f9;
  --grid-border-dark: #e2e8f0;

  /* Planetary colors */
  --color-sun: #eab308;
  --color-moon: #475569;
  --color-mercury: #fbbf24;
  --color-venus: #a78bfa;
  --color-mars: #ef4444;
  --color-jupiter: #f97316;
  --color-saturn: #d97706;
  --color-uranus: #38bdf8;
  --color-neptune: #818cf8;
  --color-pluto: #94a3b8;
  --color-node: #10b981;
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  background: #F8F9FB;
  color: var(--text-color);
  display: flex;
}

body.mode-3d {
  background: radial-gradient(circle at center,
      var(--bg-color-2),
      var(--bg-color-1));
}

/* Sleek Panels - Used only for expanded content now */
.glass-panel {
  padding: 1.25rem;
  z-index: 10;
}

.controls {
  width: max-content;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    width 0.3s ease,
    padding 0.3s ease;

  /* Make the main wrapper the single, floating control */
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--glass-shadow);
  padding: 0.2rem !important;
  z-index: 10;
}

.controls.hidden {
  display: none !important;
}

#shared-chart-panel.hidden {
  display: none !important;
}

.top-left-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: auto;
}

.info-line {
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.8;
  white-space: nowrap;
  pointer-events: none;
  font-weight: 500;
  transition: opacity 0.3s ease;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
  z-index: 1;
  /* subtle text outline to remain readable over background */
}

.panel-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  padding-top: 0.5rem;
  margin-bottom: 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-color);
  opacity: 0.5;
}

.controls.collapsed .panel-title,
.controls.collapsed .collapsible-content {
  display: none !important;
}

/* Collapsible inner content */
.collapsible-content {
  padding: 0.5rem 0.5rem 0.2rem 0.5rem;
  margin-bottom: 0.2rem;
  width: 0;
  min-width: 100%;
  box-sizing: border-box;
}

/* Unified Control Styling */
.bottom-control-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
}

.date-time-group {
  flex: 1;
}

.settings-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-color);
  opacity: 0.7;
  padding: 0 0.5rem;
}

.toggle-panel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-color);
  opacity: 0.7;
  padding: 0.4rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-panel-btn:hover {
  opacity: 1;
  background: #e2e8f0;
}

.toggle-panel-btn svg {
  pointer-events: none;
}

.controls.collapsed .control-group {
  margin-bottom: 0;
  gap: 0;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.location-group {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

.input-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
}

label {
  font-size: 0.75rem;
  color: var(--text-color);
  opacity: 0.7;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

input[type="datetime-local"],
input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 0.4rem 0.5rem;
  background: #f8fafc;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--text-color);
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(254, 215, 170, 0.4);
}

#location-search::placeholder,
#prog-location-search::placeholder {
  color: #dc2626;
  opacity: 0.8;
}

/* Custom DateTime Component - stripping inner borders as it sits inside the unified row wrapper */
.custom-datetime {
  width: 100%;
  padding: 0.2rem 0.3rem;
  background: transparent;
  border: none;
  /* Removed inner border */
  border-radius: 6px;
  color: var(--text-color);
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
}

.custom-datetime:focus-within {
  outline: none;
}

.custom-datetime.is-active {
  cursor: ns-resize;
}

.dt-part {
  padding: 0 0.1rem;
  border-radius: 4px;
  cursor: ns-resize;
  transition:
    background 0.2s,
    color 0.2s;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  display: inline-block;
  text-align: center;
}

.dt-part:focus,
.dt-part:hover {
  background: var(--accent-color);
  color: var(--text-color);
  outline: none;
}

/* Mobile Vertical Stripe */
.datetime-stripe-container {
  position: absolute;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  height: 150px;
  width: 50px;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  pointer-events: auto;
  z-index: 10000;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.datetime-stripe-container.hidden {
  display: none !important;
}

#chart-panel:has(.datetime-stripe-container:not(.hidden)),
#prognostic-container:has(.datetime-stripe-container:not(.hidden)) {
  z-index: 50 !important;
}

.datetime-stripe-container::-webkit-scrollbar {
  display: none;
}

.stripe-item {
  flex: 0 0 30px;
  /* fixed height for predictable math */
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-color);
  opacity: 0.5;
  font-size: 0.9em;
  transition: opacity 0.2s, font-size 0.2s, color 0.2s;
  scroll-snap-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.stripe-item.active {
  opacity: 1;
  font-size: 1.1em;
  font-weight: bold;
  color: var(--accent-color);
}

.dt-separator {
  opacity: 0.7;
  padding: 0 0.1rem;
  user-select: none;
  -webkit-user-select: none;
}

/* Full Edit Input */
.dt-full-edit-input {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% + 36px);
  min-width: 100px;
  height: calc(100% + 16px);
  box-sizing: border-box;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px dashed var(--accent-color);
  border-radius: 4px;
  color: var(--text-color);
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.85rem;
  text-align: center;
  padding: 0 4px !important;
  margin: 0;
  outline: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  letter-spacing: normal;
}

.dt-group {
  position: relative;
}

.dt-group.editing .dt-part,
.dt-group.editing .dt-separator {
  opacity: 0 !important;
  pointer-events: none;
}

.dt-edit-tooltip {
  position: absolute;
  bottom: calc(100% + 5px);
  top: auto;
  left: 50%;
  transform: translateX(-50%);
  background: var(--glass-bg);
  color: var(--text-color);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--glass-border);
  pointer-events: none;
  white-space: nowrap;
  opacity: 0.9;
  z-index: 5000;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* Location Tabs Styles */
.location-tabs-container {
  margin: 0.5rem 0;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
}

.location-tabs-header {
  display: flex;
  background: transparent;
}

.location-tab-btn {
  flex: 1;
  background: rgba(0, 0, 0, 0.03);
  border: none;
  border-right: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  padding: 0.5rem;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-color);
  opacity: 0.6;
  cursor: pointer;
  transition: all 0.2s ease;
}

.location-tab-btn:first-child {
  border-top-left-radius: 6px;
}

.location-tab-btn:last-child {
  border-right: none;
  border-top-right-radius: 6px;
}

.location-tab-btn:hover {
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.4);
}

.location-tab-btn.active {
  background: transparent;
  opacity: 1;
  color: #e27c45;
  border-bottom: 1px solid transparent;
}

.location-tabs-content {
  padding: 0.5rem;
  display: grid;
  min-height: 85px;
  /* Ensures height doesn't shrink when switching to shorter tabs */
  align-items: start;
}

.location-tab-pane {
  grid-area: 1 / 1;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.location-tab-pane.active {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
  z-index: 1;
}

/* Location Dropdown Styles */
.dropdown-content {
  position: absolute;
  top: 100%;
  left: 0;
  width: max-content;
  max-width: calc(100vw - 20px);
  min-width: 200px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--glass-shadow);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10000;
  margin-top: 4px;
}

#location-dropdown, #prog-location-dropdown {
  top: auto;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 4px;
}

.dropdown-content.hidden {
  display: none;
}

#saved-charts-dropdown {
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}

#saved-charts-dropdown.hidden {
  display: none;
}

.dropdown-item {
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--grid-border);
  color: var(--text-color);
  transition: background 0.2s ease;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover,
.dropdown-item.selected {
  background: var(--accent-color);
  color: var(--text-color);
}

/* Bottom Pane & Icons */
.bottom-pane {
  width: max-content;
  display: flex;
  flex-direction: row;
  gap: 10px;
  /* same as gap between prognostic container and chart panel */
  padding: 0.2rem !important;
  /* same as prognostic wrapper */
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--glass-shadow);
  transition: all 0.3s ease;
  z-index: 100;
}

.icon-btn {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  color: var(--text-color);
  opacity: 0.8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  box-shadow: var(--glass-shadow);
}

.icon-btn:hover {
  background: #ffffff;
  opacity: 1;
}

.icon-btn.active {
  background: var(--accent-color);
  color: var(--text-color);
  box-shadow: 0 2px 6px rgba(254, 215, 170, 0.6);
  opacity: 1;
}

#prog-ds-btn.active {
  background: rgba(77, 161, 255, 0.15);
  color: #4da1ff;
  box-shadow: 0 1px 3px rgba(77, 161, 255, 0.2);
}

#prog-solar-btn.active {
  background: rgba(52, 168, 83, 0.15);
  color: #34a853;
  box-shadow: 0 1px 3px rgba(52, 168, 83, 0.2);
}

#prog-transit-btn.active {
  background: rgba(147, 51, 234, 0.15);
  color: #9333ea;
  box-shadow: 0 1px 3px rgba(147, 51, 234, 0.2);
}

.icon-btn>svg {
  width: 24px;
  height: 24px;
  pointer-events: none;
}

.icon-btn>svg.hidden {
  display: none;
}

.mode-toggle-btn {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0 0.1rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  gap: 0;
  box-shadow: var(--glass-shadow);
  line-height: 1.2;
}

.mode-toggle-btn:hover {
  background: #ffffff;
}

.mode-label {
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  transition: all 0.2s ease;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-label.active {
  background: var(--accent-color);
  color: var(--text-color);
  box-shadow: 0 2px 6px rgba(254, 215, 170, 0.6);
}

.mode-divider {
  display: none;
}

/* Data / Aspects Panel - restored to standalone panel style */
.data-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: max-content;
  max-width: 90vw;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--glass-shadow);
  padding: 0.8rem 1rem;
  z-index: 2500;
}

.data-panel h2 {
  font-size: 0.75rem;
  text-align: center;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-color);
  opacity: 0.8;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.2rem;
  margin-top: 0;
  margin-bottom: 0.1rem;
}

.data-panel.hidden {
  display: none;
}

.aspect-tabs.hidden {
  display: none !important;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 9999;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: #ea580c;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-overlay.hidden {
  display: none;
}

/* Main Viewport */
#viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  touch-action: none;
  /* Let clicks pass to bottom-pane */
}

.view {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view.active {
  opacity: 1;
  pointer-events: auto;
  /* Re-enable clicks for the active chart */
}

#chart-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0px;
  /* Optional padding so it doesn't hit the exact edge */
}

#canvas-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Formatting for 2D Chart Elements */
.aspect-grid {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.aspect-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--grid-border);
}

#prognostic-toggle-btn.active {
  background: var(--accent-color) !important;
  color: var(--text-color) !important;
  box-shadow: 0 2px 6px rgba(254, 215, 170, 0.6) !important;
  opacity: 1 !important;
  border-radius: 8px;
}

.prog-mode-btn {
  position: relative;
}

.pin-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.5;
  transition: all 0.2s ease;
  box-shadow: var(--glass-shadow);
  color: var(--text-color);
  z-index: 2;
}

.prog-mode-btn:hover .pin-btn,
.pin-btn.pinned {
  opacity: 1;
}

.pin-btn:hover {
  transform: scale(1.1);
  background: #ffffff;
}

.pin-btn svg {
  width: 10px;
  height: 10px;
  pointer-events: none;
}

.pin-btn.pinned {
  background: var(--accent-color);
  color: var(--text-color);
  border-color: var(--accent-color);
}

/* Dialog Windows */
.dialog-window {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  min-width: 300px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: var(--glass-shadow);
  padding: 1.25rem;
  z-index: 5000;
}

.dialog-window.hidden {
  display: none;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
}

.dialog-header h2 {
  font-size: 0.85rem;
  text-align: left;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-color);
  opacity: 0.8;
  margin: 0;
}

.dialog-content {
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.9;
  line-height: 1.4;
}

/* Print Styles */
@media print {

  .bottom-pane,
  #chart-panel,
  #prognostic-container,
  #top-left-controls>div:first-child,
  .dialog-window {
    display: none !important;
  }
}

.mobile-only {
  display: none !important;
}

.compact-mobile #settings-btn,
.compact-mobile #mode-btn,
.compact-mobile #info-btn {
  display: none !important;
}

body:not(.mode-3d) .compact-mobile #share-chart-btn {
  display: none !important;
}

.compact-mobile #mobile-more-btn {
  display: flex !important;
}

/* Universal Compact Wrap (for narrow desktops and iPads) */
#bottom-controls-container.compact-flex-wrap {
  flex-wrap: wrap !important;
  justify-content: flex-start !important;
  gap: 10px !important;
}

#bottom-controls-container.compact-flex-wrap #bottom-left-controls {
  display: contents !important;
}

#bottom-controls-container.compact-flex-wrap #bottom-right-controls {
  margin-left: auto !important;
  display: block !important;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  .mobile-only {
    display: flex !important;
  }

  /* UNIVERSAL MOBILE FLEX SYSTEM for Bottom Controls */
  #bottom-controls-container {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    align-items: flex-end !important;
    gap: 4px !important;
    bottom: 10px;
    left: 5px;
    right: 5px;
  }

  #bottom-left-controls {
    display: contents !important;
    /* Bypass wrapper so children act as flex items in the main container */
  }

  /* Compact controls for mobile (10% scaled down from desktop defaults) */
  .custom-datetime {
    padding: 0.18rem 0.27rem !important;
    font-size: 0.76rem !important;
  }

  .dt-part {
    padding: 0 !important;
  }

  .icon-btn {
    padding: 0.27rem !important;
  }

  .icon-btn>svg {
    width: 22px !important;
    height: 22px !important;
  }

  /* Make the margin inside the custom-datetime divider tighter on mobile */
  #prognostic-custom-datetime-container>div[style*="margin"] {
    margin: 0 0.36rem !important;
  }

  #prognostic-controls {
    padding-right: 0 !important;
  }

  /* Scale down inputs, labels, and toggles proportionally (10% smaller) */
  input[type="number"],
  input[type="text"] {
    padding: 0.36rem 0.45rem !important;
    font-size: 0.76rem !important;
  }

  label {
    font-size: 0.68rem !important;
  }

  .location-tab-btn {
    padding: 0.45rem !important;
    font-size: 0.68rem !important;
  }

  .mode-toggle-btn {
    font-size: 0.68rem !important;
  }

  .panel-title {
    font-size: 0.68rem !important;
  }

  #chart-panel {
    margin: 0 !important;
    width: max-content !important;
    max-width: 100% !important;
    order: 1;
    /* By default */
  }

  #prognostic-container {
    display: flex !important;
    justify-content: flex-start !important;
    margin: 0 !important;
    width: max-content !important;
    max-width: 100% !important;
    order: 2;
    /* Follows chart-panel unless expanded */
  }

  #prognostic-wrapper {
    margin: 0 !important;
  }

  #bottom-right-controls {
    position: relative !important;
    min-width: 82px !important;
    /* Space for the 2 visible icons (approx 41px each) */
    height: 41px !important;
    margin-bottom: 0 !important;
    margin-left: auto !important;
    /* Push to right edge */
    display: block !important;
    order: 3;
  }

  /* Make panels dynamically sized on mobile */
  .controls,
  #prognostic-wrapper {
    width: max-content !important;
    max-width: calc(100vw - 4px) !important;
  }

  /* -------------------------------------------------------------
     ACTIVE STATE (Prognostic Expanded)
     - Order Prognostic first and force it to wrap
     ------------------------------------------------------------- */
  body.prog-active #prognostic-container {
    order: 0;
    /* Push to top */
    width: 100% !important;
    /* Force next elements to a new line */
  }

  .bottom-pane {
    position: absolute !important;
    bottom: 0 !important;
    right: 0 !important;
    width: max-content !important;
    margin: 0 !important;
    z-index: 1000 !important;
    flex-wrap: nowrap !important;
    flex-direction: row !important;
    gap: 2px !important;
    /* Ensure no wrapping inside bottom pane when expanded out of layout */
  }

  /* Re-align the toggle wrapper to left */
  #prognostic-toggle-wrapper {
    padding-left: 0.2rem;
  }

  /* Aspects table on mobile: semi-transparent, covers part of screen */
  .data-panel {
    top: 10px !important;
    bottom: auto !important;
    /* Leave space for bottom toggle button */
    left: auto !important;
    right: 10px !important;
    width: max-content !important;
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100% - 90px) !important;
    background: rgba(255, 255, 255, 0.70) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    padding: 1.12rem !important;
  }

  .data-panel h2 {
    text-align: center;
    font-size: 0.76rem !important;
    padding-bottom: 0.45rem !important;
    margin-bottom: 0.22rem !important;
  }

  /* Aspect table scaled down 20% via zoom since its elements use inline pixel styling */
  .aspect-matrix {
    zoom: 0.8 !important;
  }

  #aspect-tabs button {
    padding: 0.27rem 0.54rem !important;
    font-size: 0.72rem !important;
  }

  .top-left-controls {
    max-width: calc(100vw - 20px);
    align-items: flex-start;
    /* Better alignment when text wraps heavily */
  }

  #top-left-controls>div:first-child {
    flex-shrink: 0;
  }

  #saved-charts-dropdown {
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
  }

  .info-line {
    white-space: normal;
    word-break: break-word;
    font-size: clamp(0.7rem, 3vw, 0.85rem);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
    margin-top: 1px;
  }
}

/* iPad Responsive Styles - specifically scale down aspects table to fit vertically on iPad */
@media only screen and (min-width: 769px) and (max-width: 1366px) and (any-pointer: coarse) {
  .aspect-matrix {
    zoom: 0.82 !important;
  }

  #aspect-tabs button {
    padding: 0.3rem 0.6rem !important;
    font-size: 0.75rem !important;
  }

  .data-panel h2 {
    font-size: 0.76rem !important;
    padding-bottom: 0.45rem !important;
    margin-bottom: 0.22rem !important;
  }
}