/* Circlo Iteration 1 - responsive shell and consistent outline navigation.
   ASCII-only source to avoid future encoding/mojibake problems. */

:root {
  --i1-topbar-h: 72px;
  --i1-control: 44px;
  --i1-left: 286px;
  --i1-left-compact: 78px;
  --i1-right: 320px;
}

#app.app.hidden {
  display: none !important;
}

#app.app:not(.hidden) {
  display: grid !important;
  grid-template-columns: var(--i1-left) minmax(0, 1fr) var(--i1-right);
  grid-template-rows: var(--i1-topbar-h) minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  overflow-x: clip;
}

#app .topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  position: sticky !important;
  top: 0;
  z-index: 1000;
  display: grid !important;
  grid-template-columns: max-content minmax(180px, 320px) minmax(280px, 1fr) max-content;
  align-items: center !important;
  gap: 16px;
  width: 100%;
  height: var(--i1-topbar-h) !important;
  min-height: var(--i1-topbar-h) !important;
  max-height: var(--i1-topbar-h) !important;
  padding: 0 20px !important;
  box-sizing: border-box;
  overflow: visible !important;
}

#app .topbar-brand {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}

#app .top-search {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 320px;
  height: var(--i1-control) !important;
  min-height: var(--i1-control) !important;
  display: flex !important;
  align-items: center !important;
  gap: 9px;
  box-sizing: border-box;
}

#app .top-search > .i1-icon {
  flex: 0 0 20px;
}

#app .top-search input {
  width: 100% !important;
  min-width: 0 !important;
}

#app .top-nav,
#app .top-actions {
  min-width: 0;
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
}

#app .top-nav {
  justify-content: center;
  gap: clamp(6px, 1.1vw, 14px);
  overflow: hidden;
}

#app .top-actions {
  justify-content: flex-end;
  gap: 8px;
  overflow: visible;
}

#app .nav-icon,
#app .top-actions .round-btn {
  box-sizing: border-box !important;
  width: var(--i1-control) !important;
  height: var(--i1-control) !important;
  min-width: var(--i1-control) !important;
  min-height: var(--i1-control) !important;
  max-width: var(--i1-control) !important;
  max-height: var(--i1-control) !important;
  flex: 0 0 var(--i1-control) !important;
  aspect-ratio: 1 / 1 !important;
  padding: 0 !important;
  border-radius: 999px !important;
  display: inline-grid !important;
  place-items: center !important;
  line-height: 1 !important;
  overflow: visible !important;
}

#app .nav-icon .badge,
#app .round-btn .badge {
  position: absolute;
}

#app .nav-icon {
  position: relative;
}

#app .account-chip {
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px;
  width: auto;
  min-width: var(--i1-control);
  max-width: 220px;
  height: var(--i1-control) !important;
  min-height: var(--i1-control) !important;
  max-height: var(--i1-control) !important;
  padding: 4px 10px 4px 4px !important;
  flex: 0 1 auto !important;
  overflow: hidden !important;
  white-space: nowrap;
}

#app #topName {
  display: block;
  min-width: 0;
  max-width: 142px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app .avatar.xs,
#app #topAvatar {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  flex: 0 0 36px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  object-fit: cover !important;
}

#app .i1-account-chevron {
  width: 16px !important;
  height: 16px !important;
  flex: 0 0 16px;
}

#app .left-rail {
  grid-column: 1;
  grid-row: 2;
  position: sticky !important;
  top: var(--i1-topbar-h);
  height: calc(100vh - var(--i1-topbar-h)) !important;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  width: auto !important;
  min-width: 0 !important;
  box-sizing: border-box;
}

#app .content-area {
  grid-column: 2;
  grid-row: 2;
  position: relative !important;
  min-width: 0 !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  overflow-x: hidden;
  box-sizing: border-box;
}

#app .right-rail {
  grid-column: 3;
  grid-row: 2;
  position: sticky !important;
  top: var(--i1-topbar-h);
  height: calc(100vh - var(--i1-topbar-h)) !important;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  width: auto !important;
  min-width: 0 !important;
  box-sizing: border-box;
}

#app .left-rail > button {
  min-height: 48px;
  display: flex !important;
  align-items: center !important;
  gap: 14px;
  white-space: nowrap;
  overflow: hidden;
}

#app .left-rail > button:not(.rail-profile) .i1-icon {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px;
  flex: 0 0 22px;
}

#app .rail-profile {
  min-width: 0;
}

#app #railName {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#app .i1-icon {
  display: inline-block;
  width: 22px;
  height: 22px;
  min-width: 22px;
  vertical-align: middle;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  box-sizing: border-box;
}

#app .nav-icon .i1-icon,
#app .round-btn .i1-icon {
  width: 22px;
  height: 22px;
}

#app .composer-actions button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

#app .composer-actions .i1-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

#app .menu-popover,
#app .notifications-panel,
#app .search-results {
  max-width: calc(100vw - 24px);
}

/* Half-screen / smaller desktop: remove the wide user-name chip first. */
@media (max-width: 1260px) {
  #app.app:not(.hidden) {
    grid-template-columns: var(--i1-left) minmax(0, 1fr);
  }

  #app .right-rail {
    display: none !important;
  }

  #app .topbar {
    grid-template-columns: max-content minmax(160px, 260px) minmax(240px, 1fr) max-content;
    gap: 12px;
    padding-inline: 14px !important;
  }

  #app #topName,
  #app .i1-account-chevron {
    display: none !important;
  }

  #app .account-chip {
    width: var(--i1-control) !important;
    max-width: var(--i1-control) !important;
    min-width: var(--i1-control) !important;
    padding: 4px !important;
    border-radius: 999px !important;
    flex: 0 0 var(--i1-control) !important;
  }
}

/* Compact rail: keep the navigation usable without stealing half the page. */
@media (max-width: 1040px) {
  #app.app:not(.hidden) {
    grid-template-columns: var(--i1-left-compact) minmax(0, 1fr);
  }

  #app .topbar {
    grid-template-columns: max-content minmax(140px, 220px) minmax(220px, 1fr) max-content;
    gap: 9px;
    padding-inline: 10px !important;
  }

  #app .topbar-brand > span:last-child {
    display: none !important;
  }

  #app .left-rail {
    padding-inline: 8px !important;
  }

  #app .left-rail > button:not(.rail-profile) {
    justify-content: center !important;
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    margin-inline: auto !important;
    padding-inline: 0 !important;
    font-size: 0 !important;
    gap: 0 !important;
  }

  #app .left-rail .rail-profile {
    justify-content: center !important;
    padding-inline: 0 !important;
  }

  #app #railName,
  #app .rail-footer {
    display: none !important;
  }

  #app .top-nav {
    gap: 4px;
  }
}

/* Tablet / narrow window: primary nav becomes a fixed bottom bar. */
@media (max-width: 780px) {
  :root {
    --i1-topbar-h: 64px;
  }

  #app.app:not(.hidden) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--i1-topbar-h) minmax(0, 1fr);
  }

  #app .topbar {
    grid-column: 1;
    grid-template-columns: max-content minmax(0, 1fr) max-content;
    height: var(--i1-topbar-h) !important;
    min-height: var(--i1-topbar-h) !important;
    max-height: var(--i1-topbar-h) !important;
    gap: 8px;
    padding-inline: 8px !important;
  }

  #app .top-search {
    grid-column: 2;
    max-width: none;
  }

  #app .top-actions {
    grid-column: 3;
  }

  #app .top-nav {
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    height: 62px;
    padding: 7px max(10px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    display: flex !important;
    justify-content: space-around !important;
    gap: 4px !important;
    overflow: visible !important;
    box-sizing: border-box;
    background: var(--surface, var(--panel, #ffffff));
    border-top: 1px solid var(--border, rgba(127, 127, 127, .22));
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .08);
  }

  #app .left-rail,
  #app .right-rail {
    display: none !important;
  }

  #app .content-area {
    grid-column: 1;
    grid-row: 2;
    padding-bottom: calc(74px + env(safe-area-inset-bottom)) !important;
  }

  #app .topbar-brand {
    width: var(--i1-control);
    min-width: var(--i1-control);
    overflow: visible;
  }

  #app .topbar-brand .brand-ring {
    margin: 0 !important;
  }

  #app #themeToggle {
    display: none !important;
  }
}

@media (max-width: 520px) {
  #app .topbar {
    grid-template-columns: 40px minmax(0, 1fr) max-content;
    gap: 6px;
    padding-inline: 6px !important;
  }

  #app .top-search {
    height: 40px !important;
  }

  #app .nav-icon,
  #app .top-actions .round-btn,
  #app .account-chip {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    flex-basis: 40px !important;
  }

  #app .avatar.xs,
  #app #topAvatar {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    flex-basis: 32px !important;
  }

  #app .composer-actions {
    gap: 2px !important;
  }

  #app .composer-actions button {
    font-size: .88rem !important;
    padding-inline: 5px !important;
    gap: 5px;
  }
}

/* Never allow shell controls to become tall ovals because a flex/grid parent stretches them. */
#app .topbar button,
#app .topbar .account-chip {
  align-self: center !important;
}

#app .nav-icon,
#app .round-btn,
#app .account-chip {
  vertical-align: middle;
}
