/* ============================================
   TABLET — collapsed icon rail (820–1180px)
   Between the phone drawer and the full sidebar. Rows collapse to their nav
   icon, and creation moves to the compose button.
   ============================================ */

.sidebar-rail-link,
.sidebar-compose-menu button.rail-only,
#sidebar-more-dropdown a.rail-only { display: none; }

button.sidebar-rail-link { border: none; background: none; padding: 0; cursor: pointer; font-family: inherit; }

.sidebar-rail-link {
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: var(--fs-18);
  text-decoration: none;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}
/* The global `a:hover {text-decoration: underline}` (0,1,1) outranks the class-level
   `text-decoration: none` on .sidebar-rail-link (0,1,0), so it has to be reset on hover
   too. The full-width sidebar's links escape this only because they carry the reset in
   an inline style attribute. */
.sidebar-rail-link:hover { background-color: var(--surface-2); color: #fff; text-decoration: none; }
.sidebar-rail-link.is-active { color: #fff; background-color: var(--surface-1); }

/* Create: a full-width "+ New" pill under the nav, and the rail's round + (below). */
.sidebar-compose-wrap { position: relative; margin: 14px 16px 0 0; }
.sidebar-compose {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 9999px;
  background-color: var(--accent);
  color: #06130a;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--dur-fast);
}
.sidebar-compose i { font-size: var(--fs-14); }
.sidebar-compose:hover { background-color: var(--accent-bright); }

/* Shared look for both compose menus; each variant supplies its own positioning. */
.compose-menu {
  min-width: 172px;
  padding: 6px 0;
  background-color: var(--surface-pop);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
/* Opens upward over the empty space above the account, inside the column: the
   sidebar scrolls, so anything hung past its edge would be clipped. */
.sidebar-compose-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 20;
}
.compose-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 0.5rem 0.85rem;
  border: none;
  background: none;
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-14);
  text-align: left;
  cursor: pointer;
}
.compose-menu button:hover { background-color: var(--surface-2); }
.compose-menu button i { width: 16px; color: var(--text-3); font-size: var(--fs-12); }

@media (min-width: 820px) and (max-width: 1180px) {
  #app-sidebar {
    flex: 0 0 72px !important;
    width: 72px !important;
    padding: 1rem 0 !important;
    align-items: center;
    /* The sidebar carries an inline overflow:hidden, so this needs !important or the
       compose menu and the More dropdown get clipped at the 72px rail edge. */
    overflow: visible !important;
    /* position:sticky makes its own stacking context, and .main-content comes later
       in the DOM — without a z-index the flyouts paint underneath the columns. */
    z-index: 5;
  }

  /* Every rail item is a 44px box stacked with no gap, so the logo, the nav
     icons, More and compose all sit on one 44px pitch. */
  .sidebar-header {
    flex-direction: column;
    gap: 0;
    margin-bottom: 0;
    align-self: stretch;
    align-items: center;
  }
  .sidebar-header a[class*="sidebar-logo-link"] {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    line-height: 1;
    padding-left: 0;
    margin-bottom: 0;
  }
  .sidebar-user-link i { margin-right: 0; }

  .sidebar-compose-wrap { display: block; position: relative; order: 10; }
  .sidebar-compose { width: 40px; height: 40px; margin: 2px auto; border-radius: 50%; }
  .sidebar-compose i { font-size: var(--fs-16); }
  .sidebar-compose-label { display: none; }
  .sidebar-compose-menu { left: 100%; margin-left: 6px; bottom: 0; }

  /* Group hairlines shrink to a short tick under the icons. */
  #app-sidebar > ul > li.nav-divider { width: 24px; height: 1px; margin: 6px auto !important; }

  /* Rows: hide the label/count cluster, show the single nav icon. */
  /* <ul> carries a default 13px block margin that broke the pitch either side. */
  #app-sidebar > ul { width: 100%; margin: 0 !important; }
  /* The More row is a plain block <li>, unlike the others — without display:flex the
     centering below silently does nothing to it. */
  #app-sidebar > ul > li {
    display: flex !important;
    align-items: center;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  /* Hide each row's label/count cluster — but not the More dropdown, which is also
     a direct child div of its <li>. */
  #app-sidebar > ul > li > div:not(#sidebar-more-dropdown) { display: none !important; }
  .sidebar-rail-link { display: flex; }

  /* "More" is already a lone icon; drop its label and re-anchor the dropdown. */
  #sidebar-more-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 0;
    padding: 0 !important;
    border-radius: var(--radius-md);
    transition: background-color var(--dur-fast);
  }
  #sidebar-more-toggle span { display: none; }
  #sidebar-more-toggle .more-dot { display: block; position: absolute; top: 9px; right: 9px; margin: 0; box-shadow: 0 0 0 2px #000; }
  #sidebar-more-toggle i {
    display: inline;
    font-size: var(--fs-18);
    color: var(--text-2);
    width: auto;
    margin-right: 0 !important;
    transition: color var(--dur-fast);
  }
  #sidebar-more-toggle:hover { background-color: var(--surface-2); }
  #sidebar-more-toggle:hover i { color: #fff; }
  /* Beside the rail, anchored at More's foot so a long list grows upward, on screen. */
  #sidebar-more-dropdown { left: 100% !important; top: auto !important; bottom: 0 !important; margin-left: 6px; }

  /* The row no longer paints a hover background, so the 44px pill on the link is
     the only hover surface in rail mode and has to stay. Only the active state is
     dropped here, since the row below paints that itself. */
  .sidebar-rail-link.is-active { background-color: transparent; }
  #app-sidebar > ul:first-of-type > li:has(> .sidebar-rail-link.is-active) {
    background-color: var(--surface-1);
  }


  .rail-only { display: block !important; }

  /* The account chip moves into the More dropdown (as Profile), to keep the rail short
     enough to fit without scrolling. */
  .sidebar-user-link { display: none; }

  /* Compose sits at the very bottom of the rail, so its menu opens upward. */
  .sidebar-compose-wrap { margin: 0; height: 44px; }
}
