:root { --header-height: 48px; --favorites-height: 34px; }
#sec-bookmark { --row-bg: #172a30; --row-alt: #22363e; --row-hover: #2e4852; --row-border: #3b535d; position: sticky; top: var(--header-height); z-index: 5; margin-bottom: 18px; background: #172328; border-color: #465c65; border-bottom-width: 2px; border-radius: 4px; box-shadow: 0 8px 16px #0006; }
#sec-bookmark > summary { position: static; cursor: pointer; font-size: 16px; background: #23343c; color: #d4e2e6; border-radius: 3px 3px 0 0; }
#sec-bookmark[open] { padding-bottom: 6px; }
#sec-bookmark .row-rank { display: none; }
#bookmark-content { display: flex; flex-direction: column; max-height: min(190px, calc(50vh - 60px)); max-height: min(190px, calc(50dvh - 60px)); }
#bookmark-content .section-list { min-height: 0; max-height: 123px; background: transparent; overscroll-behavior: contain; overflow-y: auto; scrollbar-width: thin; scrollbar-gutter: stable; }
#bookmark-actions { flex-shrink: 0; }
#content-search, [id^="sec-"] { scroll-margin-top: calc(var(--header-height) + var(--favorites-height) + 12px); }
.visitor-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; padding: 10px; }
.visitor-actions button, .action-menu-toggle, .action-menu-items :is(button, a), [data-bookmarks="retry"] { background: #252525; color: #bfcbd3; border: 1px solid #626262; border-radius: 3px; padding: 4px 9px; cursor: pointer; font: inherit; font-size: 12px; }
.visitor-actions button:disabled { opacity: .45; cursor: default; }
#bookmark-menu { position: relative; }
#bookmark-menu summary { list-style: none; }
#bookmark-menu summary::-webkit-details-marker { display: none; }
.action-menu-toggle span { display: inline-block; }
#bookmark-menu[open] summary span, .action-menu-toggle[aria-expanded="true"] span { transform: rotate(180deg); }
.action-menu-items { position: absolute; top: calc(100% + 4px); right: 0; z-index: 2; min-width: 135px; padding: 4px; background: #252525; border: 1px solid #626262; border-radius: 3px; box-shadow: 0 4px 12px #0005; }
.action-menu-items :is(button, a) { box-sizing: border-box; display: block; width: 100%; padding: 8px; border: 0; text-align: left; overflow-wrap: anywhere; }
.action-menu-items :is(button, a):hover { background: #35454c; }
.site-menu-button { box-sizing: border-box; min-height: 30px; white-space: nowrap; }
#site-actions-menu { box-sizing: border-box; position: fixed; inset: auto; margin: 0; max-width: calc(100vw - 16px); }
#bookmark-menu [data-bookmarks="share"] { display: none; }
#sec-bookmark .addtag:not(.site-status) { display: none; }
:root[data-theme="light"] :is(.visitor-actions button, .action-menu-toggle, .action-menu-items, .action-menu-items :is(button, a), [data-bookmarks="retry"]) { background: #f2f5f7; color: #354450; border-color: #acbcc7; }
:root[data-theme="light"] .action-menu-items :is(button, a):hover { background: #e1edf2; }
:root[data-theme="light"] #sec-bookmark { --row-bg: #eef5f8; --row-alt: #e2eef3; --row-hover: #d3e6ee; --row-border: #bfd3de; background: #eef5f8; border-color: #a8c0cb; box-shadow: 0 8px 16px #172b401f; }
:root[data-theme="light"] #sec-bookmark .section-title { background: #e1edf2; color: #354f5b; }
:root[data-theme="light"] #bookmark-content .section-list { background: transparent; }
@media (max-width: 550px) {
  .visitor-actions { gap: 5px; }
  .visitor-actions button, .action-menu-toggle, .action-menu-items :is(button, a), [data-bookmarks="retry"] { box-sizing: border-box; min-height: 44px; font-size: 14px; line-height: 20px; padding: 10px; }
  #sec-bookmark > summary { box-sizing: border-box; min-height: 44px; line-height: 24px; padding: 10px 0; }
  #sec-bookmark .site-row-head { grid-template-columns: minmax(0, 1fr) auto; }
  #sec-bookmark .site-row-title, #sec-bookmark .site-status { grid-column: 1; }
  #sec-bookmark .site-row-actions { grid-column: 2; }
  /* Show two complete compact rows below the touch-sized toolbar. */
  #bookmark-content { max-height: min(224px, calc(50vh - 60px)); max-height: min(224px, calc(50dvh - 60px)); }
  #bookmark-content .section-list { max-height: 110px; }
}
@media (max-width: 480px) {
  #bookmark-menu [data-bookmarks="export"] { display: none; }
  #bookmark-menu [data-bookmarks="share"] { display: block; }
}
@media (max-width: 380px) {
  #sec-bookmark .site-row-title { grid-column: 1 / -1; }
  #bookmark-content .section-list { max-height: 158px; }
}
