:root {
  --bg: #030612;
  --panel: rgba(14, 21, 48, 0.88);
  --panel-border: rgba(201, 168, 106, 0.38);
  --gold: #c9a86a;
  --gold2: #ebd094;
  --ink: #eef1ff;
  --muted: #a4adcf;
  --teal: #6fd3b5;
  --radius: 16px;
  --radius-full: 9999px;
}
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
html, body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Tajawal', system-ui, sans-serif;
}

/* Full-Viewport Canvas */
#observatoryCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  cursor: grab;
  touch-action: none;
}
#observatoryCanvas:active {
  cursor: grabbing;
}

/* Consolidated Compact Header Stack (Guaranteed Zero Clipping) */
.observatory-header {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(98vw, 1520px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

/* Glassmorphic Floating HUDs */
.hud-bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  flex-wrap: wrap;
}

/* Top HUD */
.top-hud {
  width: 100%;
  justify-content: space-between;
  padding: 6px 14px;
  gap: 8px;
}

.header-group {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.btn-sidebar-toggle {
  padding: 4px 11px;
  font-size: 12px;
  border-color: rgba(201, 168, 106, 0.55);
}

/* Sub HUD — Prayer Strip */
.sub-hud {
  width: 100%;
  justify-content: center;
  background: rgba(10, 16, 40, 0.96);
  border: 1px solid rgba(201, 168, 106, 0.45);
  padding: 5px 14px;
  gap: 10px;
}

.btn-now {
  background: rgba(180, 40, 40, 0.25);
  border: 1px solid rgba(255, 90, 90, 0.65);
  color: #ffb4b4;
  font-weight: 800;
}
.btn-now.active, .btn-now:hover {
  background: #c52626;
  border-color: #ff7575;
  color: #ffffff;
  box-shadow: 0 0 16px rgba(255, 80, 80, 0.6);
}

.btn-season {
  background: rgba(22, 34, 76, 0.85);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  padding: 5px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s ease;
}
.btn-season:hover, .btn-season.active {
  background: var(--gold);
  color: #040714;
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(201, 168, 106, 0.4);
}

/* Right Collapsible Pro Control & Telemetry Sidebar */
.pro-sidebar {
  position: fixed;
  top: 104px;
  right: 12px;
  bottom: 14px;
  width: 325px;
  max-width: calc(100vw - 24px);
  z-index: 90;
  background: rgba(9, 15, 36, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(201, 168, 106, 0.42);
  border-radius: 16px;
  box-shadow: -8px 12px 35px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  direction: rtl;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}
.pro-sidebar.collapsed {
  transform: translateX(calc(100% + 28px));
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(201, 168, 106, 0.28);
  background: rgba(14, 22, 52, 0.8);
  flex-shrink: 0;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(201, 168, 106, 0.2);
  background: rgba(7, 12, 30, 0.6);
  flex-shrink: 0;
}
.sidebar-tab {
  background: rgba(20, 30, 68, 0.7);
  border: 1px solid rgba(201, 168, 106, 0.25);
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}
.sidebar-tab:hover {
  color: var(--ink);
  border-color: var(--gold);
}
.sidebar-tab.active {
  background: linear-gradient(135deg, rgba(201, 168, 106, 0.25), rgba(235, 208, 148, 0.16));
  border-color: var(--gold2);
  color: var(--gold2);
  font-weight: 800;
}

.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 168, 106, 0.45) transparent;
}
.sidebar-body::-webkit-scrollbar {
  width: 5px;
}
.sidebar-body::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 106, 0.4);
  border-radius: 9999px;
}

.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-section {
  background: rgba(15, 23, 54, 0.68);
  border: 1px solid rgba(201, 168, 106, 0.24);
  border-radius: 12px;
  padding: 10px 11px;
}
.sidebar-section-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--gold2);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(201, 168, 106, 0.18);
}

.sidebar-slider-block {
  margin-bottom: 8px;
}
.sidebar-slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 4px;
}
.sidebar-range {
  width: 100%;
}

.sidebar-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.sidebar-btn {
  width: 100%;
  justify-content: center;
  border-radius: 10px !important;
  padding: 6px 8px !important;
  font-size: 11.5px !important;
  text-align: center;
}

.sidebar-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-toggle-btn {
  width: 100%;
  justify-content: flex-start;
  border-radius: 10px !important;
  padding: 7px 11px !important;
  font-size: 12px !important;
}

/* Telemetry & Hijri Cards Embedded Inside Sidebar */
.telemetry-card {
  width: 100%;
  background: rgba(12, 20, 46, 0.85);
  border: 1px solid rgba(201, 168, 106, 0.35);
  border-radius: 12px;
  padding: 10px 12px;
  color: #e8ecf8;
  box-sizing: border-box;
  direction: rtl;
  transition: all 0.25s ease;
  font-family: 'Tajawal', system-ui;
}
.telemetry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(201, 168, 106, 0.25);
  padding-bottom: 5px;
  margin-bottom: 8px;
}
.btn-mini-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  padding: 0 4px;
  line-height: 1;
}
.btn-mini-toggle:hover {
  color: var(--gold2);
}
.telem-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  font-size: 11.5px;
  min-height: 22px;
  margin-bottom: 5px;
  gap: 10px;
}
.telem-label {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.telem-val {
  color: #ffffff;
  font-weight: 800;
  direction: ltr;
  text-align: left;
  white-space: nowrap;
}

/* Hijri Calendar Card */
.hijri-card {
  border-color: rgba(111, 211, 181, 0.45);
}

@media (max-width: 1080px) {
  .pro-sidebar {
    top: 142px;
    width: 300px;
  }
}
.prayer-hud {
  margin-top: 3px;
}
.prayer-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #c0c6e4;
  font-size: 11px;
}
.prayer-pill b {
  color: #ffffff;
  font-weight: 700;
  direction: ltr;
}
.prayer-pill.active {
  background: rgba(111, 211, 181, 0.22);
  border-color: #6fd3b5;
  color: #6fd3b5;
}
.prayer-pill.active b {
  color: #a8f0dc;
}

/* Side Action Buttons */
.side-triggers {
  position: absolute;
  top: 85px;
  left: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-hud {
  background: rgba(20, 30, 68, 0.92);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-hud:hover {
  background: var(--gold);
  color: #040714;
  border-color: var(--gold);
  transform: translateY(-2px);
}
.btn-hud[aria-pressed="true"] {
  background: var(--gold2);
  color: #040714;
  font-weight: 800;
}

/* Clock */
.hud-clock {
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.5px;
  background: rgba(4, 7, 20, 0.75);
  border: 1px solid var(--panel-border);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  color: var(--gold2);
}

/* Select & Inputs */
select.hud-select {
  background: rgba(18, 27, 60, 0.9);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  outline: none;
  cursor: pointer;
}
input[type="range"].hud-range {
  accent-color: var(--gold2);
  height: 6px;
  cursor: pointer;
}

/* Glassmorphic Collapsible Drawers (Fixed Left Slide-In Opposite Right Sidebar) */
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: auto;
  width: 460px;
  max-width: 90vw;
  background: rgba(9, 14, 34, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--panel-border);
  border-left: none;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 12px 0 45px rgba(0, 0, 0, 0.65);
}
.drawer.drawer-wide {
  width: 540px;
  max-width: 94vw;
}
#drawerAstrolabe {
  top: 54px;
  border-top: 1px solid var(--panel-border);
  border-top-right-radius: 14px;
}
.drawer.open {
  transform: translateX(0) !important;
}

.astro-readout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.astro-stat {
  background: rgba(16, 25, 58, 0.78);
  border: 1px solid rgba(201, 168, 106, 0.28);
  border-radius: 10px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.astro-stat span {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 600;
}
.astro-stat b {
  font-size: 12.5px;
  color: #ffffff;
  font-weight: 800;
}

.drawer-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(14, 21, 48, 0.7);
}
.drawer-header h3 {
  font-size: 18px;
  font-weight: 900;
  color: var(--gold2);
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  user-select: text;
}

/* Search & Chips inside Drawer */
.drawer-search {
  width: 100%;
  background: rgba(18, 27, 60, 0.85);
  border: 1px solid var(--panel-border);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: var(--radius-full);
  font-size: 14px;
  margin-bottom: 14px;
  outline: none;
}
.drawer-search:focus {
  border-color: var(--gold2);
}
.drawer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.drawer-chip {
  background: rgba(22, 33, 72, 0.7);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  cursor: pointer;
}
.drawer-chip.active {
  background: var(--gold2);
  color: #040714;
  font-weight: 800;
  border-color: var(--gold2);
}

.verse-card-hud {
  background: rgba(18, 27, 60, 0.65);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  transition: all 0.2s ease;
  cursor: pointer;
}
.verse-card-hud:hover {
  border-color: var(--gold2);
  transform: translateY(-2px);
  background: rgba(25, 37, 80, 0.85);
}
.verse-card-hud blockquote {
  font-family: 'Amiri', serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--gold2);
  margin-bottom: 8px;
}
.verse-card-hud .meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.verse-card-hud .exp {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 6px;
}
.verse-card-hud .prf {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--teal);
  border-right: 2px solid var(--teal);
  padding-right: 8px;
}

/* Mobile & Small Tablet Responsive Layout (Zero-Wrap Single-Strip HUDs + Full-Height dvh) */
@media (max-width: 768px) {
  .observatory-header {
    top: 6px;
    width: 98vw;
    gap: 4px;
  }

  .hud-bar {
    border-radius: 12px;
  }

  .top-hud,
  .sub-hud,
  .prayer-hud {
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(201, 168, 106, 0.45) transparent;
    padding: 5px 10px 7px !important;
    gap: 6px !important;
  }
  .prayer-hud > div {
    flex-wrap: nowrap !important;
    flex-shrink: 0;
    gap: 5px !important;
  }
  .prayer-hud > div > span,
  #prNextCard {
    white-space: nowrap;
    flex-shrink: 0;
  }
  .top-hud::-webkit-scrollbar,
  .sub-hud::-webkit-scrollbar,
  .prayer-hud::-webkit-scrollbar {
    height: 3px;
  }
  .top-hud::-webkit-scrollbar-thumb,
  .sub-hud::-webkit-scrollbar-thumb,
  .prayer-hud::-webkit-scrollbar-thumb {
    background: rgba(201, 168, 106, 0.45);
    border-radius: 9999px;
  }

  .header-group {
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 5px;
  }

  .hud-clock {
    font-size: 11.5px !important;
    padding: 3px 8px !important;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .btn-hud {
    padding: 4px 9px !important;
    font-size: 11px !important;
    white-space: nowrap;
    flex-shrink: 0;
  }

  #selectCity {
    max-width: 155px;
    min-width: 110px;
    font-size: 11px !important;
    padding: 3px 6px !important;
    text-overflow: ellipsis;
    flex-shrink: 0;
  }

  .prayer-pill {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 10.5px;
    padding: 2px 6px;
  }

  .pro-sidebar {
    top: auto !important;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 76dvh;
    border-radius: 18px 18px 0 0;
    z-index: 250;
  }

  .drawer {
    width: 100vw !important;
    max-width: 100vw !important;
    z-index: 1000;
  }

  .layers-hud {
    bottom: 8px;
    max-width: 96vw;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 4px 8px;
    gap: 6px;
  }
  .layers-hud::-webkit-scrollbar {
    display: none;
  }

  .astro-readouts {
    grid-template-columns: 1fr;
  }

  #cvDrawerAstro {
    width: 100%;
    height: auto;
    max-width: 340px;
  }
}
