:root {
  --space-bg: #1C2D35;
  --space-card: rgba(0, 0, 0, 0.2);
  --gold: #D4AF37;
  --gold-dim: #9A7B33;
  --amber: #FF922B;
  --amber-glow: rgba(255, 146, 43, 0.4);
  --copper: #D4A373;
  --vellum: #E8E0D0;
  --slate: #2C3E50;
  --accent-blue: #34495E;
  --glass: rgba(255, 255, 255, 0.03);
  --border: rgba(212, 175, 55, 0.2);

  /* New Colors */
  --cta-title: #eee0cf;
  --subtext-labels: #C18761;

  /* Layout Constants */
  --gutter: 1.5rem;
  --custom-cursor: url('../svg/custom-cursor.svg') 0 0, crosshair;
}

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

body {
  background-color: var(--space-bg);
  color: var(--vellum);
  font-family: 'Outfit', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  margin: 0;
  overflow-x: hidden;
}

/* ── BACKGROUND ELEMENTS ── */
.bg-celestial-stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 720px;
  /* Aligns roughly with the bottom of the dateBar */
  background-image: url('../svg/stars.svg');
  background-repeat: repeat;
  background-size: 300px 300px;
  opacity: 1;
  pointer-events: none;
  z-index: -2;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 70%, rgba(0, 0, 0, 0));
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 70%, rgba(0, 0, 0, 0));
}

.bg-rotating-wheel {
  position: absolute;
  top: -180px;
  right: -180px;
  width: 700px;
  height: 700px;
  opacity: 0.4;
  pointer-events: none;
  z-index: -1;
  animation: slow-rotate 180s linear infinite;
}

.bg-rotating-wheel img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes slow-rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ── HEADER ── */
header {
  width: 100%;
  padding: 3rem var(--gutter) 2rem;
  text-align: center;
  position: relative;
  background: linear-gradient(to bottom, rgba(11, 14, 20, 0.9), transparent);
  box-sizing: border-box;
}

header h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: 0.3em;
  color: #f4ebdd;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(241, 199, 172, 0.2);
  margin-bottom: 0.5rem;
}

header p {
  font-size: 1.1rem;
  color: var(--subtext-labels);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 300;
}

/* ── APP CONTAINER ── */
.container {
  width: 100%;
  max-width: 1200px;
  padding: 0 var(--gutter) 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: relative;
  box-sizing: border-box;
}

/* ── INPUT PANEL ── */
.input-card {
  background: var(--space-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  position: relative;
}

.input-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.form-grid {
  display: grid;
  grid-template-columns: 180px 140px 1fr 140px;
  gap: 1.5rem;
  align-items: start;
}

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

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

.helper-text {
  font-size: 0.7rem;
  color: var(--gold-dim);
  margin-top: 6px;
  min-height: 1em;
  font-family: 'Outfit', sans-serif;
}

.input-group {
  display: flex;
  flex-direction: column;
  position: relative;
}

.input-group label {
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  color: var(--subtext-labels);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-card input,
.input-card select {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--vellum);
  font-size: 0.95rem;
  font-family: 'Outfit', sans-serif;
  outline: none;
  transition: all 0.3s ease;
  height: 48px;
}

.input-card input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.15);
  background: rgba(0, 0, 0, 0.55);
}

.input-card input::-webkit-inner-spin-button {
  filter: brightness(0.7) sepia(1) hue-rotate(165deg) saturate(0.5);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.input-card input::-webkit-inner-spin-button:hover {
  opacity: 1;
}

.input-card input::-webkit-calendar-picker-indicator {
  filter: invert(48%) sepia(9%) saturate(2361%) hue-rotate(5deg) brightness(92%) contrast(89%);
  cursor: pointer;
}

/* ── AUTOCOMPLETE ── */
#placeSearch {
  padding-right: 2.5rem;
}

.search-icon {
  position: absolute;
  right: 0.8rem;
  color: var(--gold-dim);
  font-size: 1.2rem;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-ring {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(212, 175, 55, 0.2);
  border-top: 2px solid var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: none;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #1C2D35; /* Solid background */
  border: 1px solid var(--border);
  border-radius: 6px;
  z-index: 200;
  max-height: 240px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
}

.autocomplete-item {
  padding: 0.8rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.autocomplete-item:hover {
  background: rgba(212, 175, 55, 0.1);
  color: var(--gold);
}

.btn-generate {
  grid-column: 1 / -1;
  background: #3F5762;
  color: var(--vellum);
  border: none;
  border-radius: 6px;
  padding: 1.2rem;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 1rem;
  position: relative;
  overflow: hidden;
}

.btn-generate:hover {
  background: var(--gold);
  color: #3F5762;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(212, 175, 55, 0.3);
}

.btn-generate:disabled,
.btn-generate.disabled {
  background: #2A3B44;
  color: rgba(232, 224, 208, 0.4);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-generate:disabled:hover,
.btn-generate.disabled:hover {
  background: #2A3B44;
  color: rgba(232, 224, 208, 0.4);
  transform: none;
  box-shadow: none;
}

.btn-generate:active {
  transform: translateY(0);
}

/* ── MAIN LAYOUT ── */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 3rem;
  align-items: start;
}

/* ── CHART DISPLAY ── */
.chart-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  position: sticky;
  top: 2rem;
  align-self: flex-start;
  z-index: 10;
}

.chart-container {
  width: 100%;
  aspect-ratio: 1;
  position: relative;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(255, 146, 43, 0.05) 0%, transparent 70%);
}

#chartSvg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 30px rgba(255, 146, 43, 0.15));
}

.amber-icon {
  /* Converts black to #FF922B and adds a celestial glow */
  filter: brightness(0) saturate(100%) invert(68%) sepia(85%) saturate(1917%) hue-rotate(346deg) brightness(102%) contrast(102%) drop-shadow(0 0 3px var(--amber));
}

.chart-info-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.5rem;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  border-radius: 8px; /* Matching panel radius */
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--vellum);
  width: 100%;
  white-space: nowrap;
  box-sizing: border-box;
}

.info-item .val {
  color: var(--subtext-labels);
  font-weight: 600;
  margin-left: 0.5rem;
}

/* ── SIDEBAR PANELS ── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.panel {
  background: var(--space-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.panel-header {
  background: rgba(212, 175, 55, 0.05);
  padding: 1rem var(--gutter);
  border-bottom: 1px solid var(--border);
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: var(--gold);
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-content {
  padding: 1.5rem var(--gutter);
}

/* ── PLANET LIST ── */
.planet-row {
  display: flex;
  align-items: center;
  padding: 0.8rem 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.planet-row.highlight {
  background: rgba(212, 175, 55, 0.15);
}

.planet-row:last-child {
  border-bottom: none;
}

.planet-glyph {
  font-size: 1.4rem;
  width: 40px;
  text-align: center;
  filter: drop-shadow(0 0 5px currentColor);
}

.planet-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.planet-name {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--vellum);
}

.planet-pos {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  color: var(--subtext-labels);
}

.sign-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.sign-glyph {
  font-size: 1.2rem;
}

.sign-name {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

/* ── MOON PHASE ── */
.moon-header {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(90deg, var(--amber-glow), transparent);
  padding: 1rem;
  border-radius: 8px;
}

.moon-visual {
  font-size: 2rem;
  filter: drop-shadow(0 0 10px var(--amber));
}

.moon-text {
  display: flex;
  flex-direction: column;
}

.moon-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--gold);
  letter-spacing: 0.1em;
}

.moon-name {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 600;
}

/* ── FOOTER ── */
footer {
  padding: 4rem 1rem;
  text-align: center;
  opacity: 0.5;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.6;
}

/* ── RESPONSIVE ── */
@media (max-width: 1000px) {
  .main-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .sidebar {
    order: 2;
    padding-top: 2rem;
  }

  .chart-section {
    order: 1;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--space-bg);
    padding: 1rem var(--gutter) 1.5rem var(--gutter);
    gap: 24px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
  }

  /* Vanishing effect mask */
  .chart-section::after {
    content: '';
    position: absolute;
    bottom: -50px;
    left: 0;
    width: 100%;
    height: 50px;
    background: linear-gradient(to bottom, var(--space-bg) 20%, transparent 100%);
    pointer-events: none;
    z-index: 101;
  }

  .chart-container {
    padding: 0;
    max-width: 500px;
    width: 100%;
  }

  .chart-info-bar {
    gap: 0.8rem;
    padding: 0.8rem var(--gutter);
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    justify-content: center;
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
  }

  .info-item span:first-child {
      display: none; /* Hide 'Born:', 'Time:' etc on very small screens to save space */
  }
  
  .info-item::before {
      content: attr(data-label);
      display: inline;
      margin-right: 4px;
  }

  header h1 {
    letter-spacing: 0.1em;
  }

  .input-card {
    padding: 1.5rem var(--gutter);
    margin: 0 var(--gutter);
  }

  .panel-header br {
    display: none;
  }
  
  .header-title-stack, .toggle-label-stack {
    line-height: 1.4 !important;
    white-space: nowrap;
  }
}

/* ── ULTRA-WIDE BREAKPOINT (MASTER VIEW) ── */
@media (min-width: 1600px) {
  .container {
    max-width: 1800px;
  }

  .main-layout {
    grid-template-columns: 1fr 850px;
    gap: 4rem;
  }

  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
  }

  /* Allow the accuracy note to span both columns */
  #accuracy-note {
    grid-column: span 2;
  }

  .chart-container {
    max-width: 750px;
    margin: 0 auto;
  }
}

.btn-icon {
  margin-left: 0.5rem;
  cursor: pointer;
  opacity: 0.6;
  transition: 0.2s;
}

.btn-icon:hover {
  opacity: 1;
  color: var(--gold);
}

.hidden {
  display: none !important;
}

/* ── GLOW EFFECTS ── */
/* ── ASPECTS ── */
.aspect-row {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: var(--custom-cursor);
  user-select: none;
}

.aspect-type {
  color: var(--cta-title);
  font-weight: 500;
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.aspect-planets {
  color: var(--vellum);
  opacity: 0.8;
}

.stellium-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 1.5rem;
}

.stellium-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.stellium-tag {
  display: inline-block;
  background: var(--amber-glow);
  color: var(--amber);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: 'Cinzel', serif;
  border: 1px solid var(--amber);
  transition: all 0.2s ease;
  cursor: var(--custom-cursor);
  user-select: none;
}

/* ── TOOLTIP ── */
#chartTooltip {
  position: fixed;
  background: #1c2d35 !important; /* Solid Slate for Delicate but Opaque look */
  border: 1px solid var(--border);
  color: var(--vellum);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 10000;
  display: none;
  backdrop-filter: blur(5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  font-family: 'Outfit', sans-serif;
  opacity: 1 !important;
}

#chartTooltip .tt-name {
  color: var(--cta-title);
  font-weight: 600;
  margin-right: 5px;
}

#chartTooltip .tt-pos {
  color: var(--subtext-labels);
}

#chartTooltip .tt-keys {
  display: block;
  font-size: 0.75rem;
  color: #D4AF37;
  margin-top: 4px;
}

#chartTooltip .tt-rulers {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(212, 175, 55, 0.15);
  font-size: 0.85rem;
  line-height: 1.4;
}

#chartTooltip .tt-ruler-label {
  display: block;
  color: var(--subtext-labels);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 6px;
}

#chartTooltip .tt-ruler-label:first-child {
  margin-top: 0;
}

#chartTooltip .tt-ruler-value {
  display: block;
  color: var(--vellum);
  font-size: 0.9rem;
  margin-top: 1px;
}

#chartTooltip .tt-ruler-sub {
  display: block;
  color: var(--vellum);
  font-size: 0.85rem;
  margin-top: 1px;
}

#chartTooltip .tt-ruler-sub-label {
  color: #C9BB62;
}

/* ── HOUSE HIGHLIGHTING ── */
.house-visual-sector {
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 1, 1); /* Faster fade out */
}

.house-visual-sector.active {
  opacity: 0.15; /* Increased to 15% for uniformity */
  transition: opacity 0.33s cubic-bezier(0, 0, 0.2, 1); /* Snappier fade in */
}

.sign-visual-sector {
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 1, 1);
}

.sign-visual-sector.active {
  opacity: 0.15; /* Standardized 15% glow */
  transition: opacity 0.33s cubic-bezier(0, 0, 0.2, 1);
}

.aspect-line-visual {
  transition: stroke-width 0.3s, opacity 0.3s;
}

.aspect-line-visual.active {
  stroke-width: 3.5 !important;
  opacity: 1 !important;
}

/* ── ENTRANCE ANIMATIONS ── */
@keyframes chartEntrance {
  from { opacity: 0; transform: scale(0.98); transform-origin: center; }
  to { opacity: 1; transform: scale(1); transform-origin: center; }
}

.planet-trigger.new-item, .aspect-trigger.new-item {
  animation: chartEntrance 0.33s cubic-bezier(0, 0, 0.2, 1) forwards;
}

/* ── TOGGLE SWITCH ── */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  transform: translateY(-1px);
}

.toggle-pill {
  background: #3F5762;
  border: 1px solid #696F53;
  width: 50px;
  height: 24px;
  border-radius: 31px;
  position: relative;
  transition: all 200ms ease-in-out;
  overflow: hidden;
  box-sizing: border-box;
}

.toggle-container.active .toggle-pill {
  background: #686030;
  border: 1px solid #D4AF37;
}

.toggle-container.disabled {
  pointer-events: none;
  opacity: 0.5;
}

.toggle-container.disabled .toggle-pill {
  background: #2A3B44;
  border-color: rgba(212, 175, 55, 0.1);
}

.toggle-thumb {
  background: #1C2D35;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0.5px solid rgba(255,255,255,0.1);
}

.toggle-container.active .toggle-thumb {
  left: 26px; /* Symmetrical: 50 - 2 (left) - 20 (thumb) - 2 (right) = 46 total active range */
}

.toggle-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  transition: opacity 150ms ease;
  pointer-events: none;
  margin: 0;
  padding: 0;
}

.toggle-icon.moon {
  color: #E8E0D0;
  opacity: 1;
}

.toggle-icon.sun {
  color: #D4AF37;
  opacity: 0;
  transform: translate(-46%, -43%); /* Optical centering fudge */
}

.toggle-container.active .toggle-icon.moon {
  opacity: 0;
}

.toggle-container.active .toggle-icon.sun {
  opacity: 1;
}

/* ── MINI TOGGLE FOR SIDEBAR ── */
.mini-toggle {
  width: 34px;
  height: 18px;
  border-radius: 10px;
  background: #3F5762;
  border: 1px solid rgba(212, 175, 55, 0.2);
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  flex-shrink: 0;
  margin-right: 12px;
}

.mini-toggle.active {
  background: #686030;
  border-color: var(--gold);
}

.mini-toggle-thumb {
  width: 14px;
  height: 14px;
  background: #1C2D35;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 1px;
  transform: translateY(-50%);
  transition: left 0.2s ease-in-out;
}

.mini-toggle.active .mini-toggle-thumb {
  left: 17px;
  background: #1C2D35;
}

.extended-divider {
  margin: 1.5rem 0 0.8rem;
  border-top: none; /* Removed the line above as requested */
  position: relative;
  height: 20px;
}

.extended-divider span {
  position: absolute;
  top: 0;
  left: 0; /* Left justified as requested */
  background: transparent;
  padding: 0;
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  color: var(--gold-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
