/* Novo authenticated workspace — right-panel precision repair.
   This file intentionally loads after the main Novo and sidebar/settings layers.
   Every rule is route-scoped so the established library remains unchanged. */

html.library-novo body.library-workspace-open .main-panel {
  min-width: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
}

/* Keep every command discoverable without hiding controls in a horizontal scroller. */
html.library-novo body.library-workspace-open .command-bar {
  display: grid;
  grid-template-columns: minmax(330px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 64px;
  padding: 8px 10px;
  overflow: visible;
}

html.library-novo body.library-workspace-open .command-cluster {
  min-width: 0;
  gap: 8px;
}

html.library-novo body.library-workspace-open .command-cluster .top-search {
  min-width: 220px;
  min-height: 44px;
  flex: 1 1 300px;
}

html.library-novo body.library-workspace-open .topbar-add,
html.library-novo body.library-workspace-open .top-search > input,
html.library-novo body.library-workspace-open .command-bar .toolbar > button,
html.library-novo body.library-workspace-open .command-bar .toolbar-icon,
html.library-novo body.library-workspace-open .command-bar .folder-picker-button,
html.library-novo body.library-workspace-open .command-bar .ref-capture-sync-button,
html.library-novo body.library-workspace-open .command-bar .share-toolbar-button {
  height: 44px;
  min-height: 44px;
  border-radius: 10px;
}

html.library-novo body.library-workspace-open .topbar-add {
  min-width: 84px;
  padding-inline: 14px;
}

html.library-novo body.library-workspace-open .top-search > input {
  min-width: 0;
  padding-inline: 14px 52px;
  font-size: 13.5px;
}

html.library-novo body.library-workspace-open #app .toolbar {
  min-width: 0;
  max-width: none;
  display: flex;
  flex-wrap: nowrap !important;
  justify-content: flex-end;
  gap: 6px;
  overflow: visible !important;
}

html.library-novo body.library-workspace-open .command-bar .toolbar > button,
html.library-novo body.library-workspace-open .command-bar .toolbar-icon,
html.library-novo body.library-workspace-open .command-bar .ref-capture-sync-button,
html.library-novo body.library-workspace-open .command-bar .share-toolbar-button {
  min-width: 40px;
  padding-inline: 10px;
  font-size: 12px;
  white-space: nowrap;
}

/* Restore the readable menu proportions visible in the established library. */
html.library-novo body.library-workspace-open .command-bar .floating-menu,
html.library-novo body.library-workspace-open .command-bar .search-popover,
html.library-novo body.library-workspace-open .command-bar .bulk-folder-menu,
html.library-novo body.library-workspace-open .command-bar .ref-capture-sync-popover,
html.library-novo body.library-workspace-open .sort-row .sf-select-content {
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(9, 29, 45, .13), 0 2px 5px rgba(9, 29, 45, .06);
}

html.library-novo body.library-workspace-open .floating-menu.add-menu {
  width: min(650px, calc(100vw - 48px));
  max-height: min(76vh, 640px);
  padding: 8px;
}

html.library-novo body.library-workspace-open .add-menu-item {
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
}

html.library-novo body.library-workspace-open .add-menu-copy {
  gap: 3px;
}

html.library-novo body.library-workspace-open .add-menu-copy strong {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

html.library-novo body.library-workspace-open .add-menu-copy small {
  font-size: 12.25px;
  font-weight: 500;
  line-height: 1.4;
}

html.library-novo body.library-workspace-open .search-popover {
  left: 96px;
  width: min(680px, calc(100vw - 360px));
  max-height: min(76vh, 660px);
  padding: 8px;
}

html.library-novo body.library-workspace-open .search-help-row {
  grid-template-columns: 28px max-content minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
}

html.library-novo body.library-workspace-open .search-help-row strong {
  font-size: 13px;
  font-weight: 700;
}

html.library-novo body.library-workspace-open .search-help-row span:not(.search-option-icon) {
  overflow: visible;
  color: var(--novo-muted);
  font-size: 12.25px;
  font-weight: 500;
  line-height: 1.4;
  text-overflow: clip;
  white-space: normal;
}

html.library-novo body.library-workspace-open .search-help-section {
  gap: 8px;
  padding: 12px;
}

html.library-novo body.library-workspace-open .search-help-section > span {
  font-size: 10.5px;
}

html.library-novo body.library-workspace-open .include-section {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

html.library-novo body.library-workspace-open .include-section > span {
  grid-column: 1 / -1;
}

html.library-novo body.library-workspace-open .include-section label {
  grid-template-columns: 22px minmax(0, 1fr) auto;
  min-width: 0;
  font-size: 12.5px;
}

/* Header controls use one size and retain complete labels. */
html.library-novo body.library-workspace-open .list-header {
  min-height: 64px;
  gap: 10px;
  padding: 10px 14px;
}

html.library-novo body.library-workspace-open .list-header h1 {
  font-size: 22px;
  font-weight: 650;
  line-height: 1.15;
}

html.library-novo body.library-workspace-open .sort-row {
  min-width: 0;
  gap: 6px;
  overflow: visible;
}

html.library-novo body.library-workspace-open .sf-select-trigger,
html.library-novo body.library-workspace-open .sort-direction-button,
html.library-novo body.library-workspace-open .sort-row > [data-selected-count] {
  height: 40px;
  min-height: 40px;
  padding-inline: 10px;
  font-size: 12.5px;
}

html.library-novo body.library-workspace-open .content-grid {
  padding: 9px 10px 10px;
}

html.library-novo body.library-workspace-open .reference-list {
  border-width: 1.5px;
  border-radius: 12px;
  overflow-x: hidden;
  overflow-y: auto;
}

html.library-novo body.library-workspace-open .reference-card:first-child,
html.library-novo body.library-workspace-open .reference-card:last-child {
  border-radius: 0;
}

/* Reference rows: readable metadata, compact rhythm, and actions with no dead column. */
html.library-novo body.library-workspace-open .reference-card {
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 9px;
  min-height: 0;
  padding: 10px 13px;
}

html.library-novo body.library-workspace-open .reference-card > :nth-child(2) {
  min-width: 0;
}

html.library-novo body.library-workspace-open .card-select-stack {
  width: 24px;
  gap: 7px;
  padding-top: 2px;
}

html.library-novo body.library-workspace-open .reference-title {
  margin-bottom: 0;
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

html.library-novo body.library-workspace-open .reference-card .meta {
  color: #526b7d;
  font-size: 12.5px;
  line-height: 1.4;
}

html.library-novo body.library-workspace-open .meta-row {
  gap: 7px;
  margin-top: 0;
}

html.library-novo body.library-workspace-open .reference-card .links {
  gap: 8px;
  margin-top: 0;
}

html.library-novo body.library-workspace-open .reference-card .links a,
html.library-novo body.library-workspace-open .reference-card .links > button,
html.library-novo body.library-workspace-open .meta-primary-link a {
  font-size: 12.25px;
  font-weight: 650;
}

html.library-novo body.library-workspace-open .reference-resource-indicators {
  gap: 2px;
}

html.library-novo body.library-workspace-open .reference-resource-indicator {
  width: 24px;
  height: 24px;
  color: #526b7d;
  background: transparent;
  border-color: transparent;
  border-radius: 6px;
}

html.library-novo body.library-workspace-open .card-actions {
  display: grid;
  grid-template-columns: repeat(2, auto);
  grid-template-rows: auto 1fr;
  align-content: stretch;
  align-items: flex-start;
  align-self: stretch;
  justify-content: flex-end;
  justify-items: end;
  gap: 6px;
  min-height: 100%;
}

html.library-novo body.library-workspace-open .card-actions .ghost-button {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 11.5px;
}

html.library-novo body.library-workspace-open .card-action-star {
  position: relative;
  right: auto;
  bottom: auto;
  grid-column: 2;
  grid-row: 2;
  align-self: end;
  justify-self: end;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  margin-left: 0;
  border-color: transparent;
  background: transparent;
}

/* Expanded content spans the available reading width instead of stopping at 980px. */
html.library-novo body.library-workspace-open .reference-card > .abstract-preview {
  grid-column: 2 / -1;
  width: auto;
  max-width: none;
  margin: 7px 0 2px;
  padding: 12px 14px;
  color: #3f586a;
  font-size: 14.5px;
  line-height: 1.58;
  border-left-width: 1px !important;
  box-shadow: none;
}

html.library-novo body.library-workspace-open .reference-card > .abstract-preview:not(.is-loading):not(.is-empty):not(.is-error) {
  border-left-color: #d4e4fa !important;
}

html.library-novo body.library-workspace-open .reference-card > .abstract-preview.is-loading {
  border-left-color: #c6dcfb !important;
}

html.library-novo body.library-workspace-open .reference-card > .abstract-preview.is-empty {
  border-left-color: #ead39e !important;
}

html.library-novo body.library-workspace-open .reference-card > .abstract-preview.is-error {
  border-left-color: #edc0c7 !important;
}

html.library-novo body.library-workspace-open .reference-card > .reference-resource-panel {
  grid-column: 1 / -1;
  width: auto;
  max-width: none;
  margin: 8px -13px -10px;
  padding: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0 0 8px 8px;
}

html.library-novo body.library-workspace-open .reference-resource-panel-header {
  min-height: 54px;
  padding: 10px 13px;
}

html.library-novo body.library-workspace-open .reference-resource-panel-header small {
  overflow: visible;
  font-size: 11.75px;
  line-height: 1.35;
  text-overflow: clip;
  white-space: normal;
}

html.library-novo body.library-workspace-open .reference-resource-panel-close {
  width: 34px;
  height: 34px;
}

html.library-novo body.library-workspace-open .reference-resource-panel-body {
  padding: 12px 14px 14px;
}

html.library-novo body.library-workspace-open .notes-panel-body textarea {
  min-height: 108px;
  font-size: 13.5px;
  line-height: 1.5;
}

/* The editor needs horizontal room for its fields, not two cramped mini-forms. */
html.library-novo body.library-workspace-open .editor-modal,
html.library-novo body.library-workspace-open .editor-modal[open] {
  width: min(1180px, calc(100vw - 32px)) !important;
  max-width: calc(100vw - 32px) !important;
}

html.library-novo body.library-workspace-open .editor-card {
  width: 100%;
  max-width: 100%;
}

html.library-novo body.library-workspace-open .editor-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
}

html.library-novo body.library-workspace-open .editor-section,
html.library-novo body.library-workspace-open .editor-section-core,
html.library-novo body.library-workspace-open .editor-section-ids {
  gap: 11px 12px;
  padding: 16px;
}

html.library-novo body.library-workspace-open .editor-section label {
  font-size: 12.25px;
}

html.library-novo body.library-workspace-open .editor-section input,
html.library-novo body.library-workspace-open .editor-section select,
html.library-novo body.library-workspace-open .editor-section textarea {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 13.5px;
}

/* Match the established desktop toolbar: Ref Capture is icon-only when the
   complete command set shares one row, then regains its label on tablets. */
@media (min-width: 901px) {
  html.library-novo body.library-workspace-open .ref-capture-sync-control {
    width: 44px;
    flex: 0 0 44px;
  }

  html.library-novo body.library-workspace-open .command-bar .ref-capture-sync-button {
    width: 44px;
    min-width: 44px;
    padding-inline: 0 !important;
    font-size: 0 !important;
    gap: 0;
  }
}

/* Tablets do not have enough horizontal room for both complete command
   groups. Two clear rows prevent the search controls from sitting underneath
   Select all / Ref Capture between 761px and 900px. */
@media (min-width: 761px) and (max-width: 900px) {
  html.library-novo body.library-workspace-open .command-bar {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
    min-height: 0;
    padding: 7px;
  }

  html.library-novo body.library-workspace-open .command-cluster,
  html.library-novo body.library-workspace-open #app .toolbar {
    grid-column: 1;
    width: 100%;
  }

  html.library-novo body.library-workspace-open .command-cluster {
    grid-row: 1;
  }

  html.library-novo body.library-workspace-open #app .toolbar {
    grid-row: 2;
  }

  html.library-novo body.library-workspace-open .command-cluster .top-search {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  html.library-novo body.library-workspace-open .command-bar {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
    padding: 7px;
  }

  html.library-novo body.library-workspace-open .command-cluster,
  html.library-novo body.library-workspace-open #app .toolbar {
    grid-column: 1;
    width: 100%;
  }

  html.library-novo body.library-workspace-open .command-cluster {
    grid-row: 1;
  }

  html.library-novo body.library-workspace-open #app .toolbar {
    grid-row: 2;
  }

  html.library-novo body.library-workspace-open .command-cluster .top-search {
    min-width: 0;
  }

  html.library-novo body.library-workspace-open #app .toolbar {
    width: 100%;
    flex-wrap: wrap !important;
    justify-content: flex-end;
    overflow: visible !important;
  }

  html.library-novo body.library-workspace-open .floating-menu.add-menu,
  html.library-novo body.library-workspace-open .search-popover {
    left: 0;
    width: min(640px, calc(100vw - 30px));
    max-height: calc(var(--library-visual-height, 100dvh) - 116px);
  }

  html.library-novo body.library-workspace-open .search-help-row {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    grid-template-areas:
      "icon title key"
      "icon description description";
    gap: 2px 9px;
    padding: 10px;
  }

  html.library-novo body.library-workspace-open .search-help-row .search-option-icon {
    grid-area: icon;
  }

  html.library-novo body.library-workspace-open .search-help-row strong {
    grid-area: title;
  }

  html.library-novo body.library-workspace-open .search-help-row span:not(.search-option-icon) {
    grid-area: description;
  }

  html.library-novo body.library-workspace-open .search-help-row kbd {
    grid-area: key;
  }

  html.library-novo body.library-workspace-open .include-section {
    grid-template-columns: minmax(0, 1fr);
  }

  html.library-novo body.library-workspace-open .include-section > span {
    grid-column: 1;
  }

  html.library-novo body.library-workspace-open .list-header {
    display: flex;
    align-items: flex-start;
    align-content: flex-start;
    justify-content: flex-start;
    flex-direction: column;
    min-height: 0;
    padding: 9px 10px;
  }

  html.library-novo body.library-workspace-open .list-header h1 {
    font-size: 21px;
  }

  html.library-novo body.library-workspace-open .sort-row {
    flex: 0 0 auto;
    align-self: stretch;
    width: 100%;
  }

  html.library-novo body.library-workspace-open .sort-row > [data-custom-select="type"] .sf-select-content {
    right: 0;
    left: auto;
  }

  html.library-novo body.library-workspace-open .reference-card {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 8px;
    padding: 11px 10px;
  }

  html.library-novo body.library-workspace-open .reference-title {
    font-size: 14px;
  }

  html.library-novo body.library-workspace-open .reference-card .meta {
    font-size: 12px;
  }

  html.library-novo body.library-workspace-open .reference-card .links a,
  html.library-novo body.library-workspace-open .reference-card .links > button,
  html.library-novo body.library-workspace-open .meta-primary-link a {
    font-size: 11.75px;
  }

  html.library-novo body.library-workspace-open .card-actions {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-top: 1px;
  }

  html.library-novo body.library-workspace-open .reference-resource-indicator {
    width: 36px;
    height: 36px;
  }

  html.library-novo body.library-workspace-open .card-action-star {
    position: static;
    grid-row: auto;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    border-color: var(--novo-line);
    background: var(--novo-surface);
  }

  html.library-novo body.library-workspace-open .reference-card > .abstract-preview {
    grid-column: 1 / -1;
    margin-top: 5px;
    font-size: 13px;
  }

  html.library-novo body.library-workspace-open .reference-card > .reference-resource-panel {
    margin-right: -10px;
    margin-bottom: -9px;
    margin-left: -10px;
  }

  html.library-novo body.library-workspace-open .editor-modal,
  html.library-novo body.library-workspace-open .editor-modal[open] {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
  }

  html.library-novo body.library-workspace-open .editor-grid {
    padding: 10px;
  }

  html.library-novo body.library-workspace-open .editor-section,
  html.library-novo body.library-workspace-open .editor-section-core,
  html.library-novo body.library-workspace-open .editor-section-ids {
    padding: 13px;
  }
}

@media (max-width: 700px) {
  html.library-novo body.library-workspace-open #app .toolbar,
  html.library-novo body.library-workspace-open #app[data-has-selection="false"] .toolbar,
  html.library-novo body.library-workspace-open #app[data-has-selection="true"] .toolbar {
    width: 100%;
    min-height: 0;
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 5px;
    overflow: visible !important;
  }

  html.library-novo body.library-workspace-open #app .toolbar > button,
  html.library-novo body.library-workspace-open #app .toolbar > .bulk-folder-control,
  html.library-novo body.library-workspace-open #app .toolbar > .ref-capture-sync-control,
  html.library-novo body.library-workspace-open #app .toolbar .folder-picker-button,
  html.library-novo body.library-workspace-open #app .toolbar .ref-capture-sync-button {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  html.library-novo body.library-workspace-open #app .toolbar button:disabled,
  html.library-novo body.library-workspace-open #app .bulk-folder-control:has(> button:disabled) {
    display: none;
  }

  html.library-novo body.library-workspace-open .command-bar .toolbar > button:not(.toolbar-icon),
  html.library-novo body.library-workspace-open .toolbar .toolbar-icon,
  html.library-novo body.library-workspace-open .ref-capture-sync-button {
    min-height: 42px;
    padding-inline: 7px !important;
    font-size: 11.5px;
  }
}

@media (max-width: 340px) {
  html.library-novo body.library-workspace-open #app .toolbar,
  html.library-novo body.library-workspace-open #app[data-has-selection="false"] .toolbar,
  html.library-novo body.library-workspace-open #app[data-has-selection="true"] .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html.library-novo body.library-workspace-open .add-menu-item {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 9px;
  }

  html.library-novo body.library-workspace-open .add-menu-item kbd {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.library-novo body.library-workspace-open .reference-card,
  html.library-novo body.library-workspace-open .reference-resource-panel {
    animation: none;
    transition: none;
  }
}
