.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 25;
  background:
    radial-gradient(240px 520px at 12% 18%, var(--accent-left-glow), transparent 70%),
    radial-gradient(260px 520px at 88% 82%, var(--accent-right-glow), transparent 70%),
    linear-gradient(160deg, var(--panel-shell-1), var(--panel-shell-2));
  border-right: 1px solid var(--border-soft);
  box-shadow: 8px 0 24px var(--ink-alpha-24);
  backdrop-filter: blur(12px) saturate(120%);
  overflow: hidden;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease,
    border-color 0.3s ease;
}

.sub-sidebar {
  position: fixed;
  left: calc(var(--sidebar-width));
  top: 0;
  width: calc(220px * var(--ui-scale));
  z-index: 26;
  background: linear-gradient(160deg, var(--panel-strong), var(--panel-soft));
  border: 1px solid var(--border-soft);
  border-radius: calc(18px * var(--ui-scale));
  box-shadow: 0 18px 36px var(--ink-alpha-35);
  backdrop-filter: blur(14px) saturate(125%);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-10px * var(--ui-scale))) scale(0.98);
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.sub-sidebar.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.sub-sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
  padding: calc(12px * var(--ui-scale));
}

.sub-nav {
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
}

.sub-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: calc(12px * var(--ui-scale));
  padding: calc(9px * var(--ui-scale)) calc(12px * var(--ui-scale))
    calc(9px * var(--ui-scale)) calc(14px * var(--ui-scale));
  border-radius: calc(16px * var(--ui-scale));
  border: 1px solid var(--border-weak);
  background: var(--panel-card-weak);
  color: var(--text);
  font-family: var(--font-body);
  letter-spacing: calc(0.4px * var(--ui-scale));
  font-size: calc(12px * var(--ui-scale));
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.sub-nav-item > * {
  position: relative;
  z-index: 1;
}

.sub-nav-backdrop {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left bottom;
  opacity: 0.2;
  mix-blend-mode: screen;
  pointer-events: none;
  filter: saturate(0.85) contrast(1.05);
  mask-image: linear-gradient(
    180deg,
    var(--ink-alpha-0) 0%,
    var(--ink-alpha-75) 60%,
    var(--ink-alpha-100) 100%
  );
  -webkit-mask-image: linear-gradient(
    180deg,
    var(--ink-alpha-0) 0%,
    var(--ink-alpha-75) 60%,
    var(--ink-alpha-100) 100%
  );
  z-index: 0;
}

.sub-nav-icon {
  width: calc(20px * var(--ui-scale));
  height: calc(20px * var(--ui-scale));
  transition: filter 0.2s ease, transform 0.2s ease;
}

.sub-nav-emoji {
  width: calc(20px * var(--ui-scale));
  text-align: center;
  font-size: calc(18px * var(--ui-scale));
  line-height: 1;
}

.sub-nav-item:hover,
.sub-nav-item:focus-visible,
.sub-nav-item.active {
  border-color: var(--border-stronger);
  background: linear-gradient(120deg, var(--accent-soft), var(--panel-soft));
  box-shadow: inset 0 0 0 1px var(--accent-strong);
  transform: translateX(calc(4px * var(--ui-scale)));
}

.sub-nav-item:hover .sub-nav-icon,
.sub-nav-item:focus-visible .sub-nav-icon {
  filter: brightness(1.2) saturate(1.8) hue-rotate(14deg);
  transform: translateX(calc(2px * var(--ui-scale)));
}



.window-hub {
  position: relative;
  width: calc(36px * var(--ui-scale));
  height: calc(36px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
  border: 1px solid var(--border-soft);
  background: var(--panel-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: visible;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.window-hub img {
  width: calc(18px * var(--ui-scale));
  height: calc(18px * var(--ui-scale));
}

.window-hub.active {
  border-color: var(--accent-left);
  box-shadow: 0 0 12px var(--accent-left-glow);
}

.window-hub-count {
  position: absolute;
  top: calc(-6px * var(--ui-scale));
  right: calc(-6px * var(--ui-scale));
  min-width: calc(18px * var(--ui-scale));
  height: calc(18px * var(--ui-scale));
  padding: 0 calc(4px * var(--ui-scale));
  border-radius: 999px;
  background: var(--accent-left);
  color: var(--bg-deep);
  font-size: calc(10px * var(--ui-scale));
  font-weight: 600;
  letter-spacing: calc(0.4px * var(--ui-scale));
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 12px var(--ink-alpha-35);
}

.window-hub.has-count .window-hub-count {
  display: inline-flex;
}

.window-hub-menu {
  position: absolute;
  top: calc(100% + 12px * var(--ui-scale));
  right: 0;
  min-width: calc(220px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale));
  border-radius: calc(16px * var(--ui-scale));
  border: 1px solid var(--border-soft);
  background: var(--panel-card-strong);
  box-shadow: 0 18px 36px var(--ink-alpha-45);
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(-6px * var(--ui-scale))) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.window-hub-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.window-hub-item {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--ui-scale));
  padding: calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
  color: var(--text);
  background: var(--overlay-glass-35);
  border: 1px solid var(--border-weak);
  margin-bottom: calc(8px * var(--ui-scale));
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.window-hub-item:last-child {
  margin-bottom: 0;
}

.window-hub-item:hover {
  border-color: var(--border-stronger);
  background: var(--overlay-mid-45);
  transform: translateY(calc(-1px * var(--ui-scale)));
}

.window-hub-label {
  flex: 1;
  font-size: calc(11px * var(--ui-scale));
  letter-spacing: calc(0.6px * var(--ui-scale));
}

.window-hub-actions {
  display: inline-flex;
  align-items: center;
  gap: calc(6px * var(--ui-scale));
}

.window-hub-action {
  width: calc(26px * var(--ui-scale));
  height: calc(26px * var(--ui-scale));
  border-radius: calc(10px * var(--ui-scale));
  border: 1px solid var(--border-soft);
  background: var(--overlay-glass-55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.window-hub-action svg {
  width: calc(14px * var(--ui-scale));
  height: calc(14px * var(--ui-scale));
  stroke: var(--text);
}

.window-hub-action.remove svg {
  stroke: var(--sync-critical);
}

.window-hub-action:hover {
  border-color: var(--border-stronger);
  transform: translateY(calc(-1px * var(--ui-scale)));
}

.sidebar.locked {
  width: var(--sidebar-width);
}

.sidebar.locked-collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.locked-collapsed:hover {
  width: var(--sidebar-collapsed);
}

.sidebar:not(.locked):not(.locked-collapsed) {
  width: var(--sidebar-collapsed);
}

.sidebar:not(.locked):not(.locked-collapsed):hover {
  width: var(--sidebar-width);
}

.sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: calc(18px * var(--ui-scale));
  padding: calc(96px * var(--ui-scale)) calc(12px * var(--ui-scale))
    calc(6px * var(--ui-scale));
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .sidebar-inner,
.sidebar.locked-collapsed .sidebar-inner {
  opacity: 0.75;
}

.sidebar.locked .sidebar-inner,
.sidebar:not(.locked):not(.locked-collapsed):hover .sidebar-inner {
  opacity: 1;
  transform: translateX(0);
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
  margin-top: auto;
}


.sidebar-lock {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--ui-scale));
  height: var(--ui-hit-target);
  min-height: var(--ui-hit-target);
  width: 100%;
  margin: 0;
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: calc(14px * var(--ui-scale));
  border: 1px solid var(--border-soft);
  background: var(--panel-card-muted);
  color: var(--text);
  font-family: var(--font-body);
  font-size: calc(12px * var(--ui-scale));
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
}

.sidebar-lock:hover {
  border-color: var(--border-bright);
  background: var(--panel-strong);
}

.sidebar-lock img {
  width: calc(20px * var(--ui-scale));
  height: calc(20px * var(--ui-scale));
}

.nav {
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
}

.theme-dock {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: calc(10px * var(--ui-scale));
}

body.theme-dock-hidden .theme-dock {
  display: none;
}

body.theme-dock-hidden .theme-menu {
  display: none;
}

.theme-trigger {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: calc(14px * var(--ui-scale));
  border: 1px solid var(--border-soft);
  background: var(--panel-card-muted);
  color: var(--text);
  font-family: var(--font-body);
  font-size: calc(12px * var(--ui-scale));
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.theme-trigger:hover,
.theme-trigger:focus-visible {
  border-color: var(--border-stronger);
  background: var(--panel-card-strong);
}

.theme-orb {
  width: calc(20px * var(--ui-scale));
  height: calc(20px * var(--ui-scale));
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: radial-gradient(
    circle at 75% 25%,
    var(--orb-accent, var(--accent-left)),
    var(--orb-base, var(--bg-mid)) 70%
  );
  box-shadow: 0 0 10px var(--ink-alpha-35);
  flex: 0 0 auto;
}







.theme-menu {
  position: fixed;
  left: 0;
  top: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: calc(8px * var(--ui-scale));
  min-width: calc(180px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale));
  border-radius: calc(16px * var(--ui-scale));
  border: 1px solid var(--border-soft);
  background: var(--panel-card-muted);
  box-shadow: 0 16px 32px var(--ink-alpha-35);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-6px * var(--ui-scale)));
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
}

.theme-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.theme-option {
  display: flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  padding: calc(6px * var(--ui-scale)) calc(8px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
  border: 1px solid var(--border-weak);
  background: var(--panel-card-weak);
  color: var(--text);
  font-family: var(--font-body);
  font-size: calc(11px * var(--ui-scale));
  letter-spacing: calc(0.3px * var(--ui-scale));
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.theme-option:hover,
.theme-option:focus-visible {
  border-color: var(--border-stronger);
  background: linear-gradient(120deg, var(--accent-soft), var(--panel-soft));
  transform: translateX(calc(2px * var(--ui-scale)));
}

.theme-option.active {
  border-color: var(--border-stronger);
  background: linear-gradient(120deg, var(--accent-soft), var(--panel-soft));
  box-shadow: inset 0 0 0 1px var(--accent-strong);
}



.theme-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: calc(12px * var(--ui-scale));
  height: var(--ui-hit-target);
  min-height: var(--ui-hit-target);
  width: 100%;
  margin: 0;
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale))
    calc(10px * var(--ui-scale)) calc(18px * var(--ui-scale));
  border-radius: calc(16px * var(--ui-scale));
  border: 1px solid var(--border-weak);
  background: var(--panel-card-weak);
  color: var(--text);
  font-family: var(--font-body);
  letter-spacing: calc(0.4px * var(--ui-scale));
  font-size: calc(12px * var(--ui-scale));
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.nav-item-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
  justify-content: flex-start;
}

.nav-item-wrap .nav-item {
  flex: 1 1 auto;
  width: auto;
  padding-right: calc(40px * var(--ui-scale));
}

.nav-item img {
  width: calc(22px * var(--ui-scale));
  height: calc(22px * var(--ui-scale));
  transition: filter 0.2s ease, transform 0.2s ease;
}

.nav-submenu-toggle {
  position: absolute;
  right: calc(10px * var(--ui-scale));
  width: calc(24px * var(--ui-scale));
  height: calc(24px * var(--ui-scale));
  border-radius: calc(8px * var(--ui-scale));
  border: 1px solid var(--border-weak);
  background: var(--overlay-glass-35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.nav-submenu-toggle img {
  width: calc(14px * var(--ui-scale));
  height: calc(14px * var(--ui-scale));
  transform: rotate(-90deg);
  transition: transform 0.2s ease;
}

.nav-item.submenu-open .nav-submenu-toggle img {
  transform: rotate(0deg);
}

.sidebar-lock img {
  transition: filter 0.2s ease, transform 0.2s ease;
}

.nav-item:hover,
.nav-item:focus-visible,
.nav-item.active {
  border-color: var(--border-stronger);
  background: linear-gradient(120deg, var(--accent-soft), var(--panel-soft));
  box-shadow: inset 0 0 0 1px var(--accent-strong);
  transform: translateX(calc(4px * var(--ui-scale)));
}

.nav-item:hover .nav-submenu-toggle,
.nav-item:focus-visible .nav-submenu-toggle {
  border-color: var(--border-stronger);
  background: var(--overlay-mid-45);
}

.nav-item:hover img,
.nav-item:focus-visible img,
.sidebar-lock:hover img,
.sidebar-lock:focus-visible img {
  filter: brightness(1.2) saturate(1.8) hue-rotate(14deg);
  transform: translateX(calc(2px * var(--ui-scale)));
}

.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .nav-label,
.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .lock-label,
.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .nav-meta,
.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .theme-label,
.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .theme-name,
.sidebar.locked-collapsed .nav-label,
.sidebar.locked-collapsed .lock-label,
.sidebar.locked-collapsed .nav-meta,
.sidebar.locked-collapsed .theme-label,
.sidebar.locked-collapsed .theme-name {
  display: none;
}

.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .nav-item,
.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .sidebar-lock,
.sidebar.locked-collapsed .nav-item,
.sidebar.locked-collapsed .sidebar-lock {
  justify-content: center;
  gap: 0;
  padding: calc(10px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
  background: var(--panel-card-ghost);
}

.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .nav-item-wrap,
.sidebar.locked-collapsed .nav-item-wrap {
  justify-content: center;
}

.sidebar:not(.locked):not(.locked-collapsed):hover .nav-submenu-toggle {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0.4s;
}

.sidebar.locked .nav-submenu-toggle {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0s;
}

.sidebar.locked-collapsed .nav-submenu-toggle {
  opacity: 0;
  pointer-events: none;
  transition-delay: 0s;
}

.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .theme-trigger,
.sidebar.locked-collapsed .theme-trigger {
  justify-content: center;
  padding: calc(10px * var(--ui-scale));
}

.sidebar:not(.locked):not(.locked-collapsed):not(:hover) .nav-item.active,
.sidebar.locked-collapsed .nav-item.active {
  background: linear-gradient(120deg, var(--accent-soft), var(--panel-soft));
  border-color: var(--border-stronger);
  box-shadow: inset 0 0 0 1px var(--accent-strong);
}

.sidebar.theme-locked {
  width: var(--sidebar-width);
}

.sidebar.theme-locked .nav-label,
.sidebar.theme-locked .lock-label,
.sidebar.theme-locked .nav-meta,
.sidebar.theme-locked .theme-label,
.sidebar.theme-locked .theme-name {
  display: inline-flex;
}

.sidebar.theme-locked .nav-item,
.sidebar.theme-locked .sidebar-lock {
  justify-content: flex-start;
  gap: calc(12px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale))
    calc(10px * var(--ui-scale)) calc(18px * var(--ui-scale));
  border-radius: calc(16px * var(--ui-scale));
  background: var(--panel-card-weak);
}

.sidebar.theme-locked .sidebar-lock {
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
}

.sidebar.theme-locked .theme-trigger {
  justify-content: flex-start;
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
}



.sidebar {
  transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar.is-hidden {
  transform: translateX(-100%);
  pointer-events: none;
}

.sidebar.is-hidden ~ .sub-sidebar {
  opacity: 0;
  pointer-events: none;
}

