/* Builder Pattern Library filtering and empty-state layout. */
.pattern-library-list {
  display: grid;
  gap: 0.35rem;
  max-height: 460px;
  overflow: auto;
  padding-right: 0.1rem;
}

.pattern-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.pattern-filter-chip {
  min-height: 1.75rem;
  padding: 0.12rem 0.56rem;
  border-radius: 999px;
  border-color: rgba(148, 163, 184, 0.68);
  background: rgba(255, 255, 255, 0.72);
  color: #334155;
  font-size: 0.74rem;
  font-weight: 800;
}

.pattern-filter-chip:hover {
  border-color: rgba(37, 99, 235, 0.46);
  background: #eff6ff;
}

.pattern-filter-chip.active {
  color: #fff;
  border-color: var(--bingo-blue);
  background: linear-gradient(135deg, var(--bingo-blue), #1d4ed8);
}

.pattern-library-empty {
  display: grid;
  gap: 0.45rem;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(248, 250, 252, 0.7);
  color: var(--muted);
}

.pattern-library-empty strong {
  color: #111827;
  font-size: 0.86rem;
}

.pattern-library-empty span {
  line-height: 1.35;
}

.pattern-library-empty-actions {
  display: flex;
  justify-content: flex-start;
}

.pattern-library-empty-actions button {
  min-height: 1.9rem;
  padding-inline: 0.7rem;
  font-size: 0.78rem;
  font-weight: 850;
}

.pattern-library-card {
  width: 100%;
  border: 1px solid #c8cfda;
  border-left: 4px solid var(--pattern-accent, #c8cfda);
  border-radius: 10px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--pattern-accent, #94a3b8) 10%, #fff), #fff 34%);
  padding: 0.42rem 0.62rem 0.42rem 0.48rem;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 0.55rem;
  align-items: center;
  text-align: left;
  min-height: 76px;
  overflow: visible;
}

.pattern-library-card:hover {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--pattern-accent, #94a3b8) 16%, #fff), #fff 38%);
  border-color: color-mix(in srgb, var(--pattern-accent, #94a3b8) 65%, #94a3b8);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.pattern-library-card.selected {
  border-color: var(--bingo-blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22), 0 5px 14px rgba(37, 99, 235, 0.1);
  background: linear-gradient(90deg, #dbeafe, #fff);
}

.pattern-library-card-body {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto;
  gap: 0.35rem;
  align-content: stretch;
  min-height: 100%;
}

.pattern-library-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  min-height: 1.45rem;
  padding-right: 0.08rem;
}

.pattern-library-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  min-height: 1.55rem;
}

.pattern-library-card-name {
  font-weight: 700;
  color: #111827;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}

.pattern-library-card-category {
  color: #475569;
  font-size: 0.74rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.pattern-library-card-category::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: var(--pattern-accent, #94a3b8);
  flex: 0 0 auto;
}

.pattern-library-card-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 1.6rem;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
}

.pattern-library-card-status.on-sheet {
  color: #065f46;
  background: linear-gradient(135deg, #ecfdf3, #d1fae5);
  border-color: rgba(5, 150, 105, 0.45);
}

.pattern-library-card-status.library-only {
  color: #1d4ed8;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-color: rgba(37, 99, 235, 0.38);
}

.pattern-library-card-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.22rem;
  flex-wrap: wrap;
  min-height: 1.55rem;
}

.pattern-card-action {
  min-height: 28px;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1;
  border-color: #c3ccd8;
  background: #fff;
}

.pattern-card-action:hover {
  background: #eef3f8;
}

.pattern-card-action.primary {
  background: linear-gradient(135deg, var(--bingo-blue), #1d4ed8);
  border-color: #1d4ed8;
  color: #fff;
}

.pattern-card-action.primary:hover {
  background: linear-gradient(135deg, #3b82f6, var(--bingo-blue));
}

.pattern-library-card .grid-preview {
  width: 30px;
  gap: 1px;
  align-self: center;
  justify-self: center;
}

.pattern-library-card .mini-cell {
  border-width: 0;
  min-width: 0;
  min-height: 0;
}

.pattern-library-card .mini-cell.free-center::after {
  content: none;
}

.pattern-library-card .grid-preview.mini-silhouette {
  background: transparent;
}

.pattern-library-card .grid-preview.mini-silhouette .mini-cell {
  background: transparent;
}

.pattern-library-card .grid-preview.mini-silhouette .mini-cell.filled,
.pattern-library-card .grid-preview.mini-silhouette .mini-cell.marked {
  background: #111;
}

.pattern-library-card .grid-preview.mini-silhouette .mini-cell.marked::before {
  display: none;
}

/* Builder live pattern editor and shared grid-cell visuals. */
.grid-preview,
.pattern-block-grid,
.editor-cell {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
}

.grid-preview {
  width: 78px;
}

.grid-label {
  aspect-ratio: auto;
  text-align: center;
  font-size: calc(var(--sheet-grid-label-size) * var(--sheet-pattern-scale));
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: 0.035em;
  color: #fff;
  background: #6a6a6a;
  min-height: calc(0.54rem * var(--sheet-pattern-scale));
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-cell,
.pattern-block-grid .cell,
.editor-cell {
  aspect-ratio: 1 / 1;
  border: var(--sheet-grid-line-width, 1px) solid #6f7782;
  background: #fff;
  position: relative;
  min-height: 0;
  min-width: 0;
  padding: 0;
  width: 100%;
  height: auto;
}

.mini-cell.filled,
.pattern-block-grid .cell.filled,
.editor-cell.filled {
  background: #000;
}

.mini-cell.marked::before,
.pattern-block-grid .cell.marked::before,
.editor-cell.marked::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(0.22rem * var(--sheet-pattern-scale, 1));
  height: calc(0.22rem * var(--sheet-pattern-scale, 1));
  border-radius: 50%;
  background: #111;
  z-index: 1;
}

.editor-cell.marked::before {
  width: 0.42rem;
  height: 0.42rem;
}

.mini-cell.free-center::after,
.pattern-block-grid .cell.free-center::after,
.editor-cell.free-center::after {
  content: "FREE";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -54%) scaleY(1.18);
  color: #7f8794;
  font-size: calc(0.34rem * var(--sheet-pattern-scale, 1));
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.15;
  white-space: nowrap;
  z-index: 1;
  text-transform: uppercase;
  pointer-events: none;
}

.editor-cell.free-center::after {
  font-size: 0.72rem;
  color: #7f8794;
}

.mini-cell.free-center.filled::after,
.pattern-block-grid .cell.free-center.filled::after,
.editor-cell.free-center.filled::after {
  color: #f4f6f8;
}

.editor-grid {
  margin: 0.45rem auto 0;
  display: grid;
  width: 260px;
  max-width: 100%;
  gap: 2px;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  aspect-ratio: 1 / 1;
}

body.dark-mode .editor-grid {
  background: rgba(148, 163, 184, 0.28);
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 9px;
  padding: 3px;
}

body.dark-mode .editor-cell {
  background: #f8fafc;
  border-color: #64748b;
  box-shadow: none;
}

body.dark-mode .editor-cell:hover {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.24);
}

body.dark-mode .editor-cell.filled {
  background: #020617;
}

body.dark-mode .editor-cell.marked::before {
  background: #020617;
}

body.dark-mode .editor-cell.free-center::after {
  color: #64748b;
}

body.dark-mode .editor-cell.free-center.filled::after {
  color: #e5e7eb;
}

.editor-grid.hidden {
  display: none;
}
