/* library page (library.html) */
.lib-main { max-width: 1500px; }
/* the body scrolls (style.css): it must reach the bottom of the screen, or it clips the open menus */
.libpage { min-height: 100vh; box-sizing: border-box; }
.lib-share { background: var(--surface-1); border: 1px solid var(--line); padding: 8px 10px; margin-bottom: 10px; }
.lib-share h2 { margin: 0 0 4px; font-size: 14px; color: var(--text-strong); }
.lib-rooms { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.lib-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; padding: 6px 8px; background: var(--surface-1); border: 1px solid var(--line); }
.lib-filters input[type=search] { min-width: 240px; }
.lib-ranges { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-range { display: inline-flex; align-items: center; gap: 4px; font: 11px/1 var(--f-data); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.lib-range input { width: 64px; }
.lib-colmenu { left: auto; right: 0; min-width: 220px; max-height: 70vh; overflow-y: auto; }
.lib-colmenu label { display: flex; padding: 2px 6px; }
.lib-colmenu button { display: block; width: 100%; margin-top: 4px; }
.lib-tablewrap { overflow-x: auto; }
.lib-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 10px 0; }
.lib-table { width: 100%; border-collapse: collapse; background: var(--surface-1); border: 1px solid var(--line); }
.lib-table th { text-align: left; color: var(--muted); font: 500 10.5px/1.8 var(--f-data); letter-spacing: .08em; text-transform: uppercase; padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lib-table th.sortable { cursor: pointer; user-select: none; }
.lib-table th.on { color: var(--text-strong); }
.lib-table th.drop { box-shadow: inset 2px 0 0 var(--accent); }
.lib-table td.code { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-data); font-size: 11px; }
.lib-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lib-table td.n { text-align: right; font: 12px/1.4 var(--f-data); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lib-table tbody tr:hover td { background: var(--surface-2); }
.lib-table td.nm a { color: var(--text-strong); font-weight: 600; text-decoration: none; }
.lib-table td.nm a:hover { text-decoration: underline; }
.lib-table tr.bad td.nm a { color: var(--danger); }
.lib-table td.acts { white-space: nowrap; text-align: right; }
.lib-table td.acts button { margin-left: 2px; }
.lib-table th .ml-ico { vertical-align: middle; margin-left: 3px; }
.lib-badge { display: inline-block; margin: 0 0 0 6px; padding: 0 5px; border: 1px solid var(--line-strong); font-size: 11px; color: var(--muted); text-decoration: none; }
.lib-badge.bad { border-color: var(--danger); color: var(--danger); }
/* My mechs: scatter plot and selection to compare */
.lib-chart { margin-bottom: 8px; padding: 8px 10px; background: var(--surface-1); border: 1px solid var(--line); }
.lib-chartbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 4px; }
.lib-filters .dk-tbtn.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.lib-table th.sel, .lib-table td.sel { width: 26px; padding-right: 0; }
.lib-table tr.picked td { background: var(--accent-bg); }
.lib-table td.nm .lib-namebtn { padding: 0; border: 0; background: none; color: var(--text-strong); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.lib-table td.nm .lib-namebtn:hover { text-decoration: underline; }
.lib-table tr.bad td.nm .lib-namebtn { color: var(--danger); }

/* filters wrapper: transparent on desktop, moved into a sheet below 900 px */
.lib-fbody { display: contents; }
.lib-mobile-only { display: none; }
.ui-sheet .lib-fbody { display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-3); }
.ui-sheet .lib-fbody .lib-ranges { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2) var(--sp-3); }
.ui-sheet .lib-fbody .lib-range { justify-content: space-between; }
.ui-sheet .lib-fbody .lib-range input { width: 90px; }
.ui-sheet .lib-fbody .ml-seg { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.lib-sortsheet { display: flex; flex-direction: column; gap: var(--sp-3); }
.lib-sortsheet label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: 12px; color: var(--muted); }
.lib-sortsheet .lib-dir { display: flex; gap: var(--sp-2); }
.lib-sortsheet .lib-dir button { flex: 1; }
.lib-sortsheet .lib-dir button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

@media (max-width: 899.98px) {
  .lib-mobile-only { display: inline-flex; }
  .lib-filters > .lib-fbody { display: none; }
  .lib-filters input[type=search] { min-width: 0; flex: 1 1 100%; }
  .lib-filters .tb-spacer { display: none; }
  .lib-filters .dk-tbtn[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
  .lib-tablewrap { overflow-x: visible; }
  .lib-table, .lib-table tbody { display: block; background: none; border: 0; }
  .lib-table thead { display: none; }
  .lib-table tr { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); position: relative; margin-bottom: var(--sp-2); padding: var(--sp-2) var(--sp-3);
    background: var(--surface-1); border: 1px solid var(--line); -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .lib-table tr.picked { border-color: var(--accent); }
  .lib-table td { display: block; border: 0; padding: 0; flex: 1 1 40%; min-width: 0; text-align: left; overflow-wrap: anywhere; }
  .lib-table td:empty { display: none; }
  .lib-table td[data-label]::before { content: attr(data-label); display: block; font: 500 11px/1.4 var(--f-data); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .lib-table td.n { text-align: left; white-space: normal; }
  .lib-table td.code { max-width: none; white-space: normal; }
  .lib-table td.nm { flex: 1 1 0; min-width: 60%; font-size: 15px; }
  .lib-table td.sel { display: none; flex: 0 0 var(--touch); order: -1; width: var(--touch); }
  .lib-main.selecting .lib-table td.sel { display: flex; align-items: center; justify-content: center; }
  .lib-table td.sel input { width: 22px; height: 22px; }
  .lib-table td.acts { flex: 1 1 100%; display: flex; flex-wrap: wrap; justify-content: flex-start; gap: var(--sp-2); }
  .lib-table td.acts button { margin: 0; }
  .lib-table tbody tr:hover td { background: none; }
}
@media (max-width: 599.98px) {
  /* decision 5: chart and column management are hidden on phones */
  #chartBtn, #chartPanel, #columnsBtn, #columnsMenu { display: none !important; }
}
@media (pointer: coarse) {
  .lib-filters .dk-tbtn, .lib-filters select, .lib-filters input, .lib-pager .dk-tbtn, .lib-table td.acts .dk-ibtn, .lib-sortsheet select, .lib-sortsheet button,
  .ui-sheet .lib-fbody button, .ui-sheet .lib-fbody select, .ui-sheet .lib-fbody input[type=number] { min-height: var(--touch); }
  .lib-table td.acts .dk-ibtn { min-width: var(--touch); }
  .libpage .dk-top .dk-tbtn, .libpage .dk-top .btn, .libpage .dk-top select, .lib-filters .ml-seg button { min-height: var(--touch); }
  .libpage .dk-top .dk-tbtn.sq, .lib-filters .ml-seg button { min-width: var(--touch); }
  .lib-table td.nm .lib-namebtn { min-height: var(--touch); }
  .lib-colmenu label, .lib-rooms label { min-height: var(--touch); align-items: center; }
}
