.menu-host {
  --bg: #0b0f15;
  --child-bg: rgba(20, 30, 40, 0.82);
  --child-bg-2: rgba(36, 55, 70, 0.88);
  --outline: rgba(123, 162, 191, 0.26);
  --outline-strong: rgba(151, 202, 230, 0.42);
  --accent: #9cc9df;
  --accent-2: #5f9fbd;
  --accent-3: #b7e7ff;
  --accent-glow: rgba(156, 201, 223, 0.58);
  --glow-line: 0 0 10px rgba(156, 201, 223, 0.48);
  --text: #eef5f8;
  --text-muted: #b0bec9;
  --text-faint: #5b6b7a;
  --hostile: #e35a5a;
  --friend: #9edcff;
  --warning: #e8b86c;

  --font-ui: 'Space Grotesk', 'Inter', system-ui, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --fs-md: 13px;
  --fs-sm: 12px;
  --fs-micro: 9px;

  --menu-w: 340px;
  --header-h: 32px;
  --row-h: 28px;
  --tab-h: 24px;
  --kb-w: 36px;
  --kb-h: 16px;
  --gap-row: 8px;

  --shadow-window: 0 28px 70px -26px rgba(0, 0, 0, 0.86), 0 12px 26px -18px rgba(82, 151, 190, 0.42);
  --shadow-soft: 0 14px 34px -18px rgba(0, 0, 0, 0.75);

  position: relative;
  overflow: hidden;
  font-family: var(--font-ui);
  color: var(--text);
  --pointer-x: 50%;
  --pointer-y: 38%;
  background:
    radial-gradient(260px circle at var(--pointer-x, 50%) var(--pointer-y, 38%), rgba(156,201,223,.17), transparent 58%),
    linear-gradient(125deg, rgba(134,199,232,.065), transparent 32%),
    linear-gradient(180deg, rgba(7, 11, 16, .98), rgba(4, 7, 11, .98));
}

.menu-host *, .menu-host *::before, .menu-host *::after { box-sizing: border-box; }
.menu-host button { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; font: inherit; color: inherit; }

.r-viewport {
  position: absolute; inset: 0;
  overflow: hidden;
  cursor: grab;
  z-index: 1;
}
.r-viewport.is-panning { cursor: grabbing; }
.r-canvas-inner {
  position: absolute; top: 0; left: 0;
  width: 0; height: 0;
  overflow: visible;
  will-change: transform;
}
.r-zoom-badge {
  position: absolute; right: 10px; bottom: 10px;
  z-index: 20;
  background: rgba(11, 15, 21, 0.85);
  border: 1px solid var(--outline);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 8px;
  letter-spacing: 0.04em;
  user-select: none;
  pointer-events: none;
}

.r-bg {
  position: absolute; inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(320px circle at var(--pointer-x, 50%) var(--pointer-y, 38%), rgba(156,201,223,.1), transparent 62%),
    linear-gradient(180deg, rgba(7, 11, 16, .15), rgba(4, 7, 11, .18));
  opacity:.68;
  transition: opacity .2s ease;
}
.menu-host.is-pointer-active .r-bg { opacity: .82; }

.r-nav-wrap {
  position: absolute; left: 50%; top: 12px;
  transform: translateX(-50%);
  transform-origin: 50% 0;
  width: 178px;
  z-index: 5;
  display: flex; flex-direction: column; gap: 3px;
  filter:
    drop-shadow(0 0 1px rgba(0,0,0,0.40))
    drop-shadow(0 0 3px rgba(0,0,0,0.25))
    drop-shadow(0 0 6px rgba(0,0,0,0.18))
    drop-shadow(0 4px 10px rgba(0,0,0,0.45));
}
.r-nav {
  width: 100%; height: 28px;
  background: rgba(9, 14, 20, 0.76);
  backdrop-filter: blur(12px) saturate(145%);
  -webkit-backdrop-filter: blur(12px) saturate(145%);
  border: 1px solid var(--outline);
  display: flex; flex-direction: row;
  padding: 3px;
  gap: 3px;
  box-sizing: border-box;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.r-nav__btn {
  flex: 1 1 0;
  height: 100%;
  background: rgba(18, 25, 34, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--outline);
  border-radius: 4px;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer;
  padding: 0;
  font-size: 0;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.r-nav__btn i {
  font-size: 8px;
  line-height: 1;
  transition: transform .16s ease, text-shadow .16s ease;
}
.r-nav__btn:hover {
  background: rgba(34, 48, 60, 0.78);
  color: var(--text);
  transform: translateY(-1px);
}
.r-nav__btn:hover i { transform: scale(1.28); text-shadow: 0 0 12px var(--accent-glow); }
.r-nav__btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: linear-gradient(180deg, rgba(156,201,223,.18), rgba(18,25,34,.7));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 0 16px -8px var(--accent-glow);
}
.r-nav__btn.is-active::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 0; height: 1.5px;
  background: var(--accent);
}

.r-nav-search {
  width: 100%; height: 25px;
  background: rgba(8, 13, 18, .84);
  border: 1px solid var(--outline);
  padding: 2px;
  box-sizing: border-box;
  border-radius: 6px;
}
.r-nav-search__input {
  width: 100%; height: 100%;
  background: rgba(20, 30, 40, .78);
  border: 1px solid var(--outline);
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px;
  box-sizing: border-box;
}
.r-nav-search__input:focus-within {
  border-color: var(--accent);
}
.r-nav-search__input i {
  font-size: 9px;
  color: var(--text-muted);
}
.r-nav-search__input input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 11px;
}

.r-nav-results {
  width: 100%;
  background: rgba(8, 13, 18, .96);
  border: 1px solid var(--outline);
  border-top: 2px solid var(--accent);
  box-shadow: 0 8px 24px rgba(0,0,0,0.55);
  max-height: 480px;
  overflow: hidden;
  display: flex; flex-direction: column;
  border-radius: 0 0 6px 6px;
}
.r-nav-results__head {
  height: 30px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 11px;
  border-bottom: 1px solid var(--outline);
}
.r-nav-results__head i { font-size: 10px; color: var(--text-muted); }
.r-nav-results__list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.r-nav-results__row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 5px 12px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  transition: background .14s ease, color .14s ease;
}
.r-nav-results__row:hover { background: var(--child-bg-2); }
.r-nav-results__cat {
  font-size: 9px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  min-width: 56px;
}
.r-nav-results__name {
  color: var(--text);
  flex: 1;
  min-width: 0;
  transform-origin: left center;
  transition: transform .15s ease, color .15s ease, text-shadow .15s ease;
}
.r-nav-results__row:hover .r-nav-results__name {
  transform: scale(1.06);
  color: #fff;
  text-shadow: 0 0 12px rgba(156,201,223,.45);
}
.r-nav-results__chev {
  color: var(--text-muted);
  font-size: 9px;
  margin-left: auto;
}
.r-nav-results__item.is-open .r-nav-results__row {
  background: var(--child-bg-2);
  color: var(--accent);
}
.r-nav-results__item.is-open .r-nav-results__name { color: var(--accent); }
.r-nav-results__item.is-open .r-nav-results__chev { color: var(--accent); }

.r-nav-results__subs {
  background: var(--child-bg);
  border-top: 1px solid var(--outline);
  border-bottom: 1px solid var(--outline);
  padding: 4px 0;
}
.r-nav-results__sub {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 24px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .14s ease, color .14s ease, transform .14s ease;
}
.r-nav-results__sub:hover { background: var(--child-bg-2); color: var(--text); transform: translateX(2px); }
.r-nav-results__sub-dot {
  width: 4px; height: 4px;
  background: var(--text-faint);
  flex-shrink: 0;
}
.r-nav-results__sub:hover .r-nav-results__sub-dot { background: var(--accent); }
.r-nav-results__sub-name { flex: 1; }

.r-win {
  position: absolute;
  width: var(--menu-w);
  background:
    linear-gradient(180deg, rgba(13, 20, 28, 0.82), rgba(8, 12, 18, 0.88)),
    linear-gradient(120deg, rgba(134,199,232,.052), transparent 38%);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--outline);
  box-shadow: var(--shadow-window);
  z-index: 10;
  display: flex; flex-direction: column;
  max-height: 80vh;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.r-win:hover {
  border-color: rgba(156,201,223,.42);
  box-shadow: var(--shadow-window), 0 0 34px -22px var(--accent-glow);
}
.r-win__header {
  position: relative;
  height: calc(var(--header-h) + 2px);
  display: flex; align-items: center;
  padding: 0 12px;
  cursor: grab;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(20,30,40,.72), rgba(9,14,20,.28));
}
.r-win__header:active { cursor: grabbing; }
.r-win__accent-bar {
  position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3));
  box-shadow: var(--glow-line);
}
.r-win__icon { color: var(--accent); font-size: 12px; margin-right: 12px; }
.r-win__title {
  font-size: var(--fs-md); font-weight: 600; color: var(--text);
  display: inline-block;
  transform-origin: left center;
  transition: transform .16s ease, color .16s ease, text-shadow .16s ease;
}
.r-win__header:hover .r-win__title {
  transform: scale(1.06);
  color: #fff;
  text-shadow: 0 0 14px rgba(156,201,223,.48);
}
.r-win__close {
  margin-left: auto;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 16px; line-height: 1;
}
.r-win__close:hover { color: var(--hostile); }
.r-win__rule {
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--outline);
}
.r-win__body {
  padding: 12px 6px 14px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--outline) transparent;
}
.r-win__body::-webkit-scrollbar { width: 6px; }
.r-win__body::-webkit-scrollbar-thumb { background: var(--outline); }

.r-module { margin-bottom: var(--gap-row); }
.r-module:last-child { margin-bottom: 0; }
.r-module.is-expanded { margin-bottom: calc(var(--gap-row) + 4px); }
.r-module.is-expanded + .r-module { margin-top: 4px; }
.r-module__row {
  position: relative;
  min-height: var(--row-h);
  background: linear-gradient(180deg, rgba(24,36,48,.78), rgba(16,24,34,.78));
  border: 1px solid var(--outline);
  border-radius: 5px;
  display: flex; align-items: center;
  padding: 0 12px;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 500;
  user-select: none;
  overflow: hidden;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.r-module__row:hover {
  color: var(--text);
  border-color: var(--outline-strong);
  background: linear-gradient(180deg, rgba(42,60,75,.94), rgba(20,33,44,.88));
  box-shadow: 0 10px 24px -18px var(--accent-glow);
  transform: translateX(2px);
}
.r-module__row.is-on { color: var(--text); border-color: rgba(156,201,223,.42); }
.r-module__row.is-on .r-module__accent {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-3));
  box-shadow: var(--glow-line);
  border-radius: 5px 0 0 5px;
}
.r-module__label {
  flex: 1;
  min-width: 0;
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform-origin: left center;
  transition: transform .16s ease, color .16s ease, text-shadow .16s ease;
}
.r-module__row:hover .r-module__label {
  transform: scale(1.055);
  color: #fff;
  text-shadow: 0 0 14px rgba(156,201,223,.42);
}
.r-module__chev {
  margin-left: 10px; color: var(--text-muted); font-size: 9px; width: 10px;
}

.r-kb {
  width: var(--kb-w); height: var(--kb-h);
  background: rgba(7, 11, 16, .78);
  border: 1px solid var(--outline);
  border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  transition: border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.r-kb:hover { border-color: var(--outline-strong); color: var(--text); transform: scale(1.08); }
.r-kb.is-binding { border-color: var(--accent); color: var(--accent); box-shadow: var(--glow-line); }

.r-module__body {
  margin: 4px 4px 0;
  padding: 10px 14px 12px;
  display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(180deg, rgba(8,12,18,.46), rgba(8,12,18,.14));
  border: 1px solid rgba(123,162,191,.09);
  border-radius: 6px;
}

.r-tabs {
  height: var(--tab-h);
  background: rgba(7, 11, 16, .78);
  border: 1px solid var(--outline);
  display: flex;
  border-radius: 5px;
  padding: 2px;
  gap: 2px;
}
.r-tabs__tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: 500;
  color: var(--text-muted);
  position: relative;
  border-radius: 3px;
  transition: background .14s ease, color .14s ease, transform .14s ease, text-shadow .14s ease;
}
.r-tabs__tab:hover { color: var(--text); transform: scale(1.05); text-shadow: 0 0 12px rgba(156,201,223,.35); }
.r-tabs__tab.is-active { color: var(--text); background: rgba(156,201,223,.12); }
.r-tabs__tab.is-active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  box-shadow: var(--glow-line);
}

.r-slider { display: flex; flex-direction: column; gap: 4px; }
.r-slider__head {
  display: flex; justify-content: space-between;
  font-size: var(--fs-sm); color: var(--text);
}
.r-slider__val { font-family: var(--font-mono); color: var(--text-muted); font-size: 11px; }
.r-slider__track {
  height: 7px; background: rgba(7, 11, 16, .82);
  border: 1px solid var(--outline);
  position: relative; cursor: pointer;
  border-radius: 999px;
  overflow: hidden;
}
.r-slider__fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3));
}
.r-slider__fill::after {
  content: ""; position: absolute; right: -1px; top: -2px; bottom: -2px; width: 2px;
  background: var(--accent); box-shadow: var(--glow-line);
}

.r-check {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-sm); color: var(--text);
  text-align: left; min-height: 20px;
  transition: transform .14s ease, color .14s ease;
}
.r-check:hover { transform: translateX(2px); color: #fff; }
.r-check__box {
  width: 14px; height: 14px;
  background: rgba(7, 11, 16, .82); border: 1px solid var(--outline);
  border-radius: 3px;
  position: relative;
  flex-shrink: 0;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.r-check:hover .r-check__box { transform: scale(1.1); }
.r-check__box.is-on { border-color: var(--accent); box-shadow:0 0 14px -7px var(--accent-glow); }
.r-check__box.is-on::after {
  content: ""; position: absolute; inset: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  box-shadow: var(--glow-line);
  border-radius: 2px;
}

.r-dd { position: relative; display: flex; flex-direction: column; gap: 4px; }
.r-dd__lbl { font-size: var(--fs-sm); color: var(--text); }
.r-dd__btn {
  height: 24px;
  background: rgba(7, 11, 16, .82); border: 1px solid var(--outline);
  border-radius: 5px;
  padding: 0 10px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.r-dd__btn:hover { border-color: var(--outline-strong); box-shadow: 0 10px 22px -18px var(--accent-glow); transform: scale(1.015); }
.r-dd__chev { color: var(--text-muted); font-size: 9px; }
.r-dd__list {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px);
  background: rgba(8, 13, 18, .98); border: 1px solid var(--outline-strong);
  z-index: 50;
  box-shadow: var(--shadow-soft);
  border-radius: 6px;
  overflow: hidden;
}
.r-dd__opt {
  display: block; width: 100%;
  padding: 6px 10px;
  text-align: left;
  font-size: 12px; color: var(--text-muted);
}
.r-dd__opt:hover { background: var(--child-bg-2); color: var(--text); }
.r-dd__opt.is-active { color: var(--accent); }

.r-color { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.r-color__lbl { font-size: var(--fs-sm); color: var(--text); }
.r-color__field {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--outline);
  background: rgba(7, 11, 16, .82);
  padding: 2px 6px 2px 2px;
  cursor: pointer;
  position: relative;
  border-radius: 5px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.r-color__field:hover { border-color: var(--outline-strong); box-shadow: 0 10px 22px -18px var(--accent-glow); transform: scale(1.025); }
.r-color__sw { width: 18px; height: 18px; border: 1px solid var(--outline); border-radius: 4px; }
.r-color__hex { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }
.r-color__field input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.r-btn {
  height: 26px; padding: 0 14px;
  background: rgba(7, 11, 16, .82); border: 1px solid var(--outline);
  color: var(--text); font-size: 12px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, color .15s ease;
}
.r-btn:hover { border-color: var(--outline-strong); transform: scale(1.04); box-shadow: 0 10px 22px -18px var(--accent-glow); }
.r-btn.is-accent { border-color: var(--accent); color: var(--accent); box-shadow: var(--glow-line); background:rgba(156,201,223,.08); }

.r-input {
  height: 24px; padding: 0 8px;
  background: rgba(7, 11, 16, .82); border: 1px solid var(--outline);
  color: var(--text); font-family: var(--font-mono); font-size: 12px;
  outline: none;
  width: 100%;
  border-radius: 5px;
}
.r-input:focus { border-color: var(--accent); box-shadow: var(--glow-line); }

.r-empty {
  font-size: 11px; color: var(--text-faint);
  font-style: italic;
  padding: 6px 0;
}
