/*
 * LumaCite Library – Reference Capture test route
 * Sidebar and dialog refinement inspired by the LumaCite Citation Generator
 * extension. This file is intentionally loaded only by
 * /cloud-reference-manager.
 */

:root {
  --ref-brand: #ef3f34;
  --ref-brand-dark: #c8312b;
  --ref-brand-soft: #fff0ee;
  --ref-ink: #172033;
  --ref-muted: #53647b;
  --ref-quiet: #7b899b;
  --ref-line: #d7e0ec;
  --ref-line-strong: #c7d4e3;
  --ref-shell-line: #aebfd3;
  --ref-line-soft: #e8edf4;
  --ref-canvas: #f4f7ff;
  --ref-paper: #ffffff;
  --ref-paper-blue: #f7faff;
  --ref-blue: #1473e6;
  --ref-blue-soft: #eaf3ff;
  --ref-green: #0f8058;
  --ref-green-soft: #e9f8f1;
  --ref-amber: #9b5b00;
  --ref-amber-soft: #fff5db;
  --ref-danger: #b42318;
  --ref-danger-soft: #fff1f0;
  --ref-focus: rgba(20, 115, 230, 0.24);
  --sidebar-width: 288px;
}

/* Outer canvas: a stronger grid with restrained but visible LumaCite color washes. */
body {
  background-color: var(--ref-canvas);
  background-image:
    linear-gradient(rgba(20, 115, 230, 0.14) 1.5px, transparent 1.5px),
    linear-gradient(90deg, rgba(20, 115, 230, 0.14) 1.5px, transparent 1.5px),
    radial-gradient(circle at 10% 14%, rgba(20, 115, 230, 0.32), transparent 35%),
    radial-gradient(circle at 88% 76%, rgba(239, 63, 52, 0.42), transparent 40%);
  background-size: 42px 42px, 42px 42px, auto, auto;
}

/* Route shell: slightly denser and better balanced at desktop sizes. */
.library-app {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

/* Sidebar surface and rhythm. */
.sidebar {
  gap: 10px;
  padding: 12px;
  border: 2.5px solid var(--ref-shell-line);
  border-radius: 16px;
  background: var(--ref-paper);
  box-shadow: none;
  color: var(--ref-ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.main-panel {
  border: 2.5px solid var(--ref-shell-line);
}

.sidebar-fixed-top {
  gap: 12px;
}

.sidebar-fixed-bottom {
  gap: 8px;
}

.sidebar-scroll-region {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  padding: 4px 2px 4px 0;
}

/* Long taxonomy groups scroll independently so every accordion heading stays visible. */
.sidebar-scroll-region > .collapsible-section {
  min-height: 0;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-scroll-region > .collapsible-section:not(.collapsed) {
  flex: 1 1 0;
}

.sidebar-scroll-region > .collapsible-section > .section-heading {
  flex: 0 0 auto;
}

.sidebar-scroll-region > .collapsible-section > .section-body {
  min-height: 0;
  flex: 1 1 auto;
  align-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: #aebccc transparent;
  scrollbar-width: thin;
}

.sidebar-scroll-region > .collapsible-section.collapsed > .section-body {
  display: none;
}

.sidebar-scroll-region > .collapsible-section > .section-body::-webkit-scrollbar {
  width: 8px;
}

.sidebar-scroll-region > .collapsible-section > .section-body::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-scroll-region > .collapsible-section > .section-body::-webkit-scrollbar-thumb {
  border: 2px solid var(--ref-paper);
  border-radius: 999px;
  background: #aebccc;
}

@media (min-width: 1025px) and (max-width: 1100px) {
  .sidebar-scroll-region {
    overflow: visible;
  }

  .sidebar-scroll-region > .collapsible-section:not(.collapsed) {
    flex: 0 0 auto;
    overflow: visible;
  }

  .sidebar-scroll-region > .collapsible-section > .section-body {
    max-height: min(360px, 48vh);
    flex: 0 1 auto;
  }
}

/* Account lockup: follows the Citation Generator header proportions. */
.brand-row {
  min-height: 72px;
  grid-template-columns: 36px minmax(0, 1fr) 34px;
  gap: 10px;
  padding: 11px 10px 11px 12px;
  border: 2px solid var(--ref-line-strong);
  border-radius: 14px;
  background: var(--ref-paper);
  box-shadow: none;
}

.brand-row::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 14px;
  right: 14px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: var(--ref-brand);
}

.sidebar-brand-mark {
  width: 36px;
  height: 36px;
  align-self: center;
}

.brand-copy {
  gap: 3px;
}

.brand-row strong {
  color: var(--ref-ink) !important;
  background: none;
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.025em;
  line-height: 1.05;
  text-shadow: none;
}

.brand-row strong::after {
  width: 6px;
  height: 6px;
  margin-left: 7px;
  background: var(--ref-green);
  box-shadow: none;
}

.brand-email {
  max-width: 166px !important;
  color: var(--ref-muted) !important;
  font-size: 11.5px !important;
  font-weight: 450 !important;
  line-height: 1.35;
}

.brand-row [data-sync-status] {
  min-height: 19px;
  margin-top: 1px;
  padding: 3px 7px;
  border: 1px solid #f5c6c2;
  border-radius: 999px;
  background: var(--ref-brand-soft);
  color: var(--ref-brand-dark) !important;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.1;
}

.brand-row [data-sync-status][data-state="synced"] {
  border-color: #bde7d4;
  background: var(--ref-green-soft);
  color: var(--ref-green) !important;
}

.brand-row [data-sync-status][data-state="local"] {
  display: none !important;
}

.account-menu-toggle {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 10px;
  background: var(--ref-paper-blue);
  color: var(--ref-muted);
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.account-menu-toggle::before {
  width: 17px;
  height: 17px;
}

.account-menu-toggle:hover,
.account-menu-toggle:focus-visible {
  border-color: #b9c8da;
  background: var(--ref-blue-soft);
  color: var(--ref-blue);
  box-shadow: none;
}

/* Account and taxonomy menus. */
.account-menu {
  top: calc(100% + 7px);
  right: 0;
  min-width: 172px;
  gap: 2px;
  padding: 6px;
  overflow: hidden;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 12px;
  background: var(--ref-paper);
  box-shadow: none;
}

.account-menu button {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ref-ink);
  font-size: 13px;
  font-weight: 570;
}

.account-menu button::before {
  width: 18px;
  height: 18px;
  background: currentColor;
  content: "";
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 18px 18px;
  mask-size: 18px 18px;
}

.account-menu button[data-action="open-help"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M9.1 9a3 3 0 1 1 5.8 1c0 2-2.9 2-2.9 4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M9.1 9a3 3 0 1 1 5.8 1c0 2-2.9 2-2.9 4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}

.account-menu button[data-action="open-settings"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21 4h-7M10 4H3M21 12h-9M8 12H3M21 20h-5M12 20H3'/%3E%3Ccircle cx='12' cy='4' r='2'/%3E%3Ccircle cx='10' cy='12' r='2'/%3E%3Ccircle cx='14' cy='20' r='2'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21 4h-7M10 4H3M21 12h-9M8 12H3M21 20h-5M12 20H3'/%3E%3Ccircle cx='12' cy='4' r='2'/%3E%3Ccircle cx='10' cy='12' r='2'/%3E%3Ccircle cx='14' cy='20' r='2'/%3E%3C/svg%3E");
}

.account-menu button:hover {
  background: var(--ref-paper-blue);
  color: var(--ref-blue);
}

/* Primary library navigation. */
.nav-section {
  gap: 4px;
}

.sidebar-fixed-top > .nav-section {
  padding: 0 1px;
}

.nav-section > p {
  padding: 0 8px 3px;
  color: var(--ref-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.075em;
}

.nav-item {
  min-height: 42px;
  padding: 8px 10px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ref-muted);
  font-size: 13px;
  font-weight: 570;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.nav-item-main {
  gap: 10px;
}

.nav-item:hover {
  border-color: var(--ref-line-soft);
  background: var(--ref-paper-blue);
  color: var(--ref-ink);
}

.nav-item[data-view="all"],
.nav-item[data-view="starred"],
.nav-item[data-view="trash"] {
  background-image: none !important;
}

.nav-item[data-view="all"]:hover {
  border-color: #d5e3f4;
  background: var(--ref-paper-blue) !important;
  background-image: none !important;
  color: var(--ref-blue);
}

.nav-item[data-view="starred"]:hover {
  border-color: #f0dcaa;
  background: #fffaf0 !important;
  background-image: none !important;
  color: var(--ref-amber);
}

.nav-item[data-view="trash"]:hover {
  border-color: #f1d2cf;
  background: #fff8f7 !important;
  background-image: none !important;
  color: var(--ref-danger);
}

.nav-item.active,
.folder-row.active,
.label-row.active {
  border-color: #c7dcf7;
  background: var(--ref-blue-soft) !important;
  background-image: none !important;
  color: var(--ref-blue);
  font-weight: 650;
  box-shadow: inset 2px 0 0 var(--ref-blue);
}

.nav-item[data-view="all"].active {
  border: 2px solid var(--ref-blue);
  background: var(--ref-blue-soft) !important;
  background-image: none !important;
  color: var(--ref-blue);
  box-shadow: none;
}

.nav-item[data-view="starred"].active {
  border: 2px solid #d28a00;
  background: var(--ref-amber-soft) !important;
  background-image: none !important;
  color: var(--ref-amber);
  box-shadow: none;
}

.nav-item[data-view="trash"].active {
  border: 2px solid var(--ref-brand);
  background: var(--ref-danger-soft) !important;
  background-image: none !important;
  color: var(--ref-danger);
  box-shadow: none;
}

.nav-item:focus-visible {
  outline: 2px solid var(--ref-blue);
  outline-offset: 1px;
  box-shadow: none;
}

.nav-item > span:last-child {
  min-width: 24px;
  color: var(--ref-quiet);
  font-size: 12px;
  font-weight: 650;
}

.nav-item.active > span:last-child {
  color: currentColor;
}

.sidebar-icon {
  width: 19px;
  height: 19px;
  flex-basis: 19px;
}

.collection-icon::before,
.folder-icon::before,
.flag-icon::before,
.star-icon::before,
.trash-icon::before {
  -webkit-mask-size: 19px 19px;
  mask-size: 19px 19px;
}

/* Collapsible taxonomy groups. */
.sidebar-scroll-region > .nav-section {
  padding-top: 7px;
  border-top: 1px solid var(--ref-line-soft);
}

.section-heading {
  min-height: 36px;
  gap: 6px;
}

.section-toggle {
  min-height: 34px !important;
  gap: 8px;
  padding: 0 7px !important;
  border-radius: 9px !important;
  color: var(--ref-muted) !important;
}

.section-toggle:hover {
  background: var(--ref-paper-blue) !important;
  color: var(--ref-ink) !important;
}

.section-toggle span:last-child {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.075em;
}

.section-chevron {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
  -webkit-mask-size: 14px 14px;
  mask-size: 14px 14px;
}

.section-heading-actions {
  width: 32px;
  min-width: 32px;
}

.section-heading-actions > button {
  position: relative;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 10px;
  background: var(--ref-paper);
  color: var(--ref-blue);
  font-size: 0;
  box-shadow: none;
}

.section-heading-actions > button::before,
.section-heading-actions > button::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
  transform: translate(-50%, -50%);
}

.section-heading-actions > button::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.section-heading-actions > button:hover {
  border-color: #bdd6f5;
  background: var(--ref-blue-soft);
  color: var(--ref-blue);
  box-shadow: none;
}

.section-body > .muted {
  display: block;
  padding: 3px 8px 8px 29px;
  color: var(--ref-quiet);
  font-size: 12px;
  font-weight: 450;
  line-height: 1.45;
}

.folder-tree,
.chip-list {
  gap: 3px;
}

.folder-row,
.chip {
  min-height: 36px;
  border-radius: 9px;
  font-size: 12.5px;
}

/* Bottom action retains a quiet danger hierarchy. */
.signout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 12px;
  border: 1.5px solid #edb8b3;
  border-radius: 10px;
  background: var(--ref-paper);
  color: var(--ref-brand-dark);
  font-size: 12.5px;
  font-weight: 650;
  box-shadow: none;
}

.signout::before {
  width: 17px;
  height: 17px;
  background: currentColor;
  content: "";
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='m16 17 5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E") center / 17px 17px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='m16 17 5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E") center / 17px 17px no-repeat;
}

.signout:hover {
  border-color: #eba9a3;
  background: var(--ref-brand-soft);
  color: var(--ref-danger);
}

/* Floating and folder menus use the same component language. */
.floating-menu,
.search-popover,
.bulk-folder-menu,
.sf-select-content,
.folder-menu {
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 12px;
  background: var(--ref-paper);
  box-shadow: none;
}

.folder-menu {
  padding: 6px;
}

.folder-menu-item {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ref-ink);
  font-size: 13px;
  font-weight: 550;
}

.folder-menu-item:hover {
  background: var(--ref-paper-blue);
  color: var(--ref-blue);
}

.folder-menu-item.danger:hover {
  background: var(--ref-danger-soft);
  color: var(--ref-danger);
}

/* Dialogs: compact Citation Generator proportions and controls. */
.modal::backdrop,
.online-modal::backdrop {
  background: rgba(23, 32, 51, 0.58);
  backdrop-filter: blur(3px);
}

.modal-card,
.online-modal-card {
  border: 2px solid var(--ref-line-strong);
  border-radius: 16px;
  background: var(--ref-paper);
  box-shadow: none;
}

.modal-card h2 {
  color: var(--ref-ink);
  font-size: 22px;
  font-weight: 720;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.modal-card > header > button,
.editor-close,
.online-modal-card header button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1.5px solid var(--ref-line-strong) !important;
  border-radius: 10px;
  background: var(--ref-paper) !important;
  color: var(--ref-muted) !important;
  font-size: 12.5px;
  font-weight: 620;
  box-shadow: none;
}

.modal-card > header > button:hover,
.editor-close:hover,
.online-modal-card header button:hover {
  border-color: #b9c8da !important;
  background: var(--ref-paper-blue) !important;
  color: var(--ref-ink) !important;
}

.modal-card input:not([type="checkbox"]):not([type="radio"]),
.modal-card select,
.modal-card textarea {
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 10px;
  background: var(--ref-paper);
  color: var(--ref-ink);
  box-shadow: none;
}

.modal-card input:not([type="checkbox"]):not([type="radio"]):focus,
.modal-card select:focus,
.modal-card textarea:focus {
  border-color: var(--ref-blue);
  outline: 0;
  box-shadow: 0 0 0 3px var(--ref-focus);
}

.modal-card .ghost-button,
.modal-card .primary-button {
  min-height: 42px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 650;
  box-shadow: none;
}

.modal-card .ghost-button {
  border: 1.5px solid var(--ref-line-strong);
  background: var(--ref-paper);
  color: var(--ref-ink);
}

.modal-card .ghost-button:hover {
  border-color: #b9c8da;
  background: var(--ref-paper-blue);
}

.modal-card .primary-button {
  border: 1px solid var(--ref-brand);
  background: var(--ref-brand);
  color: #fff;
}

.modal-card .primary-button:hover {
  border-color: var(--ref-brand-dark);
  background: var(--ref-brand-dark);
}

[data-dialog="taxonomy"] {
  width: min(520px, calc(100vw - 32px));
}

[data-dialog="taxonomy"] .modal-card {
  width: 100%;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

[data-dialog="taxonomy"] .modal-card > header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--ref-line-soft);
}

[data-dialog="taxonomy"] .modal-card > .muted {
  margin: 0;
  padding: 17px 20px 8px;
  color: var(--ref-muted);
  font-size: 13.5px;
  line-height: 1.5;
}

[data-dialog="taxonomy"] .modal-card > label {
  display: grid;
  gap: 7px;
  padding: 8px 20px 20px;
  color: var(--ref-muted);
  font-size: 12.5px;
  font-weight: 620;
}

[data-dialog="taxonomy"] .modal-card input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 450;
}

[data-dialog="taxonomy"] .modal-card > footer {
  padding: 16px 20px;
  border-top: 1px solid var(--ref-line-soft);
}

[data-dialog="taxonomy"] .modal-card > footer .primary-button {
  min-width: 132px;
}

@media (max-width: 1100px) {
  :root {
    --sidebar-width: 276px;
  }

  .library-app {
    gap: 12px;
    padding: 12px;
  }

  .sidebar {
    border-radius: 14px;
  }
}

@media (max-width: 760px) {
  .library-app {
    padding: 8px;
  }
}

/* --------------------------------------------------------------------------
   Right-side application system
   A flat, compact component language shared by the command bar, filters,
   empty state, popovers, dropdowns, and reference editor.
   -------------------------------------------------------------------------- */

.main-panel {
  overflow: hidden;
  border-radius: 16px;
  background: var(--ref-paper);
  color: var(--ref-ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Command bar */
.command-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1.5px solid var(--ref-line);
  border-radius: 0;
  background: var(--ref-paper);
  box-shadow: none;
}

.command-cluster {
  gap: 10px;
}

.topbar-add {
  min-width: 92px;
  height: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--ref-brand);
  border-radius: 10px;
  background: var(--ref-brand);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: none;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.topbar-add:hover {
  border-color: var(--ref-brand-dark);
  background: var(--ref-brand-dark);
  box-shadow: none;
  transform: none;
}

.add-button span {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 18px;
  font-weight: 500;
  line-height: 19px;
}

.top-search {
  gap: 8px;
  min-width: 260px;
}

.command-bar .top-search > input,
.command-bar .toolbar button,
.command-bar .search-box button,
.command-bar .folder-picker-button,
.top-search > input {
  height: 44px !important;
  min-height: 44px !important;
  border: 1.5px solid var(--ref-line-strong) !important;
  border-radius: 10px !important;
  background: var(--ref-paper) !important;
  color: var(--ref-ink) !important;
  box-shadow: none !important;
}

.top-search > input {
  padding: 0 14px;
  font-size: 14px;
  font-weight: 450;
}

.top-search > input::placeholder {
  color: var(--ref-quiet);
  opacity: 1;
}

.top-search > input:hover {
  border-color: #b9c8da !important;
}

.top-search > input:focus {
  border-color: var(--ref-blue) !important;
  outline: 0;
  box-shadow: 0 0 0 3px var(--ref-focus) !important;
}

.toolbar {
  gap: 8px;
}

.toolbar-icon,
.folder-picker-button,
.bulk-folder-control {
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  flex-basis: 44px;
}

.command-bar .toolbar button {
  padding-inline: 13px;
  font-size: 12.5px;
  font-weight: 650;
}

.command-bar .toolbar > button:not(.toolbar-icon) {
  background: var(--ref-paper) !important;
  color: var(--ref-ink) !important;
}

.command-bar .toolbar > button:not(.toolbar-icon):last-child:not(:disabled) {
  min-width: 82px;
  border-color: var(--ref-ink) !important;
  background: var(--ref-ink) !important;
  color: #fff !important;
}

.command-bar .toolbar > button:not(.toolbar-icon):last-child:not(:disabled):hover {
  border-color: #27334a !important;
  background: #27334a !important;
  color: #fff !important;
}

.command-bar .toolbar button:disabled {
  border-color: var(--ref-line-soft) !important;
  background: #f6f8fb !important;
  color: #a5b0c0 !important;
  cursor: not-allowed;
  opacity: 1;
}

.command-bar .toolbar button:hover:not(:disabled),
.command-bar .search-box button:hover:not(:disabled),
.command-bar .folder-picker-button:hover,
.command-bar .folder-picker-button:focus-visible,
.command-bar .folder-picker-button.active {
  border-color: #b9c8da !important;
  background: var(--ref-paper-blue) !important;
  color: var(--ref-blue) !important;
  box-shadow: none !important;
  transform: none;
}

.toolbar-symbol,
.sidebar-icon.folder-icon,
.sort-direction-symbol {
  color: currentColor;
}

/* Heading and filters */
.list-header {
  min-height: 66px;
  align-items: center;
  gap: 16px;
  padding: 8px 18px;
  border-bottom: 1.5px solid var(--ref-line-soft);
  background: var(--ref-paper-blue);
}

.list-header > div:first-child {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 9px;
}

.list-header h1 {
  color: var(--ref-ink);
  font-size: 23px;
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1;
  margin: 0;
}

.list-header [data-result-count] {
  display: inline-flex;
  align-items: center;
  align-self: baseline;
  color: var(--ref-muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  margin: 0;
}

.sort-row {
  gap: 8px;
  color: var(--ref-muted);
  font-size: 12.5px;
  font-weight: 620;
}

.sort-row .sort-direction-button,
.sort-row .sf-select-trigger,
.sort-row > [data-selected-count] {
  height: 42px !important;
  min-height: 42px !important;
  border: 1.5px solid var(--ref-line-strong) !important;
  border-radius: 10px !important;
  background: var(--ref-paper) !important;
  color: var(--ref-muted) !important;
  box-shadow: none !important;
}

.sort-row .sort-direction-button {
  width: 42px !important;
  min-width: 42px !important;
  flex-basis: 42px;
}

.sort-row .sf-select[data-custom-select="filters"] {
  width: 132px;
  min-width: 132px;
}

.sort-row .sf-select[data-custom-select="sort"] {
  width: 152px;
  min-width: 152px;
}

.sort-row .sf-select[data-custom-select="type"] {
  width: 142px;
  min-width: 142px;
}

.sort-row .sf-select-trigger {
  padding: 0 12px;
  color: var(--ref-ink) !important;
  font-size: 12.75px;
  font-weight: 650;
  line-height: 1.35;
}

.sort-row .sf-select-trigger > span:first-child {
  line-height: inherit;
}

.sort-row > [data-selected-count] {
  min-width: 104px;
  padding: 0 13px;
  color: var(--ref-muted) !important;
  white-space: nowrap;
}

.sort-row .sort-direction-button:hover,
.sort-row .sf-select-trigger:hover,
.sort-row .sf-select-trigger[aria-expanded="true"] {
  border-color: #b9c8da !important;
  background: var(--ref-blue-soft) !important;
  color: var(--ref-blue) !important;
}

.sort-row .sf-select-trigger:focus-visible {
  border-color: var(--ref-blue) !important;
  outline: 0;
  box-shadow: 0 0 0 3px var(--ref-focus) !important;
}

.sf-select-chevron {
  width: 14px;
  height: 14px;
}

.sf-select-chevron::before {
  width: 14px;
  height: 14px;
}

/* Compact dropdowns */
.sort-row .sf-select-content,
.sf-select-content {
  top: calc(100% + 6px);
  max-height: min(42vh, 300px);
  overflow-x: hidden;
  padding: 6px;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 12px;
  background: var(--ref-paper);
  background-image: none !important;
  background-clip: padding-box;
  box-shadow: none;
  scrollbar-gutter: stable;
}

.sf-select[data-custom-select="sort"] .sf-select-content {
  width: max(100%, 176px);
}

.sf-select[data-custom-select="type"] .sf-select-content {
  width: max(100%, 190px);
}

.sf-select[data-custom-select="filters"] .sf-select-content {
  width: max(100%, 216px);
}

.sort-row .quick-filter-trigger {
  grid-template-columns: 18px minmax(0, 1fr) 14px;
  gap: 6px;
  padding-inline: 10px;
}

.sort-row .quick-filter-trigger.has-active-filters {
  grid-template-columns: 18px minmax(0, 1fr) auto 14px;
}

.quick-filter-trigger-icon,
.quick-filter-option-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.quick-filter-trigger > span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-filter-active-count {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ref-blue);
  color: #fff !important;
  font-size: 10.5px !important;
  font-weight: 750 !important;
  line-height: 1;
}

.quick-filter-active-count.hidden {
  display: none;
}

.sort-row .quick-filter-trigger.has-active-filters {
  border-color: #a9c8ee !important;
  background: var(--ref-blue-soft) !important;
  color: var(--ref-blue) !important;
}

.sort-row .quick-filter-menu {
  max-height: none;
  overflow: visible;
  padding: 6px;
  scrollbar-gutter: auto !important;
}

.quick-filter-option {
  min-height: 40px;
  display: grid;
  grid-template-columns: 17px 20px minmax(0, 1fr) max-content;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--ref-muted);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 620;
  transition: background 120ms ease, color 120ms ease;
}

.quick-filter-option + .quick-filter-option {
  margin-top: 2px;
}

.quick-filter-option:hover,
.quick-filter-option.active {
  background: var(--ref-blue-soft);
  color: var(--ref-blue);
}

.quick-filter-option:focus-within {
  outline: 2px solid var(--ref-blue);
  outline-offset: -2px;
}

.quick-filter-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--ref-blue);
  cursor: pointer;
}

.quick-filter-option > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-filter-option strong {
  color: var(--ref-quiet);
  font-size: 11.5px;
  font-weight: 620;
  text-align: right;
}

.quick-filter-option.active strong {
  color: var(--ref-blue);
}

.sf-select[data-custom-select="sort"] .sf-select-item {
  grid-template-columns: minmax(0, 1fr) 18px;
  column-gap: 8px;
}

.sf-select[data-custom-select="type"] .sf-select-item {
  grid-template-columns: minmax(0, 1fr) max-content 18px;
  column-gap: 8px;
}

.sort-row .sf-select-item,
.sf-select-item {
  min-height: 38px;
  margin: 0;
  padding: 8px 10px !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  background-image: none !important;
  color: var(--ref-muted) !important;
  font-size: 12.5px;
  font-weight: 580;
  box-shadow: none !important;
}

.sort-row .sf-select-item + .sf-select-item,
.sf-select-item + .sf-select-item {
  margin-top: 2px;
}

.sort-row .sf-select-item:hover,
.sort-row .sf-select-item.is-hovered,
.sort-row .sf-select-item.active:hover,
.sort-row .sf-select-item.active.is-hovered,
.sf-select-item:hover,
.sf-select-item.is-hovered {
  background: var(--ref-blue-soft) !important;
  background-image: none !important;
  color: var(--ref-blue) !important;
}

.sort-row .sf-select-content .sf-select-item:hover,
.sort-row .sf-select-content .sf-select-item.is-hovered,
.sort-row .sf-select-content .sf-select-item.active:hover,
.sort-row .sf-select-content .sf-select-item.active.is-hovered {
  background: var(--ref-blue-soft) !important;
  background-image: none !important;
  color: var(--ref-blue) !important;
}

.sort-row .sf-select-item.active,
.sf-select-item.active {
  background: var(--ref-paper-blue) !important;
  background-image: none !important;
  color: var(--ref-ink) !important;
  font-weight: 680;
}

.sf-select-item strong,
.sf-select-item.active strong,
.sort-row .sf-select-item strong,
.sort-row .sf-select-item:hover strong,
.sort-row .sf-select-item.is-hovered strong {
  color: var(--ref-quiet) !important;
  font-size: 11.5px;
  font-weight: 620;
}

.sort-row .sf-select-content .sf-select-item:hover strong,
.sort-row .sf-select-content .sf-select-item.is-hovered strong,
.sort-row .sf-select-content .sf-select-item.active:hover strong,
.sort-row .sf-select-content .sf-select-item.active.is-hovered strong {
  color: var(--ref-blue) !important;
}

.sf-select-item.active .sf-select-check {
  color: var(--ref-blue);
}

/* Content frame and empty state */
.content-grid {
  padding: 14px 18px 18px;
  background: var(--ref-paper);
}

.reference-list {
  border: 1.5px solid var(--ref-line);
  border-radius: 12px;
  background: var(--ref-paper);
  background-image: none;
  box-shadow: none;
}

.empty-state {
  min-height: 500px;
  padding: 48px 24px;
  background: var(--ref-paper-blue);
  background-image: none !important;
  color: var(--ref-muted);
}

.empty-state > div {
  display: grid;
  justify-items: center;
  max-width: 590px;
}

.empty-state > div::before {
  width: 58px;
  height: 58px;
  margin-bottom: 18px;
  border: 0;
  border-radius: 14px;
  background: transparent url("/cloud-reference-manager/LumaCite_Citation_Generator_Logo.png") center / contain no-repeat !important;
  box-shadow: none;
  clip-path: none;
  color: transparent;
  content: "";
}

.empty-state h2 {
  margin: 0;
  color: var(--ref-ink);
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 720;
  letter-spacing: -0.045em;
  line-height: 1.05;
  text-align: center;
}

.empty-state p {
  max-width: 500px;
  margin: 11px 0 0;
  color: var(--ref-muted);
  font-size: 14px;
  font-weight: 450;
  line-height: 1.55;
  text-align: center;
}

.empty-actions {
  gap: 8px;
  margin-top: 22px;
}

.empty-actions .primary-button,
.empty-actions .ghost-button {
  min-height: 42px;
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 650;
  box-shadow: none;
}

.empty-actions .primary-button {
  border: 1.5px solid var(--ref-brand);
  background: var(--ref-brand);
  color: #fff;
}

.empty-actions .primary-button:hover {
  border-color: var(--ref-brand-dark);
  background: var(--ref-brand-dark);
}

.empty-actions .ghost-button {
  border: 1.5px solid var(--ref-line-strong);
  background: var(--ref-paper);
  color: var(--ref-ink);
}

.empty-actions .ghost-button:hover {
  border-color: #b9c8da;
  background: var(--ref-blue-soft);
  color: var(--ref-blue);
}

/* Add menu */
.floating-menu.add-menu {
  width: min(650px, calc(100vw - 80px));
  max-height: min(70vh, 510px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 7px;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 14px;
  background: var(--ref-paper);
  background-image: none !important;
  backdrop-filter: none;
  box-shadow: none;
}

.add-menu-item {
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 11px;
  min-height: 62px;
  padding: 9px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  background-image: none !important;
  color: var(--ref-muted);
}

.add-menu-item + .add-menu-item {
  margin-top: 2px;
}

.add-menu-item.featured {
  background: var(--ref-brand-soft);
  background-image: none !important;
  box-shadow: inset 2px 0 0 var(--ref-brand);
}

.add-menu-item:hover,
.add-menu-item.featured:hover {
  background: var(--ref-blue-soft);
  background-image: none !important;
  color: var(--ref-blue);
  box-shadow: none;
}

.add-menu-item.featured:hover {
  box-shadow: inset 2px 0 0 var(--ref-brand);
}

.add-menu-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--ref-paper-blue);
  color: var(--ref-muted);
}

.add-menu-icon::before {
  inset: 7px !important;
}

.add-menu-item.featured .add-menu-icon {
  background: #ffe2de;
  color: var(--ref-brand);
}

.add-menu-item:hover .add-menu-icon {
  background: var(--ref-paper);
  color: var(--ref-blue);
}

.add-menu-copy {
  gap: 3px;
}

.add-menu-copy strong {
  color: var(--ref-ink);
  font-size: 13.25px;
  font-weight: 680;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.add-menu-copy small {
  color: var(--ref-muted);
  font-size: 11.75px;
  font-weight: 480;
  line-height: 1.42;
}

.add-menu-item kbd,
.search-help-row kbd {
  min-width: 34px;
  min-height: 26px;
  padding: 4px 7px;
  border: 1px solid var(--ref-line);
  border-radius: 7px;
  background: var(--ref-paper-blue);
  color: var(--ref-muted);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 10.5px;
  font-weight: 650;
  line-height: 16px;
  box-shadow: none;
}

/* Search options popover */
.search-popover {
  z-index: 210;
  left: 102px;
  width: min(700px, calc(100vw - 370px));
  max-height: min(72vh, 510px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 7px;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 14px;
  background: var(--ref-paper);
  background-image: none !important;
  backdrop-filter: none;
  box-shadow: none;
}

.search-help-row {
  min-height: 48px;
  grid-template-columns: 34px auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ref-muted);
}

.search-help-row + .search-help-row {
  margin-top: 2px;
}

.search-help-row:hover {
  background: var(--ref-blue-soft);
}

.search-option-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--ref-paper-blue);
  color: var(--ref-muted);
}

.search-option-icon::before {
  inset: 7px !important;
}

.search-help-row:hover .search-option-icon {
  background: var(--ref-paper);
  color: var(--ref-blue);
}

.search-help-row strong {
  color: var(--ref-ink);
  font-size: 12.5px;
  font-weight: 680;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.search-help-row span:not(.search-option-icon) {
  color: var(--ref-muted);
  font-size: 11.75px;
  font-weight: 480;
  line-height: 1.4;
}

.search-help-section {
  gap: 7px;
  margin-top: 5px;
  padding: 10px;
  border: 0;
  border-top: 1px solid var(--ref-line-soft);
}

.search-help-section > span {
  color: var(--ref-muted);
  font-size: 11.5px;
  font-weight: 680;
  letter-spacing: 0.02em;
}

.search-help-section > button {
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--ref-line);
  border-radius: 999px;
  background: var(--ref-paper-blue);
  color: var(--ref-muted);
  font-size: 11px;
  font-weight: 620;
  box-shadow: none;
}

.search-help-section > button:hover {
  border-color: #bdd6f5;
  background: var(--ref-blue-soft);
  color: var(--ref-blue);
}

.search-help-section.include-section {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.search-help-section.include-section > span {
  margin-bottom: 1px;
}

.include-section label {
  min-height: 34px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 18px;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--ref-muted);
  font-size: 12px;
  font-weight: 580;
}

.include-section label:hover {
  background: var(--ref-paper-blue);
}

.include-section .search-option-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.include-section .search-option-icon::before {
  inset: 5px !important;
}

.include-section input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--ref-blue);
}

/* Reference editor */
[data-dialog="editor"] {
  padding: 0;
}

.editor-card {
  width: min(1060px, calc(100vw - 48px));
  height: min(760px, calc(100vh - 44px));
  max-height: calc(100vh - 44px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--ref-line-strong);
  border-radius: 18px;
  background: var(--ref-paper);
  box-shadow: none;
}

.editor-header,
.editor-footer {
  padding: 14px 18px;
  background: var(--ref-paper);
}

.editor-header {
  min-height: 76px;
  border-bottom: 1.5px solid var(--ref-line);
}

.editor-footer {
  min-height: 70px;
  border-top: 1.5px solid var(--ref-line);
}

.editor-title-wrap {
  gap: 11px;
}

.editor-title-icon {
  width: 40px;
  height: 40px;
  border: 1.5px solid #f0b7b2;
  border-radius: 10px;
  background: var(--ref-brand-soft);
  color: var(--ref-brand);
  box-shadow: none;
}

.editor-title-icon::before {
  margin: 8px auto;
}

.editor-card h2 {
  margin: 0;
  color: var(--ref-ink);
  font-size: 21px;
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.editor-title-wrap p {
  margin-top: 4px;
  color: var(--ref-muted);
  font-size: 12.5px;
  font-weight: 480;
  line-height: 1.35;
}

.editor-close {
  min-width: 78px;
  min-height: 38px;
  border: 1.5px solid var(--ref-line-strong) !important;
  border-radius: 10px;
  background: var(--ref-paper) !important;
  color: var(--ref-muted) !important;
  font-size: 12.5px;
  font-weight: 650;
  box-shadow: none;
}

.editor-grid {
  gap: 11px;
  padding: 14px 16px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--ref-paper-blue);
  background-image: none !important;
}

.editor-section,
.editor-section-core,
.editor-section-ids {
  position: relative;
  gap: 10px 12px;
  padding: 14px;
  border: 1.5px solid var(--ref-line) !important;
  border-radius: 12px;
  background: var(--ref-paper);
  background-image: none !important;
  box-shadow: none;
}

.editor-section-core,
.editor-section-ids {
  border-top: 1.5px solid var(--ref-line) !important;
}

.editor-section h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 1px;
  color: var(--ref-muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.075em;
  line-height: 1.2;
  text-transform: uppercase;
}

.editor-section h3::before {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 999px;
  background: var(--ref-line-strong);
  content: "";
}

.editor-section-core h3::before {
  background: var(--ref-brand);
}

.editor-section-ids h3::before {
  background: var(--ref-blue);
}

.editor-section label {
  gap: 6px;
  color: var(--ref-muted);
  font-size: 11.75px;
  font-weight: 650;
  line-height: 1.25;
}

.editor-section input,
.editor-section select,
.editor-section textarea {
  min-height: 42px;
  padding: 9px 11px;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 9px;
  background: var(--ref-paper);
  color: var(--ref-ink);
  font-size: 13px;
  font-weight: 450;
  box-shadow: none;
}

.editor-section textarea {
  min-height: 84px;
  line-height: 1.5;
}

.editor-section input::placeholder,
.editor-section textarea::placeholder {
  color: #98a5b6;
  opacity: 1;
}

.editor-section input:hover,
.editor-section select:hover,
.editor-section textarea:hover {
  border-color: #b9c8da;
}

.editor-section input:focus,
.editor-section select:focus,
.editor-section textarea:focus {
  border-color: var(--ref-blue);
  outline: 0;
  box-shadow: 0 0 0 3px var(--ref-focus);
}

.editor-footer .ghost-button,
.editor-footer .primary-button {
  min-height: 42px;
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 12.75px;
  font-weight: 680;
  box-shadow: none;
}

.editor-footer .ghost-button {
  border: 1.5px solid var(--ref-line-strong);
  background: var(--ref-paper);
  color: var(--ref-ink);
}

.editor-footer .primary-button {
  min-width: 132px;
  border: 1.5px solid var(--ref-brand);
  background: var(--ref-brand);
  color: #fff;
}

/* Quiet, consistent scrollbars across secondary right-side scroll surfaces. */
.editor-grid,
.floating-menu.add-menu,
.search-popover,
.sf-select-content,
.bulk-folder-scroll-region {
  scrollbar-width: thin;
  scrollbar-color: #aebccc transparent;
}

.editor-grid::-webkit-scrollbar,
.floating-menu.add-menu::-webkit-scrollbar,
.search-popover::-webkit-scrollbar,
.sf-select-content::-webkit-scrollbar,
.bulk-folder-scroll-region::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.editor-grid::-webkit-scrollbar-track,
.floating-menu.add-menu::-webkit-scrollbar-track,
.search-popover::-webkit-scrollbar-track,
.sf-select-content::-webkit-scrollbar-track,
.bulk-folder-scroll-region::-webkit-scrollbar-track {
  margin-block: 8px;
  background: transparent;
}

.editor-grid::-webkit-scrollbar-thumb,
.floating-menu.add-menu::-webkit-scrollbar-thumb,
.search-popover::-webkit-scrollbar-thumb,
.sf-select-content::-webkit-scrollbar-thumb,
.bulk-folder-scroll-region::-webkit-scrollbar-thumb {
  border: 2px solid var(--ref-paper);
  border-radius: 999px;
  background: #aebccc;
}

/*
 * The reference list already has a custom, draggable scrollbar. Keep native
 * scrolling active while suppressing Chrome's second track, thumb, and arrow
 * buttons so the two scrollbar systems cannot overlap visually.
 */
.reference-list {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.reference-list::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.reference-list::-webkit-scrollbar-button,
.reference-list::-webkit-scrollbar-track,
.reference-list::-webkit-scrollbar-thumb,
.reference-list::-webkit-scrollbar-corner {
  display: none;
}

.reference-scrollbar {
  right: 21px;
  width: 5px;
}

.reference-scrollbar-thumb {
  width: 5px;
  border-radius: 999px;
  background: #aebccc;
}

@media (max-width: 1260px) {
  .command-bar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .command-cluster {
    flex: 1 1 100%;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-end;
  }

  .search-popover {
    left: 0;
    width: min(700px, calc(100vw - 64px));
  }
}

@media (max-width: 900px) {
  .list-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .sort-row {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .editor-card {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
  }
}

/* Reference metadata: calmer weight, clear link semantics, no accidental red body copy. */
.reference-card .source {
  color: #0b74f6;
  font-weight: 580;
}

.reference-card .meta-primary-link a {
  color: #009f68;
  font-weight: 580;
}

.reference-card .meta-primary-link a:hover {
  color: #056747;
}

.reference-card .links {
  align-items: center;
}

.reference-resource-indicators {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
  padding-left: 7px;
  border-left: 1px solid var(--ref-line-soft);
  color: #9aa8ba;
  white-space: nowrap;
  vertical-align: middle;
}

.reference-resource-indicator {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  line-height: 1;
  text-decoration: none;
  transition: color 140ms ease, background-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.reference-resource-indicator svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
}

.reference-resource-indicator.active {
  color: var(--ref-blue);
  background: var(--ref-blue-soft);
}

.reference-resource-indicator.pdf.active {
  color: var(--ref-red);
  background: #fff0ee;
}

.reference-resource-indicator.notes.active {
  color: #7250bb;
  background: #f3edff;
}

.reference-card .links .reference-resource-indicator:hover {
  color: #516176;
  background: #eef3f9;
  text-decoration: none;
  transform: translateY(-1px);
}

.reference-card .links .reference-resource-indicator.pdf.active:hover {
  color: #c5302a;
  background: #ffe5e1;
}

.reference-card .links .reference-resource-indicator.attachment.active:hover {
  color: #075fca;
  background: #e2efff;
}

.reference-card .links .reference-resource-indicator.notes.active:hover {
  color: #5b36a5;
  background: #e9ddff;
}

.reference-resource-indicator.selected {
  box-shadow: 0 0 0 2px var(--ref-paper), 0 0 0 4px rgba(11, 116, 246, 0.2);
}

.reference-resource-indicator:focus-visible {
  outline: 2px solid var(--ref-blue);
  outline-offset: 2px;
}

.reference-resource-count {
  color: currentColor !important;
  font-size: 10px !important;
  font-weight: 720 !important;
  line-height: 1;
}

.reference-resource-dot {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 5px;
  height: 5px;
  border: 1.5px solid var(--ref-paper);
  border-radius: 999px;
  background: currentColor;
}

.reference-card.resource-panel-open {
  padding-bottom: 0;
  background: #fff;
}

.reference-resource-panel {
  grid-column: 1 / -1;
  overflow: hidden;
  min-width: 0;
  margin: 8px -14px 0;
  border: 0;
  border-top: 2px solid #86b9f5;
  border-radius: 0;
  background: #fbfdff;
  box-shadow: none;
  animation: reference-resource-panel-open 150ms ease-out;
}

.reference-resource-panel.pdf-panel {
  border-top-color: #f29b94;
}

.reference-resource-panel.notes-panel {
  border-top-color: #bba6e8;
}

@keyframes reference-resource-panel-open {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.reference-resource-panel-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid #e7edf5;
  background: #f5f9fe;
}

.pdf-panel .reference-resource-panel-header {
  background: #fff8f6;
}

.notes-panel .reference-resource-panel-header {
  background: #faf7ff;
}

.reference-resource-panel-header > span:nth-child(2) {
  min-width: 0;
}

.reference-resource-panel-header strong,
.reference-resource-panel-header small {
  display: block;
}

.reference-resource-panel-header strong {
  color: #13233a;
  font-size: 13px;
  font-weight: 790;
  line-height: 1.25;
}

.reference-resource-panel-header small {
  overflow: hidden;
  margin-top: 2px;
  color: #6f7f94;
  font-size: 11.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-resource-panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: var(--ref-blue);
  background: var(--ref-blue-soft);
}

.reference-resource-panel-icon.pdf {
  color: var(--ref-red);
  background: #fff0ee;
}

.reference-resource-panel-icon.notes {
  color: #7250bb;
  background: #f3edff;
}

.reference-resource-panel-icon svg,
.resource-file-action svg,
.resource-file-kind svg {
  width: 16px;
  height: 16px;
}

.reference-resource-panel-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #77869a;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.reference-resource-panel-close:hover {
  background: #eaf0f7;
  color: #20344f;
}

.reference-resource-panel-body {
  padding: 12px 14px 14px;
  background: #fff;
}

.pdf-panel-body {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 9px;
}

.resource-url-form {
  display: flex;
  flex: 1 1 390px;
  align-items: end;
  gap: 8px;
  min-width: 260px;
}

.resource-url-form label {
  display: grid;
  flex: 1 1 auto;
  gap: 5px;
  min-width: 0;
}

.resource-url-form label > span {
  color: #53657c;
  font-size: 11px;
  font-weight: 750;
}

.resource-url-form input,
.notes-panel-body textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd7e5;
  border-radius: 8px;
  background: #fff;
  color: #17263b;
  font: inherit;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.resource-url-form input {
  height: 36px;
  padding: 0 10px;
  font-size: 12.5px;
}

.resource-url-form input:focus,
.notes-panel-body textarea:focus {
  border-color: #77aff2;
  box-shadow: 0 0 0 3px rgba(11, 116, 246, 0.12);
}

.resource-primary-action,
.resource-secondary-action,
.resource-file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  box-sizing: border-box;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.resource-primary-action {
  padding: 0 12px;
  border: 1px solid var(--ref-blue);
  background: var(--ref-blue);
  color: #fff;
}

.resource-primary-action:hover {
  border-color: #075fca;
  background: #075fca;
  color: #fff;
}

.resource-secondary-action,
.resource-file-action {
  padding: 0 11px;
  border: 1px solid #cbd7e5;
  background: #fff;
  color: #334a66;
}

.resource-secondary-action:hover,
.resource-file-action:hover {
  border-color: #9fb4cc;
  background: #f5f9fd;
}

.resource-file-action input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.resource-file-action:focus-within {
  outline: 2px solid var(--ref-blue);
  outline-offset: 2px;
}

.resource-file-summary {
  overflow: hidden;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff5f3;
  color: #8f302b;
  font-size: 11.5px;
  font-weight: 670;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-panel-body {
  display: grid;
  gap: 10px;
}

.resource-file-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.resource-file-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #e5ecf4;
  border-radius: 9px;
  background: #fbfdff;
}

.resource-file-kind {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #edf5ff;
  color: var(--ref-blue);
}

.resource-file-copy {
  min-width: 0;
}

.resource-file-copy strong,
.resource-file-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-file-copy strong {
  color: #21344d;
  font-size: 12px;
  font-weight: 730;
}

.resource-file-copy small {
  margin-top: 2px;
  color: #7a899d;
  font-size: 10.5px;
}

.resource-file-row > button {
  padding: 5px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #7b8798;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.resource-file-row > button:hover {
  background: #fff0ee;
  color: #ba322b;
}

.resource-empty-state {
  padding: 14px;
  border: 1px dashed #cbd7e5;
  border-radius: 9px;
  background: #fbfdff;
  color: #7a899d;
  font-size: 12px;
  text-align: center;
}

.files-panel-body > .resource-file-action {
  justify-self: start;
}

.notes-panel-body {
  display: grid;
  gap: 9px;
}

.notes-panel-body textarea {
  min-height: 94px;
  resize: vertical;
  padding: 10px 11px;
  font-size: 13px;
  line-height: 1.45;
}

.resource-panel-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.resource-panel-footer > span {
  margin-right: auto;
  color: #8390a2;
  font-size: 10.5px;
}

@media (max-width: 760px) {
  .reference-resource-panel {
    grid-column: 1 / -1;
    margin-right: -10px;
    margin-left: -10px;
  }

  .reference-resource-panel-header small {
    white-space: normal;
  }

  .pdf-panel-body,
  .resource-url-form {
    align-items: stretch;
  }

  .resource-url-form {
    flex: 1 1 100%;
    flex-wrap: wrap;
    min-width: 0;
  }

  .resource-url-form label {
    flex-basis: 100%;
  }

  .resource-panel-footer {
    flex-wrap: wrap;
  }

  .resource-panel-footer > span {
    flex-basis: 100%;
  }
}

.bibliographic-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 5px;
}

.bibliographic-meta .meta-separator {
  color: #8a99ad;
  font-weight: 450;
}

/* One folder asset is shared by the sidebar and reference chips. */
.sidebar-scroll-region .sidebar-icon.folder-icon::before,
.pill-row .reference-chip-folder::before {
  inset: 0;
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 6.7A2.7 2.7 0 0 1 5.7 4h4.1l2.1 2.3h6.4A2.7 2.7 0 0 1 21 9v8.3a2.7 2.7 0 0 1-2.7 2.7H5.7A2.7 2.7 0 0 1 3 17.3V6.7Z' fill='%23FFD31C' stroke='%23F28C00' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='M3.6 9h16.8' stroke='%23FFAA00' stroke-width='1.5'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: none;
  -webkit-mask: none;
  mask: none;
  -webkit-mask-image: none;
  mask-image: none;
}

.sidebar-scroll-region .sidebar-icon.folder-icon::before {
  background-size: 19px 19px;
}

.pill-row .reference-chip-folder::before {
  content: none;
}

.pill-row .reference-chip .reference-chip-folder-icon {
  display: block;
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  min-width: 14px;
  order: 1;
  overflow: visible;
  background: transparent url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 6.7A2.7 2.7 0 0 1 5.7 4h4.1l2.1 2.3h6.4A2.7 2.7 0 0 1 21 9v8.3a2.7 2.7 0 0 1-2.7 2.7H5.7A2.7 2.7 0 0 1 3 17.3V6.7Z' fill='%23FFD31C' stroke='%23F28C00' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='M3.6 9h16.8' stroke='%23FFAA00' stroke-width='1.5'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
}

/* Vivid label palette shared by the creator, sidebar flags, and reference chips. */
.label-color-coral {
  --label-accent: #f23b33;
  --label-surface: #fff0ef;
  --label-border: #ff968f;
  --label-ink: #b92821;
  --label-contrast: #ffffff;
}

.label-color-cobalt {
  --label-accent: #1769ff;
  --label-surface: #eaf2ff;
  --label-border: #83afff;
  --label-ink: #104fc2;
  --label-contrast: #ffffff;
}

.label-color-cyan {
  --label-accent: #00a8e8;
  --label-surface: #e6f9ff;
  --label-border: #68d6ff;
  --label-ink: #0079a9;
  --label-contrast: #ffffff;
}

.label-color-emerald {
  --label-accent: #00a76f;
  --label-surface: #e5fbf2;
  --label-border: #68ddb1;
  --label-ink: #007a51;
  --label-contrast: #ffffff;
}

.label-color-lime {
  --label-accent: #72b700;
  --label-surface: #f2ffd8;
  --label-border: #b3e65a;
  --label-ink: #477600;
  --label-contrast: #ffffff;
}

.label-color-amber {
  --label-accent: #f2a900;
  --label-surface: #fff6d5;
  --label-border: #ffd15c;
  --label-ink: #956500;
  --label-contrast: #172033;
}

.label-color-orange {
  --label-accent: #ff6a00;
  --label-surface: #fff0e2;
  --label-border: #ffa565;
  --label-ink: #bb4900;
  --label-contrast: #ffffff;
}

.label-color-magenta {
  --label-accent: #e4007f;
  --label-surface: #ffebf6;
  --label-border: #ff7ec3;
  --label-ink: #a6005d;
  --label-contrast: #ffffff;
}

.label-color-violet {
  --label-accent: #7a3cff;
  --label-surface: #f0eaff;
  --label-border: #ae8cff;
  --label-ink: #5425bd;
  --label-contrast: #ffffff;
}

.label-color-navy {
  --label-accent: #173c8f;
  --label-surface: #eaf0ff;
  --label-border: #859fdf;
  --label-ink: #102c6b;
  --label-contrast: #ffffff;
}

.label-row[class*="label-color-"] .flag-icon::before,
.pill-row .reference-chip-label[class*="label-color-"]::before {
  background: var(--label-accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 22V4'/%3E%3Cpath d='M4 15s1-1 4-1 5 2 8 2 4-1 4-1V4s-1 1-4 1-5-2-8-2-4 1-4 1z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 22V4'/%3E%3Cpath d='M4 15s1-1 4-1 5 2 8 2 4-1 4-1V4s-1 1-4 1-5-2-8-2-4 1-4 1z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.pill-row .reference-chip-label[class*="label-color-"] {
  border-color: var(--label-border);
  background: var(--label-surface);
  color: var(--label-ink);
}

[data-dialog="taxonomy"] .taxonomy-color-field {
  margin: 0;
  padding: 2px 20px 20px;
  border: 0;
}

[data-dialog="taxonomy"] .taxonomy-color-field.hidden {
  display: none;
}

[data-dialog="taxonomy"] .taxonomy-color-field legend {
  padding: 0;
  color: var(--ref-muted);
  font-size: 12.5px;
  font-weight: 650;
}

[data-dialog="taxonomy"] .taxonomy-color-field > p {
  margin: 5px 0 11px;
  color: var(--ref-quiet);
  font-size: 12px;
  font-weight: 450;
  line-height: 1.35;
}

.taxonomy-color-palette {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
}

.label-color-choice {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.label-color-choice input {
  position: absolute;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.label-color-swatch {
  min-height: 40px;
  display: grid;
  place-items: center;
  border: 2px solid var(--label-accent);
  border-radius: 10px;
  background: var(--label-accent);
  color: var(--label-contrast);
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  transition: transform 120ms ease, outline-color 120ms ease;
}

.label-color-choice:hover .label-color-swatch {
  transform: translateY(-1px);
}

.label-color-choice input:checked + .label-color-swatch {
  outline: 3px solid color-mix(in srgb, var(--label-accent) 30%, transparent);
  outline-offset: 2px;
}

/* Keep the reference frame evenly inset, at half the previous visual margin. */
.content-grid {
  padding: 9px;
}

.reference-scrollbar {
  top: 12px;
  right: 12px;
  bottom: 12px;
}

/* Give the library search more room by trimming only horizontal button chrome. */
.command-bar {
  gap: 8px;
  padding-inline: 10px;
}

.command-cluster {
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
}

.topbar-add {
  min-width: 82px;
  padding-inline: 10px;
}

.toolbar {
  gap: 6px;
}

.command-bar .toolbar button {
  padding-inline: 9px;
}

.command-bar .toolbar > button:not(.toolbar-icon):last-child:not(:disabled) {
  min-width: 74px;
}

.label-color-choice input:focus-visible + .label-color-swatch {
  outline: 3px solid var(--ref-focus);
  outline-offset: 2px;
}

@media (max-width: 680px) {
  .command-cluster {
    flex-wrap: wrap;
  }

  .top-search {
    flex: 1 1 100%;
    min-width: 0;
  }

  .floating-menu.add-menu,
  .search-popover {
    left: 0;
    width: min(650px, calc(100vw - 28px));
  }

  .search-help-row {
    grid-template-columns: 32px minmax(0, 1fr) auto;
  }

  .search-help-row span:not(.search-option-icon) {
    display: none;
  }

  .editor-header,
  .editor-footer {
    padding: 12px;
  }

  .editor-grid {
    padding: 10px;
  }
}

/* --------------------------------------------------------------------------
   QA corrections: neutral menus, lighter type, filled empty frame, and
   single-axis modal scrolling.
   -------------------------------------------------------------------------- */

.list-header h1 {
  font-size: 20px;
  font-weight: 680;
  letter-spacing: -0.025em;
}

.empty-state {
  width: 100%;
  height: 100%;
  min-height: 100%;
  box-sizing: border-box;
}

.reference-list:has(.empty-state) {
  overflow: hidden;
}

.empty-state h2 {
  font-size: clamp(27px, 2.4vw, 32px);
  font-weight: 680;
  letter-spacing: -0.035em;
}

.empty-state p {
  font-weight: 430;
}

.add-menu-copy strong {
  font-size: 13px;
  font-weight: 640;
}

.floating-menu.add-menu .add-menu-item,
.floating-menu.add-menu .add-menu-item.featured {
  background: transparent;
  background-image: none !important;
  box-shadow: none;
}

.floating-menu.add-menu .add-menu-item .add-menu-icon,
.floating-menu.add-menu .add-menu-item.featured .add-menu-icon {
  background: var(--ref-paper-blue);
  color: var(--ref-muted);
}

.floating-menu.add-menu .add-menu-item:hover,
.floating-menu.add-menu .add-menu-item.featured:hover {
  background: var(--ref-blue-soft);
  background-image: none !important;
  color: var(--ref-blue);
  box-shadow: none;
}

.floating-menu.add-menu .add-menu-item:hover .add-menu-icon,
.floating-menu.add-menu .add-menu-item.featured:hover .add-menu-icon {
  background: var(--ref-paper);
  color: var(--ref-blue);
}

.search-popover,
.floating-menu.add-menu {
  scrollbar-gutter: auto !important;
}

.sf-select-content {
  /*
   * Reserve an opaque gutter inside the dropdown. This prevents reference
   * cards and their actions from showing through beside the scrollbar.
   */
  scrollbar-gutter: stable !important;
  background-color: var(--ref-paper) !important;
}

.sf-select-content::-webkit-scrollbar,
.search-popover::-webkit-scrollbar,
.floating-menu.add-menu::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.sf-select-content::-webkit-scrollbar-track {
  margin-block: 8px;
  border-radius: 999px;
  background: var(--ref-paper);
}

.sf-select-content::-webkit-scrollbar-button {
  width: 0;
  height: 0;
  display: none;
}

.sf-select-content::-webkit-scrollbar-thumb,
.search-popover::-webkit-scrollbar-thumb,
.floating-menu.add-menu::-webkit-scrollbar-thumb {
  border: 1px solid var(--ref-paper);
}

/* Editor: the dialog itself never scrolls. Only the central form area does. */
.editor-modal,
.editor-modal[open] {
  width: min(1060px, calc(100vw - 32px)) !important;
  max-width: calc(100vw - 32px) !important;
  min-width: 0 !important;
  max-height: calc(100vh - 32px) !important;
  overflow: hidden !important;
  box-sizing: border-box;
}

.editor-card {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  height: min(760px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  overflow: hidden !important;
  box-sizing: border-box;
}

.editor-header,
.editor-footer,
.editor-grid,
.editor-section,
.editor-section label,
.editor-section input,
.editor-section select,
.editor-section textarea {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.editor-grid {
  width: 100%;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-gutter: auto;
}

.editor-section {
  width: 100%;
}

.editor-grid::-webkit-scrollbar {
  width: 7px;
  height: 0;
}

.editor-grid::-webkit-scrollbar-track {
  margin-block: 8px;
  background: transparent;
}

.editor-grid::-webkit-scrollbar-thumb {
  border: 1px solid var(--ref-paper-blue);
  border-radius: 999px;
  background: #aebccc;
}

/* Import: fixed header/footer with one quiet internal vertical scrollbar. */
[data-dialog="import"],
[data-dialog="import"][open] {
  width: min(760px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow: hidden !important;
  box-sizing: border-box;
}

[data-dialog="import"] .modal-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: min(620px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 0;
  overflow: hidden !important;
  box-sizing: border-box;
}

[data-dialog="import"] .modal-card > header,
[data-dialog="import"] .modal-card > footer {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 14px 18px;
  background: var(--ref-paper);
}

[data-dialog="import"] .modal-card > header {
  border-bottom: 1.5px solid var(--ref-line);
}

[data-dialog="import"] .modal-card > footer {
  border-top: 1.5px solid var(--ref-line);
}

.import-scroll-region {
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px 18px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--ref-paper-blue);
  scrollbar-width: thin;
  scrollbar-color: #aebccc transparent;
}

.import-scroll-region > .muted {
  margin: 0;
  color: var(--ref-muted);
  font-size: 13px;
  font-weight: 430;
  line-height: 1.5;
}

.import-scroll-region .import-file-panel,
.import-scroll-region .import-folder-field,
.import-scroll-region .large-textarea {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.import-scroll-region .large-textarea {
  width: 100%;
  min-height: clamp(160px, 24vh, 210px);
  resize: vertical;
}

.import-scroll-region::-webkit-scrollbar {
  width: 7px;
}

.import-scroll-region::-webkit-scrollbar-track {
  margin-block: 8px;
  background: transparent;
}

.import-scroll-region::-webkit-scrollbar-thumb {
  border: 1px solid var(--ref-paper-blue);
  border-radius: 999px;
  background: #aebccc;
}

@media (max-width: 720px) {
  .editor-modal,
  .editor-modal[open],
  [data-dialog="import"],
  [data-dialog="import"][open] {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100vh - 16px) !important;
  }

  .editor-card,
  [data-dialog="import"] .modal-card {
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
  }
}

/* Ref Capture local-first sync */
.ref-capture-sync-control {
  position: relative;
  flex: 0 0 auto;
}

.ref-capture-sync-button {
  position: relative;
  min-width: 126px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 10px;
  background: var(--ref-paper);
  color: var(--ref-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  box-shadow: none;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.ref-capture-sync-button:hover,
.ref-capture-sync-button[aria-expanded="true"] {
  border-color: #8fb8ee;
  background: var(--ref-blue-soft);
  color: var(--ref-blue);
}

.ref-capture-sync-button:focus-visible {
  outline: 2px solid var(--ref-blue);
  outline-offset: 2px;
}

.ref-capture-sync-control[data-state="ready"] .ref-capture-sync-button,
.ref-capture-sync-control[data-state="synced"] .ref-capture-sync-button {
  border-color: #9bd3bd;
  background: var(--ref-green-soft);
  color: var(--ref-green);
}

.ref-capture-sync-control[data-state="offline"] .ref-capture-sync-button {
  border-color: #efc7c3;
  background: var(--ref-danger-soft);
  color: var(--ref-danger);
}

.ref-capture-sync-control[data-state="syncing"] .ref-capture-sync-button {
  border-color: #8fb8ee;
  background: var(--ref-blue-soft);
  color: var(--ref-blue);
}

.ref-capture-sync-icon,
.ref-capture-button-icon,
.ref-capture-sync-state-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3Cpath d='M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16'/%3E%3Cpath d='M8 16H3v5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3Cpath d='M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16'/%3E%3Cpath d='M8 16H3v5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.ref-capture-sync-icon {
  width: 18px;
  height: 18px;
  flex-basis: 18px;
}

.ref-capture-sync-control[data-state="syncing"] .ref-capture-sync-icon,
.ref-capture-sync-control[data-state="syncing"] .ref-capture-button-icon {
  animation: ref-capture-sync-rotate 900ms linear infinite;
}

@keyframes ref-capture-sync-rotate {
  to {
    transform: rotate(360deg);
  }
}

.ref-capture-sync-badge {
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ref-brand);
  color: #fff;
  font-size: 10px;
  font-weight: 750;
  line-height: 1;
}

.ref-capture-sync-popover {
  position: absolute;
  z-index: 90;
  top: calc(100% + 10px);
  right: 0;
  width: min(380px, calc(100vw - 32px));
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--ref-line-strong);
  border-radius: 16px;
  background: var(--ref-paper);
  color: var(--ref-ink);
  box-shadow: 0 16px 42px rgba(23, 32, 51, 0.16);
}

.ref-capture-sync-popover.hidden {
  display: none !important;
}

.ref-capture-sync-popover > header {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1.5px solid var(--ref-line);
  background: var(--ref-paper);
}

.ref-capture-sync-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ref-capture-sync-brand img {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 9px;
  object-fit: cover;
}

.ref-capture-sync-brand div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.ref-capture-sync-brand strong {
  color: var(--ref-ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.ref-capture-sync-brand span {
  overflow: hidden;
  color: var(--ref-quiet);
  font-size: 10.5px;
  font-weight: 550;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ref-capture-sync-close {
  box-sizing: border-box;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  max-width: 34px;
  max-height: 34px;
  flex: 0 0 34px;
  align-self: center;
  display: grid;
  place-items: center;
  position: relative;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 9px;
  background: var(--ref-paper-blue);
  color: var(--ref-muted);
  box-shadow: none;
  cursor: pointer;
}

.ref-capture-sync-close::before,
.ref-capture-sync-close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 1.8px;
  border-radius: 999px;
  background: currentColor;
}

.ref-capture-sync-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.ref-capture-sync-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.ref-capture-sync-close:hover {
  border-color: #efb2ad;
  background: var(--ref-danger-soft);
  color: var(--ref-danger);
}

.trash-actions .trash-action.delete .delete-symbol {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.trash-actions .trash-action.delete .delete-symbol::before,
.trash-actions .trash-action.delete .delete-symbol::after {
  top: 7px;
  left: 1px;
  width: 14px;
  height: 1.8px;
  border-radius: 999px;
}

.ref-capture-sync-status-card {
  margin: 14px 14px 10px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 12px;
  background: var(--ref-paper-blue);
}

.ref-capture-sync-state-icon {
  width: 38px;
  height: 38px;
  padding: 10px;
  border-radius: 10px;
  background-color: var(--ref-blue);
  background-origin: content-box;
  color: var(--ref-blue);
  -webkit-mask-origin: content-box;
  mask-origin: content-box;
}

.ref-capture-sync-status-card > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.ref-capture-sync-status-card strong {
  color: var(--ref-ink);
  font-size: 13px;
  font-weight: 680;
  line-height: 1.25;
}

.ref-capture-sync-status-card span {
  color: var(--ref-muted);
  font-size: 11px;
  font-weight: 470;
  line-height: 1.4;
}

.ref-capture-sync-status-card[data-ref-capture-sync-state="ready"],
.ref-capture-sync-status-card[data-ref-capture-sync-state="synced"] {
  border-color: #9bd3bd;
  background: var(--ref-green-soft);
}

.ref-capture-sync-status-card[data-ref-capture-sync-state="ready"] .ref-capture-sync-state-icon,
.ref-capture-sync-status-card[data-ref-capture-sync-state="synced"] .ref-capture-sync-state-icon {
  background-color: var(--ref-green);
}

.ref-capture-sync-status-card[data-ref-capture-sync-state="offline"] {
  border-color: #efc7c3;
  background: var(--ref-danger-soft);
}

.ref-capture-sync-status-card[data-ref-capture-sync-state="offline"] .ref-capture-sync-state-icon {
  background-color: var(--ref-danger);
}

.ref-capture-sync-metrics {
  margin: 0 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1.5px solid var(--ref-line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--ref-paper);
}

.ref-capture-sync-metrics > div {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 10px 12px;
}

.ref-capture-sync-metrics > div + div {
  border-left: 1.5px solid var(--ref-line);
}

.ref-capture-sync-metrics strong {
  color: var(--ref-blue);
  font-size: 18px;
  font-weight: 720;
  line-height: 1;
}

.ref-capture-sync-metrics span {
  color: var(--ref-muted);
  font-size: 10px;
  font-weight: 570;
  line-height: 1.3;
}

.ref-capture-auto-sync {
  margin: 10px 14px 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 11px;
  border: 1.5px solid var(--ref-line);
  border-radius: 12px;
  background: var(--ref-paper);
  cursor: pointer;
}

.ref-capture-auto-sync > span:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.ref-capture-auto-sync strong {
  color: var(--ref-ink);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.25;
}

.ref-capture-auto-sync small {
  color: var(--ref-muted);
  font-size: 10px;
  font-weight: 450;
  line-height: 1.3;
}

.ref-capture-auto-sync input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.ref-capture-switch {
  width: 34px;
  height: 20px;
  flex: 0 0 auto;
  position: relative;
  border: 1.5px solid #aebccc;
  border-radius: 999px;
  background: #dbe3ed;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.ref-capture-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  transition: transform 140ms ease;
}

.ref-capture-auto-sync input:checked + .ref-capture-switch {
  border-color: var(--ref-blue);
  background: var(--ref-blue);
}

.ref-capture-auto-sync input:checked + .ref-capture-switch::after {
  transform: translateX(14px);
}

.ref-capture-auto-sync input:focus-visible + .ref-capture-switch {
  outline: 2px solid var(--ref-blue);
  outline-offset: 2px;
}

.ref-capture-sync-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 9px;
  padding: 12px 14px;
}

.ref-capture-sync-actions button {
  min-width: 0;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 10px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
}

.ref-capture-refresh-button {
  border: 1.5px solid var(--ref-line-strong);
  background: var(--ref-paper);
  color: var(--ref-ink);
}

.ref-capture-sync-now-button {
  border: 1.5px solid var(--ref-blue);
  background: var(--ref-blue);
  color: #fff;
}

.ref-capture-sync-now-button:disabled,
.ref-capture-refresh-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.ref-capture-last-sync {
  margin: 0;
  padding: 10px 14px 12px;
  border-top: 1.5px solid var(--ref-line);
  background: var(--ref-paper-blue);
  color: var(--ref-muted);
  font-size: 10px;
  font-weight: 480;
  line-height: 1.4;
}

@media (max-width: 1540px) {
  .ref-capture-sync-button {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  .ref-capture-sync-button > [data-ref-capture-sync-label] {
    display: none;
  }

  .ref-capture-sync-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    border: 2px solid var(--ref-paper);
  }
}

@media (max-width: 900px) {
  .ref-capture-sync-popover {
    position: fixed;
    top: 76px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
  }
}

/* --------------------------------------------------------------------------
   Mobile and tablet workspace organization
   This layer changes layout and interaction hierarchy only below 1025px.
   Desktop sizing and styling remain governed by the rules above.
   -------------------------------------------------------------------------- */

.mobile-sidebar-header,
.mobile-sidebar-backdrop,
.mobile-library-toggle,
.mobile-action-text {
  display: none;
}

@media (max-width: 1024px) {
  body.library-workspace-open {
    overflow: hidden;
  }

  body.mobile-library-navigation-open {
    touch-action: none;
  }

  .library-app {
    display: block;
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: 8px;
    overflow: hidden;
  }

  .main-panel {
    width: 100%;
    max-width: none;
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    min-width: 0;
  }

  .sidebar {
    position: fixed;
    z-index: 1000;
    top: 8px;
    bottom: 8px;
    left: 8px;
    width: min(360px, calc(100vw - 28px)) !important;
    max-width: min(360px, calc(100vw - 28px)) !important;
    height: auto;
    margin: 0;
    visibility: hidden;
    transform: translateX(calc(-100% - 18px));
    transition: transform 180ms ease, visibility 0s linear 180ms;
    box-shadow: 0 24px 64px rgba(23, 32, 51, 0.24);
  }

  #app.mobile-library-open .sidebar {
    visibility: visible;
    transform: translateX(0);
    transition: transform 180ms ease;
  }

  .mobile-sidebar-header {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 2px 2px 8px;
    color: var(--ref-ink);
  }

  .mobile-sidebar-header strong {
    font-size: 14px;
    font-weight: 700;
  }

  .mobile-sidebar-close {
    position: relative;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border: 1.5px solid var(--ref-line-strong);
    border-radius: 10px;
    background: var(--ref-paper-blue);
    color: var(--ref-muted);
  }

  .mobile-sidebar-close::before,
  .mobile-sidebar-close::after {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    content: "";
  }

  .mobile-sidebar-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
  }

  .mobile-sidebar-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  .mobile-sidebar-backdrop {
    position: fixed;
    z-index: 990;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(23, 32, 51, 0.34);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  #app.mobile-library-open .mobile-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .command-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
    width: 100% !important;
    margin: 0 !important;
    padding: 8px;
    border-radius: 0;
  }

  .command-cluster {
    position: relative;
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  .mobile-library-toggle {
    height: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    border: 1.5px solid var(--ref-line-strong);
    border-radius: 10px;
    background: var(--ref-paper);
    color: var(--ref-ink);
    font-size: 12.5px;
    font-weight: 650;
    white-space: nowrap;
  }

  .mobile-library-toggle .sidebar-icon {
    width: 18px;
    height: 18px;
    color: var(--ref-blue);
  }

  .topbar-add {
    width: auto;
    min-width: 78px;
  }

  .top-search {
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 6px;
  }

  .top-search > input {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }

  .top-search .toolbar-icon {
    display: inline-grid !important;
  }

  .floating-menu.add-menu,
  .search-popover {
    top: calc(100% + 8px) !important;
    right: 0;
    left: 0 !important;
    width: 100% !important;
    max-width: none;
  }

  .toolbar {
    width: 100%;
    min-height: 44px;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .toolbar > button,
  .toolbar > .bulk-folder-control,
  .toolbar > .ref-capture-sync-control,
  .toolbar button {
    flex: 0 0 auto;
  }

  .command-bar .toolbar > button:not(.toolbar-icon) {
    width: auto;
    min-width: max-content;
    flex: 0 0 auto;
    padding-inline: 12px;
  }

  .toolbar > .bulk-folder-control {
    width: auto !important;
    min-width: 0 !important;
    flex-basis: auto !important;
  }

  #app[data-has-selection="true"] .toolbar > .ref-capture-sync-control {
    display: none;
  }

  .toolbar::-webkit-scrollbar {
    display: none;
  }

  .toolbar button:disabled,
  .bulk-folder-control:has(> button:disabled) {
    display: none;
  }

  .mobile-action-text {
    display: inline;
  }

  .toolbar .toolbar-icon,
  .toolbar .folder-picker-button {
    width: auto !important;
    min-width: 44px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding-inline: 11px !important;
    gap: 6px;
  }

  .ref-capture-sync-button {
    width: auto;
    min-width: 44px;
    padding: 0 11px;
    gap: 6px;
  }

  .ref-capture-sync-button > [data-ref-capture-sync-label] {
    display: inline;
  }

  .ref-capture-sync-popover {
    position: fixed;
    top: 68px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100dvh - 84px);
    overflow-y: auto;
  }

  .list-header {
    min-height: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
  }

  .list-header > div:first-child {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    gap: 7px;
  }

  .list-header h1 {
    font-size: 20px;
  }

  .sort-row {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(104px, 0.8fr) 42px minmax(0, 1.15fr) minmax(0, 0.85fr);
    align-items: center;
    gap: 6px;
    padding: 0;
    overflow: visible;
  }

  .sort-row .sort-direction-button {
    width: 42px !important;
    min-width: 42px !important;
  }

  .sort-row .sf-select,
  .sort-row .sf-select-trigger {
    width: 100%;
    min-width: 0;
  }

  .sort-row .sf-select[data-custom-select="filters"],
  .sort-row .sf-select[data-custom-select="sort"],
  .sort-row .sf-select[data-custom-select="type"] {
    width: auto;
    min-width: 0;
    max-width: 100%;
    flex-basis: auto;
  }

  .sort-row .sf-select-trigger {
    padding-inline: 10px;
  }

  #app[data-has-selection="false"] [data-selected-count] {
    display: none;
  }

  #app[data-has-selection="true"] [data-selected-count] {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .content-grid {
    min-height: 0;
    padding: 8px;
  }

  .reference-list {
    min-height: 0;
    border-radius: 12px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .reference-scrollbar {
    display: none;
  }

  .empty-state {
    min-height: 100%;
    padding: 32px 18px;
  }

  .empty-actions {
    justify-content: center;
  }
}

@media (max-width: 700px) {
  #app[data-has-selection="true"] .toolbar {
    min-height: 94px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  #app[data-has-selection="true"] .toolbar > button,
  #app[data-has-selection="true"] .toolbar > .bulk-folder-control,
  #app[data-has-selection="true"] .toolbar .folder-picker-button {
    width: 100% !important;
    max-width: none;
  }

  #app[data-has-selection="true"] .list-header {
    position: relative;
  }

  #app[data-has-selection="true"] .list-header > div:first-child {
    padding-right: 112px;
  }

  #app[data-has-selection="true"] [data-selected-count] {
    position: absolute;
    top: 10px;
    right: 10px;
    height: 28px !important;
    min-height: 28px !important;
    padding-block: 0 !important;
    grid-column: auto;
  }

  #app[data-has-selection="true"] .bulk-folder-menu {
    top: calc(100% + 60px) !important;
    right: auto;
    left: 0;
    width: min(280px, calc(100vw - 38px));
  }

  .reference-card {
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    padding: 12px 10px;
  }

  .reference-card > div:nth-child(2) {
    min-width: 0;
  }

  .card-select-stack {
    width: 28px;
    gap: 0;
    padding-top: 2px;
  }

  .card-select-stack > input[type="checkbox"] {
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
  }

  .reference-drag-handle {
    display: none;
  }

  .card-actions {
    grid-column: 2;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 2px;
  }

  .card-actions .ghost-button {
    min-height: 42px;
    padding: 0 14px;
  }

  .card-action-star {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    margin-left: auto;
    border: 1.5px solid var(--ref-line-strong);
    border-radius: 10px;
    background: var(--ref-paper);
  }

  .meta,
  .links,
  .abstract-preview {
    overflow-wrap: anywhere;
  }

  .pill-row .reference-chip {
    min-height: 34px;
  }

  .pill-row .reference-chip .folder-chip-remove {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .pill-row .reference-chip .folder-chip-remove::before,
  .pill-row .reference-chip .folder-chip-remove::after {
    top: 11px;
    left: 7px;
  }

  .empty-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .empty-actions .primary-button,
  .empty-actions .ghost-button {
    width: 100%;
  }
}

@media (min-width: 701px) and (max-width: 1024px) {
  #app[data-has-selection="false"] .command-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  #app[data-has-selection="false"] .toolbar {
    width: auto;
  }

  .list-header {
    align-items: center;
    flex-direction: row;
    gap: 12px;
  }

  .list-header > div:first-child {
    width: auto;
    flex: 1 1 auto;
  }

  .sort-row {
    width: min(540px, 72%);
    flex: 0 1 540px;
  }

  #app[data-has-selection="false"] [data-selected-count] {
    display: none;
  }

  #app[data-has-selection="true"] .list-header {
    align-items: stretch;
    flex-direction: column;
  }

  #app[data-has-selection="true"] .list-header > div:first-child,
  #app[data-has-selection="true"] .sort-row {
    width: 100%;
  }

  #app[data-has-selection="true"] .sort-row {
    grid-template-columns: minmax(112px, 0.8fr) 42px minmax(0, 1.15fr) minmax(0, 0.85fr) auto;
    flex: 0 0 auto;
  }

  #app[data-has-selection="true"] [data-selected-count] {
    grid-column: auto;
    justify-self: stretch;
  }

  .editor-card {
    height: calc(100dvh - 32px) !important;
    max-height: calc(100dvh - 32px) !important;
  }
}

@media (min-width: 761px) and (max-width: 900px) {
  .auth-page {
    width: calc(100% - 32px);
    height: 100dvh;
    min-height: 100dvh;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 360px);
    gap: 16px;
    margin: 0 auto;
  }

  .auth-art .glass-card {
    width: 100%;
    padding: 30px;
  }

  .auth-brandline {
    margin-bottom: 24px;
  }

  .auth-card {
    padding-inline: 30px;
  }
}

@media (max-width: 760px) and (max-height: 800px) {
  .auth-page {
    height: auto;
    min-height: calc(100dvh - 20px);
    grid-template-rows: auto auto;
    overflow: visible;
  }
}

@media (max-width: 420px) {
  .library-app {
    padding: 6px;
  }

  .main-panel {
    height: calc(100vh - 12px);
    height: calc(100dvh - 12px);
  }

  .command-bar {
    padding: 7px;
  }

  .command-cluster {
    gap: 6px;
  }

  .mobile-library-toggle {
    gap: 4px;
    padding-inline: 7px;
    font-size: 12px;
  }

  .topbar-add {
    min-width: 72px;
    padding-inline: 8px;
  }

  .top-search > input {
    font-size: 13px;
  }

  .list-header {
    padding: 9px 8px;
  }

  .sort-row .sf-select-trigger {
    padding-inline: 8px;
    font-size: 11.5px;
  }
}

@media (prefers-reduced-motion: reduce) and (max-width: 1024px) {
  .sidebar,
  .mobile-sidebar-backdrop {
    transition: none;
  }
}

/* Compact login aligned with the current LumaCite site and extension language. */
body:not(.auth-screen-open) > .site-header.site-header--unified[data-auth-site-chrome][data-auth-site-chrome][data-auth-site-chrome][data-auth-site-chrome],
body:not(.auth-screen-open) > .site-footer.site-footer--unified[data-auth-site-chrome][data-auth-site-chrome][data-auth-site-chrome][data-auth-site-chrome] {
  display: none !important;
}

body.auth-screen-open > .site-header[data-auth-site-chrome][data-auth-site-chrome][data-auth-site-chrome][data-auth-site-chrome] {
  display: grid !important;
}

body.auth-screen-open > .site-footer[data-auth-site-chrome][data-auth-site-chrome][data-auth-site-chrome][data-auth-site-chrome] {
  display: block !important;
}

body.auth-screen-open {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: #f4f7ff;
  background-image:
    linear-gradient(rgba(20, 115, 230, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 115, 230, 0.11) 1px, transparent 1px),
    radial-gradient(ellipse at 14% 18%, rgba(20, 115, 230, 0.22), transparent 42%),
    radial-gradient(ellipse at 88% 82%, rgba(239, 63, 52, 0.2), transparent 46%),
    linear-gradient(180deg, #fbfdff 0%, #f4f7ff 100%);
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
}

body.auth-screen-open .app-shell {
  width: 100%;
  min-height: calc(100vh - 63px);
  min-height: calc(100dvh - 63px);
  display: grid;
  place-items: center;
  overflow: visible;
  padding: 40px 20px 72px;
}

body.auth-screen-open .auth-page {
  width: min(980px, calc(100vw - 40px));
  height: min(590px, calc(100dvh - 40px));
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 0;
  align-items: stretch;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d7e0ec;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(23, 32, 51, 0.12);
}

body.auth-screen-open .auth-art,
body.auth-screen-open .auth-card {
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.auth-screen-open .auth-art {
  position: relative;
  overflow: hidden;
  background-color: #f7faff;
  background-image:
    radial-gradient(circle at 18% 12%, rgba(20, 115, 230, 0.14), transparent 42%),
    radial-gradient(circle at 85% 88%, rgba(239, 63, 52, 0.12), transparent 44%);
  background-size: auto, auto;
}

body.auth-screen-open .auth-art::after {
  content: "";
  position: absolute;
  right: -54px;
  bottom: -62px;
  width: 190px;
  height: 190px;
  border: 28px solid rgba(239, 63, 52, 0.08);
  border-radius: 50%;
  background: transparent;
}

body.auth-screen-open .glass-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(34px, 5vw, 54px);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #172033;
  box-shadow: none;
  backdrop-filter: none;
}

body.auth-screen-open .glass-card::before,
body.auth-screen-open .glass-card::after {
  display: none;
}

body.auth-screen-open .auth-brandline,
body.auth-screen-open .auth-logo-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #172033;
}

body.auth-screen-open .auth-brandline {
  position: static;
  margin: 0;
  font-family: Manrope, Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 18px;
}

body.auth-screen-open .auth-brand-copy,
body.auth-screen-open .auth-logo-lockup > span {
  display: grid;
  gap: 2px;
  line-height: 1;
}

body.auth-screen-open .auth-brand-copy strong,
body.auth-screen-open .auth-logo-lockup strong {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

body.auth-screen-open .auth-brand-copy small,
body.auth-screen-open .auth-logo-lockup small {
  color: #67758c;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

body.auth-screen-open .brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 9px !important;
  box-shadow: none;
}

body.auth-screen-open .auth-intro {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  justify-items: start;
}

body.auth-screen-open .eyebrow {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  margin: 0 0 18px;
  border: 1px solid #f2b7b2;
  border-radius: 999px;
  background: #fff0ee;
  color: #c8312b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  padding: 0 11px;
}

body.auth-screen-open .glass-card h1 {
  max-width: 470px;
  margin: 0;
  color: #172033;
  font-family: Manrope, Inter, "Segoe UI", system-ui, sans-serif;
  font-size: clamp(40px, 4.1vw, 54px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

body.auth-screen-open .glass-card p {
  max-width: 430px;
  margin: 18px 0 0;
  color: #53647b;
  font-size: 15px;
  line-height: 1.55;
}

body.auth-screen-open .auth-proof-grid {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin: 0;
}

body.auth-screen-open .auth-proof-grid span {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d7e0ec;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.88);
  color: #354457;
  font-size: 11px;
  font-weight: 750;
  padding: 7px 9px;
  white-space: nowrap;
}

body.auth-screen-open .auth-proof-grid span:nth-child(n) {
  border-color: #d7e0ec;
  background: rgba(255, 255, 255, 0.88);
  color: #354457;
}

body.auth-screen-open .auth-proof-grid b {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eaf3ff;
  color: #1473e6;
  font-size: 10px;
}

body.auth-screen-open .auth-card {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 13px;
  max-height: none;
  overflow: hidden;
  border-left: 1px solid #e2e8f0;
  background: #fff;
  padding: clamp(32px, 4.2vw, 48px);
}

body.auth-screen-open .auth-card-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: 0 0 8px;
}

body.auth-screen-open .auth-logo-lockup {
  display: none;
}

body.auth-screen-open .auth-access-pill {
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #f2b7b2;
  border-radius: 999px;
  background: #fff0ee;
  color: #c8312b;
  font-size: 10px;
  font-weight: 800;
  padding: 0 10px;
}

body.auth-screen-open .auth-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 5px;
}

body.auth-screen-open .auth-card h2 {
  margin: 0;
  color: #172033;
  font-family: Manrope, Inter, "Segoe UI", system-ui, sans-serif;
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.035em;
}

body.auth-screen-open .auth-card .muted {
  margin: 0;
  color: #67758c;
  font-size: 13px;
  line-height: 1.4;
}

body.auth-screen-open .auth-card label {
  display: grid;
  gap: 7px;
  color: #344056;
  font-size: 12px;
  font-weight: 750;
}

body.auth-screen-open .auth-card input {
  min-height: 44px;
  border: 1px solid #cfd8e6;
  border-radius: 7px;
  background: #fff;
  color: #172033;
  font-size: 14px;
  padding: 10px 12px;
  box-shadow: none;
}

body.auth-screen-open .auth-card input::placeholder {
  color: #8a96a8;
}

body.auth-screen-open .auth-card input:focus {
  border-color: #1473e6;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(20, 115, 230, 0.14);
}

body.auth-screen-open .auth-card .primary-button,
body.auth-screen-open .auth-card .ghost-button {
  width: 100%;
  min-height: 44px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 800;
  transition: background-color 140ms ease, border-color 140ms ease;
}

body.auth-screen-open .auth-card .primary-button {
  border: 1px solid #ef3f34;
  background: #ef3f34;
  color: #fff;
  box-shadow: none;
}

body.auth-screen-open .auth-card .primary-button:hover {
  border-color: #c8312b;
  background: #c8312b;
  transform: none;
}

body.auth-screen-open .auth-card .ghost-button {
  border: 1px solid #bdc8d5;
  background: #fff;
  color: #172033;
}

body.auth-screen-open .auth-card .ghost-button:hover {
  border-color: #172033;
  background: #f7faff;
  transform: none;
}

body.auth-screen-open .auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 9px;
  color: #8a96a8;
  font-size: 10px;
  font-weight: 700;
}

body.auth-screen-open .auth-divider::before,
body.auth-screen-open .auth-divider::after {
  height: 1px;
  background: #e2e8f0;
  content: "";
}

body.auth-screen-open .auth-note {
  min-height: 16px;
  margin: -2px 0 0;
  color: #b42318;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
}

body.auth-screen-open .auth-beta-prompt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 3px;
  padding: 14px;
  border: 1px solid #d7e0ec;
  border-radius: 9px;
  background: #f7faff;
}

body.auth-screen-open .auth-beta-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

body.auth-screen-open .auth-beta-copy strong {
  color: #172033;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.25;
}

body.auth-screen-open .auth-beta-copy span {
  color: #67758c;
  font-size: 10.5px;
  font-weight: 550;
  line-height: 1.35;
}

body.auth-screen-open .auth-beta-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #1473e6;
  border-radius: 7px;
  background: #fff;
  color: #1473e6;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1;
  padding: 0 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease;
}

body.auth-screen-open .auth-beta-link:hover {
  background: #1473e6;
  color: #fff;
}

body.auth-screen-open .auth-beta-link:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(20, 115, 230, 0.14);
}

@media (max-height: 650px) and (min-width: 761px) {
  body.auth-screen-open .auth-page {
    height: calc(100dvh - 24px);
    margin: 0;
  }

  body.auth-screen-open .glass-card,
  body.auth-screen-open .auth-card {
    padding: 28px 36px;
  }

  body.auth-screen-open .glass-card h1 {
    font-size: clamp(35px, 4vw, 46px);
  }

  body.auth-screen-open .auth-card {
    gap: 9px;
  }
}

@media (max-width: 760px) {
  body.auth-screen-open .auth-page {
    width: min(440px, calc(100vw - 24px));
    height: min(600px, calc(100dvh - 24px));
    min-height: 0;
    display: block;
    margin: 0;
    overflow: hidden;
    border-radius: 14px;
  }

  body.auth-screen-open .auth-art {
    display: none;
  }

  body.auth-screen-open .auth-card {
    width: 100%;
    height: 100%;
    justify-content: center;
    gap: 11px;
    border-left: 0;
    padding: clamp(22px, 7vw, 34px);
  }

  body.auth-screen-open .auth-card-head {
    justify-content: space-between;
    margin-bottom: 7px;
  }

  body.auth-screen-open .auth-logo-lockup {
    display: flex;
  }

  body.auth-screen-open .auth-card h2 {
    font-size: clamp(27px, 8vw, 34px);
  }

  body.auth-screen-open .auth-beta-prompt {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  body.auth-screen-open .auth-beta-link {
    width: 100%;
  }
}

@media (max-height: 540px), (max-width: 360px) {
  body.auth-screen-open .auth-page {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
    margin: 0;
  }

  body.auth-screen-open .auth-card {
    gap: 7px;
    padding: 14px 18px;
  }

  body.auth-screen-open .auth-card-head {
    margin-bottom: 2px;
  }

  body.auth-screen-open .auth-brand-copy small,
  body.auth-screen-open .auth-logo-lockup small,
  body.auth-screen-open .auth-card .muted,
  body.auth-screen-open .auth-divider {
    display: none;
  }

  body.auth-screen-open .auth-card h2 {
    font-size: 26px;
  }

  body.auth-screen-open .auth-card input,
  body.auth-screen-open .auth-card .primary-button,
  body.auth-screen-open .auth-card .ghost-button {
    min-height: 40px;
  }

  body.auth-screen-open .auth-note {
    min-height: 13px;
  }

  body.auth-screen-open .auth-beta-prompt {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 9px 10px;
  }

  body.auth-screen-open .auth-beta-copy span {
    display: none;
  }

  body.auth-screen-open .auth-beta-link {
    width: auto;
    min-height: 36px;
    padding-inline: 10px;
  }
}

/* Pixel/Android viewport resilience and cross-device workspace ergonomics. */
@media (max-width: 1024px) {
  body.library-workspace-open #app {
    position: fixed;
    inset: 0;
    width: 100%;
    height: var(--library-visual-height, 100dvh);
    overflow: hidden;
    overscroll-behavior: none;
  }

  body.library-workspace-open .library-app {
    height: var(--library-visual-height, 100dvh);
  }

  body.library-workspace-open .main-panel {
    height: calc(var(--library-visual-height, 100dvh) - 16px);
  }

  .editor-modal[open],
  [data-dialog="import"][open] {
    position: fixed !important;
    inset:
      max(8px, env(safe-area-inset-top, 0px))
      max(8px, env(safe-area-inset-right, 0px))
      max(8px, env(safe-area-inset-bottom, 0px))
      max(8px, env(safe-area-inset-left, 0px)) !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .editor-modal[open] .editor-card,
  [data-dialog="import"][open] .modal-card {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
  }

  dialog.modal:not(.editor-modal):not([data-dialog="import"])[open] {
    max-width: calc(100vw - 16px) !important;
    max-height: calc(var(--library-visual-height, 100dvh) - 16px) !important;
  }
}

@media (max-width: 700px) {
  #app[data-has-selection="false"] .toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  #app[data-has-selection="false"] .toolbar > button,
  #app[data-has-selection="false"] .toolbar > .ref-capture-sync-control,
  #app[data-has-selection="false"] .ref-capture-sync-button {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .editor-header,
  [data-dialog="import"] .modal-card > header {
    padding-top: max(12px, env(safe-area-inset-top, 0px));
  }

  .editor-footer,
  [data-dialog="import"] .modal-card > footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 360px) {
  .command-cluster {
    grid-template-columns: 44px 64px minmax(0, 1fr);
    gap: 5px;
  }

  .mobile-library-toggle {
    width: 44px;
    min-width: 44px;
    padding: 0;
  }

  .mobile-library-toggle > span:last-child {
    display: none;
  }

  .topbar-add {
    width: 64px;
    min-width: 64px;
    padding-inline: 5px;
  }

  .top-search {
    grid-template-columns: minmax(0, 1fr) 40px;
    gap: 4px;
  }

  .top-search .toolbar-icon {
    min-width: 40px !important;
    width: 40px !important;
    padding: 0 !important;
  }

  .toolbar,
  #app[data-has-selection="true"] .toolbar {
    gap: 4px;
  }

  .command-bar .toolbar > button:not(.toolbar-icon),
  .toolbar .toolbar-icon,
  .ref-capture-sync-button {
    padding-inline: 6px !important;
    font-size: 11.5px;
  }
}

/* --------------------------------------------------------------------------
   Private reference sharing
   Paperpile-inspired information hierarchy with LumaCite-native controls.
   -------------------------------------------------------------------------- */

@media (min-width: 1025px) {
  .command-cluster .top-search {
    flex: 0 1 620px;
    width: min(620px, 100%);
    max-width: 620px;
    min-width: 230px;
  }
}

.share-toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.lc-icon {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.share-toolbar-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  stroke-width: 2.15;
}

.add-menu-icon.share-svg .lc-icon {
  width: 19px;
  height: 19px;
  stroke-width: 2.05;
}

.share-modal {
  width: min(780px, calc(100vw - 32px));
  max-width: 780px;
  overflow: hidden;
}

.share-card {
  width: min(780px, calc(100vw - 32px));
  max-width: 780px;
  max-height: min(86vh, 760px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  padding: 0;
}

.share-card > header {
  align-items: flex-start;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--ref-line-soft);
}

.share-card > header h2 { margin: 0; }

.share-card > header p {
  margin: 5px 0 0;
  color: var(--ref-muted);
  font-size: 12.5px;
}

.share-card > header .share-close-button {
  display: grid;
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border-radius: 10px;
  color: var(--ref-muted);
}

.share-close-button .lc-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.1;
}

.share-card-body {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 24px 8px;
  scrollbar-gutter: stable;
}

.share-section {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 14px;
  padding: 21px 0;
}

.share-email-section { border-top: 1px solid var(--ref-line-soft); }

.share-section-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: #718097;
}

.share-section-icon .lc-icon {
  width: 23px;
  height: 23px;
  stroke-width: 1.9;
}

.share-section-content h3 {
  margin: 0;
  color: var(--ref-ink);
  font-size: 15px;
  font-weight: 720;
}

.share-section-content > p {
  margin: 4px 0 14px;
  color: var(--ref-muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.share-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px auto;
  align-items: stretch;
  overflow: hidden;
  border: 1.5px solid var(--ref-line-strong);
  border-radius: 9px;
  background: var(--ref-paper);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.share-link-row[data-state="ready"] { border-color: #a9c8ef; }
.share-link-row[data-state="error"] { border-color: #efaaa5; }

.share-card .share-link-row input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--ref-blue) !important;
  font-size: 12.5px;
  font-weight: 580;
  box-shadow: none !important;
  text-overflow: ellipsis;
}

.share-link-row button {
  min-height: 42px;
  border: 0;
  border-left: 1px solid var(--ref-line-soft);
  border-radius: 0;
  background: var(--ref-paper);
  color: var(--ref-muted);
  font-size: 12px;
  font-weight: 680;
}

.share-link-row button:hover:not(:disabled) { background: var(--ref-paper-blue); color: var(--ref-blue); }
.share-link-row button:disabled { color: #aab4c2; cursor: wait; }
.share-copy-button {
  display: inline-flex;
  min-width: 108px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding-inline: 13px;
}

.share-copy-button .lc-icon {
  width: 16px;
  height: 16px;
  stroke-width: 2.1;
}

.share-open-button {
  display: grid;
  width: 42px;
  place-items: center;
}

.share-open-button .lc-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.05;
}

.share-status {
  min-height: 18px;
  margin: 7px 0 4px !important;
  color: var(--ref-muted);
  font-size: 11.5px !important;
}

.share-link-row[data-state="ready"] + .share-status { color: #087354; }
.share-link-row[data-state="error"] + .share-status { color: #c8342b; }

.share-collection-options {
  margin: 13px 0 16px;
  padding: 14px;
  border: 1px solid var(--ref-line-soft);
  border-radius: 10px;
  background: #f8fafd;
}

.share-collection-options .share-field { margin-top: 0; }

.share-field-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.share-field-label em {
  color: var(--ref-muted);
  font-size: 10.5px;
  font-style: normal;
  font-weight: 540;
}

.share-field > small {
  color: var(--ref-muted);
  font-size: 10.75px;
  font-weight: 480;
  line-height: 1.35;
}

.share-name-toggle { margin-top: 13px; }

.share-owner-name-field {
  margin-top: 11px !important;
  margin-left: 63px;
}

.share-toggle-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 10px;
  color: var(--ref-ink);
  cursor: pointer;
}

.share-option-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: #718097;
  stroke-width: 1.9;
}

.share-toggle-row > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.share-toggle-row strong { font-size: 12.5px; font-weight: 670; }
.share-toggle-row small { color: var(--ref-muted); font-size: 11px; line-height: 1.35; }
.share-toggle-row.compact { margin: 0; }

.share-switch {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 34px;
}

.share-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.share-switch > span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c6ced9;
  transition: background-color 140ms ease;
}

.share-switch > span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(23, 32, 51, 0.25);
  content: "";
  transition: transform 140ms ease;
}

.share-switch input:checked + span { background: var(--ref-blue); }
.share-switch input:checked + span::after { transform: translateX(14px); }
.share-switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--ref-focus); }

.share-field {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--ref-ink);
  font-size: 11.5px;
  font-weight: 670;
}

.share-card .share-field input,
.share-card .share-field textarea {
  width: 100%;
  min-height: 42px;
  border: 1.5px solid var(--ref-line-strong) !important;
  border-radius: 8px !important;
  background: var(--ref-paper) !important;
  color: var(--ref-ink) !important;
  font-size: 12.5px;
  font-weight: 450;
  box-shadow: none !important;
}

.share-card .share-field textarea { min-height: 82px; resize: vertical; }

.share-card .share-field input:focus,
.share-card .share-field textarea:focus {
  border-color: var(--ref-blue) !important;
  box-shadow: 0 0 0 3px var(--ref-focus) !important;
}

.share-email-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 13px;
}

.share-message-toggle {
  border: 0;
  background: transparent;
  color: var(--ref-blue);
  font-size: 12px;
  font-weight: 680;
}

.share-message-toggle:hover { text-decoration: underline; }
.share-message-fields { margin-top: 14px; }

.share-email-error {
  margin: 6px 0 0 !important;
  color: #c8342b !important;
  font-size: 11.5px !important;
}

.share-card > footer {
  padding: 14px 24px;
  border-top: 1px solid var(--ref-line-soft);
  background: #fbfcfe;
}

.share-card > footer .ghost-button,
.share-card > footer .primary-button {
  min-width: 86px;
  min-height: 40px;
  border-radius: 8px;
}

.share-card > footer .primary-button:disabled {
  background: #dfe5ed;
  color: #8b97a8;
  box-shadow: none;
  cursor: not-allowed;
}

.shared-link-chip {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.shared-link-chip span {
  color: var(--ref-blue);
  font-size: 10px;
  font-weight: 760;
}

@media (max-width: 700px) {
  .share-card {
    width: calc(100vw - 16px);
    max-height: calc(var(--library-visual-height, 100dvh) - 16px);
  }

  .share-card > header,
  .share-card > footer { padding-inline: 16px; }
  .share-card-body { padding-inline: 16px; }
  .share-section { grid-template-columns: 24px minmax(0, 1fr); gap: 10px; }
  .share-link-row { grid-template-columns: minmax(0, 1fr) 42px; }
  .share-copy-button { grid-column: 1 / -1; border-top: 1px solid var(--ref-line-soft) !important; border-left: 0 !important; }
  .share-email-actions { align-items: flex-start; flex-direction: column; }
  .share-owner-name-field { margin-left: 0; }
}
