/* =========================================================================
 * NodexaBot layout V5 — Discord-style shell, Ember theme (see nodexa-shell.js).
 * rail (72px) | module column (264px) | content. Scoped to html.nx-v5.
 * ===================================================================== */
html.nx-v5 {
  --nx5-rail: 72px;
  --nx5-col: 264px;
  --nx5-bg: var(--h-bg, #09090b);
  --nx5-rail-bg: #060607;
  --nx5-col-bg: #0c0c0f;
  --nx5-card: var(--h-card, #111114);
  --nx5-line: var(--h-line, #23232a);
  --nx5-text: var(--h-text, #fafafa);
  --nx5-muted: var(--h-muted, #a1a1aa);
  --nx5-dim: #71717a;
  --nx5-accent: var(--h-accent, #f97316);
  --nx5-accent-text: #fdba74;
  --nx5-soft: color-mix(in srgb, var(--nx5-accent) 13%, transparent);
}
html.nx-v5[data-nodexa-theme="clean-light"] { --nx5-rail-bg: #efedea; --nx5-col-bg: #f7f6f4; --nx5-card: #ffffff; --nx5-accent: #ea580c; --nx5-accent-text: #c2410c; --nx5-dim: #78716c; --nx5-soft: rgba(234, 88, 12, .12); }
html.nx-v5[data-nodexa-theme="clean-light"] :is(#dashboard, #twitchDashboard) .score-ring::after,
html.nx-v5[data-nodexa-theme="clean-light"] :is(#dashboard, #twitchDashboard) .twitch-score-ring::after { background: var(--nx-card) !important; }
html.nx-v5[data-nodexa-theme="clean-light"] :is(#dashboard, #twitchDashboard) :is(.score-ring, .twitch-score-ring) b { color: var(--nx-text) !important; }

/* ---------- Frame ---------- */
html.nx-v5 :is(#dashboard, #twitchDashboard).active-page {
  display: grid !important;
  grid-template-columns: var(--nx5-rail) var(--nx5-col) minmax(0, 1fr);
  align-items: start; min-height: 100vh; padding: 0 !important; background: var(--nx5-bg) !important;
}
html.nx-v5 :is(.dashboard-shell, .twitch-dashboard-shell) {
  margin: 0 !important; padding: 0 !important; min-width: 0; width: auto !important; max-width: none !important; background: transparent !important; transform: none !important;
}
html.nx-v5 :is(.dashboard-content, .twitch-dashboard-content) {
  padding: 28px clamp(18px, 3vw, 40px) 56px !important; margin: 0 auto !important; max-width: 1320px !important; background: transparent !important;
}

/* ---------- Rail ---------- */
html.nx-v5 .nx5-rail {
  position: sticky; top: var(--nx-topbar-h, 0px); height: calc(100vh - var(--nx-topbar-h, 0px)); z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0;
  /* The whole column scrolls as one list (servers, +, products), like Discord. */
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: none;
  background: var(--nx5-rail-bg); border-right: 1px solid color-mix(in srgb, var(--nx5-line) 60%, transparent);
}
html.nx-v5 .nx5-products, html.nx-v5 .nx5-rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 8px; }
html.nx-v5 .nx5-rail::-webkit-scrollbar { display: none; }
html.nx-v5 .nx5-servers { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; padding: 2px 0; width: 100%; }
html.nx-v5 .nx5-rail-bottom { margin-top: 0; }
html.nx-v5 .nx5-sep { width: 32px; height: 2px; border-radius: 1px; background: var(--nx5-line); margin: 2px 0; }
html.nx-v5 .nx5-rail-btn {
  position: relative; flex: none; width: 48px; height: 48px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--nx5-card); color: var(--nx5-muted); cursor: pointer; text-decoration: none;
  transition: border-radius .18s ease, background .18s ease, color .18s ease; overflow: visible; padding: 0;
}
html.nx-v5 .nx5-rail-btn[hidden] { display: none; }
html.nx-v5 .nx5-rail-btn:hover, html.nx-v5 .nx5-rail-btn:focus-visible { border-radius: 16px; background: var(--nx5-soft); color: var(--nx5-accent-text); outline: none; }
html.nx-v5 .nx5-rail-btn:focus-visible { box-shadow: 0 0 0 2px var(--nx5-accent); }
/* Discord-style pill on the left edge */
html.nx-v5 .nx5-rail-btn::before {
  content: ""; position: absolute; left: -12px; top: 50%; width: 4px; height: 0; border-radius: 0 4px 4px 0;
  background: var(--nx5-text); transform: translateY(-50%); transition: height .18s ease;
}
html.nx-v5 .nx5-rail-btn:hover::before { height: 20px; }
html.nx-v5 .nx5-rail-btn.is-active { border-radius: 16px; background: var(--nx5-accent); color: #0b0b0d; }
html.nx-v5 .nx5-rail-btn.is-active::before { height: 40px; background: var(--nx5-accent); }
html.nx-v5 .nx5-server img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
html.nx-v5 .nx5-server.is-active img { box-shadow: 0 0 0 2px var(--nx5-accent); }
html.nx-v5 .nx5-initials { font: 700 15px/1 Inter, system-ui, sans-serif; letter-spacing: -.02em; }
html.nx-v5 .nx5-add { color: var(--nx5-accent); background: var(--nx5-card); }
html.nx-v5 .nx5-add:hover { background: var(--nx5-accent); color: #0b0b0d; }

/* ---------- Module column ---------- */
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) {
  position: sticky !important; top: var(--nx-topbar-h, 0px) !important; left: auto !important; height: calc(100vh - var(--nx-topbar-h, 0px)) !important; max-height: none; width: auto !important;
  margin: 0 !important; padding: 0 10px 12px !important; transform: none !important; z-index: 20 !important;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  background: var(--nx5-col-bg) !important; border: 0 !important; border-right: 1px solid var(--nx5-line) !important; border-radius: 0 !important; box-shadow: none !important;
}
/* Logo and product switcher live in the rail now. */
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) :is(.dash-brand, .twitch-dash-brand, .dashboard-product-switcher, .twitch-product-switcher) { display: none !important; }
/* Server / channel header, like Discord's server name bar */
html.nx-v5 .nx5-column-head {
  position: sticky; top: 0; z-index: 2; margin: 0 -10px 10px !important; padding: 0 !important;
  background: var(--nx5-col-bg); border-bottom: 1px solid var(--nx5-line);
}
html.nx-v5 .nx5-column-head .server-picker, html.nx-v5 .twitch-channel-card.nx5-column-head {
  width: 100%; min-height: 60px; display: flex !important; align-items: center; gap: 10px; padding: 10px 14px !important;
  border: 0 !important; border-radius: 0 !important; background: transparent !important; box-shadow: none !important; text-align: left; color: var(--nx5-text);
}
html.nx-v5 .nx5-column-head .server-picker:hover, html.nx-v5 .twitch-channel-card.nx5-column-head:hover { background: color-mix(in srgb, var(--nx5-text) 4%, transparent) !important; }
html.nx-v5 .nx5-column-head .server-logo, html.nx-v5 .twitch-channel-card.nx5-column-head > span {
  width: 32px; height: 32px; border-radius: 10px !important; display: grid; place-items: center; flex: none;
  background: var(--nx5-soft) !important; color: var(--nx5-accent-text) !important; font-weight: 800; font-size: 12px; overflow: hidden;
}
html.nx-v5 .nx5-column-head .server-logo img { width: 100%; height: 100%; object-fit: cover; }
html.nx-v5 .nx5-column-head :is(#serverPickerName, #twitchSidebarChannel) { font-size: 15px; font-weight: 750; letter-spacing: -.01em; color: var(--nx5-text); }
html.nx-v5 .nx5-column-head :is(#serverPickerRole, small) { color: var(--nx5-dim); font-size: 11.5px; }
html.nx-v5 .nx5-column-head .server-picker-menu { left: 8px !important; right: 8px !important; top: calc(100% + 6px) !important; width: auto !important; z-index: 40; }

html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) .nx-side-tools { margin: 0 0 4px !important; padding: 0 !important; }
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) .nx-side-search { border-radius: 10px !important; background: var(--nx5-rail-bg) !important; border-color: var(--nx5-line) !important; }
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) .nx-command-link { color: var(--nx5-dim) !important; font-size: 12px !important; }
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) .sidebar-group { margin: 0 !important; padding: 0 !important; }
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) :is(.sidebar-group > label, .nx-group-heading, .nx-pro-twitch-group, .twitch-admin-nav-group small) {
  display: flex !important; align-items: center; margin: 16px 8px 4px !important; padding: 0 !important;
  font-size: 11px !important; font-weight: 700 !important; letter-spacing: .06em !important; color: var(--nx5-dim) !important; text-transform: uppercase;
  background: none !important; border: 0 !important;
}
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) :is(.side-item, .twitch-sidebar-nav button) {
  display: flex !important; align-items: center; gap: 10px; width: 100%; min-height: 36px; margin: 1px 0 !important; padding: 6px 8px !important;
  border: 0 !important; border-radius: 8px !important; background: transparent !important; box-shadow: none !important;
  color: var(--nx5-muted) !important; font-size: 14px !important; font-weight: 500 !important; text-align: left;
}
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) :is(.side-item, .twitch-sidebar-nav button):hover { background: color-mix(in srgb, var(--nx5-text) 5%, transparent) !important; color: var(--nx5-text) !important; }
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) :is(.side-item.active, .twitch-sidebar-nav button.active) {
  background: var(--nx5-soft) !important; color: var(--nx5-text) !important; font-weight: 600 !important; box-shadow: none !important;
}
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) .nx5-icon { display: grid !important; place-items: center; width: 20px; height: 20px; flex: none; color: var(--nx5-dim) !important; background: none !important; border: 0 !important; margin: 0 !important; }
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) :is(.side-item, .twitch-sidebar-nav button):hover .nx5-icon { color: var(--nx5-text) !important; }
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) :is(.side-item.active, .twitch-sidebar-nav button.active) .nx5-icon { color: var(--nx5-accent) !important; }
/* Status badges: quiet text instead of boxed pills; ON stands out in green. */
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) :is(.side-item, .twitch-sidebar-nav button) > em {
  margin-left: auto; padding: 0 !important; border: 0 !important; background: none !important;
  font-style: normal; font-size: 10px !important; font-weight: 700; letter-spacing: .04em; color: color-mix(in srgb, var(--nx5-dim) 80%, transparent) !important;
}
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) .side-item > em:is([data-state="on"], .on, .active) { color: #4ade80 !important; }
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) :is(.sidebar-footer, .twitch-sidebar-bottom) {
  position: sticky !important; bottom: -12px; margin: 14px -10px -12px !important; padding: 10px 12px !important;
  background: var(--nx5-rail-bg) !important; border-top: 1px solid var(--nx5-line) !important;
}
html.nx-v5 .mini-profile .avatar { border-radius: 50% !important; background: var(--nx5-soft) !important; color: var(--nx5-accent-text) !important; }

/* ---------- Content header (inside the content column) ---------- */
html.nx-v5 :is(.dashboard-topbar, .twitch-topbar) {
  position: sticky !important; top: var(--nx-topbar-h, 0px); z-index: 15; display: flex !important; align-items: center; gap: 12px;
  min-height: 60px; height: auto !important; margin: 0 !important; padding: 10px clamp(18px, 3vw, 40px) !important;
  background: color-mix(in srgb, var(--nx5-bg) 88%, transparent) !important; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 0 !important; border-bottom: 1px solid var(--nx5-line) !important; border-radius: 0 !important; box-shadow: none !important;
}
html.nx-v5 .nx5-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
html.nx-v5 .nx5-title :is(.breadcrumb, span) { font-size: 0 !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.nx-v5 .nx5-title :is(#dashboardBreadcrumb, #twitchBreadcrumb) { font-size: 16px !important; font-weight: 750; color: var(--nx5-text); letter-spacing: -.01em; }
html.nx-v5 .nx5-title :is(.dash-mobile-menu, .twitch-mobile-menu) { display: none !important; }
html.nx-v5 :is(.dash-actions, .twitch-top-actions) { display: flex !important; align-items: center; gap: 8px; margin-left: auto; }
html.nx-v5 :is(.dash-actions, .twitch-top-actions) .theme-switch-btn { display: none !important; } /* in the rail */
html.nx-v5 :is(.dash-actions, .twitch-top-actions) :is(.square-btn, .button) { min-height: 36px; border-radius: 9px !important; }
html.nx-v5 .twitch-workspace-switcher { flex: 0 1 300px; min-width: 0; display: flex; gap: 8px; }
html.nx-v5 .twitch-workspace-switcher select { min-width: 0; flex: 1; height: 36px; border-radius: 9px; }

/* ---------- Content: calmer, fewer boxes ---------- */
html.nx-v5 :is(#dashboard, #twitchDashboard) .nx-pro-page { max-width: none !important; margin: 0 !important; }
html.nx-v5 :is(#dashboard, #twitchDashboard) .nx-pro-page > :is(.ticket-page-heading, .module-page-heading, .server-page-heading, .premium-page-heading, .admin-page-heading, .am-heading, .music-topline, .twitch-page-head, .twitch-section-heading, .ait-hero, .nts-hero) {
  padding: 4px 0 18px !important; margin-bottom: 18px !important; border: 0 !important; border-bottom: 1px solid var(--nx5-line) !important; border-radius: 0 !important; background: none !important; box-shadow: none !important;
}
html.nx-v5 #dashboardOverview .dash-heading {
  padding: 4px 0 6px !important; border: 0 !important; background: none !important; box-shadow: none !important;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px;
}
html.nx-v5 #dashboardOverview #dashboardGreeting { font-size: clamp(28px, 3.2vw, 38px) !important; letter-spacing: -.035em; line-height: 1.1; margin: 8px 0 6px; }
html.nx-v5 #dashboardOverview .nd-prof-workspace-strip { display: none !important; } /* the rail already shows the server */
html.nx-v5 #dashboardOverview .dash-stat-grid { gap: 12px !important; }
html.nx-v5 #dashboardOverview .dash-stat { border-radius: 14px !important; }
html.nx-v5 :is(#dashboardOverview .stat-icon.nx5-icon, .module-card-icon.nx5-icon) {
  display: grid !important; place-items: center; width: 38px; height: 38px; border-radius: 11px !important;
  background: var(--nx5-soft) !important; color: var(--nx5-accent) !important; border: 0 !important; font-size: 0 !important;
}
html.nx-v5 #dashboardOverview .dash-stat > button { display: none !important; }
html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.panel, .twitch-card, .module-library-card) { border-radius: 14px !important; }

/* Overlays above everything */
html.nx-v5 :is(.nx-command-palette, .nodexa-theme-dialog) { z-index: 1200; }

/* ---------- Narrow desktop ---------- */
@media (max-width: 1100px) {
  html.nx-v5 { --nx5-col: 232px; }
  html.nx-v5 :is(.dash-actions, .twitch-top-actions) .button-secondary { display: none !important; }
}

/* ---------- Phones: rail + column slide in together (Discord mobile) ---------- */
@media (max-width: 720px) {
  html.nx-v5 :is(#dashboard, #twitchDashboard).active-page { display: block !important; }
  html.nx-v5 .nx5-rail {
    position: fixed; top: var(--nx-topbar-h, 0px); left: 0; bottom: 0; height: auto; z-index: 91;
    width: var(--nx5-rail); box-sizing: border-box; /* fixed width: no gap before the module column */
    transform: translateX(-100%); transition: transform .22s ease;
  }
  html.nx-v5 :is(#dashboard, #twitchDashboard) :is(.dashboard-sidebar, .twitch-dashboard-sidebar) {
    position: fixed !important; top: var(--nx-topbar-h, 0px) !important; bottom: 0 !important; left: var(--nx5-rail) !important; height: auto !important; z-index: 90 !important;
    width: min(300px, calc(100vw - var(--nx5-rail) - 36px)) !important;
    transform: translateX(calc(-100% - var(--nx5-rail))) !important; transition: transform .22s ease;
    border-radius: 0 18px 18px 0 !important;
  }
  html.nx-v5 :is(#dashboard, #twitchDashboard).nx5-drawer-open .nx5-rail,
  html.nx-v5 :is(#dashboard, #twitchDashboard).nx5-drawer-open :is(.dashboard-sidebar, .twitch-dashboard-sidebar) { transform: none !important; }
  html.nx-v5 :is(#dashboard, #twitchDashboard).nx5-drawer-open :is(.dashboard-sidebar, .twitch-dashboard-sidebar) { box-shadow: 24px 0 60px rgba(0, 0, 0, .55) !important; }
  html.nx-v5 body .nx-nav-scrim { z-index: 85 !important; }
  html.nx-v5 :is(.dashboard-topbar, .twitch-topbar) { flex-wrap: wrap; padding: 8px 12px !important; gap: 8px; }
  html.nx-v5 .nx5-title :is(.dash-mobile-menu, .twitch-mobile-menu) {
    display: grid !important; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 10px;
    border: 1px solid var(--nx5-line) !important; background: var(--nx5-card) !important; color: var(--nx5-text) !important; font-size: 18px;
  }
  html.nx-v5 :is(.dash-actions, .twitch-top-actions) .button { display: none !important; }
  html.nx-v5 .twitch-workspace-switcher { order: 3; flex: 1 1 100%; }
  html.nx-v5 :is(.dashboard-content, .twitch-dashboard-content) { padding: 16px 12px 32px !important; }
}

/* ---------- Inside the app: native bar has the menu button ---------- */
html.nx-v5.nx-mobile-app .nx5-title :is(.dash-mobile-menu, .twitch-mobile-menu) { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  html.nx-v5 :is(.nx5-rail, .nx5-rail-btn, .dashboard-sidebar, .twitch-dashboard-sidebar),
  html.nx-v5 .nx5-rail-btn::before { transition: none !important; }
}

/* Line icons outside the menu (shortcuts, tabs, tiles) */
html.nx-v5 :is(#dashboard, #twitchDashboard) button > .nx5-icon:not(.stat-icon):not(.module-card-icon) { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; color: var(--nx5-accent); font-size: 0; background: none; border: 0; }

/* ---- 5.42.1: instant feedback ------------------------------------------ */
/* No double-tap-zoom delay on taps; our own press state instead of the grey flash. */
html.nx-v5 :is(a, button, .side-item, .nx5-rail-btn, .module-card, .module-library-card, [role="button"], summary, label) {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
html.nx-v5 :is(.side-item, .nx5-rail-btn, .server-picker-option, .twitch-nav button, .owner-shortcuts-grid > button, .nx-pro-twitch-shortcuts > button) {
  transition: transform .09s ease, background-color .12s ease, color .12s ease, border-radius .15s ease;
}
html.nx-v5 :is(.side-item, .server-picker-option, .twitch-nav button, .owner-shortcuts-grid > button, .nx-pro-twitch-shortcuts > button):active { transform: scale(.975); }
html.nx-v5 .nx5-rail-btn:active { transform: scale(.92); }
html.nx-v5 :is(.module-card, .module-library-card):active { transform: scale(.99); }

/* Thin progress bar while data a tap asked for is loading. */
html.nx-v5::after {
  content: "";
  position: fixed;
  z-index: 2147483000;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, #f97316 30%, #fdba74 50%, #f97316 70%, transparent 100%);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity .2s ease;
}
html.nx-v5:is(.nx-busy, .nx-switching)::after { opacity: 1; animation: nx5-busy 1s linear infinite; }

/* Server switch: the new server shows at once; old figures fade until fresh data arrives. */
html.nx-v5.nx-switching #dashboard .dashboard-content :is(.dash-stat, .panel) { opacity: .55; transition: opacity .15s ease; }
html.nx-v5 #dashboard .dashboard-content :is(.dash-stat, .panel) { transition: opacity .2s ease; }

@media (prefers-reduced-motion: reduce) {
  html.nx-v5:is(.nx-busy, .nx-switching)::after { animation: none; background: #f97316; }
  html.nx-v5 :is(.side-item, .nx5-rail-btn, .module-card, .module-library-card):active { transform: none; }
}

/* ---- 5.44.1: one top bar in the app --------------------------------------
   The app has its own bar (menu, logo, reload). The website's bar under it was
   a second one, so inside the app it is hidden. The module name is in the
   module's header card and search is in the menu ("Find a module…"). */
html.nx-v5.nx-mobile-app #dashboard .dashboard-topbar { display: none !important; }
/* Twitch: the bar also holds the channel picker. Hide it with one channel; with
   several, keep only the picker (title, theme and other buttons stay hidden). */
html.nx-v5.nx-mobile-app #twitchDashboard .twitch-topbar:not(:has(#twitchWorkspaceSelect option:nth-child(2))) { display: none !important; }
html.nx-v5.nx-mobile-app #twitchDashboard .twitch-topbar > :not(.twitch-workspace-switcher) { display: none !important; }
html.nx-v5.nx-mobile-app :is(#dashboard, #twitchDashboard) :is(.dashboard-content, .twitch-dashboard-content) { padding-top: 14px !important; }
