/* ============================================================================
   SHADCN/UI & VERCEL MODAL BACKDROP & DIALOGS (ROUNDED-XL + MICRO-SCALING)
   ============================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 28;
  background: rgba(0, 0, 0, 0.50);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: shadcnBackdropIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.side-card {
  position: fixed;
  top: calc(max(6px, env(safe-area-inset-top)) + 72px);
  left: 16px;
  z-index: 15;
  width: 356px;
  max-width: calc(100vw - 32px);
  background: #09090b;
  border: 1px solid #27272a;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
}

.modern-dialog {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  width: 440px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-radius: 12px;
  background: #09090b;
  border: 1px solid #27272a;
  animation: shadcnModalIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Keep CPU/GPU performance dialog docked in top-left without full-screen blur backdrop */
#perf-card.modern-dialog {
  top: calc(max(6px, env(safe-area-inset-top)) + 72px);
  left: 16px;
  transform: none;
  width: 380px;
  animation: shadcnDropdownIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.dialog-desc {
  font-size: 13px;
  line-height: 1.5;
  color: #a1a1aa;
  margin-top: 4px;
}

.modal-footer-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #27272a;
  flex-shrink: 0;
}

.btn-modal-secondary {
  background: transparent;
  color: #e4e4e7;
  border: 1px solid #27272a;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-modal-secondary:hover {
  background: #27272a;
  color: #fafafa;
}

.btn-modal-primary {
  background: #10b981;
  color: #09090b;
  border: 1px solid #10b981;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn-modal-primary:hover {
  background: #059669;
  border-color: #059669;
  color: #fafafa;
}

.dialog-scroll-body {
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #27272a transparent;
}

.dialog-scroll-body::-webkit-scrollbar {
  width: 5px;
}

.dialog-scroll-body::-webkit-scrollbar-thumb {
  background: #27272a;
  border-radius: 99px;
}

.side-drawer {
  position: fixed;
  top: calc(max(6px, env(safe-area-inset-top)) + 72px);
  right: 16px;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 74px);
  z-index: 15;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: #09090b;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid #27272a;
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
}

.card-header, .drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #27272a;
  flex-shrink: 0;
}

.card-tag {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #10b981;
  margin-bottom: 3px;
}

.card-header h2, .drawer-header h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #fafafa;
}

.close-btn {
  background: transparent;
  color: #a1a1aa;
  border: 1px solid transparent;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.close-btn:hover {
  background: #27272a;
  color: #fafafa;
}

.card-body {
  font-size: 13px;
  line-height: 1.5;
  color: #d4d4d8;
}

/* Logical Menu Sections inside Dialogs */
.menu-section {
  background: rgba(24, 24, 27, 0.6);
  border: 1px solid #27272a;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.section-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #e6f2e8;
}

.section-badge {
  font-size: 10px;
  font-weight: 700;
  color: #9ec8a2;
  background: rgba(66, 158, 80, 0.16);
  border: 1px solid rgba(110, 231, 135, 0.25);
  padding: 2px 7px;
  border-radius: 99px;
}

/* Segmented Control (Base Map Selector) */
.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 3px;
}

.gfx-tier-control {
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 4px;
}

.gfx-tier-control .seg-btn {
  padding: 6px 6px;
  font-size: 11.5px;
  white-space: nowrap;
}

.seg-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.seg-btn:hover {
  color: #fff;
}

.seg-btn.active {
  background: rgba(66, 158, 80, 0.32);
  border-color: rgba(110, 231, 135, 0.55);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* Dimmed / unsuitable graphics tier button based on hardware profiling */
.seg-btn.dimmed-tier:not(.active) {
  opacity: 0.38;
  filter: grayscale(0.65);
  border: 1px dashed rgba(255, 165, 80, 0.35);
  color: #8c988f;
}

.seg-btn.dimmed-tier:not(.active):hover {
  opacity: 0.65;
  color: #d6e0d9;
}

.dropdown-item.dimmed-tier {
  opacity: 0.42;
  color: #8c988f;
}

.dropdown-item.active-tier {
  color: #6ee787;
  font-weight: 700;
}

.gfx-hw-info {
  margin-top: 6px;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11px;
  color: #b7c8bc;
  line-height: 1.38;
}

.gfx-hw-info strong {
  color: #ecfdf5;
  font-weight: 700;
}

/* Modern Toggle Switch Rows */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.12s ease;
}

.toggle-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.toggle-text strong {
  font-size: 12.5px;
  font-weight: 600;
  color: #f0f5f1;
  line-height: 1.25;
}

.toggle-text small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.25;
}

.toggle-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 38px;
  height: 22px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 99px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.18s ease;
}

.toggle-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #d8e2dc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), background 0.18s ease;
}

.toggle-row input[type="checkbox"]:checked {
  background: var(--accent-green);
  border-color: var(--accent-green-bright);
}

.toggle-row input[type="checkbox"]:checked::after {
  transform: translateX(16px);
  background: #ffffff;
}

/* Modern Sliders */
.slider-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.compact-slider {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 0;
}

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #dce6de;
}

.slider-head strong {
  color: #ffd8b0;
  font-weight: 700;
}

.slider-label input[type="range"] {
  accent-color: var(--accent-orange);
  width: 100%;
  height: 5px;
  cursor: pointer;
}

.slider-label small {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Info Card Stats & Buttons */
#info-card.compartment-dialog {
  width: 448px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  border-color: rgba(52, 211, 153, 0.45);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.82), 0 0 0 1px rgba(16, 185, 129, 0.16);
}

#info-card.compartment-dialog #info-body {
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #27272a transparent;
}

#info-card.compartment-dialog #info-body::-webkit-scrollbar {
  width: 5px;
}

#info-card.compartment-dialog #info-body::-webkit-scrollbar-thumb {
  background: #27272a;
  border-radius: 99px;
}

.comp-dialog-sub {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: #d4d4d8;
}

.comp-coord-pill {
  font-size: 11px;
  color: #9ca3af;
}

.comp-nav-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: rgba(24, 24, 27, 0.75);
  border: 1px solid #27272a;
  border-radius: 10px;
  padding: 4px;
}

.comp-nav-btn {
  background: rgba(255, 255, 255, 0.06);
  color: #e4e4e7;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.comp-nav-btn:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.22);
  border-color: rgba(52, 211, 153, 0.55);
  color: #ffffff;
}

.comp-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.comp-mode-switch {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.comp-mode-btn {
  background: transparent;
  color: #a1a1aa;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.comp-mode-btn:hover {
  color: #ffffff;
}

.comp-mode-btn.active {
  background: rgba(16, 185, 129, 0.28);
  border-color: rgba(52, 211, 153, 0.6);
  color: #ffffff;
}

.comp-stat-grid-6 {
  margin: 2px 0;
  gap: 6px;
}

.stat-box.highlight-stat {
  background: rgba(16, 185, 129, 0.11);
  border-color: rgba(52, 211, 153, 0.32);
}

.stat-box.highlight-stat .stat-val {
  color: #6ee7b7;
}

.comp-species-card {
  background: rgba(24, 24, 27, 0.65);
  border: 1px solid #27272a;
  border-radius: 10px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comp-species-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: #e4e4e7;
}

.comp-si-badge {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: #a7f3d0;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
}

.comp-species-bar {
  display: flex;
  width: 100%;
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: #18181b;
}

.sp-seg.sp-gran { background: #10b981; }
.sp-seg.sp-tall { background: #f59e0b; }
.sp-seg.sp-lov  { background: #84cc16; }

.comp-species-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #d4d4d8;
}

.sp-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.sp-dot.sp-gran { background: #10b981; }
.sp-dot.sp-tall { background: #f59e0b; }
.sp-dot.sp-lov  { background: #84cc16; }

.comp-section-box {
  background: rgba(24, 24, 27, 0.72);
  border: 1px solid #27272a;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.comp-section-box.why-age-box {
  background: rgba(14, 33, 24, 0.55);
  border-color: rgba(52, 211, 153, 0.32);
}

.comp-sec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.comp-sec-title {
  font-size: 12px;
  font-weight: 700;
  color: #f0fdf4;
}

.comp-rule-badge {
  display: inline-block;
  align-self: flex-start;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: #a7f3d0;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.comp-explain-p {
  font-size: 12px;
  line-height: 1.48;
  color: #e4e4e7;
}

.comp-explain-note {
  font-size: 11.5px;
  line-height: 1.45;
  color: #bbf7d0;
  background: rgba(0, 0, 0, 0.28);
  border-left: 3px solid #10b981;
  padding: 6px 8px;
  border-radius: 0 6px 6px 0;
}

.comp-source-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.comp-source-item {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 7px 9px;
}

.src-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #86efac;
  margin-bottom: 2px;
}

.src-title code, .src-desc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
  color: #fde68a;
}

.src-desc {
  font-size: 11.5px;
  line-height: 1.42;
  color: #d4d4d8;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.stat-box {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
}

.stat-box .stat-lbl {
  font-size: 10.5px;
  color: var(--text-muted);
}

.stat-box .stat-val {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.card-footer {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.dialog-action-row {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.full-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.full-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.full-btn.accent-btn {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
  color: #111812;
  font-weight: 700;
}

.full-btn.accent-btn:hover {
  background: var(--accent-orange-hover);
}

.full-btn.danger-outline-btn {
  background: rgba(229, 83, 75, 0.18);
  border-color: rgba(229, 83, 75, 0.55);
  color: #ffc5c2;
}

.full-btn.danger-outline-btn:hover {
  background: rgba(229, 83, 75, 0.32);
}

/* Tabs in Team Drawer */
.drawer-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  padding: 3px;
  margin-bottom: 10px;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  background: rgba(255, 125, 25, 0.22);
  border-color: rgba(255, 125, 25, 0.65);
  color: #fff;
}

.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.drawer-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.item-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 3px;
  scrollbar-width: thin;
}

.list-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.list-item:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 125, 25, 0.45);
}

.item-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.item-thumb {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 125, 25, 0.65);
  flex-shrink: 0;
}

.item-title {
  font-size: 13px;
  font-weight: 700;
  color: #f3f7f4;
}

.item-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.hunter-row {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hunter-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-orange);
  width: 20px;
}

.hunter-input {
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  color: #fff;
  padding: 5px 7px;
  font-size: 12px;
  width: 115px;
  user-select: text;
}

.hunter-select {
  background: rgba(0, 0, 0, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  color: #ffd8b5;
  padding: 5px 4px;
  font-size: 11.5px;
  flex: 1;
  min-width: 0;
}

.drawer-box {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}


/* ============================================================================
   SYSTEM & PERFORMANCE (CPU / GPU %) DIALOG
   ============================================================================ */
.perf-meter-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.perf-meter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.perf-meter-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #e2ebe4;
}

.perf-meter-val {
  font-size: 16px;
  font-weight: 800;
  color: #6ee787;
  font-variant-numeric: tabular-nums;
}

.perf-bar-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.perf-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #34d399 0%, #6ee787 100%);
  border-radius: 99px;
  transition: width 0.25s ease, background 0.25s ease;
}

.perf-bar-fill.load-med {
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.perf-bar-fill.load-high {
  background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
}

.perf-meter-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .side-card,
  #info-card.side-card,
  #info-card.compartment-dialog {
    top: auto;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 64px);
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 144px);
    overflow-y: auto;
    padding: 14px;
  }

  .side-drawer {
    left: 8px;
    right: 8px;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 64px);
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 144px);
    top: auto;
    padding: 14px;
  }

  .modern-dialog,
  #perf-card.modern-dialog {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    animation: shadcnModalIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 76px);
    padding: 15px;
  }

  .scope-overlay-card {
    top: auto;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 64px);
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    max-height: calc(100dvh - 140px);
    overflow-y: auto;
    padding: 12px;
  }

  .scope-canvas-wrap {
    width: 220px;
    height: 220px;
  }
}


/* ============================================================================
   DIALOG & MODAL COMPONENT RULES (EXTRACTED FROM INLINE HTML)
   ============================================================================ */
.tree-algo-details {
  margin: 6px 0 8px;
  background: rgba(24, 24, 27, 0.72);
  border: 1px solid #27272a;
  border-radius: 10px;
  padding: 2px 10px;
}

.tree-algo-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 2px;
  font-size: 12.5px;
  font-weight: 600;
  color: #e4e4e7;
  user-select: none;
}

.tree-algo-summary::-webkit-details-marker {
  display: none;
}

.tree-algo-summary > span:first-child::before {
  content: "▸ ";
  color: #34d399;
  font-weight: 700;
}

.tree-algo-details[open] .tree-algo-summary > span:first-child::before {
  content: "▾ ";
}

.tree-algo-pref-group {
  margin: 4px 0 10px 0;
}

.tree-algo-pref-label {
  font-size: 11.5px;
  opacity: 0.92;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#tree-algo-active-badge {
  font-size: 10px;
}

.tree-algo-seg-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stand-seg-mode-btn {
  text-align: left;
  padding: 8px 10px;
}

#tree-algo-desc-box {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(216, 240, 224, 0.82);
  background: rgba(15, 28, 20, 0.65);
  border: 1px solid rgba(90, 190, 120, 0.25);
  border-radius: 8px;
  padding: 7px 9px;
}

.manual-wind-toggle-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

#btn-delete-moose-prefs {
  width: auto;
  padding: 9px 14px;
}

#scope-stat-windsrc {
  font-size: 11px;
}

.stat-val-sm {
  font-size: 12.5px;
}

.perf-gfx-hdr-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.perf-gfx-hdr-lbl {
  font-size: 11.5px;
  opacity: 0.9;
}

.perf-hint-note {
  font-size: 11px;
  color: #9eb0a2;
  margin-top: 8px;
  line-height: 1.4;
}

#qr-code-img {
  display: block;
  border-radius: 8px;
}

#mobile-url-status {
  font-size: 11.5px;
  color: #a1a1aa;
  word-break: break-all;
  margin-top: 10px;
}

#mobile-lan-status {
  font-size: 11px;
  color: #71717a;
  word-break: break-all;
}
