/* =========================================================
   ZOMNIVERSE APP SHELL + RAIL — ZAR SYSTEM IDENTITY
   Safe single-source version
========================================================= */

:root {
  --app-rail-width: 78px;
  --app-drawer-width: 350px;

  --zom-app-bg: #05070d;
  --zom-app-bg-soft: #080b14;

  --zom-rail-bg-top: rgba(10, 16, 34, 0.98);
  --zom-rail-bg-bottom: rgba(3, 7, 18, 0.99);

  --zom-line-soft: rgba(130, 154, 215, 0.16);
  --zom-line-mid: rgba(130, 154, 215, 0.24);

  --zom-text-main: rgba(244, 248, 255, 0.96);
  --zom-text-soft: rgba(182, 194, 229, 0.72);
  --zom-text-muted: rgba(151, 165, 207, 0.56);

  --zom-blue: #7fb5ff;
  --zom-blue-strong: #6ea8ff;
  --zom-violet: #8b7cff;
  --zom-green: #8fd4bd;
  --zom-danger: #e11d48;

  --zom-radius-lg: 22px;
  --zom-radius-md: 16px;
  --zom-radius-pill: 999px;
}

/* =========================================================
   APP SHELL
========================================================= */

body.app-mode {
  height: 100%;
  overflow: hidden;
  background: var(--zom-app-bg);
}

body.app-mode #nav-root {
  display: none !important;
}

body.app-mode #app-shell {
  width: 100%;
  height: 100dvh;

  display: grid;
  grid-template-columns: var(--app-rail-width) minmax(0, 1fr);

  overflow: hidden;

  background:
    radial-gradient(circle at 0% 0%, rgba(107, 128, 255, 0.08), transparent 36%),
    radial-gradient(circle at 55% 0%, rgba(90, 210, 180, 0.035), transparent 34%),
    var(--zom-app-bg);
}

body.app-mode #workspace-canvas {
  min-width: 0;
  min-height: 0;
  height: 100dvh;

  margin-top: 0;

  display: flex;
  flex-direction: column;

  overflow: hidden;
}

/* Site mode safety */
body.site-mode #app-shell {
  display: block;
}

body.site-mode .zom-app-rail,
body.site-mode .zom-app-menu-drawer {
  display: none !important;
}

body.site-mode #workspace-canvas {
  margin-top: var(--nav-height);
}

/* =========================================================
   APP RAIL
========================================================= */

.zom-app-rail {
  position: relative;
  z-index: 120;

  width: var(--app-rail-width);
  height: 100dvh;

  display: flex;
  flex-direction: column;
  align-items: center;

  padding: 16px 10px;

  background:
    linear-gradient(180deg, var(--zom-rail-bg-top), var(--zom-rail-bg-bottom));

  border-right: 1px solid var(--zom-line-soft);

  box-shadow:
    8px 0 34px rgba(0, 0, 0, 0.34),
    inset -1px 0 0 rgba(255, 255, 255, 0.035);

  box-sizing: border-box;
}

.zom-app-rail::after {
  content: "";
  position: absolute;
  top: 0;
  right: -1px;
  bottom: 0;

  width: 1px;

  background:
    linear-gradient(
      180deg,
      transparent,
      rgba(126, 169, 255, 0.28),
      transparent
    );

  pointer-events: none;
}

.zom-app-rail__brand {
  width: 48px;
  height: 48px;

  display: grid;
  place-items: center;

  margin-bottom: 22px;

  border-radius: 18px;

  background:
    radial-gradient(circle at 50% 35%, rgba(134, 123, 255, 0.22), transparent 68%),
    rgba(18, 25, 52, 0.72);

  border: 1px solid rgba(142, 164, 255, 0.2);

  text-decoration: none;

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 10px 26px rgba(0, 0, 0, 0.24);
}

.zom-app-rail__brand:hover {
  background:
    radial-gradient(circle at 50% 35%, rgba(134, 123, 255, 0.34), transparent 70%),
    rgba(25, 34, 70, 0.76);
}

.zom-app-rail__brand-img {
  width: 30px;
  height: 30px;
  object-fit: contain;

  filter:
    drop-shadow(0 0 8px rgba(127, 181, 255, 0.32))
    drop-shadow(0 0 12px rgba(139, 124, 255, 0.2));
}

.zom-app-rail__nav {
  width: 100%;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;

 /*  overflow-y: auto; */
  scrollbar-width: none;
}

.zom-app-rail__nav::-webkit-scrollbar {
  display: none;
}

.zom-app-rail__bottom {
  margin-top: auto;

  display: flex;
  flex-direction: column;
  gap: 12px;
}

.zom-app-rail__item {
  position: relative;

  width: 48px;
  height: 48px;

  display: grid;
  place-items: center;

  border: 0;
  border-radius: 18px;

  background: transparent;
  color: rgba(198, 209, 240, 0.74);

  text-decoration: none;
  font-size: 18px;

  cursor: pointer;

  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.zom-app-rail__item:hover {
  color: #ffffff;

  background:
    radial-gradient(circle at 50% 25%, rgba(127, 181, 255, 0.16), transparent 70%),
    rgba(116, 139, 255, 0.08);

  transform: translateY(-1px);
}

.zom-app-rail__item.is-active,
.zom-app-rail__item.is-open {
  color: var(--zom-blue);

  background:
    radial-gradient(circle at 50% 20%, rgba(107, 168, 255, 0.32), transparent 70%),
    linear-gradient(180deg, rgba(39, 62, 132, 0.58), rgba(20, 35, 84, 0.52));

/*   box-shadow:
    0 0 0 1px rgba(113, 150, 255, 0.26),
    0 10px 26px rgba(44, 88, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06); */
}

.zom-app-rail__item.is-active::before,
.zom-app-rail__item.is-open::before {
  content: "";
  position: absolute;

  left: -10px;
  width: 3px;
  height: 26px;

  border-radius: var(--zom-radius-pill);

  background:
    linear-gradient(180deg, var(--zom-blue), var(--zom-violet));

  box-shadow:
    0 0 14px rgba(112, 151, 255, 0.75),
    0 0 24px rgba(139, 124, 255, 0.34);
}

/* =========================================================
   DRAWER SHELL
========================================================= */

.zom-app-menu-drawer {
  position: fixed;
  z-index: 110;

  top: 0;
  left: var(--app-rail-width);

  width: var(--app-drawer-width);
  height: 100dvh;

  pointer-events: none;
}

.zom-app-menu-drawer[hidden] {
  display: none !important;
}

.zom-app-menu-drawer__panel {
  width: 100%;
  height: 100%;

  display: flex;
  flex-direction: column;

  background:
    radial-gradient(circle at 20% 0%, rgba(95, 124, 255, 0.14), transparent 38%),
    radial-gradient(circle at 85% 12%, rgba(128, 212, 189, 0.045), transparent 28%),
    linear-gradient(180deg, rgba(9, 14, 30, 0.985), rgba(4, 7, 16, 0.99));

  border-right: 1px solid rgba(145, 164, 220, 0.18);

  box-shadow:
    24px 0 70px rgba(0, 0, 0, 0.46),
    inset -1px 0 0 rgba(255, 255, 255, 0.035);

  pointer-events: auto;

  transform: translateX(-14px);
  opacity: 0;

  animation: zomDrawerIn 180ms ease forwards;
}

@keyframes zomDrawerIn {
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* =========================================================
   DRAWER HEADER
========================================================= */

.zom-app-menu-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  padding: 24px 18px 18px;

  border-bottom: 1px solid rgba(145, 164, 220, 0.13);
}

.zom-app-menu-drawer__kicker {
  margin: 0 0 6px;

  font-size: 11px;
  line-height: 1;

  letter-spacing: 0.18em;
  text-transform: uppercase;

  color: rgba(143, 212, 189, 0.66);
}

.zom-app-menu-drawer__header h2 {
  margin: 0;

  font-size: 20px;
  line-height: 1.15;
  font-weight: 700;

  color: var(--zom-text-main);
}

.zom-app-menu-drawer__close {
  width: 40px;
  height: 40px;

  display: grid;
  place-items: center;

  border: 1px solid rgba(145, 164, 220, 0.16);
  border-radius: 16px;

  background: rgba(255, 255, 255, 0.035);
  color: rgba(220, 228, 255, 0.76);

  cursor: pointer;

  transition:
    background 160ms ease,
    color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.zom-app-menu-drawer__close:hover {
  color: #ffffff;
  background: rgba(123, 145, 255, 0.12);
  border-color: rgba(145, 164, 220, 0.28);
  transform: translateY(-1px);
}

.zom-app-menu-drawer__body {
  flex: 1;
  min-height: 0;

  overflow-y: auto;
  padding: 14px 14px 18px;

  scrollbar-width: thin;
  scrollbar-color: rgba(140, 160, 220, 0.35) transparent;
}

/* =========================================================
   DRAWER PANEL VISIBILITY — AUTHORITATIVE
   Important: prevents all panels from showing together
========================================================= */

.zom-app-menu-group[hidden] {
  display: none !important;
}

.zom-app-menu-group {
  display: none !important;
  flex-direction: column;
  gap: 10px;
}

.zom-app-menu-group.is-active {
  display: flex !important;
}

/* =========================================================
   DRAWER LINKS
========================================================= */

.zom-app-menu-link {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;

  width: 100%;

  padding: 13px;

  border: 1px solid rgba(145, 164, 220, 0.13);
  border-radius: 20px;

  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.018));

  color: var(--zom-text-soft);

  text-decoration: none;
  text-align: left;

  box-sizing: border-box;

  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.zom-app-menu-link:hover {
  background:
    radial-gradient(circle at 12% 0%, rgba(127, 181, 255, 0.12), transparent 64%),
    rgba(123, 145, 255, 0.08);

  border-color: rgba(123, 145, 255, 0.24);

  transform: translateY(-1px);

  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.2);
}

.zom-app-menu-link.is-active {
  background:
    radial-gradient(circle at 16% 0%, rgba(98, 132, 255, 0.28), transparent 72%),
    linear-gradient(180deg, rgba(35, 54, 122, 0.52), rgba(18, 31, 79, 0.48));

  border-color: rgba(113, 150, 255, 0.3);

  box-shadow:
    0 0 0 1px rgba(113, 150, 255, 0.08),
    0 14px 30px rgba(44, 88, 255, 0.16);
}

.zom-app-menu-link__icon {
  width: 44px;
  height: 44px;

  display: grid;
  place-items: center;

  border-radius: 16px;

  background: rgba(5, 10, 23, 0.78);
  color: var(--zom-blue);

  box-shadow:
    inset 0 0 0 1px rgba(145, 164, 220, 0.08),
    0 8px 18px rgba(0, 0, 0, 0.18);
}

.zom-app-menu-link strong {
  display: block;

  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;

  color: var(--zom-text-main);
}

.zom-app-menu-link small {
  display: block;

  margin-top: 5px;

  font-size: 12px;
  line-height: 1.35;

  color: var(--zom-text-soft);
}

/* =========================================================
   DONATE BLOCK
========================================================= */

.zom-app-menu-donate {
  display: flex;
  flex-direction: column;
  gap: 12px;

  padding: 13px;

  border: 1px solid rgba(145, 164, 220, 0.13);
  border-radius: 22px;

  background:
    radial-gradient(circle at 16% 0%, rgba(255, 54, 115, 0.14), transparent 64%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.018));

  box-sizing: border-box;
}

.zom-app-menu-donate__text {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;

  color: var(--zom-text-soft);
}

.zom-app-menu-donate__text strong {
  display: block;

  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;

  color: var(--zom-text-main);
}

.zom-app-menu-donate__text small {
  display: block;

  margin-top: 5px;

  font-size: 12px;
  line-height: 1.35;

  color: var(--zom-text-soft);
}

.zom-app-donate-button-wrap {
  position: relative;

  width: max-content;
  min-width: 132px;
  min-height: 42px;

  display: flex;
  align-items: center;
  justify-content: flex-start;
}

#zom-app-custom-donate-btn {
  position: absolute;
  inset: 0;
  z-index: 2;

  min-width: 132px;
  height: 42px;
  padding: 0 18px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  border-radius: var(--zom-radius-pill);

  font-family: 'Fira Code', monospace;
  font-size: 0.8rem;
  font-weight: 700;

  color: rgba(226, 233, 255, 0.84);

  background:
    radial-gradient(circle at 15% 0%, rgba(255, 54, 115, 0.13), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));

  border: 1px solid rgba(180, 160, 220, 0.22);

  pointer-events: none;
  white-space: nowrap;

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 10px 24px rgba(0, 0, 0, 0.2);

  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.16s ease;
}

#zom-app-custom-donate-btn .heart {
  color: var(--zom-danger);
  font-size: 0.95rem;
  line-height: 1;
}

#zom-app-paypal-donate-button {
  position: relative;
  z-index: 3;

  min-width: 132px;
  min-height: 42px;

  display: flex;
  align-items: center;
  justify-content: flex-start;

  cursor: pointer;
}

#zom-app-paypal-donate-button iframe,
#zom-app-paypal-donate-button img {
  opacity: 0;
}

.zom-app-donate-button-wrap:hover #zom-app-custom-donate-btn {
  color: #ffffff;

  background:
    radial-gradient(circle at 15% 0%, rgba(255, 54, 115, 0.2), transparent 64%),
    rgba(123, 145, 255, 0.1);

  border-color: rgba(180, 160, 220, 0.34);

  transform: translateY(-1px);
}

/* =========================================================
   MOBILE — BOTTOM RAIL + RISING DRAWER
========================================================= */

@media (max-width: 768px) {
  body.app-mode #app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 64px;
  }

  body.app-mode #workspace-canvas {
    height: calc(100dvh - 64px);
  }

  .zom-app-rail {
    grid-row: 2;

    width: 100%;
    height: 64px;

    flex-direction: row;
    justify-content: center;

    padding: 8px 0px;

    border-right: 0;
    border-top: 1px solid rgba(145, 164, 220, 0.18);
  }

  .zom-app-rail__brand,
  .zom-app-rail__bottom {
    display: none;
  }

  .zom-app-rail__nav {
    flex-direction: row;
    justify-content: center;
    gap: 10px;

    overflow-x: auto;
  }

  .zom-app-rail__item {
    width: 44px;
    height: 44px;
    border-radius: 15px;
  }

  .zom-app-rail__item.is-active::before,
  .zom-app-rail__item.is-open::before {
    left: auto;
    top: -8px;

    width: 24px;
    height: 3px;
  }

  .zom-app-menu-drawer {
    top: auto;
    left: 0;
    bottom: 64px;

    width: 100%;
    height: min(58dvh, 430px);
  }

  .zom-app-menu-drawer__panel {
    border-right: 0;
    border-top: 1px solid rgba(145, 164, 220, 0.18);

    border-radius: 22px 22px 0 0;

    transform: translateY(18px);

    animation: zomDrawerUp 180ms ease forwards;
  }

  @keyframes zomDrawerUp {
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
}
/* =========================================================
   MOBILE APP RAIL — HORIZONTAL SCROLL
========================================================= */

@media (max-width: 768px) {
  .zom-app-rail {
    overflow: hidden !important;
  }

.zom-app-rail__nav {
    padding: 0 5px;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

  .zom-app-rail__nav::-webkit-scrollbar {
    display: none;
  }

  .zom-app-rail__item {
    flex: 0 0 44px;
  }
}
@media (max-width: 768px) {
  .zom-app-rail__bottom {
    display: flex !important;
    flex-direction: row;
    gap: 10px;
    margin-top: 0;
    flex: 0 0 auto;
  }
}

.zom-app-rail [hidden],
.zom-app-menu-drawer [hidden],
.zom-app-rail .is-rail-scope-hidden,
.zom-app-menu-drawer .is-rail-scope-hidden {
  display: none !important;
}

[data-zom-auth-logout][hidden] {
  display: none !important;
}