#app {
  display: flex;
  width: 100%;
  height: 100%;
}

#sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  width: var(--sidebar-w);
  height: 100%;
  flex: none;
  flex-direction: column;
  overflow: hidden;
  border-width: 0 1px 0 0;
  transition: width .2s ease, transform .2s ease;
}

#sidebar[data-width="wide2"] {
  width: var(--sidebar-w2);
}
#sidebar[data-width="collapsed"] {
  width: 0;
  border: 0;
}
#sidebar[data-width="collapsed"] > * {
  display: none;
}

#sidebar-header {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}

#root-switcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
}

.menu-btn {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.menu-btn:hover,
.menu-btn.is-active {
  background: var(--accent);
}
.menu-btn .grow {
  min-width: 0;
  flex: 1;
}

#root-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--root-color, var(--fg));
  color: var(--bg);
}

#root-copy {
  display: block;
}
#root-name {
  display: block;
  font-weight: 650;
  font-size: 13px;
}
#root-description {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.icon-button {
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex: none;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--accent);
  color: var(--fg);
}

#root-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  display: grid;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: 0 14px 38px rgba(0, 0, 0, .25);
}

#root-menu[hidden] {
  display: none;
}

#search-box {
  display: flex;
  height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
}

#search-box:focus-within {
  border-color: var(--fg);
}
#search {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
}
#search::placeholder {
  color: var(--muted);
}

#sidebar-tabs {
  display: flex;
  gap: 4px;
}
.tab {
  display: flex;
  flex: 1;
  justify-content: center;
  padding: 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tab:hover,
.tab.active {
  background: var(--accent);
  color: var(--fg);
}

#sidebar-tree {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding: 8px;
}

.tree-group {
  display: flex;
  flex-direction: column;
}
.tree-children {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 2px 0 2px 22px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}
.tree-children[hidden] {
  display: none;
}

.tree-row,
.app-row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.tree-row:hover,
.app-row:hover,
.app-row.is-active {
  background: var(--accent);
}

.tree-row__chevron {
  color: var(--muted);
  transition: transform .2s ease;
}
.tree-row[aria-expanded="true"] .tree-row__chevron {
  transform: rotate(90deg);
}
.tree-row__icon,
.app-row__icon {
  color: var(--item-color, var(--muted));
}
.tree-row__label,
.app-row__label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-row__label {
  font-weight: 550;
}
.tree-row__count {
  color: var(--muted);
  font-size: 11px;
}

.app-row {
  color: var(--muted);
}
.app-row:hover,
.app-row.is-active {
  color: var(--fg);
}
.app-row__select {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.app-row__external {
  opacity: 0;
}
.app-row:hover .app-row__external,
.app-row:focus-within .app-row__external,
.app-row.is-active .app-row__external {
  opacity: 1;
}

#sidebar-empty {
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}

#sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
}
#versions {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 4px;
  padding-left: 54px;
}
#versions a {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}
#versions a:hover,
#versions a[aria-current="page"] {
  background: var(--accent);
  color: var(--fg);
}

#stage {
  position: relative;
  min-width: 0;
  flex: 1;
  background: var(--preview-bg);
}
#preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}
#preview-frame[hidden] {
  display: none;
}
#preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  pointer-events: none;
}
#preview-appspace {
  margin: 0;
  color: var(--fg);
  font-size: clamp(2rem, 6vw, 4.5rem);
  letter-spacing: -.04em;
}
#preview-message {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1rem;
}
#preview-message .iconify {
  width: 22px;
  height: 22px;
}
#preview-empty[hidden] {
  display: none;
}

#sidebar-toggle {
  position: fixed;
  z-index: 40;
  bottom: 8px;
  left: 8px;
  display: flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--fg);
  cursor: pointer;
}
#sidebar-toggle svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
#sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
  }
  #sidebar[data-width="wide2"] {
    width: min(var(--sidebar-w2), calc(100vw - 2rem));
  }
  #sidebar[data-width="collapsed"] {
    width: var(--sidebar-w);
    transform: translateX(-110%);
  }
  #sidebar[data-width="collapsed"] > * {
    display: flex;
  }
  #sidebar[data-width="collapsed"] #sidebar-tree {
    display: flex;
  }
  #sidebar-backdrop {
    position: fixed;
    z-index: 15;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(0, 0, 0, .35);
    backdrop-filter: blur(2px);
  }
  #sidebar-backdrop:not([hidden]) {
    display: block;
  }
}
