/* =========================================================
   Moon UI — Final Mobile-first | No horizontal scroll
   Sidebar-safe fixed UI
   ========================================================= */

/* ---------- Hard containment ---------- */
.moon-app,
.moon-app *,
.moon-app *::before,
.moon-app *::after {
  box-sizing: border-box;
}

.moon-app {
  --moon-radius-lg: 18px;
  --moon-radius-md: 14px;
  --moon-radius-sm: 12px;
  --moon-pad: 0.85rem;
  --moon-safe-bottom: env(safe-area-inset-bottom, 0px);
  --moon-safe-top: env(safe-area-inset-top, 0px);
  --moon-safe-left: env(safe-area-inset-left, 0px);
  --moon-safe-right: env(safe-area-inset-right, 0px);

  width: 100%;
  max-width: min(1120px, 100%);
  margin: 0 auto;
  padding:
    0.65rem
    max(0.65rem, var(--moon-safe-right))
    calc(5.5rem + var(--moon-safe-bottom))
    max(0.65rem, var(--moon-safe-left));

  color: var(--text-main-color);
  position: relative;
  isolation: isolate;

  overflow-x: hidden;
  overflow-y: visible;
  min-width: 0;

  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* همه سکشن‌ها و کارت‌ها داخل عرض والد */
.moon-section,
.moon-hero-card,
.moon-hero-top,
.moon-hero-visual,
.moon-hero-main,
.moon-hero-metrics,
.moon-hero-chips,
.moon-hero-progress,
.moon-location-bar,
.moon-calendar-shell,
.moon-detail-shell,
.moon-detail-head,
.moon-detail-head-left,
.moon-detail-head-text,
.moon-detail-head-right,
.moon-tab-panels,
.moon-tab-panel,
.moon-table-card,
.moon-table,
.moon-tr,
.moon-empty,
.moon-json,
.moon-cards,
.moon-cal-grid,
.moon-weekdays,
.moon-tabs,
.moon-cal-header,
.moon-cal-title-wrap,
.moon-loc-info,
.moon-loc-actions {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.moon-section {
  margin-bottom: 0.9rem;
  overflow-x: hidden;
}

/* media containment */
.moon-app img,
.moon-app canvas,
.moon-app svg,
.moon-app video,
.moon-app pre,
.moon-app table {
  max-width: 100%;
}

.moon-app canvas {
  display: block;
  height: auto;
}

/* ---------- HERO ---------- */
.moon-hero-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--moon-radius-lg);
  background: var(--main-cards-bg);
  border: var(--main-cards-box-border);
  box-shadow: var(--main-cards-box-shadow);
  padding: var(--moon-pad);
}

.moon-hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 25%, rgba(0, 243, 255, 0.12), transparent 32%),
    radial-gradient(circle at 80% 15%, rgba(79, 172, 254, 0.12), transparent 28%),
    radial-gradient(circle at 70% 85%, rgba(255, 215, 0, 0.07), transparent 26%),
    linear-gradient(165deg, rgba(255,255,255,0.03), transparent 50%);
}

.moon-hero-top {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
  align-items: center;
}

.moon-hero-visual {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 150px;
  overflow: hidden;
}

.moon-orb-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: min(150px, 48vw);
  height: min(150px, 48vw);
  max-width: 100%;
  overflow: hidden;
}

#hero-moon-canvas {
  position: relative;
  z-index: 2;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  border-radius: 50%;
  filter:
    drop-shadow(0 10px 28px rgba(0, 0, 0, 0.45))
    drop-shadow(0 0 22px rgba(0, 243, 255, 0.18));
}

.moon-hero-glow {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  z-index: 1;
  filter: blur(14px);
  opacity: 0.5;
  transition: opacity .35s ease, transform .35s ease, background .35s ease;
  pointer-events: none;
}

.moon-hero-ring {
  position: absolute;
  inset: 2%;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 0 30px rgba(0, 243, 255, 0.05);
  pointer-events: none;
  z-index: 1;
}

.moon-hero-emoji {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.15rem;
  z-index: 3;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.55));
  line-height: 1;
  pointer-events: none;
}

.moon-hero-main {
  position: relative;
  overflow: hidden;
}

.moon-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-two-color);
  font-size: 0.78rem;
  margin-bottom: 0.4rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--neon-green, #00ff88);
  box-shadow: 0 0 12px var(--neon-green, #00ff88);
  animation: moonPulse 1.8s infinite;
}

@keyframes moonPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: .55; }
}

.moon-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 243, 255, 0.35);
  background: rgba(0, 243, 255, 0.08);
  color: var(--sub-menu-txt-color, #9be7ff);
  font-size: 0.7rem;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.moon-hero-title {
  font-size: clamp(1.15rem, 5vw, 2.05rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.3rem;
  line-height: 1.35;
  text-shadow: var(--text-shadow-color);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.moon-hero-sub {
  color: var(--text-two-color);
  margin: 0 0 0.8rem;
  line-height: 1.75;
  font-size: clamp(0.8rem, 3.4vw, 0.9rem);
  overflow-wrap: anywhere;
}

.moon-hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.moon-metric {
  background: var(--main-bg-dis, rgba(255,255,255,0.03));
  border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
  border-radius: var(--moon-radius-md);
  padding: 0.65rem 0.7rem;
  min-height: 70px;
  overflow: hidden;
}

.moon-metric .label {
  display: block;
  color: var(--text-two-color);
  font-size: 0.7rem;
  margin-bottom: 0.2rem;
}

.moon-metric .value {
  display: block;
  color: var(--text-main-color);
  font-size: clamp(0.84rem, 3.5vw, 0.98rem);
  font-weight: 800;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.moon-metric .hint {
  display: block;
  color: var(--neon-cyan, #00f2fe);
  font-size: 0.68rem;
  margin-top: 0.16rem;
  overflow-wrap: anywhere;
}

.moon-hero-progress {
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 0.75rem 0.8rem;
  overflow: hidden;
}

.moon-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  color: var(--text-two-color);
  font-size: 0.78rem;
}

.moon-progress-head > * {
  min-width: 0;
}

.moon-progress-head strong {
  color: var(--accent-neon, #00f3ff);
  overflow-wrap: anywhere;
}

.moon-progress-track {
  position: relative;
  height: 10px;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #111827, #1f2937 50%, #111827);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}

.moon-progress-fill {
  height: 100%;
  width: 0%;
  max-width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4facfe, #00f2fe 55%, #ffd700);
  box-shadow: 0 0 18px rgba(0, 242, 254, 0.4);
  transition: width .55s ease;
}

.moon-progress-marker {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent-neon, #00f3ff);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.8);
  left: 0%;
  transition: left .55s ease;
}

.moon-progress-labels {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.15rem;
  margin-top: 0.45rem;
  color: var(--text-two-color);
  font-size: 0.58rem;
  text-align: center;
}

.moon-progress-labels > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moon-hero-chips {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
  overflow: hidden;
}

.moon-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  max-width: 100%;
  padding: 0.36rem 0.62rem;
  border-radius: 999px;
  background: rgba(0, 243, 255, 0.07);
  border: 1px solid rgba(0, 243, 255, 0.2);
  color: var(--text-main-color);
  font-size: 0.72rem;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

.moon-chip strong {
  color: var(--neon-cyan, #00f2fe);
  font-weight: 700;
}

/* ---------- LOCATION BAR ---------- */
.moon-location-bar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: var(--main-cards-bg);
  border: var(--main-cards-box-border);
  box-shadow: var(--main-cards-box-shadow);
  border-radius: 16px;
  padding: 0.75rem 0.8rem;
  overflow: hidden;
}

.moon-loc-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.moon-loc-label {
  color: var(--text-two-color);
  font-size: 0.7rem;
}

.moon-loc-info strong {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.moon-loc-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.moon-loc-actions > * {
  min-width: 0;
  width: 100%;
}

/* ---------- BUTTONS ---------- */
/* .moon-btn {
  appearance: none;
  border: var(--main-btn-border-color, 1px solid transparent);
  background: var(--main-btn-color, linear-gradient(90deg,#00f2fe,#4facfe));
  color: var(--main-btn-text-color, #001018);
  box-shadow: var(--main-btn-shadow, none);
  border-radius: var(--moon-radius-sm);
  padding: 0.68rem 0.7rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  transition: .18s ease;
  white-space: normal;
  text-align: center;
  line-height: 1.35;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  touch-action: manipulation;
} 

.moon-btn:hover {
  background: var(--main-btn-color-hover, #00f2fe);
  color: var(--main-btn-txt-color-hover, #001018);
}

.moon-btn:active {
  transform: translateY(1px);
}

.moon-btn-ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(0, 243, 255, 0.28);
  box-shadow: none;
}

.moon-btn-ghost:hover {
  background: rgba(0, 243, 255, 0.12);
  color: #fff;
}

.moon-btn-sm {
  padding: 0.55rem 0.5rem;
  font-size: 0.76rem;
  border-radius: 11px;
} */

.moon-icon-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid rgba(0, 243, 255, 0.28);
  background: rgba(0, 243, 255, 0.06);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: .18s ease;
  display: inline-grid;
  place-items: center;
  padding: 0;
  touch-action: manipulation;
}

.moon-icon-btn:hover {
  background: rgba(0, 243, 255, 0.16);
}

/* ---------- CALENDAR ---------- */
.moon-calendar-shell,
.moon-detail-shell {
  background: var(--main-cards-bg);
  border: var(--main-cards-box-border);
  box-shadow: var(--main-cards-box-shadow);
  border-radius: 18px;
  padding: 0.75rem;
  overflow: hidden;
}

/* هدر تقویم: دکمه‌ها به لبه نچسبن */
.moon-cal-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "prev title next"
    "today today today";
  gap: 0.55rem 0.45rem;
  align-items: center;
  margin-bottom: 0.8rem;
  padding-inline: 0.1rem;
}

.moon-cal-header #btn-prev-month { grid-area: prev; }
.moon-cal-header #btn-next-month { grid-area: next; }

.moon-cal-title-wrap {
  grid-area: title;
  text-align: center;
  overflow: hidden;
  padding-inline: 0.2rem;
}

.moon-cal-nav-right {
  grid-area: today;
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  min-width: 0;
}

.moon-cal-nav-right .moon-btn {
  width: min(100%, 220px);
}

.moon-cal-title {
  margin: 0;
  font-size: clamp(0.92rem, 4vw, 1.08rem);
  line-height: 1.4;
  text-shadow: var(--text-shadow-color);
  overflow-wrap: anywhere;
}

.moon-cal-subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-two-color);
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.moon-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.18rem;
  margin-bottom: 0.35rem;
  color: var(--text-two-color);
  font-size: clamp(0.6rem, 2.7vw, 0.72rem);
  text-align: center;
}

.moon-weekdays > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moon-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.18rem;
  overflow: hidden;
}

.moon-day {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 58px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.14));
  padding: 0.22rem 0.05rem 0.2rem;
  cursor: pointer;
  transition: .16s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.06rem;
  overflow: hidden;
  color: inherit;
  font-family: inherit;
  touch-action: manipulation;
}

.moon-day:hover {
  border-color: rgba(0, 243, 255, 0.4);
  transform: translateY(-1px);
}

.moon-day.is-muted { opacity: 0.38; }

.moon-day.is-today {
  border-color: rgba(0, 255, 136, 0.55);
  box-shadow: inset 0 0 0 1px rgba(0, 255, 136, 0.14);
}

.moon-day.is-selected {
  border-color: rgba(0, 243, 255, 0.9);
  background:
    radial-gradient(circle at 50% 30%, rgba(0, 243, 255, 0.14), transparent 55%),
    linear-gradient(180deg, rgba(0, 243, 255, 0.08), rgba(0,0,0,0.16));
  box-shadow: 0 0 0 1px rgba(0, 243, 255, 0.2), 0 0 18px rgba(0, 243, 255, 0.1);
}

.moon-day.is-fullish::after,
.moon-day.is-newish::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.moon-day.is-fullish::after {
  background: var(--gold-glow, #ffd700);
  box-shadow: 0 0 8px var(--gold-glow, #ffd700);
}

.moon-day.is-newish::after {
  background: #64748b;
}

.moon-day-num {
  font-size: clamp(0.58rem, 2.5vw, 0.7rem);
  color: var(--text-two-color);
  font-weight: 700;
  line-height: 1.2;
}

.moon-day.is-selected .moon-day-num,
.moon-day.is-today .moon-day-num { color: #fff; }

.moon-day canvas {
  width: min(22px, 70%) !important;
  height: min(22px, 70%) !important;
  max-width: 100%;
  border-radius: 50%;
  flex: 0 0 auto;
}

.moon-day-illum {
  font-size: clamp(0.52rem, 2.3vw, 0.62rem);
  color: var(--neon-cyan, #00f2fe);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.moon-day-phase {
  display: none;
  font-size: 0.58rem;
  color: var(--text-two-color);
  text-align: center;
  max-width: 100%;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.08rem;
  line-height: 1.2;
}

.moon-cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  margin-top: 0.7rem;
  color: var(--text-two-color);
  font-size: 0.72rem;
}

.lg-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 0.28rem;
  vertical-align: middle;
  flex: 0 0 auto;
}

.lg-dot.today { background: var(--neon-green, #00ff88); box-shadow: 0 0 8px var(--neon-green, #00ff88); }
.lg-dot.selected { background: var(--accent-neon, #00f3ff); box-shadow: 0 0 8px var(--accent-neon, #00f3ff); }
.lg-dot.fullish { background: var(--gold-glow, #ffd700); }
.lg-dot.newish { background: #64748b; }

.moon-day.is-loading { pointer-events: none; }

.moon-day.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
  animation: moonShimmer 1.2s infinite;
}

@keyframes moonShimmer {
  from { transform: translateX(35%); }
  to { transform: translateX(-35%); }
}

/* ---------- DETAIL ---------- */
.moon-detail-head {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.moon-detail-head-left {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  overflow: hidden;
}

.moon-detail-head-text {
  flex: 1 1 auto;
  overflow: hidden;
}

#detail-moon-canvas {
  width: 56px !important;
  height: 56px !important;
  max-width: 28vw;
  border-radius: 50%;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 14px rgba(0, 243, 255, 0.22));
}

.moon-detail-title {
  margin: 0;
  font-size: clamp(0.95rem, 4vw, 1.1rem);
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.moon-detail-sub {
  margin: 0.2rem 0 0;
  color: var(--text-two-color);
  font-size: 0.78rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.moon-detail-head-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.moon-stat-pill {
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  background: rgba(0, 243, 255, 0.1);
  border: 1px solid rgba(0, 243, 255, 0.28);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.35;
}

.moon-stat-pill.soft {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.12);
  color: var(--text-two-color);
  font-weight: 500;
}

/* Tabs */
.moon-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.15rem;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
}

.moon-tabs::-webkit-scrollbar { display: none; }

.moon-tab {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  color: var(--text-two-color);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  transition: .16s ease;
  white-space: nowrap;
  touch-action: manipulation;
}

.moon-tab:hover {
  color: #fff;
  border-color: rgba(0, 243, 255, 0.35);
}

.moon-tab.is-active {
  color: #001018;
  background: linear-gradient(90deg, #00f2fe, #4facfe);
  border-color: transparent;
  font-weight: 800;
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.22);
}

.moon-tab-panel {
  display: none;
  animation: moonFade .25s ease;
  overflow: hidden;
}

.moon-tab-panel.is-active { display: block; }

@keyframes moonFade {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.moon-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.moon-info-card {
  background: var(--main-ex-bg, rgba(255,255,255,0.03));
  border: var(--main-ex-border, 1px solid rgba(255,255,255,0.08));
  border-radius: var(--moon-radius-md);
  padding: 0.75rem 0.8rem;
  overflow: hidden;
}

.moon-info-card h4 {
  margin: 0 0 0.28rem;
  color: var(--neon-cyan, #00f2fe);
  font-size: 0.74rem;
  font-weight: 700;
}

.moon-info-card .big {
  font-size: clamp(0.88rem, 3.6vw, 0.98rem);
  font-weight: 800;
  color: #fff;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.moon-info-card .small {
  margin-top: 0.2rem;
  color: var(--text-two-color);
  font-size: 0.74rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ---------- Tables ---------- */
.moon-table-card {
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 0.65rem;
}

.moon-table-head {
  padding: 0.7rem 0.8rem;
  font-size: 0.88rem;
  font-weight: 800;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  background: linear-gradient(180deg, rgba(0,243,255,0.07), transparent);
  overflow-wrap: anywhere;
}

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

.moon-tr {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.moon-tr:last-child { border-bottom: 0; }
.moon-tr:nth-child(even) { background: rgba(255,255,255,0.015); }

.moon-td-k {
  color: var(--text-two-color);
  font-size: 0.74rem;
  line-height: 1.5;
}

.moon-td-v {
  color: #fff;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.moon-empty {
  border: 1px dashed rgba(0, 243, 255, 0.28);
  background: rgba(0, 243, 255, 0.04);
  border-radius: 16px;
  padding: 0.9rem;
}

.moon-empty-title {
  font-weight: 800;
  margin-bottom: 0.35rem;
  overflow-wrap: anywhere;
}

.moon-empty p {
  margin: 0;
  color: var(--text-two-color);
  line-height: 1.8;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.moon-json {
  direction: ltr;
  text-align: left;
  background: #0b1220;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 0.8rem;
  max-height: 420px;
  overflow: auto;
  color: #dbeafe;
  font-size: 0.7rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

/* =========================================================
   LOADING / TOAST  (Sidebar-safe)
   - z-index پایین‌تر از منوی سایت
   - دور از گوشه‌ها
   ========================================================= */
.moon-loading {
  position: fixed;
  left: 50%;
  /* بالاتر از دکمه پایین/سایدبار موبایل */
  bottom: calc(5.25rem + var(--moon-safe-bottom));
  transform: translateX(-50%);
  width: auto;
  max-width: min(86%, 360px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(0, 243, 255, 0.35);
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
  color: #fff;
  border-radius: 999px;
  padding: 0.58rem 0.85rem;
  /* مهم: زیر سایدبار/همبرگر سایت بماند */
  z-index: 30;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 0.8rem;
  pointer-events: none;
  overflow: hidden;
}

.moon-loading[hidden] {
  display: none !important;
}

.moon-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent-neon, #00f3ff);
  animation: moonSpin .75s linear infinite;
  flex: 0 0 auto;
}

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

.moon-toast {
  position: fixed;
  /* پایین‌تر از دکمه همبرگر/سایدبار بالا */
  top: calc(4.25rem + var(--moon-safe-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255, 71, 87, 0.45);
  color: #fff;
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  width: min(520px, calc(100% - 2.5rem));
  max-width: calc(100% - 2.5rem);
  font-size: 0.84rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-word;
  pointer-events: none;
}

.moon-toast[hidden] { display: none !important; }

/* =========================================================
   Breakpoints
   ========================================================= */

@media (max-width: 360px) {
  .moon-app {
    padding-inline: max(0.5rem, var(--moon-safe-left)) max(0.5rem, var(--moon-safe-right));
  }

  .moon-hero-card,
  .moon-calendar-shell,
  .moon-detail-shell,
  .moon-location-bar {
    padding: 0.65rem;
    border-radius: 16px;
  }

  .moon-day {
    min-height: 54px;
    border-radius: 8px;
  }

  .moon-day canvas {
    width: min(18px, 68%) !important;
    height: min(18px, 68%) !important;
  }

  .moon-loc-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .moon-progress-labels {
    font-size: 0.52rem;
  }

  .moon-orb-wrap {
    width: min(132px, 46vw);
    height: min(132px, 46vw);
  }

  #detail-moon-canvas {
    width: 52px !important;
    height: 52px !important;
  }

  .moon-loading {
    bottom: calc(7.75rem + var(--moon-safe-bottom));
    max-width: min(88%, 320px);
    font-size: 0.76rem;
  }

  .moon-toast {
    top: calc(4.5rem + var(--moon-safe-top));
  }
}

@media (min-width: 380px) {
  .moon-day {
    min-height: 66px;
  }

  .moon-day canvas {
    width: min(26px, 72%) !important;
    height: min(26px, 72%) !important;
  }

  .moon-orb-wrap {
    width: min(150px, 48vw);
    height: min(150px, 48vw);
  }
}

@media (min-width: 400px) {
  .moon-day {
    min-height: 72px;
  }

  .moon-day canvas {
    width: min(30px, 74%) !important;
    height: min(30px, 74%) !important;
  }

  .moon-loc-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 480px) {
  .moon-hero-card,
  .moon-calendar-shell,
  .moon-detail-shell,
  .moon-location-bar {
    padding: 0.95rem;
    border-radius: 20px;
  }

  .moon-day-phase { display: block; }

  .moon-day {
    min-height: 86px;
    border-radius: 12px;
  }

  .moon-day canvas {
    width: min(36px, 76%) !important;
    height: min(36px, 76%) !important;
  }

  .moon-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .moon-tr {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr);
    gap: 0.65rem;
    align-items: start;
    padding: 0.7rem 0.85rem;
  }

  .moon-td-k {
    font-size: 0.8rem;
    padding-top: 0.08rem;
  }

  .moon-location-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .moon-loc-info {
    flex: 1 1 auto;
  }

  .moon-loc-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: auto;
    max-width: 100%;
    flex: 0 1 auto;
  }

  .moon-loc-actions > * {
    width: auto;
  }

  #detail-moon-canvas {
    width: 72px !important;
    height: 72px !important;
  }

  .moon-orb-wrap {
    width: min(170px, 42vw);
    height: min(170px, 42vw);
  }

  .moon-loading {
    bottom: calc(1.5rem + var(--moon-safe-bottom));
  }

  .moon-toast {
    top: calc(1.25rem + var(--moon-safe-top));
  }
}

@media (min-width: 720px) {
  .moon-app {
    padding: 1rem 1rem calc(3rem + var(--moon-safe-bottom));
  }

  .moon-hero-top {
    grid-template-columns: minmax(160px, 210px) minmax(0, 1fr);
    gap: 1.15rem;
  }

  .moon-orb-wrap {
    width: 190px;
    height: 190px;
  }

  .moon-hero-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .moon-cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7rem;
  }

  .moon-cal-nav-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }

  .moon-cal-nav-right .moon-btn {
    width: auto;
  }

  .moon-cal-grid,
  .moon-weekdays {
    gap: 0.35rem;
  }

  .moon-day {
    min-height: 100px;
    border-radius: 14px;
    padding: 0.42rem 0.28rem;
  }

  .moon-day canvas {
    width: min(46px, 78%) !important;
    height: min(46px, 78%) !important;
  }

  .moon-detail-head {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .moon-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #detail-moon-canvas {
    width: 88px !important;
    height: 88px !important;
  }
}

@media (min-width: 980px) {
  .moon-hero-top {
    grid-template-columns: minmax(200px, 250px) minmax(0, 1fr);
    gap: 1.5rem;
  }

  .moon-orb-wrap {
    width: 220px;
    height: 220px;
  }

  .moon-hero-title { font-size: 2rem; }

  .moon-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .moon-day { min-height: 110px; }

  .moon-day canvas {
    width: min(52px, 80%) !important;
    height: min(52px, 80%) !important;
  }
}

@media (min-width: 1200px) {
  .moon-app {
    padding-inline: 1.25rem;
  }
}

@media (max-height: 480px) and (orientation: landscape) {
  .moon-app {
    padding-bottom: calc(3.5rem + var(--moon-safe-bottom));
  }

  .moon-hero-visual {
    min-height: 120px;
  }

  .moon-orb-wrap {
    width: min(120px, 26vw);
    height: min(120px, 26vw);
  }

  .moon-day {
    min-height: 58px;
  }

  .moon-day canvas {
    width: min(20px, 70%) !important;
    height: min(20px, 70%) !important;
  }

  .moon-loading {
    bottom: calc(1rem + var(--moon-safe-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-dot,
  .moon-spinner,
  .moon-day.is-loading::before,
  .moon-tab-panel,
  .moon-progress-fill,
  .moon-progress-marker {
    animation: none !important;
    transition: none !important;
  }
}
