/* ==========================================================================
   AI Project Universe V2.3
   Compact mobile project toolbar + modern AI Architect navigation drawer.
   ========================================================================== */

/* Outer Project Universe viewer toolbar */
@media (max-width: 760px) {
  .viewer[open] {
    grid-template-rows: 54px minmax(0, 1fr) !important;
  }

  .viewer__bar {
    position: relative;
    min-height: 54px !important;
    height: 54px !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 6px 8px !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    overflow: hidden;
  }

  .viewer__bar > div:first-child {
    display: flex !important;
    flex: 1 1 auto;
    min-width: 0 !important;
    max-width: calc(100% - 48px) !important;
    align-items: center;
    gap: 8px;
  }

  .viewer__badge {
    flex: 0 0 auto;
    padding: 5px 7px !important;
    font-size: 9px !important;
    line-height: 1;
    border-radius: 7px;
  }

  #viewerTitle {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: -.01em;
  }

  .viewer__actions {
    display: flex !important;
    flex: 0 0 40px !important;
    width: 40px !important;
    max-width: 40px !important;
    min-width: 40px !important;
    justify-content: flex-end !important;
    align-items: center;
    gap: 0 !important;
  }

  .viewer__actions a {
    display: none !important;
  }

  #viewerClose {
    position: relative;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    border: 2px solid #0a0a0a !important;
    border-radius: 12px !important;
    background: #5f5f5f !important;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 1 !important;
    box-shadow: 2px 2px 0 #0a0a0a;
  }

  #viewerClose::before,
  #viewerClose::after {
    content: "";
    position: absolute;
    left: 10px;
    top: 17px;
    width: 16px;
    height: 2px;
    border-radius: 99px;
    background: white;
  }

  #viewerClose::before { transform: rotate(45deg); }
  #viewerClose::after  { transform: rotate(-45deg); }

  #viewerClose:active {
    transform: translate(2px, 2px);
    box-shadow: none;
  }

  .viewer__loading {
    inset: 54px 0 0 !important;
  }
}

/* AI Architect internal navigation */
.ai-architect-header {
  isolation: isolate;
}

.ai-nav-backdrop {
  display: none;
}

.ai-drawer-heading {
  display: none;
}

@media (max-width: 767px) {
  html.ai-architect-nav-open,
  body.ai-architect-nav-open {
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  .ai-architect-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 1200 !important;
    height: 58px !important;
    min-height: 58px !important;
    padding: 0 11px !important;
    gap: 8px !important;
    background:
      linear-gradient(135deg, rgba(8, 8, 8,.96), rgba(19, 19, 19,.94)) !important;
    border-bottom: 1px solid rgba(175, 175, 175,.28) !important;
    box-shadow: 0 8px 30px rgba(8, 8, 8,.36);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
  }

  .ai-architect-header .ai-menu-trigger {
    position: relative;
    flex: 0 0 42px;
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    border: 1px solid rgba(175, 175, 175,.34) !important;
    border-radius: 13px !important;
    background: rgba(23, 23, 23,.8) !important;
    color: #e8e8e8 !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
    transition:
      transform .2s ease,
      border-color .2s ease,
      background .2s ease,
      box-shadow .2s ease;
  }

  .ai-architect-header .ai-menu-trigger:hover,
  .ai-architect-header .ai-menu-trigger[aria-expanded="true"] {
    border-color: rgba(175, 175, 175,.82) !important;
    background: linear-gradient(135deg, rgba(43, 43, 43,.95), rgba(29, 29, 29,.88)) !important;
    box-shadow: 0 0 0 3px rgba(175, 175, 175,.08), 0 9px 24px rgba(8, 8, 8,.34);
  }

  .ai-architect-header .ai-menu-trigger:active {
    transform: scale(.94);
  }

  .ai-architect-header > div {
    min-width: 0;
  }

  .ai-architect-header > div > div:first-child {
    min-width: 0;
  }

  .ai-architect-header > div > div:first-child span {
    display: block !important;
    min-width: 0;
    max-width: min(53vw, 250px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px !important;
    letter-spacing: .08em !important;
  }

  .ai-nav-backdrop {
    position: fixed;
    inset: 58px 0 0;
    z-index: 1090;
    display: block;
    visibility: hidden;
    opacity: 0;
    border: 0;
    background:
      radial-gradient(circle at 12% 8%, rgba(175, 175, 175,.13), transparent 34%),
      rgba(6, 6, 6,.68);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: opacity .23s ease, visibility .23s ease;
    pointer-events: none;
  }

  .ai-nav-backdrop.is-visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .ai-architect-drawer {
    position: fixed !important;
    inset: 68px auto max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)) !important;
    z-index: 1100 !important;
    width: min(84vw, 326px) !important;
    max-width: calc(100vw - 20px) !important;
    min-width: 0 !important;
    height: auto !important;
    max-height: calc(100dvh - 78px - env(safe-area-inset-bottom)) !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border: 1px solid rgba(175, 175, 175,.32) !important;
    border-radius: 22px !important;
    background:
      linear-gradient(155deg, rgba(11, 11, 11,.985), rgba(8, 8, 8,.985)) !important;
    box-shadow:
      0 30px 90px rgba(0,0,0,.58),
      0 0 0 1px rgba(113, 113, 113,.08),
      inset 0 1px 0 rgba(255,255,255,.05);
    backdrop-filter: blur(22px) saturate(135%);
    -webkit-backdrop-filter: blur(22px) saturate(135%);
    transform-origin: left top;
    animation: aiDrawerIn .26s cubic-bezier(.2,.8,.2,1) both;
    overscroll-behavior: contain;
  }

  .ai-architect-drawer.hidden {
    display: none !important;
  }

  .ai-architect-drawer.flex {
    display: flex !important;
  }

  @keyframes aiDrawerIn {
    from {
      opacity: 0;
      transform: translate3d(-20px,0,0) scale(.97);
    }
    to {
      opacity: 1;
      transform: translate3d(0,0,0) scale(1);
    }
  }

  .ai-drawer-heading {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 62px;
    padding: 11px 11px 10px 15px;
    border-bottom: 1px solid rgba(161, 161, 161,.16);
    background:
      linear-gradient(90deg, rgba(175, 175, 175,.08), transparent 55%),
      rgba(23, 23, 23,.56);
  }

  .ai-drawer-heading__copy {
    min-width: 0;
  }

  .ai-drawer-heading__copy strong,
  .ai-drawer-heading__copy span {
    display: block;
  }

  .ai-drawer-heading__copy strong {
    color: #e7e7e7;
    font-size: 12px;
    line-height: 1.15;
    letter-spacing: .09em;
    text-transform: uppercase;
  }

  .ai-drawer-heading__copy span {
    margin-top: 4px;
    color: #cecece;
    font-size: 9px;
    letter-spacing: .06em;
  }

  .ai-drawer-close {
    position: relative;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(147, 147, 147,.4);
    border-radius: 12px;
    background: rgba(50, 50, 50,.24);
    color: transparent;
    cursor: pointer;
    transition: transform .2s ease, background .2s ease;
  }

  .ai-drawer-close:hover {
    background: rgba(64, 64, 64,.42);
  }

  .ai-drawer-close:active {
    transform: scale(.92);
  }

  .ai-drawer-close::before,
  .ai-drawer-close::after {
    content: "";
    position: absolute;
    left: 10px;
    top: 17px;
    width: 17px;
    height: 2px;
    border-radius: 99px;
    background: #b8b8b8;
  }

  .ai-drawer-close::before { transform: rotate(45deg); }
  .ai-drawer-close::after  { transform: rotate(-45deg); }

  .ai-architect-drawer nav {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
    align-content: start;
    gap: 7px !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 10px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(175, 175, 175,.55) rgba(23, 23, 23,.35);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .ai-architect-drawer nav::-webkit-scrollbar {
    width: 6px;
  }

  .ai-architect-drawer nav::-webkit-scrollbar-track {
    background: rgba(23, 23, 23,.36);
  }

  .ai-architect-drawer nav::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: linear-gradient(#afafaf, #717171);
  }

  .ai-architect-drawer nav > :not([hidden]) ~ :not([hidden]) {
    margin-top: 0 !important;
  }

  .ai-architect-drawer nav > a {
    display: block;
    min-width: 0;
    color: inherit;
    text-decoration: none;
  }

  .ai-architect-drawer nav > a > div {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 55px;
    width: 100%;
    min-width: 0;
    padding: 9px 10px !important;
    border: 1px solid rgba(161, 161, 161,.13);
    border-radius: 14px !important;
    background:
      linear-gradient(145deg, rgba(23, 23, 23,.72), rgba(14, 14, 14,.66));
    color: #c2c2c2 !important;
    font-size: 11px !important;
    line-height: 1.2;
    font-weight: 650 !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
    transition:
      transform .18s ease,
      border-color .18s ease,
      background .18s ease,
      color .18s ease,
      box-shadow .18s ease;
    overflow: hidden;
  }

  .ai-architect-drawer nav > a > div:hover {
    transform: translateY(-1px);
    border-color: rgba(175, 175, 175,.45);
    background:
      linear-gradient(145deg, rgba(43, 43, 43,.72), rgba(31, 31, 31,.58));
    color: #efefef !important;
    box-shadow: 0 9px 24px rgba(8, 8, 8,.32);
  }

  .ai-architect-drawer nav > a > div.bg-primary {
    border-color: rgba(156, 156, 156,.78) !important;
    background:
      linear-gradient(135deg, #606060, #7b7b7b 52%, #6f6f6f) !important;
    color: white !important;
    box-shadow:
      0 10px 24px rgba(96, 96, 96,.28),
      inset 0 1px 0 rgba(255,255,255,.18);
  }

  .ai-architect-drawer nav svg {
    flex: 0 0 18px !important;
    width: 18px !important;
    height: 18px !important;
  }

  .ai-architect-drawer nav > a > div {
    overflow-wrap: anywhere;
  }

  .ai-architect-main {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: clip !important;
  }
}

@media (max-width: 374px) {
  .ai-architect-drawer {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    left: 8px !important;
    right: 8px !important;
  }

  .ai-architect-drawer nav {
    grid-template-columns: minmax(0,1fr) !important;
  }

  .ai-architect-drawer nav > a > div {
    min-height: 48px;
  }
}

@media (min-width: 768px) {
  .ai-nav-backdrop,
  .ai-drawer-heading {
    display: none !important;
  }

  .ai-architect-drawer {
    transform: none !important;
  }
}
