.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 0;
  min-height: 100vh;
  padding: 0;
  transition: grid-template-columns 180ms ease;
}

.app-shell.drawer-mode-icons {
  grid-template-columns: 64px minmax(0, 1fr);
}

.workspace {
  max-width: 1680px;
  min-width: 0;
  overflow-x: clip;
  margin: 0 auto;
  width: 100%;
  padding: 9px;
}

.app-drawer {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  height: 100vh;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: rgba(250, 252, 255, 0.96);
  padding: 0 10px 10px;
  backdrop-filter: blur(18px);
}

.app-drawer.icon-drawer {
  padding: 0 8px 10px;
}

.drawer-logo-button {
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.drawer-logo-button:hover,
.drawer-logo-button:focus-visible {
  border-color: #bfdbfe;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.drawer-brand {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 56px;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--line);
}

.app-drawer.icon-drawer .drawer-brand {
  grid-template-columns: 40px;
  justify-content: center;
  min-height: 104px;
  padding: 8px 0;
}

.app-drawer.icon-drawer .drawer-brand-text {
  display: none;
}

.drawer-logo-app-menu {
  position: absolute;
  top: calc(100% - 4px);
  left: 0;
  z-index: 80;
  display: none;
  width: min(220px, calc(100vw - 24px));
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 6px;
  box-shadow: var(--shadow-lg);
}

.drawer-logo-app-menu.is-open {
  display: grid;
}

.drawer-logo-app-menu button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 6px;
  text-align: left;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.drawer-logo-app-menu button:hover,
.drawer-logo-app-menu button.active {
  border-color: #bfdbfe;
  background: var(--blue-soft);
  color: var(--blue);
}

.drawer-logo-app-menu .menu-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.drawer-logo-app-menu span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-app-switcher {
  position: relative;
  display: grid;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 0 0 12px;
}

.drawer-app-switcher > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.drawer-app-select,
.drawer-app-menu button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 7px;
  text-align: left;
  font-size: 13px;
  font-weight: 850;
}

.drawer-app-select .menu-icon-box,
.drawer-app-menu .menu-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.drawer-app-select strong,
.drawer-app-menu span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-app-menu {
  position: absolute;
  top: calc(100% - 6px);
  left: 0;
  right: 0;
  z-index: 30;
  display: none;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 6px;
  box-shadow: var(--shadow-lg);
}

.drawer-app-switcher.is-open .drawer-app-menu,
.drawer-app-switcher:focus-within .drawer-app-menu {
  display: grid;
}

.drawer-app-menu button {
  border-color: transparent;
  cursor: pointer;
}

.drawer-app-menu button:hover,
.drawer-app-menu button.active {
  background: var(--blue-soft);
  border-color: #bfdbfe;
  color: var(--blue);
}

.drawer-action-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(205, 215, 229, 0.9);
  border-radius: 8px;
  background: #ffffff;
  color: #34415b;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
}

.drawer-action-button:hover {
  border-color: rgba(38, 74, 130, 0.22);
  background: #eef4ff;
  color: var(--blue);
}

.drawer-logo-button {
  transition: background 160ms ease, color 160ms ease, transform 120ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.drawer-logo-button:hover,
.drawer-logo-button:focus-visible {
  background: #eef4ff;
  color: var(--blue);
}

.drawer-brand strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.app-drawer.icon-drawer .drawer-nav {
  justify-items: center;
}

.drawer-nav a {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px 0 8px;
  text-align: left;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, transform 120ms ease;
}

.app-drawer.icon-drawer .drawer-nav a {
  grid-template-columns: 38px;
  width: 44px;
  min-height: 44px;
  justify-content: center;
  padding: 0;
}

.menu-icon-box {
  display: grid;
  place-items: center;
}

.drawer-nav a .menu-icon-box {
  width: 34px;
  height: 34px;
  overflow: hidden;
  border-radius: 11px;
  background: transparent;
  color: #334155;
}

.app-drawer.icon-drawer .drawer-nav a .menu-icon-box {
  width: 38px;
  height: 38px;
}

.drawer-nav a strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-nav-group {
  display: block;
  margin: 8px 8px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.app-drawer.icon-drawer .drawer-nav a strong {
  display: none;
}

.drawer-nav a:hover {
  background: #eef3f9;
  color: #26354f;
}

.drawer-nav a.active {
  background: #eef4ff;
  color: var(--blue);
}

.drawer-user {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.app-drawer.icon-drawer .drawer-user {
  grid-template-columns: 38px;
  justify-content: center;
}

.drawer-user-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: color-mix(in srgb, var(--profile-icon-color, var(--blue)) 12%, #ffffff);
  color: var(--profile-icon-color, var(--blue));
  font-size: 13px;
  font-weight: 900;
  overflow: hidden;
}

.drawer-user-avatar .menu-icon-box {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: transparent;
  color: inherit;
}

.drawer-user-avatar .menu-svg-icon {
  width: 17px;
  height: 17px;
}

.drawer-user-avatar .custom-menu-icon-box {
  padding: 0;
}

.drawer-user-avatar .custom-menu-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.drawer-user-avatar.user-avatar-large {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  font-size: 22px;
}

.drawer-user-avatar.user-avatar-large .menu-svg-icon {
  width: 28px;
  height: 28px;
}

.drawer-user-profile-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.drawer-user-profile-button:hover .drawer-user-avatar,
.drawer-user-profile-button:focus-visible .drawer-user-avatar {
  background: #dbeafe;
}

.drawer-user-text {
  min-width: 0;
}

.drawer-user-text strong,
.drawer-user-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-user-text strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}

.drawer-user-text span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.drawer-logout-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 900;
}

.drawer-logout-button .logout-svg-icon {
  width: 16px;
  height: 16px;
}

.drawer-logout-button:hover {
  border-color: #f3b4b4;
  background: var(--red-soft);
  color: var(--red);
}

.app-drawer.icon-drawer .drawer-user-text,
.app-drawer.icon-drawer .drawer-logout-button {
  display: none;
}

.app-drawer.icon-drawer .drawer-user-profile-button {
  grid-template-columns: 38px;
}

.user-profile-dialog {
  max-width: 540px;
}

.profile-icon-editor {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 12px;
}

.profile-icon-controls {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.profile-icon-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px auto;
  align-items: center;
  gap: 8px;
}

.profile-icon-row input[type="color"] {
  width: 44px;
  min-width: 44px;
  padding: 4px;
}

.profile-icon-row .ghost-button {
  flex: 0 0 auto;
}

.profile-icon-upload {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--blue);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  padding: 10px 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.profile-icon-upload:hover {
  border-color: #bfdbfe;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.profile-icon-upload .menu-svg-icon {
  width: 14px;
  height: 14px;
}

.profile-icon-upload input {
  display: none;
}

.profile-readonly-grid {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.profile-readonly-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.profile-readonly-grid strong {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.drawer-nav a.active .menu-icon-box {
  background: #ffffff;
  color: var(--menu-icon-color, var(--blue));
}

.menu-svg-icon {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
  overflow: visible;
}

.custom-menu-icon {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.drawer-nav a.active::before {
  position: absolute;
  left: -12px;
  width: 3px;
  height: 24px;
  border-radius: 999px;
  background: var(--blue);
  content: "";
}

.app-drawer.icon-drawer .drawer-nav a.active::before {
  left: -10px;
  height: 26px;
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.drawer-mode-icons {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 8px;
  }

  .app-drawer {
    position: static;
    height: auto;
  }

  .drawer-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
