/*
  Living Library Manager feature CSS
  Shared admin shell/components live in assets/css/admin-core.css.
  This file contains only Library workspace, editor, preview, block, and media layouts.
*/

.uh-library-user-card span { color: var(--admin-text-muted); }
.uh-library-user-card strong { font-size: .82rem; overflow-wrap: anywhere; }
.uh-library-card-head a { font-size: .86rem; color: var(--admin-sage-dark); font-weight: 800; }
.uh-library-field span { font-weight: 500; letter-spacing: 0; color: var(--admin-text-muted); font-size: .75rem; }
.uh-library-field.slim input { padding: .62rem .72rem; }
.uh-library-filter-row { display: flex; flex-wrap: wrap; gap: .38rem; margin: .8rem 0; }
.uh-library-entry-item {
  width: 100%;
  display: grid;
  gap: .25rem;
  padding: .72rem;
  color: var(--admin-text);
  text-align: left;
  cursor: pointer;
}

.uh-library-workspace{display:grid;gap:1rem;align-items:start}.uh-library-entries-card{padding:.82rem;position:sticky;top:1rem;max-height:calc(100vh - 2rem);overflow:auto}.uh-library-preview-rail{display:grid;gap:1rem;position:sticky;top:1rem;max-height:calc(100vh - 2rem);overflow:auto}.uh-library-editor-card{min-width:0;overflow:hidden}.uh-library-list-meta{display:flex;justify-content:space-between;color:var(--uh-muted);font-size:.76rem;font-weight:800;margin:.4rem 0 .5rem}.uh-library-entry-list{display:grid;gap:.55rem}.uh-library-entry-item strong{font-family:Georgia,serif;font-size:.98rem;line-height:1.18}.uh-library-entry-item span{font-size:.76rem;color:var(--uh-muted)}.uh-library-editor{padding:.82rem}.uh-library-tab-panel{display:none}.uh-library-tab-panel.active{display:block}.uh-library-form-grid{display:grid;gap:.65rem;margin-bottom:.65rem}.uh-library-form-grid.two{grid-template-columns:1fr 1fr}.uh-library-form-grid.three{grid-template-columns:repeat(3,1fr)}.uh-library-section-title{display:flex;justify-content:space-between;gap:1rem;align-items:flex-start;margin:1rem 0 .75rem}.uh-library-section-title p{margin:.15rem 0 0;color:var(--uh-muted);font-size:.88rem}.uh-library-section-title code{font-size:.85em;background:#f0e0c7;border-radius:8px;padding:.1rem .25rem}.uh-library-hero-editor{margin-top:1rem;padding:.82rem;border:1px solid var(--uh-line);border-radius:22px;background:#fff8ec}.uh-library-hero-row{display:grid;grid-template-columns:190px minmax(0,1fr);gap:1rem;align-items:start}.uh-library-hero-thumb{margin:0;min-height:120px;border-radius:18px;overflow:hidden;background:linear-gradient(135deg,#eadcc3,#f9f1df);border:1px dashed #ccb797;display:grid;place-items:center;color:var(--uh-muted);text-align:center}.uh-library-hero-thumb img{width:100%;height:100%;object-fit:cover;display:block}.uh-library-hero-thumb figcaption{padding:.82rem;font-size:.86rem}.uh-library-hero-actions{display:flex;gap:.55rem;flex-wrap:wrap;margin-bottom:.6rem}.uh-library-file-meta{margin:.15rem 0 .75rem;color:var(--uh-muted);font-size:.85rem}.uh-library-block-list{display:grid;gap:.75rem}.uh-library-block-item{border:1px solid var(--uh-line);border-radius:18px;padding:.55rem;background:#fffdf8;display:grid;gap:.55rem}.uh-library-block-head{display:flex;justify-content:space-between;gap:.65rem}.uh-library-block-head strong{font-family:Georgia,serif}.uh-library-preview-entry{display:grid;gap:.7rem}.uh-library-preview-hero{height:155px;border-radius:18px;overflow:hidden;background:linear-gradient(135deg,#e9dcc8,#f8f0df);border:1px solid var(--uh-line)}.uh-library-preview-hero img{width:100%;height:100%;object-fit:cover;display:block}.uh-library-preview-label{display:inline-flex;align-self:start;border-radius:999px;background:var(--uh-sage-soft);padding:.32rem .6rem;color:#2f4328;font-size:.77rem;font-weight:850}.uh-library-preview-entry h3{font-family:Georgia,serif;font-size:1.28rem;line-height:1.08;margin:0}.uh-library-preview-entry p{margin:0;color:var(--uh-muted);font-size:.92rem}.uh-library-preview-meta{display:flex;flex-wrap:wrap;gap:.35rem}.uh-library-preview-meta span{border:1px solid var(--uh-line);background:#fffdf8;border-radius:999px;padding:.28rem .52rem;font-size:.75rem;color:var(--uh-muted);font-weight:750}.uh-library-media-status{display:grid;gap:.55rem}.uh-library-media-row{display:grid;grid-template-columns:54px 1fr;gap:.65rem;align-items:center}.uh-library-media-row img,.uh-library-media-thumb{width:54px;height:42px;border-radius:10px;object-fit:cover;background:#efe2ca}.uh-library-qa-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(280px,1fr);gap:1rem}.uh-library-qa-grid article,.uh-library-empty-state{border:1px solid var(--uh-line);border-radius:18px;background:#fffdf8;padding:.82rem}.uh-library-qa-grid textarea{width:100%;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:.78rem;border:1px solid var(--uh-line);border-radius:12px;background:#fffaf0;padding:.75rem}.uh-library-inline-preview{border:1px solid var(--uh-line);border-radius:18px;background:#fffdf8;padding:.82rem}.uh-library-import-summary{position:fixed;inset:0;background:rgba(45,32,24,.35);display:grid;place-items:center;z-index:60;padding:.82rem}.uh-library-dialog h2{font-family:Georgia,serif;margin-top:0}.uh-library-dialog-actions{display:flex;justify-content:flex-end;gap:.65rem;margin-top:1rem}.uh-library-empty-note{border:1px dashed var(--uh-line);border-radius:18px;padding:.82rem;color:var(--uh-muted);background:#fffdf8}.visually-hidden{position:absolute!important;width:1px;height:1px;overflow:hidden;clip:rect(1px,1px,1px,1px)}

/* Dedicated Library Manager v3 parity/layout hotfix */










.uh-library-form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.uh-library-block-add { display:flex; gap:.55rem; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.uh-library-block-add select,
.uh-library-block-controls select,
.uh-library-block-controls button { border:1px solid var(--uh-line); border-radius:var(--admin-radius-button, 8px); background:#fffdf8; padding:.46rem .65rem; font:inherit; font-weight:750; color:var(--uh-ink); }
.uh-library-block-controls { display:flex; gap:.45rem; flex-wrap:wrap; align-items:center; padding:.45rem; border:1px solid rgba(92,72,49,.12); border-radius:14px; background:#fff8ec; }
.uh-library-block-controls label { display:flex; gap:.3rem; align-items:center; color:var(--uh-muted); font-size:.8rem; font-weight:800; }
.uh-library-block-fields { display:grid; gap:.65rem; }
.uh-library-block-item { padding:.8rem; }
.uh-library-preview-card .uh-entry-page { border:0; box-shadow:none; padding:0; background:transparent; }
.uh-library-preview-card .uh-entry-hero { padding:0; display:block; }
.uh-library-preview-card .uh-entry-layout { display:block; }
.uh-library-preview-card .uh-main, .uh-library-preview-card .uh-sidebar, .uh-library-preview-card .uh-full { display:grid; gap:.6rem; }
.uh-library-preview-card .uh-block { margin:.65rem 0; }
.uh-library-inline-preview .uh-entry-page { max-width:100%; }
.uh-library-field.inline { display:flex; align-items:center; gap:.45rem; }
.uh-library-field.inline input { width:auto; }

/* v3 visual parity fixes: preview scaling and dedicated workspace proportions */
.uh-library-workspace{
  grid-template-columns:minmax(240px,280px) minmax(420px,1fr) minmax(320px,350px);
}
.uh-library-preview-card [data-library-preview-card]{
  max-height:none;
  overflow:hidden;
}
.uh-library-preview-card .uh-entry-page,
.uh-library-inline-preview .uh-entry-page{
  --uh-sidebar-col: minmax(0,1fr);
  font-size:.82rem;
}
.uh-library-preview-card .uh-entry-hero,
.uh-library-inline-preview .uh-entry-hero{
  display:grid;
  grid-template-columns:1fr;
  gap:.65rem;
  padding:.85rem;
  border-radius:22px;
  margin:0 0 .85rem;
}
.uh-library-preview-card .uh-hero-copy,
.uh-library-inline-preview .uh-hero-copy{
  min-width:0;
}
.uh-library-preview-card .uh-hero-copy h1,
.uh-library-inline-preview .uh-hero-copy h1{
  font-size:clamp(1.45rem,4vw,1.85rem) !important;
  line-height:1.05 !important;
  letter-spacing:-.03em;
  margin:.35rem 0 .35rem;
  overflow-wrap:anywhere;
}
.uh-library-preview-card .uh-subtitle,
.uh-library-inline-preview .uh-subtitle{
  font-size:.92rem !important;
  line-height:1.35;
}
.uh-library-preview-card .uh-hero-art,
.uh-library-inline-preview .uh-hero-art{
  min-height:130px;
  max-height:170px;
  width:100%;
  border-radius:18px;
  overflow:hidden;
}
.uh-library-preview-card .uh-hero-art img,
.uh-library-inline-preview .uh-hero-art img{
  width:100%;
  height:100%;
  object-fit:cover;
}
.uh-library-preview-card .uh-entry-layout,
.uh-library-inline-preview .uh-entry-layout{
  display:block;
  margin-top:.5rem;
}
.uh-library-preview-card .uh-main,
.uh-library-preview-card .uh-full,
.uh-library-inline-preview .uh-main,
.uh-library-inline-preview .uh-full{
  display:grid;
  grid-template-columns:1fr;
  gap:.75rem;
}
.uh-library-preview-card .uh-sidebar,
.uh-library-inline-preview .uh-sidebar{
  position:static;
  display:grid;
  grid-template-columns:1fr;
  gap:.75rem;
  margin-top:.75rem;
}
.uh-library-preview-card .uh-block,
.uh-library-inline-preview .uh-block,
.uh-library-preview-card .uh-width-oneThird,
.uh-library-preview-card .uh-width-twoThirds,
.uh-library-preview-card .uh-width-full,
.uh-library-inline-preview .uh-width-oneThird,
.uh-library-inline-preview .uh-width-twoThirds,
.uh-library-inline-preview .uh-width-full{
  grid-column:1/-1;
}
.uh-library-preview-card .uh-block-title,
.uh-library-inline-preview .uh-block-title,
.uh-library-preview-card .uh-card h2,
.uh-library-inline-preview .uh-card h2{
  font-size:1.12rem !important;
  line-height:1.12;
}
.uh-library-preview-card .uh-step-grid,
.uh-library-inline-preview .uh-step-grid,
.uh-library-preview-card .uh-image-grid,
.uh-library-inline-preview .uh-image-grid{
  grid-template-columns:1fr;
}
.uh-library-preview-card .uh-callout,
.uh-library-preview-card .uh-card,
.uh-library-preview-card .uh-quote,
.uh-library-preview-card .uh-reflection-card,
.uh-library-inline-preview .uh-callout,
.uh-library-inline-preview .uh-card,
.uh-library-inline-preview .uh-quote,
.uh-library-inline-preview .uh-reflection-card{
  padding:.8rem;
  border-radius:18px;
}
.uh-library-preview-card .uh-footer-nav{display:none;}

/* v3 nav normalization: keep admin links aligned consistently across admin pages */




/* Phase 2 block editor parity repairs */
.uh-library-block-item{padding:0;overflow:hidden}
.uh-library-block-head{width:100%;appearance:none;border:0;background:#fffaf0;color:var(--uh-ink);padding:.7rem .82rem;cursor:pointer;align-items:center;text-align:left}
.uh-library-block-head span{display:grid;gap:.18rem;min-width:0}
.uh-library-block-head em{font-style:normal;color:var(--uh-muted);font-size:.78rem;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:34rem}
.uh-library-block-head small{color:var(--uh-muted);font-weight:800;white-space:nowrap}
.uh-library-block-item.is-collapsed .uh-library-block-head{background:#fff6e8}
.uh-library-block-body{display:grid;gap:.65rem;padding:.65rem .72rem .82rem;border-top:1px solid var(--uh-line)}
.uh-library-block-controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:.45rem;align-items:end;padding:.55rem;border:1px solid var(--uh-line);border-radius:14px;background:#fff8ec}
.uh-library-block-controls label{display:grid;gap:.2rem;font-size:.72rem;color:var(--uh-muted);font-weight:850}
.uh-library-block-controls input,.uh-library-block-controls select{width:100%;border:1px solid #d9c7a7;border-radius:10px;background:#fffdf8;color:var(--uh-ink);padding:.42rem .5rem;font:inherit;font-size:.78rem}
.uh-library-block-controls button{border:1px solid var(--uh-line);border-radius:var(--admin-radius-button, 8px);background:#fffdf8;color:var(--uh-ink);padding:.45rem .6rem;font-weight:800;cursor:pointer}
.uh-library-block-controls button:hover{background:#fff0d7}
.uh-library-block-fields{display:grid;gap:.55rem}
.uh-library-block-preview{border:1px dashed #d3c0a1;border-radius:14px;background:#fffaf1;padding:.65rem;display:grid;gap:.45rem}
.uh-library-block-preview h4{margin:0;color:var(--uh-muted);font-size:.78rem;text-transform:uppercase;letter-spacing:.08em}
.uh-library-block-local-preview p{margin:.2rem 0 0;color:var(--uh-muted)}

/* Phase 3 media mechanics: image fields use upload/select controls instead of path-only inputs */
.uh-library-image-field{border:1px solid var(--uh-line);border-radius:16px;background:#fffaf1;padding:.65rem;gap:.55rem}
.uh-library-block-image-preview{margin:0;border:1px solid var(--uh-line);border-radius:14px;overflow:hidden;background:#f3e6d2;display:grid;grid-template-rows:auto min-content;max-width:360px}
.uh-library-block-image-preview img{width:100%;height:150px;object-fit:cover;display:block}
.uh-library-block-image-preview figcaption{padding:.45rem .55rem;font-size:.72rem;color:var(--uh-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background:#fffdf8}
.uh-library-block-image-empty{border:1px dashed #cfb995;border-radius:14px;background:#fff7e8;color:var(--uh-muted);padding:.8rem;text-align:center;font-weight:750}
.uh-library-media-actions{display:flex;gap:.45rem;flex-wrap:wrap;align-items:center}
.uh-library-grid-preview{display:grid;grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:.5rem}
.uh-library-grid-preview figure{margin:0;border:1px solid var(--uh-line);border-radius:12px;overflow:hidden;background:#fffdf8}
.uh-library-grid-preview img{width:100%;height:86px;object-fit:cover;display:block}
.uh-library-grid-preview figcaption{padding:.35rem .45rem;font-size:.7rem;color:var(--uh-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.uh-library-media-picker .uh-library-dialog{max-height:min(760px,90vh);overflow:auto}
.uh-library-media-picker-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:.65rem;margin-top:1rem}
.uh-library-media-picker-grid button{appearance:none;border:1px solid var(--uh-line);border-radius:16px;background:#fffdf8;padding:.45rem;text-align:left;color:var(--uh-ink);cursor:pointer;display:grid;gap:.35rem}
.uh-library-media-picker-grid button:hover{border-color:var(--uh-sage);background:#f3ead7}
.uh-library-media-picker-grid img{width:100%;height:96px;object-fit:cover;border-radius:12px;background:#efe2ca}
.uh-library-media-picker-grid span{font-weight:800;font-size:.82rem}
.uh-library-media-picker-grid small{color:var(--uh-muted);font-size:.68rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* Master Phase 9: final Library workspace breakpoints. These rules are kept
   at the end of the feature stylesheet so the workspace cannot be forced back
   into multiple columns by older parity rules. */
@media (max-width: 1320px) {
  .uh-library-workspace {
    grid-template-columns: minmax(230px, 270px) minmax(0, 1fr);
  }
  .uh-library-preview-rail {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: static;
    max-height: none;
    overflow: visible;
  }
}
@media (max-width: 1200px) {
  .uh-library-form-grid.three,
  .uh-library-form-grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 1180px) {
  .uh-library-workspace {
    grid-template-columns: 1fr;
  }
  .uh-library-entries-card,
  .uh-library-preview-rail {
    grid-column: 1;
    position: static;
    max-height: none;
    overflow: visible;
  }
  .uh-library-preview-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 860px) {
  .uh-library-workspace,
  .uh-library-preview-rail,
  .uh-library-form-grid.two,
  .uh-library-form-grid.three,
  .uh-library-form-grid.four,
  .uh-library-hero-row,
  .uh-library-qa-grid {
    grid-template-columns: 1fr;
  }
  .uh-library-entries-card,
  .uh-library-editor-card,
  .uh-library-preview-rail {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}
@media (max-width: 560px) {
  .uh-library-tabs {
    padding: .55rem .65rem .08rem;
  }
  .uh-library-editor {
    padding: .78rem;
  }
  .uh-library-hero-thumb {
    min-height: 190px;
  }
  .uh-library-section-title,
  .uh-library-card-head {
    flex-wrap: wrap;
  }
}


/* Follow-up Milestone 2: two-column Library workspace with collapsible entries panel. */
.uh-library-workspace {
  grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}
.uh-library-workspace.is-entries-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}
.uh-library-entries-card {
  min-width: 0;
  transition: width 180ms ease, padding 180ms ease, transform 180ms ease;
}
.uh-library-entries-head {
  gap: .55rem;
  align-items: center;
}
.uh-library-entries-head-actions {
  display: flex;
  gap: .4rem;
  align-items: center;
}
.uh-library-entries-toggle {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 1.4rem;
  line-height: 1;
}
.uh-library-workspace.is-entries-collapsed .uh-library-entries-card {
  padding: .65rem .45rem;
  overflow: hidden;
}
.uh-library-workspace.is-entries-collapsed .uh-library-entries-head {
  justify-content: center;
}
.uh-library-workspace.is-entries-collapsed .uh-library-entries-head h2,
.uh-library-workspace.is-entries-collapsed [data-library-new-small],
.uh-library-workspace.is-entries-collapsed .uh-library-entries-content {
  display: none;
}
.uh-library-workspace.is-entries-collapsed .uh-library-entries-head-actions {
  width: 100%;
  justify-content: center;
}
.uh-library-editor-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  min-height: 0;
  padding: 0;
}
.uh-library-mobile-entries-button {
  display: none;
}
.uh-library-editor-width-note {
  display: none;
  color: var(--admin-text-muted);
  font-size: .78rem;
  font-weight: 750;
}
.uh-library-entries-backdrop {
  display: none;
}
.uh-library-block-toolbar {
  position: sticky;
  top: .5rem;
  z-index: 12;
  margin: .25rem 0 .85rem;
  padding: .72rem .78rem;
  border: 1px solid var(--admin-border-soft);
  border-radius: var(--admin-radius-card);
  background: rgba(255, 249, 234, .97);
  box-shadow: var(--admin-shadow-soft);
  backdrop-filter: blur(8px);
}
.uh-library-block-item {
  scroll-margin-top: 7.25rem;
}

@media (max-width: 1180px) {
  .uh-library-workspace,
  .uh-library-workspace.is-entries-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }
  .uh-library-editor-card {
    grid-column: 1;
  }
  .uh-library-editor-topbar {
    padding: .65rem .75rem 0;
  }
  .uh-library-mobile-entries-button {
    display: inline-flex;
  }
  .uh-library-editor-width-note {
    display: inline;
  }
  .uh-library-entries-card,
  .uh-library-workspace.is-entries-collapsed .uh-library-entries-card {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 121;
    width: min(88vw, 340px);
    max-width: 340px;
    height: 100dvh;
    max-height: 100dvh;
    padding: 1rem;
    border-radius: 0 var(--admin-radius-panel) var(--admin-radius-panel) 0;
    overflow: auto;
    transform: translateX(-105%);
    visibility: hidden;
    box-shadow: 18px 0 44px rgba(61,49,31,.18);
  }
  .uh-library-workspace.is-entries-open .uh-library-entries-card {
    transform: translateX(0);
    visibility: visible;
  }
  .uh-library-workspace.is-entries-collapsed .uh-library-entries-head h2,
  .uh-library-workspace.is-entries-collapsed [data-library-new-small],
  .uh-library-workspace.is-entries-collapsed .uh-library-entries-content {
    display: revert;
  }
  .uh-library-workspace.is-entries-collapsed .uh-library-entries-head {
    justify-content: space-between;
  }
  .uh-library-workspace.is-entries-collapsed .uh-library-entries-head-actions {
    width: auto;
    justify-content: flex-end;
  }
  .uh-library-entries-toggle {
    display: inline-grid;
  }
  .uh-library-entries-backdrop {
    position: fixed;
    inset: 0;
    z-index: 120;
    border: 0;
    padding: 0;
    background: rgba(45, 36, 27, .34);
    opacity: 0;
    visibility: hidden;
    transition: opacity 160ms ease, visibility 160ms ease;
  }
  .uh-library-workspace.is-entries-open .uh-library-entries-backdrop {
    display: block;
    opacity: 1;
    visibility: visible;
  }
  body.library-entries-open {
    overflow: hidden;
  }
  .uh-library-block-toolbar {
    top: .35rem;
  }
}

@media (max-width: 560px) {
  .uh-library-editor-topbar {
    align-items: stretch;
  }
  .uh-library-editor-width-note {
    align-self: center;
  }
  .uh-library-block-toolbar {
    position: sticky;
    top: .25rem;
    padding: .65rem;
  }
  .uh-library-block-toolbar .uh-library-block-add {
    width: 100%;
    justify-content: stretch;
  }
  .uh-library-block-toolbar .uh-library-block-add select,
  .uh-library-block-toolbar .uh-library-block-add button {
    flex: 1 1 100%;
    width: 100%;
  }
}

/* Sticky block tools must not be trapped by the editor card's legacy overflow. */
.uh-library-editor-card {
  overflow: visible;
}
.uh-library-tabs {
  overflow-x: auto;
  max-width: 100%;
}
.admin-shell .uh-library-editor-card.admin-card--flush {
  overflow: visible;
}
@media (max-width: 860px) {
  .uh-library-block-toolbar {
    top: 4.65rem;
  }
  .uh-library-block-item {
    scroll-margin-top: 10.75rem;
  }
}

/* Milestone 3 — block editor workflow */
.uh-library-block-toolbar{
  display:grid;
  grid-template-columns:minmax(180px,1fr) auto;
  align-items:center;
  gap:.65rem 1rem;
}
.uh-library-block-toolbar>div:first-child{grid-row:1 / span 2;align-self:start}
.uh-library-block-tools,.uh-library-block-add{display:flex;gap:.45rem;align-items:center;justify-content:flex-end;flex-wrap:wrap}
.uh-library-block-tools select{min-width:220px;max-width:320px}
.uh-library-block-toolbar select,.uh-library-block-toolbar button{min-height:40px}
.uh-library-block-item{position:relative;scroll-margin-top:8.5rem;transition:border-color .16s ease,box-shadow .16s ease,transform .16s ease,opacity .16s ease}
.uh-library-block-head{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.5rem;align-items:stretch;padding:0;background:#fffaf0}
.uh-library-block-drag-handle,.uh-library-block-toggle{appearance:none;border:0;background:transparent;color:var(--uh-ink);font:inherit}
.uh-library-block-drag-handle{display:flex;align-items:center;gap:.65rem;min-width:0;padding:.65rem .75rem;text-align:left;cursor:grab}
.uh-library-block-drag-handle:active{cursor:grabbing}
.uh-library-block-drag-handle>span:last-child{display:grid;gap:.12rem;min-width:0}
.uh-library-block-drag-handle strong{font-family:Georgia,serif}
.uh-library-block-drag-handle em{font-style:normal;color:var(--uh-muted);font-size:.78rem;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:38rem}
.uh-library-drag-grip{color:var(--admin-text-muted,#877865);font-size:1.1rem;letter-spacing:-.18em;flex:0 0 auto}
.uh-library-block-number{display:block;color:var(--admin-sage-dark,#4f6244);font-size:.68rem;font-weight:850;letter-spacing:.055em;text-transform:uppercase}
.uh-library-block-toggle{display:flex;align-items:center;gap:.5rem;padding:.5rem .7rem;border-left:1px solid var(--uh-line);cursor:pointer;color:var(--uh-muted);font-weight:800}
.uh-library-block-toggle small{white-space:nowrap}
.uh-library-block-toggle span{font-size:1.1rem;line-height:1}
.uh-library-block-drag-handle:focus-visible,.uh-library-block-toggle:focus-visible{outline:3px solid rgba(102,123,88,.25);outline-offset:-3px}
.uh-library-block-item.is-active{border-color:var(--admin-sage,#667b58);box-shadow:0 0 0 3px rgba(102,123,88,.12)}
.uh-library-block-item.is-newly-added{animation:uhLibraryBlockArrival 1.05s ease}
@keyframes uhLibraryBlockArrival{0%,45%{box-shadow:0 0 0 5px rgba(185,147,66,.26);border-color:#b99342}100%{box-shadow:0 0 0 3px rgba(102,123,88,.12);border-color:var(--admin-sage,#667b58)}}
.uh-library-block-item.is-dragging{opacity:.54;transform:scale(.995);box-shadow:var(--admin-shadow-panel)}
.uh-library-block-item.is-drop-before::before,.uh-library-block-item.is-drop-after::after{content:"Drop block here";position:absolute;left:.4rem;right:.4rem;height:4px;border-radius:999px;background:var(--admin-sage,#667b58);color:transparent;z-index:5;box-shadow:0 0 0 2px rgba(255,253,246,.9)}
.uh-library-block-item.is-drop-before::before{top:-7px}.uh-library-block-item.is-drop-after::after{bottom:-7px}
.uh-library-toast{display:flex;align-items:center;gap:.8rem;justify-content:space-between}
.uh-library-toast-action{border:1px solid currentColor;border-radius:8px;background:#fffdf6;color:var(--admin-sage-dark,#4f6244);padding:.38rem .62rem;font:inherit;font-weight:850;cursor:pointer}
.uh-library-toast-action:focus-visible{outline:3px solid rgba(255,255,255,.55);outline-offset:2px}
@media (max-width:1180px){
  .uh-library-block-toolbar{grid-template-columns:1fr;top:4.9rem}
  .uh-library-block-toolbar>div:first-child{grid-row:auto}
  .uh-library-block-tools,.uh-library-block-add{justify-content:flex-start}
  .uh-library-block-item{scroll-margin-top:13.5rem}
}
@media (max-width:640px){
  .uh-library-block-tools,.uh-library-block-add{display:grid;grid-template-columns:1fr 1fr;width:100%}
  .uh-library-block-tools select,.uh-library-block-add select{grid-column:1 / -1;max-width:none;min-width:0;width:100%}
  .uh-library-block-tools button,.uh-library-block-add button{width:100%}
  .uh-library-block-head{grid-template-columns:minmax(0,1fr) 48px}
  .uh-library-block-toggle small{display:none}
  .uh-library-block-toggle{justify-content:center;padding:.5rem}
  .uh-library-block-drag-handle{padding:.58rem}
  .uh-library-block-item{scroll-margin-top:16rem}
}

/* Milestone 4: shared link and icon pickers */
.uh-library-link-picker,
.uh-library-icon-picker {
  display: grid;
  gap: .65rem;
  min-width: 0;
  padding: .8rem;
  border: 1px solid var(--admin-border-soft, #e6dabd);
  border-radius: var(--admin-radius-card, 12px);
  background: var(--admin-surface-strong, #fffdf6);
}
.uh-library-field-label { font-weight: 800; color: var(--admin-heading, #2c271f); }
.uh-library-picker-mode { display: flex; flex-wrap: wrap; gap: .5rem; }
.uh-library-link-picker label,
.uh-library-icon-picker label { display: grid; gap: .35rem; min-width: 0; }
.uh-library-link-picker select,
.uh-library-icon-picker select { width: 100%; }
.uh-library-link-health,
.uh-library-icon-choice-preview {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0;
  padding: .55rem .65rem;
  border-radius: var(--admin-radius-input, 7px);
  background: var(--admin-surface-soft, #f5ecd6);
}
.uh-library-link-health code,
.uh-library-icon-choice-preview code { overflow-wrap: anywhere; }
.uh-library-link-status {
  flex: 0 0 auto;
  border: 1px solid var(--admin-border-soft, #e6dabd);
  border-radius: var(--admin-radius-pill, 999px);
  padding: .22rem .52rem;
  font-size: .74rem;
  font-weight: 800;
  background: var(--admin-surface, #fff9ea);
}
.uh-library-link-status.is-available,
.uh-library-link-status.is-public { background: var(--admin-sage-pale, #eef3e7); color: var(--admin-success, #506e42); }
.uh-library-link-status.is-draft,
.uh-library-link-status.is-unchecked { background: var(--admin-gold-soft, #efe1bd); color: var(--admin-warning, #8a6333); }
.uh-library-link-status.is-archived,
.uh-library-link-status.is-invalid,
.uh-library-link-status.is-missing { background: var(--admin-danger-soft, #f0d8d0); color: var(--admin-danger, #8e3f32); }
.uh-library-icon-choice-preview img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: #fcf7e7; }
.uh-library-icon-choice-preview span { min-width: 0; overflow-wrap: anywhere; }
.uh-library-block-controls > .uh-library-icon-picker { grid-column: 1 / -1; }
@media (max-width: 620px) {
  .uh-library-picker-mode > .uh-library-btn { flex: 1 1 9rem; }
  .uh-library-link-health,
  .uh-library-icon-choice-preview { align-items: flex-start; flex-direction: column; }
}

/* Milestone 5 — database-backed Icon Library */
.uh-library-icon-manager{display:grid;gap:1rem}
.uh-library-icon-manager-tools{display:grid;grid-template-columns:minmax(0,1fr) 220px;gap:.8rem}
.uh-library-icon-manager-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.8rem;padding:1rem;border:1px solid var(--admin-border);border-radius:var(--admin-radius-card);background:var(--admin-surface-strong)}
.uh-library-icon-manager-actions{grid-column:1/-1;display:flex;gap:.6rem;flex-wrap:wrap}
.uh-library-icon-table{min-width:760px}
.uh-library-icon-manager-thumb{width:52px;height:52px;object-fit:contain;border-radius:10px;background:var(--admin-bg);border:1px solid var(--admin-border-soft);padding:5px}
.uh-library-icon-choice-preview{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap}
.uh-library-icon-choice-preview [data-icon-favorite]{margin-left:auto}
@media(max-width:768px){.uh-library-icon-manager-tools,.uh-library-icon-manager-form{grid-template-columns:1fr}.uh-library-icon-manager-actions{grid-column:auto}}

/* Milestone 6: validation and publication review */
.uh-library-block-validation{display:inline-flex;align-items:center;width:max-content;margin-top:.3rem;padding:.18rem .48rem;border:1px solid var(--admin-border-soft);border-radius:var(--admin-radius-pill);font-size:.72rem;font-style:normal;font-weight:800;line-height:1.2;background:var(--admin-sage-pale);color:var(--admin-success)}
.uh-library-block-validation.is-warning{background:var(--admin-gold-soft);color:var(--admin-warning);border-color:rgba(185,147,66,.35)}
.uh-library-block-validation.is-error{background:var(--admin-danger-soft);color:var(--admin-danger);border-color:rgba(142,63,50,.32)}
.uh-library-block-item.has-validation-error{border-color:rgba(142,63,50,.5)}
.uh-library-block-item.has-validation-warning:not(.has-validation-error){border-color:rgba(185,147,66,.48)}
.uh-library-publication-overlay{position:fixed;inset:0;z-index:1600;display:grid;place-items:center;padding:1.25rem;background:rgba(43,37,29,.5)}
.uh-library-publication-overlay[hidden]{display:none}
.uh-library-publication-dialog{position:relative;width:min(760px,calc(100vw - 2rem));max-height:min(82vh,820px);overflow:auto;background:var(--admin-surface);border:1px solid var(--admin-border);box-shadow:var(--admin-shadow-panel)}
.uh-library-publication-close{position:absolute;top:.75rem;right:.75rem;width:40px;min-width:40px;padding:0;font-size:1.35rem}
.uh-library-publication-dialog h2{margin:.2rem 3rem 1rem 0}
.uh-library-publication-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;margin:1rem 0 1.25rem}
.uh-library-publication-summary>div{display:grid;gap:.12rem;padding:.85rem;border:1px solid var(--admin-border-soft);border-radius:var(--admin-radius-card);background:var(--admin-surface-strong)}
.uh-library-publication-summary strong{font-family:var(--admin-font-heading);font-size:1.55rem;color:var(--admin-heading)}
.uh-library-publication-summary span{font-size:.78rem;color:var(--admin-text-muted)}
.uh-library-publication-issues{display:grid;gap:.6rem}
.uh-library-publication-issue{display:grid;gap:.2rem;width:100%;padding:.8rem .9rem;text-align:left;border:1px solid var(--admin-border-soft);border-radius:var(--admin-radius-button);background:var(--admin-surface-strong);color:var(--admin-text);cursor:pointer}
.uh-library-publication-issue.is-error{border-left:4px solid var(--admin-danger)}
.uh-library-publication-issue.is-warning{border-left:4px solid var(--admin-gold)}
.uh-library-publication-issue small{color:var(--admin-text-muted)}
.uh-library-publication-clear{padding:1rem;border:1px solid rgba(80,110,66,.3);border-radius:var(--admin-radius-card);background:var(--admin-sage-pale)}
.uh-library-publication-clear p{margin:.35rem 0 0}
.uh-library-publication-actions{position:sticky;bottom:-1px;display:flex;justify-content:flex-end;gap:.65rem;margin:1.25rem -.1rem -.1rem;padding:1rem .1rem .1rem;background:linear-gradient(to bottom,rgba(255,249,234,0),var(--admin-surface) 28%)}
@media(max-width:768px){.uh-library-publication-overlay{padding:0}.uh-library-publication-dialog{width:100vw;max-width:none;height:100dvh;max-height:none;border-radius:0;padding:1rem}.uh-library-publication-summary{grid-template-columns:1fr}.uh-library-publication-actions{flex-direction:column-reverse}.uh-library-publication-actions .admin-btn{width:100%}}

/* Library block templates */
.uh-library-template-tools{display:grid;grid-template-columns:minmax(240px,1fr) minmax(160px,220px);gap:var(--admin-space-4);margin:var(--admin-space-4) 0}
.uh-library-template-table td:first-child strong{display:block;color:var(--admin-heading)}
.uh-library-template-table td:first-child small{display:block;color:var(--admin-text-muted);margin-top:.2rem;max-width:42rem}
.uh-library-template-actions{display:flex;flex-wrap:wrap;gap:.4rem}
.uh-library-template-overlay{position:fixed;inset:0;z-index:1200;background:rgba(44,39,31,.44);display:grid;place-items:center;padding:1rem}
.uh-library-template-overlay[hidden]{display:none}
.uh-library-template-dialog{position:relative;width:min(720px,96vw);max-height:min(88vh,760px);overflow:auto}
.uh-library-template-options{display:grid;gap:.65rem;margin:1rem 0;color:var(--admin-text-soft)}
.uh-library-template-options label{display:flex;gap:.55rem;align-items:flex-start}
@media(max-width:768px){.uh-library-template-tools{grid-template-columns:1fr}.uh-library-template-table{min-width:760px}.uh-library-template-dialog{width:100%;max-height:94vh}}

/* Corrective block-editor parity: compact one-line headings and structured rows. */
.uh-library-block-item{
  border-radius:12px;
  overflow:visible;
}
.uh-library-block-head{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto 42px;
  align-items:center;
  gap:0;
  min-height:58px;
  padding:0;
  border-radius:11px 11px 0 0;
  background:#fffaf0;
  overflow:hidden;
}
.uh-library-block-item.is-collapsed .uh-library-block-head{border-radius:11px}
.uh-library-block-drag-handle{
  display:grid;
  grid-template-columns:18px auto minmax(112px,max-content) minmax(90px,1fr) auto;
  align-items:center;
  gap:.58rem;
  min-width:0;
  min-height:58px;
  padding:.5rem .72rem;
  border-radius:0;
  white-space:nowrap;
  overflow:hidden;
}
.uh-library-block-drag-handle>span:last-child{display:inline-flex;gap:0;min-width:auto}
.uh-library-drag-grip{font-size:1rem;line-height:1;color:var(--admin-text-muted,#877865)}
.uh-library-block-number{font-size:.7rem;font-weight:850;color:var(--admin-text-muted,#877865);letter-spacing:.02em}
.uh-library-block-type{min-width:0;font-family:var(--admin-font-heading,Georgia,serif);font-size:.94rem;line-height:1.1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.uh-library-block-title{min-width:0;max-width:none!important;font-style:normal;font-size:.79rem;font-weight:700;color:var(--admin-text-soft,#675b4a);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.uh-library-block-meta{padding:0 .7rem;color:var(--admin-text-muted,#877865);font-size:.72rem;font-weight:800;white-space:nowrap}
.uh-library-block-toggle{display:grid;place-items:center;min-width:42px;min-height:58px;padding:0;border-left:1px solid var(--admin-border-soft,#e6dabd);border-radius:0;font-size:1rem}
.uh-library-block-toggle span{font-size:1rem}
.uh-library-block-validation{padding:.2rem .46rem;font-size:.68rem;line-height:1;border-radius:8px;white-space:nowrap}
.uh-library-block-body{border-radius:0 0 11px 11px}
.uh-library-block-placeholder{
  display:grid;
  place-items:center;
  margin:.18rem 0;
  border:2px dashed var(--admin-sage,#667b58);
  border-radius:12px;
  background:rgba(222,230,208,.58);
  color:var(--admin-sage-dark,#4f6244);
  font-size:.78rem;
  font-weight:900;
  letter-spacing:.02em;
  box-shadow:inset 0 0 0 3px rgba(255,253,246,.75);
}
.uh-library-block-drag-ghost{
  position:fixed;
  z-index:9999;
  width:min(520px,calc(100vw - 28px));
  height:58px;
  overflow:hidden;
  pointer-events:none;
  border:1px solid var(--admin-sage,#667b58);
  border-radius:11px;
  background:#fff9ea;
  box-shadow:0 18px 42px rgba(61,49,31,.22);
  opacity:.96;
}
.uh-library-block-drag-ghost .uh-library-block-toggle,.uh-library-block-drag-ghost .uh-library-block-meta{display:none}
.uh-library-block-item.is-dragging{opacity:.28;transform:none;box-shadow:none}
.uh-library-block-item.is-just-moved{animation:uhLibraryMoved 850ms ease}
@keyframes uhLibraryMoved{0%{box-shadow:0 0 0 5px rgba(102,123,88,.32);transform:translateY(-2px)}100%{box-shadow:none;transform:none}}

.uh-library-repeater{
  grid-column:1/-1;
  display:grid;
  gap:.65rem;
  padding:.7rem;
  border:1px solid var(--admin-border-soft,#e6dabd);
  border-radius:12px;
  background:#fffaf0;
}
.uh-library-repeater-head,.uh-library-entry-add{display:flex;justify-content:space-between;align-items:end;gap:.65rem;flex-wrap:wrap}
.uh-library-repeater-head>div{display:flex;gap:.45rem;align-items:center}
.uh-library-repeater-head>div>span{font-size:.68rem;font-weight:850;color:var(--admin-clay,#a96f4f);text-transform:uppercase;letter-spacing:.06em}
.uh-library-repeater-rows,[data-selected-entries]{display:grid;gap:.65rem}
.uh-library-repeater-row{
  position:relative;
  display:grid;
  gap:.55rem;
  padding:.65rem;
  border:1px solid var(--admin-border,#d8c8a8);
  border-radius:10px;
  background:#fffdf6;
  transition:opacity .14s ease,box-shadow .14s ease,border-color .14s ease,transform .14s ease;
}
.uh-library-repeater-row>header{display:flex;gap:.48rem;align-items:center;color:var(--admin-text-soft,#675b4a)}
.uh-library-row-number{display:inline-grid;place-items:center;min-width:24px;height:24px;border-radius:8px;background:var(--admin-sage-soft,#dee6d0);font-size:.72rem;font-weight:900}
.uh-library-repeater-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.55rem;align-items:start}
.uh-library-repeater-fields .field-wide,.uh-library-row-image{grid-column:1/-1}
.uh-library-repeater-fields .uh-library-icon-picker{grid-column:auto}
.uh-library-row-actions{display:flex;gap:.38rem;align-items:center;justify-content:flex-end;flex-wrap:wrap}
.uh-library-row-actions button,.uh-library-selected-entry button{min-height:34px;padding:.34rem .55rem;border:1px solid var(--admin-border,#d8c8a8);border-radius:8px;background:#fff9ea;color:var(--admin-text,#342d24);font-weight:800;cursor:pointer}
.uh-library-row-actions button.danger,.uh-library-selected-entry button.danger{color:var(--admin-danger,#8e3f32)}
.uh-library-row-drag{margin-right:auto;cursor:grab!important;letter-spacing:-.15em}
.uh-library-row-drag:active{cursor:grabbing!important}
.uh-library-row-errors{display:grid;gap:.2rem;color:var(--admin-danger,#8e3f32);font-size:.75rem;font-weight:750}
.uh-library-repeater-row.has-row-errors{border-color:rgba(142,63,50,.48)}
.uh-library-repeater-row.is-row-dragging{opacity:.35}
.uh-library-repeater-row.is-row-drop-before::before,.uh-library-repeater-row.is-row-drop-after::after{content:"Drop row here";position:absolute;left:.35rem;right:.35rem;height:4px;border-radius:999px;background:var(--admin-sage,#667b58);color:transparent;z-index:2}
.uh-library-repeater-row.is-row-drop-before::before{top:-7px}.uh-library-repeater-row.is-row-drop-after::after{bottom:-7px}
.uh-library-selected-entry{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:.6rem;align-items:center;padding:.58rem;border:1px solid var(--admin-border,#d8c8a8);border-radius:10px;background:#fffdf6}
.uh-library-selected-entry>span{font-size:.72rem;font-weight:900}.uh-library-selected-entry small{display:block;color:var(--admin-text-muted,#877865)}.uh-library-selected-entry>div:last-child{display:flex;gap:.35rem;flex-wrap:wrap}
.uh-library-entry-add label{flex:1 1 220px}.uh-library-entry-add button{flex:0 0 auto}
.uh-library-row-image .uh-library-block-image-preview{max-width:220px}

@media (max-width:900px){
  .uh-library-block-drag-handle{grid-template-columns:18px auto minmax(96px,max-content) minmax(70px,1fr) auto;gap:.4rem;padding:.45rem .55rem}
  .uh-library-block-head .uh-library-block-meta{display:none}
  .uh-library-block-head{grid-template-columns:minmax(0,1fr) 42px}
  .uh-library-repeater-fields{grid-template-columns:1fr}
  .uh-library-repeater-fields .field-wide,.uh-library-row-image,.uh-library-repeater-fields .uh-library-icon-picker{grid-column:1}
}
@media (max-width:560px){
  .uh-library-block-drag-handle{grid-template-columns:18px minmax(92px,max-content) minmax(64px,1fr) auto;min-height:54px;padding:.4rem .48rem}
  .uh-library-block-number{display:none}
  .uh-library-block-type{font-size:.86rem}
  .uh-library-block-title{font-size:.74rem}
  .uh-library-block-toggle{min-height:54px}
  .uh-library-selected-entry{grid-template-columns:auto minmax(0,1fr)}
  .uh-library-selected-entry>div:last-child{grid-column:1/-1;justify-content:flex-end}
}

/* Keep the block drop destination readable even when the drag ghost overlaps the list. */
.uh-library-block-placeholder{
  position:relative;
  place-items:stretch;
  min-height:58px;
}
.uh-library-block-placeholder::before{
  content:"";
  position:absolute;
  left:.45rem;
  right:.45rem;
  top:50%;
  height:3px;
  border-radius:999px;
  background:var(--admin-sage,#667b58);
  transform:translateY(-50%);
  box-shadow:0 0 0 3px rgba(255,253,246,.82);
}
.uh-library-block-placeholder>span{
  position:absolute;
  z-index:2;
  top:50%;
  right:.7rem;
  transform:translateY(-50%);
  padding:.38rem .62rem;
  border-radius:8px;
  background:var(--admin-sage-dark,#4f6244);
  color:#fffdf4;
  box-shadow:0 6px 14px rgba(61,49,31,.16);
  white-space:nowrap;
}
@media(max-width:560px){
  .uh-library-block-placeholder>span{right:.4rem;padding:.32rem .48rem;font-size:.7rem}
}
