:root {
  --library-bg: #f5f7fb;
  --library-card: #ffffff;
  --library-border: #d8dfec;
  --library-text: #1f2937;
  --library-muted: #667085;
  --library-accent: #1d4ed8;
  --library-accent-soft: #dbeafe;
  --library-success: #166534;
  --library-error: #b91c1c;
  --line: #d5d9e0ad;
  --beamlab-primary: #282c3b;
}

body {
  overflow: unset;
}

main {
  overflow: unset;
  height: unset;
}
.property-accordion summary {
  background: var(--beamlab-primary);
  color: #fff;
}
.property-accordion[open] summary {
  background: var(--beamlab-primary);
  color: #fff;
}
.library-page-shell {
  display: grid;
  grid-template-columns: minmax(440px, 1.2fr) minmax(380px, 1fr);
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 76px);
  box-sizing: border-box;
  height: calc(100vh - 76px); 
}

.library-panel {
  background: var(--library-card);
  border: 1px solid var(--library-border);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.08);
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;                /* indispensable pour le scroll interne en grid */
  overflow-y: auto;             /* chaque panneau a son propre scroll */
  overscroll-behavior: contain; /* le scroll ne "fuit" pas vers la page */
  display: block;               /* évite que flex écrase les enfants */
}
/* Plus besoin de scroll imbriqué */
.library-content-view {
  overflow: visible;
}

.library-properties-panel {
  overflow: visible;
}
.library-panel-header h1 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--library-text);
}

.library-panel-header p {
  margin: 8px 0 0;
  color: var(--library-muted);
  font-size: 0.92rem;
}

.library-top-controls {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.library-view-switch {
  display: inline-flex;
  border: 1px solid var(--library-border);
  border-radius: 10px;
  overflow: hidden;
  width: fit-content;
}

.library-switch-btn {
  border: 0;
  background: #fff;
  color: var(--library-text);
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}

.library-switch-btn.active {
  background: var(--library-accent);
  color: #fff;
}

#library-search-input {
  border: 1px solid var(--library-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

#library-search-input:disabled {
  background: #f3f4f6;
  color: #9ca3af;
}

.library-content-view {
  margin-top: 12px;
  min-height: 0;
  overflow: auto;
}

.catalog-groups {
  display: grid;
  gap: 10px;
}

.catalog-type-accordion {
  border: 1px solid var(--library-border);
  border-radius: 10px;
  background: #fff;
}

.catalog-type-accordion > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
  font-weight: 700;
  /* color: #fff;
  background: var(--beamlab-primary); */
  border-bottom: 1px solid transparent;
  border-radius: 10px;
}

.catalog-type-accordion[open] > summary {
  border-bottom-color: var(--library-border);
}

.catalog-type-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.catalog-type-table th,
.catalog-type-table td {
  border-bottom: 1px solid #edf2f7;
  padding: 7px 8px;
  text-align: left;
  white-space: nowrap;
}

.catalog-type-table th {
  color: #475467;
  font-weight: 700;
  background: #fcfdff;
  position: sticky;
  top: 0;
}

.catalog-row {
  cursor: pointer;
}

.catalog-row:hover {
  background: #f1f6ff;
}

.catalog-row.selected {
  background: var(--library-accent-soft);
  outline: 1px solid #93c5fd;
}

.custom-type-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.custom-type-btn {
  border: 1px solid var(--library-border);
  border-radius: 12px;
  background: #fff;
  color: var(--library-text);
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-grow: 1;
}

.custom-type-btn.active {
  background: var(--library-accent-soft);
  border-color: #93c5fd;
  color: #1e3a8a;
}

.custom-type-btn-image {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: 0 0 auto;
}

.custom-type-btn-label {
  display: inline-block;
}

.custom-section-form {
  margin-top: 14px;
}

.custom-section-form h3 {
  margin: 0 0 10px;
}

.custom-hint {
  margin: 0 0 10px;
  color: #475467;
  font-size: 0.88rem;
}

.custom-fields-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  
}

.custom-input-label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--library-text);

}

.custom-input-label input {
  border: 1px solid var(--library-border);
  border-radius: 8px;
  padding: 8px 10px;
}

.custom-input-label.is-mandatory span::after {
  content: " *";
  color: #b42318;
}

.custom-form-state {
  margin: 12px 0 0;
  color: var(--library-muted);
  font-size: 0.88rem;
}

.library-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.library-preview-header h2 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--library-text);
}

.library-feedback {
  margin: 8px 0 0;
  min-height: 1.2em;
  font-size: 0.88rem;
  color: var(--library-muted);
}

.library-feedback.is-success {
  color: var(--library-success);
}

.library-feedback.is-error {
  color: var(--library-error);
}

.library-feedback.is-info {
  color: var(--library-muted);
}

.library-preview-canvas-wrap {
  margin-top: 12px;
  border: 1px dashed #b8c3d9;
  border-radius: 12px;
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 16px 16px;
  height: 420px;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-sizing: border-box;
}

#library-preview-canvas {
  background: transparent;   /* indispensable, sinon le canvas blanc masque les points */
  display: block;
}

.library-properties-panel {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  overflow: auto;
}

.library-props-table {
  width: 100%;
  border-collapse: collapse;
}

.library-props-table th,
.library-props-table td {
  border-bottom: 1px solid #edf2f7;
  padding: 8px 4px;
  text-align: left;
  font-size: 0.9rem;
}

.library-props-table th {
  color: #475467;
  width: 45%;
}

.library-props-table .prop-label {
  display: block;
  color: #334155;
  font-weight: 700;
}

.library-props-table .prop-subtitle {
  display: block;
  margin-top: 2px;
  color: #64748b;
  font-weight: 400;
  font-size: 0.78rem;
  line-height: 1.25;
}

.library-props-table td {
  color: #101828;
}

.library-props-table .unit {
  color: #667085;
  margin-left: 4px;
  font-size: 0.8rem;
}

.library-empty-state {
  color: var(--library-muted);
  margin: 8px 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .library-page-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .library-preview-canvas-wrap {
    height: 320px;
    min-height: 320px;
  }
}
