

.weave-library-fields input, .weave-library-fields select { min-height: 40px; min-width: 0; width: 100%; border: 1px solid #d7e0cf; border-radius: 6px; padding: 9px 11px; color: var(--ink); background: #fff; font-size: 12px; }
.weave-library-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 12px; }
.weave-library-legend > span { display: flex; align-items: center; gap: 7px; }
.weave-library-legend i { display: inline-block; width: 13px; height: 13px; background: #fff; border: 1px solid #7b8974; }
.weave-library-legend i.is-up { background: #c3262e; border-color: #c3262e; }

.weave-library-link { border: 0; padding: 4px 0; background: transparent; color: var(--primary); font-size: 11px; font-weight: 600; text-decoration: underline; text-decoration-color: #bbcabb; text-underline-offset: 3px; }
.weave-library-link:hover { text-decoration-color: currentColor; }
.weave-library-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 20px; }
.weave-library-card { min-width: 0; overflow: hidden; border: 1px solid #dfe6da; border-radius: 10px; background: #fff; }
.weave-library-card-tile { display: flex; justify-content: center; align-items: center; height: 172px; padding: 24px; border-bottom: 1px solid #e5eadd; background: #f0f3e9; }
.weave-library-card-tile canvas { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; image-rendering: pixelated; box-shadow: 0 0 0 1px #c5cebe; }
.weave-library-card-body { padding: 17px 17px 0; }
.weave-library-card h2 { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.65; overflow-wrap: anywhere; }
.weave-library-card-actions { display: flex; flex-wrap: wrap; gap: 7px 18px; border-top: 1px solid #edf0e8; padding: 12px 0; }
.weave-library-card-action { padding: 5px 0; border: none; background: none; color: var(--primary); font-size: 11px; font-weight: 600; }
.weave-library-card-action:hover { text-decoration: underline; text-underline-offset: 3px; }
.weave-library-card-action.is-delete { color: #986150; margin-left: auto; }
.weave-library-empty { min-height: 290px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 35px 20px; border: 1px solid var(--line); border-radius: 12px; background: #fff; text-align: center; }
.weave-library-empty h2 { font-size: 23px; font-weight: 550; line-height: 1.4; letter-spacing: -.5px; margin: 0; }
.weave-library-empty p { max-width: 340px; margin: 11px 0 23px; font-size: 12px; line-height: 1.8; color: var(--muted); }
.weave-library-editor { width: min(950px, calc(100% - 40px)); max-width: none; max-height: calc(100dvh - 40px); margin: auto; padding: 25px; overflow: auto; border: 1px solid #d9e3d2; border-radius: 13px; color: var(--ink); background: #fdfefb; box-shadow: 0 24px 85px #17342630; }
.weave-library-editor::backdrop, .weave-library-confirm::backdrop { background: #1c302966; backdrop-filter: blur(3px); }
.weave-library-editor form { min-width: 0; }
.weave-library-editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.weave-library-editor-heading .eyebrow { font-size: 9px; margin-bottom: 7px; }
.weave-library-editor h2 { margin: 0; font-size: 25px; line-height: 1.2; letter-spacing: -.65px; font-weight: 600; }
.weave-library-editor-heading .icon-button { font-size: 24px; line-height: 18px; }
.weave-library-fields { display: grid; grid-template-columns: minmax(140px, 1fr) 150px 118px 118px auto; align-items: end; gap: 14px; }
.weave-library-fields > label { display: flex; flex-direction: column; gap: 7px; min-width: 0; font-size: 11px; font-weight: 600; color: #536c4c; }
.weave-library-fields .button { min-height: 40px; padding-block: 10px; }
.weave-library-help { margin: 9px 0 0; color: #6a7a63; font-size: 11px; line-height: 1.75; overflow-wrap: anywhere; }
#weave-library-editor-error { margin: 15px 0 0; }
.weave-library-conflict { padding: 12px 14px; background: #fffbef; border: 1px solid #e7dab7; border-radius: 8px; margin-top: 15px; }
.weave-library-conflict p { margin: 0 0 10px; font-size: 11px; line-height: 1.75; color: #775e2c; }
.weave-library-editing-area { display: grid; grid-template-columns: minmax(0, 1fr) 225px; gap: 25px; margin-top: 22px; }
.weave-library-matrix-panel, .weave-library-repeat-panel { min-width: 0; }
.weave-library-editor h3 { margin: 0; font-size: 12px; font-weight: 600; line-height: 1.6; }
.weave-library-matrix-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.weave-library-matrix-heading > div { display: flex; gap: 17px; }
.weave-library-grid-scroll { max-width: 100%; max-height: 390px; overflow: auto; overscroll-behavior: contain; margin-top: 11px; padding: 7px; border: 1px solid #c4d0bb; border-radius: 7px; background: #e9eee2; }
.weave-library-grid { display: grid; grid-template-columns: repeat(var(--weave-columns), 25px); width: max-content; max-width: none; gap: 1px; background: #c0cabb; border: 1px solid #c0cabb; }
.weave-library-grid-row { display: contents; }
.weave-library-cell { width: 25px; height: 25px; border: 0; border-radius: 0; padding: 0; background: #fff; }
.weave-library-cell.is-up { background: #c3262e; }
.weave-library-cell:hover { box-shadow: inset 0 0 0 2px #719b73; }
.weave-library-cell:focus-visible { outline: 3px solid #dd9b27; outline-offset: -3px; position: relative; z-index: 1; }
.weave-library-repeat-frame { display: grid; place-items: center; min-height: 190px; margin-top: 12px; padding: 14px; background: #f0f3e9; border: 1px solid #dce4d5; border-radius: 7px; }
.weave-library-repeat-frame canvas { display: block; max-width: 100%; max-height: 225px; width: auto; height: auto; image-rendering: pixelated; box-shadow: 0 0 0 1px #c5cebe; }
.weave-library-editor-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); padding-top: 18px; margin-top: 23px; }
.weave-library-editor-actions > div { display: flex; gap: 9px; }
.weave-library-editor-actions > p { margin: 0; color: #7b7355; font-size: 11px; line-height: 1.6; }
.weave-library-confirm { width: min(440px, calc(100% - 32px)); padding: 26px; border: 1px solid #dbe4d4; border-radius: 12px; color: var(--ink); background: #fff; box-shadow: 0 22px 80px #183a3429; }
.weave-library-confirm h2 { margin: 0; font-size: 21px; line-height: 1.45; font-weight: 600; letter-spacing: -.5px; overflow-wrap: anywhere; }
.weave-library-confirm > p { margin: 14px 0 0; font-size: 12px; line-height: 1.8; color: var(--muted); }
.weave-library-confirm > p.form-error { color: #9b463f; }
.weave-library-confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.weave-library-danger { background: #a05140; border-color: #a05140; color: #fff; }
.weave-library-danger:hover { background: #874335; border-color: #874335; }

@media (max-width: 700px) {
  
  
  
  .weave-library-legend { padding-bottom: 0; }
  .weave-library-editor { padding: 20px; width: calc(100% - 24px); max-height: calc(100dvh - 24px); }
  .weave-library-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 13px 10px; }
  .weave-library-name-field, .weave-library-fields > label[for="weave-library-use"] { grid-column: 1 / -1; }
  .weave-library-editing-area { grid-template-columns: minmax(0, 1fr); gap: 21px; }
  .weave-library-repeat-panel { display: grid; grid-template-columns: minmax(0, 155px) minmax(0, 1fr); gap: 9px 15px; align-items: center; }
  .weave-library-repeat-panel h3 { grid-column: 1 / -1; }
  .weave-library-repeat-frame { margin: 0; min-height: 125px; padding: 12px; }
  .weave-library-repeat-panel .weave-library-help { margin: 0; }
  .weave-library-grid-scroll { max-height: 330px; }
}
@media (max-width: 400px) {
  
  
  
  
  
  .weave-library-editor { padding: 15px; }
  .weave-library-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .weave-library-fields .button { grid-column: 1 / -1; width: fit-content; }
  .weave-library-editor-actions { flex-direction: column; align-items: stretch; gap: 10px; }
  .weave-library-editor-actions > div { justify-content: flex-end; }
  .weave-library-repeat-panel { grid-template-columns: minmax(0, 115px) minmax(0, 1fr); }
  .weave-library-repeat-frame { min-height: 105px; padding: 8px; }
  .weave-library-confirm { padding: 21px; }
}
.weave-library-card { display: flex; flex-direction: column; }
.weave-library-card-body { flex: 1; display: flex; flex-direction: column; }
.weave-library-card-actions { margin-top: auto; }
#weave-library-reload { margin-left: auto; }
/* Library cards match the project cards: no border, soft shadow, rounder corners. */
.weave-library-card { border: 0; border-radius: 14px; box-shadow: var(--card-shadow); }
.weave-library-card-tile { border-bottom-color: var(--line); background: #f6f7f4; }
/* Card previews fill the whole tile with the repeating weave (red = warp raised). */
.weave-library-card-tile { padding: 0; overflow: hidden; }
.weave-library-card-tile canvas { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; box-shadow: none; }

/* Create with AI, inside the weave editor. */
.weave-library-editor-tools { display: flex; align-items: center; gap: 10px; }
.weave-library-ai-button { display: inline-flex; align-items: center; gap: 6px; }
.weave-library-ai-button svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.weave-library-ai-status { margin-top: 8px; }

/* Compact editor: tighter spacing so the grid and preview get the room. */
.weave-library-editor { width: min(860px, calc(100% - 32px)); padding: 18px 20px; }
.weave-library-editor-heading { align-items: center; margin-bottom: 14px; }
.weave-library-editor h2 { font-size: 19px; letter-spacing: -.4px; }
.weave-library-fields { grid-template-columns: minmax(140px, 1fr) 96px 96px auto; gap: 10px; }
.weave-library-fields > label { gap: 5px; }
.weave-library-fields input, .weave-library-fields .button { min-height: 36px; padding-block: 7px; }
#weave-library-editor-error, .weave-library-conflict { margin-top: 10px; }
.weave-library-editing-area { grid-template-columns: minmax(0, 1fr) 200px; gap: 18px; margin-top: 14px; }
.weave-library-editing-area .weave-library-help { margin-top: 4px; }
.weave-library-grid-scroll { margin-top: 8px; padding: 5px; }
.weave-library-repeat-frame { min-height: 0; margin-top: 8px; padding: 10px; }
.weave-library-editor-actions { padding-top: 12px; margin-top: 14px; }
@media (max-width: 700px) {
  .weave-library-editor { padding: 14px; width: calc(100% - 20px); }
  .weave-library-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .weave-library-editing-area { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}
@media (max-width: 400px) {
  .weave-library-editor-heading { flex-wrap: wrap; gap: 10px; }
  .weave-library-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Compact card footer: name and size on one line, actions below. */
.weave-library-card-heading { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.weave-library-card-heading h2 { flex: 1; min-width: 0; }
.weave-library-card-uses { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.weave-library-card-use { padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 600; color: #536c4c; background: #eef3ea; }
.weave-library-card-use.is-selvedge { color: #6b4f1d; background: #f6eedb; }
.weave-library-card-size { flex: none; color: #64745e; font-size: 11px; font-variant-numeric: tabular-nums; }
.weave-library-card-body { padding: 11px 14px 0; }
.weave-library-card h2 { font-size: 13px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
.weave-library-card-actions { margin-top: 8px; padding: 6px 0 8px; gap: 4px 16px; }
/* Binding problems block saving. */
.weave-library-binding { margin-top: 8px; padding: 8px 12px; border: 1px solid #e6c3bb; border-radius: 7px; background: #fdf3f0; color: #8b3a2e; font-size: 11px; line-height: 1.6; }
.weave-library-binding p { margin: 0; font-weight: 600; }
.weave-library-binding ul { margin: 3px 0 0; padding-left: 17px; }
