/* Managed sidebar sections use the same rail and More controls at each size. */
.sidebar-tab { flex:none; }
#sidebar-layout-status {
  color:var(--muted);
  font-size:13px;
  line-height:1.45;
  margin:8px 4px;
}
#sidebar-layout-status:empty { margin:0; }
#sidebar-layout-check { margin:0 4px 6px; }
#more-dialog .sidebar-row-options { width:44px; height:44px; padding:10px; }
#more-dialog .sidebar-row-options[aria-expanded="true"] { background:var(--soft); }
.sidebar-item-actions {
  display:grid;
  gap:2px;
  margin:0 0 6px 32px;
  padding:4px;
  border:1px solid var(--line);
  border-radius:10px;
  background:var(--surface);
}
.sidebar-item-actions button { min-height:44px; padding:6px 12px; background:transparent; text-align:left; }
.sidebar-item-actions button:hover,
.sidebar-item-actions button:focus-visible { background:var(--soft); }
.sidebar-item-actions p { margin:6px 10px 2px; color:var(--muted); font-size:13px; }
#more-dialog :is(button,.sidebar-item-actions button):focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }

@media (min-width:701px) {
  /* The 224px footer and 4px inset leave the usual nav center with 58px of top padding. */
  .rail { padding-block:clamp(4px,calc(100dvh - 300px),58px) 4px; justify-content:flex-start; }
  .rail > nav { min-height:0; margin-block:auto; overflow-y:auto; scrollbar-width:none; padding:4px; }
  .rail-bottom { position:static; align-self:flex-start; flex:none; width:72px; align-items:center; }
  .rail-bottom > :is(#app-download-open,#settings-open) { width:72px; height:56px; padding:17px 25px; border-radius:12px; }
  .rail-bottom > :is(#app-download-open,#settings-open):focus-visible { outline-offset:-3px; }
  .rail-bottom > #app-download-open + #settings-open { margin-top:-12px; }
  .rail > nav > button,#sidebar-navbar > #search-open { flex:none; }
  .rail #sidebar-navbar,.rail #space-shortcuts { display:flex; flex-direction:column; gap:12px; }
  .rail #space-shortcuts:empty { display:none; }
  /* Count only managed tabs; Search sits after Chat inside the navbar host. */
  #sidebar-navbar > [data-view="library"]:nth-child(5 of .sidebar-tab) { position:relative; margin-top:16px; }
  #sidebar-navbar > [data-view="library"]:nth-child(5 of .sidebar-tab)::before {
    content:""; position:absolute; top:-14px; left:8px; right:8px; height:1px;
    background:var(--line); pointer-events:none;
  }
  #more-dialog {
    inset:0; margin:auto; max-height:calc(100dvh - 48px);
    padding:26px 24px 24px; border-radius:18px;
  }
  #more-dialog .sheet-handle {
    top:8px; left:auto; right:8px; width:36px; height:36px;
    border-radius:50%; background:var(--soft);
  }
  #more-dialog .sheet-handle::before { content:"×"; font-size:20px; line-height:1; }
  #more-dialog .sheet-handle span { display:none; }
}

@media (min-width:701px) and (max-height:280px) {
  .rail { overflow-y:auto; scrollbar-width:none; }
  .rail > nav { min-height:52px; }
}

@media (max-width:700px) {
  .rail #sidebar-navbar { display:contents; }
  .rail #sidebar-navbar[data-chat-only="true"] { display:none; }
  .rail:has(#sidebar-navbar[data-chat-only="true"]) { justify-content:flex-end; padding-right:max(8px,env(safe-area-inset-right)); }
}
