.y3d-template-grid__toolbar,
.y3d-archive__filters {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 12px;
	align-items: center;
	margin-bottom: 20px;
}

.y3d-template-grid__toolbar label,
.y3d-archive__filters label {
	display: block;
	margin: 0;
}

.y3d-template-grid__toolbar .y3-select,
.y3d-template-grid__toolbar .y3-input,
.y3d-archive__filters .y3-select,
.y3d-archive__filters .y3-input {
	width: 100%;
}

.y3d-template-grid__search,
.y3d-archive__search {
	position: relative;
}

/*
 * Die Lupe im Suchfeld. Auswahl über `y3-fa`, das zentrale Präfix – und nicht
 * über `.fas`: Diese Klasse gab es hier bis zur Umstellung auf die zentrale
 * Icon-Integration (#64). Danach fand die Regel ihr Icon nicht mehr, die
 * absolute Positionierung griff nicht, und die Lupe stand in einer eigenen
 * Zeile unter dem Feld (#103). Bewusst ohne Schnittklasse: Ob das Icon Solid
 * oder Regular gesetzt wird, ändert nichts daran, wo es zu stehen hat.
 */
.y3d-template-grid__search .y3-fa,
.y3d-archive__search .y3-fa {
	position: absolute;
	top: 50%;
	right: 14px;
	transform: translateY(-50%);
	pointer-events: none;
}

.y3d-template-grid__status {
	margin: 0 0 14px;
	color: var(--y3-color-text-muted, #667085);
	font-size: .9rem;
}

.y3d-template-grid__items,
.y3d-archive__grid {
	align-items: stretch;
}

.y3d-template-grid__item {
	display: flex;
}

.y3d-template-card {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	overflow: hidden;
	padding: 0;
	background: var(--y3-color-surface, #fff);
	border: 1px solid var(--y3-color-border, #e4e7ec);
	border-radius: var(--y3-radius-card, 12px);
	box-shadow: var(--y3-shadow-card, 0 3px 14px rgba(16, 24, 40, .06));
}

/*
 * Die Vorschauflaeche aller Karten.
 *
 * Ihre Hoehe folgt einem festen Seitenverhaeltnis der Kartenbreite, nicht dem
 * jeweiligen Bild. Nur so beginnen Text und Aktionen in allen Karten einer
 * Reihe auf derselben Hoehe - auch bei Karten ohne Vorschaubild, deren
 * Platzhalter viel kleiner ist als ein Bild.
 *
 * Feste Pixelhoehen taeten dasselbe, aber nur in einer Spaltenzahl. Ueber das
 * Verhaeltnis bleibt die Flaeche in jeder responsiven Ansicht stimmig.
 */
.y3d-template-card__preview,
.y3d-user-design-card__preview {
	display: grid;
	box-sizing: border-box;
	/*
	 * Eine einzelne Zeile und Spalte mit `minmax(0, 1fr)`: Damit ist die
	 * Flaeche fuer das Bild in beiden Richtungen bestimmt, und `height: 100%`
	 * am Bild hat einen Bezug. Ohne definierte Zeile bleibt eine
	 * Prozentangabe wirkungslos, und ein hochformatiges Bild waechst aus der
	 * Flaeche heraus.
	 */
	grid-template-rows: minmax(0, 1fr);
	grid-template-columns: minmax(0, 1fr);
	place-items: center;
	aspect-ratio: var(--y3d-card-preview-ratio, 4 / 3);
	overflow: hidden;
	padding: 18px;
	background: linear-gradient(135deg, #f8fafc, #eef2f6);
}

/*
 * Das Bild bleibt vollstaendig sichtbar und unverzerrt.
 *
 * `object-fit: contain` ist hier die eigentliche Absicherung: Selbst wenn ein
 * Theme dem Bild Breite und Hoehe aufzwingt, bleibt das Seitenverhaeltnis
 * erhalten. Die Kartenklasse davor hebt die Spezifitaet gerade so weit, dass
 * uebliche Themeregeln auf `img` nicht gewinnen, ohne globale Stile zu
 * uebersteuern.
 */
.y3d-template-card .y3d-template-card__image,
.y3d-user-design-card .y3d-user-design-card__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	filter: drop-shadow(0 5px 12px rgba(16, 24, 40, .13));
}

.y3d-template-card__placeholder {
	display: grid;
	place-items: center;
	width: 96px;
	height: 96px;
	border: 2px dashed #cbd5e1;
	border-radius: 12px;
	color: #94a3b8;
	font-size: 2rem;
}

.y3d-template-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	padding: 20px;
}

.y3d-template-card__terms {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 10px;
}

.y3d-template-card__terms span {
	padding: 3px 8px;
	background: var(--y3-color-surface-soft, #f2f4f7);
	border-radius: 999px;
	color: var(--y3-color-text-muted, #475467);
	font-size: .75rem;
}

.y3d-template-card__title {
	margin: 0;
	font-size: 1.18rem;
	line-height: 1.3;
}

.y3d-template-card__title a {
	color: inherit;
	text-decoration: none;
}

.y3d-template-card__title a:hover {
	color: var(--y3-color-primary, #175cd3);
}

.y3d-template-card__open {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: auto;
	text-decoration: none;
}

.y3d-template-card__details {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 14px;
	margin: auto 0 0;
	padding-top: 18px;
	color: var(--y3-color-text-muted, #667085);
	font-size: .85rem;
}

.y3d-template-card__details span {
	display: inline-flex;
	gap: 6px;
	align-items: center;
}

.y3d-template-grid__empty,
.y3d-archive__empty {
	margin-top: 20px;
}

.y3d-archive__main {
	padding-block: clamp(36px, 6vw, 80px);
}

.y3d-archive__header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 24px;
}

.y3d-archive__header h1 {
	margin: 0;
}

.y3d-user-designs__main {
	padding-block: clamp(36px, 6vw, 80px);
}

.y3d-user-designs__header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 18px;
	margin-bottom: 28px;
}

.y3d-user-designs__header h1,
.y3d-user-designs__header p {
	margin: 0;
}

.y3d-user-designs__header p {
	margin-top: 6px;
	color: var(--y3-color-text-muted, #667085);
}

.y3d-user-designs__grid {
	align-items: stretch;
}

.y3d-user-design-card {
	position: relative;
	display: flex;
	flex-direction: column;
	overflow: visible;
	padding: 0;
	background: var(--y3-color-surface, #fff);
	border: 1px solid var(--y3-color-border, #e4e7ec);
	border-radius: var(--y3-radius-card, 12px);
	box-shadow: var(--y3-shadow-card, 0 3px 14px rgba(16, 24, 40, .06));
}

.y3d-user-design-card.is-confirming-delete {
	z-index: 10;
}

/* Geometrie und Bildregeln stehen oben gemeinsam mit der Template-Karte. */
.y3d-user-design-card__preview {
	border-radius: var(--y3-radius-card, 12px) var(--y3-radius-card, 12px) 0 0;
}

.y3d-user-design-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	align-items: flex-start;
	padding: 20px;
}

.y3d-user-design-card__body h2 {
	margin: 12px 0 0;
	font-size: 1.18rem;
	line-height: 1.3;
}

.y3d-user-design-card__template,
.y3d-user-design-card__date {
	margin: 8px 0 0;
	color: var(--y3-color-text-muted, #667085);
	font-size: .88rem;
}

.y3d-user-design-card__open {
	display: inline-flex;
	justify-content: center;
	width: 100%;
	margin-top: 20px;
	text-decoration: none;
}

.y3d-user-design-card__actions {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
	width: 100%;
	margin-top: auto;
	padding-top: 20px;
}

.y3d-user-design-card__actions .y3-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	gap: 7px;
	text-decoration: none;
}

.y3d-user-design-card__actions .y3d-user-design-card__open {
	grid-column: 1 / -1;
	margin-top: 0;
}

.y3d-user-design-card__delete {
	position: relative;
}

.y3d-user-design-card__delete-popover {
	position: absolute;
	right: 0;
	bottom: calc(100% + 10px);
	z-index: 20;
	width: min(310px, calc(100vw - 32px));
	padding: 14px;
	border: 1px solid var(--y3-color-border, #d7d7d7);
	border-radius: var(--y3-radius-md, 8px);
	background: var(--y3-color-surface, #fff);
	box-shadow: 0 12px 32px rgba(16, 24, 40, .22);
}

.y3d-user-design-card__delete-popover::after {
	position: absolute;
	right: 18px;
	bottom: -6px;
	width: 11px;
	height: 11px;
	border-right: 1px solid var(--y3-color-border, #d7d7d7);
	border-bottom: 1px solid var(--y3-color-border, #d7d7d7);
	background: inherit;
	content: '';
	transform: rotate(45deg);
}

.y3d-user-design-card__delete-popover p { margin: 0 0 10px; }
.y3d-user-design-card__delete-popover span { overflow-wrap: anywhere; }
.y3d-user-design-card__delete-warning { color: #b42318; font-size: .82rem; }
.y3d-user-design-card__delete-popover > div { display: flex; flex-wrap: wrap; gap: 8px; }
.y3d-user-design-card__delete-popover > div .y3-button { width: auto; }

.y3d-user-designs__status {
	min-height: 1.4em;
	margin: -16px 0 18px;
	color: var(--y3-color-text-muted, #667085);
	font-size: .9rem;
}

.y3d-user-designs__status.is-error { color: #b42318; }
.y3d-user-designs__status.is-success { color: #067647; }

.y3d-user-design-card__unavailable {
	margin-top: 20px;
}

.y3d-design-status {
	display: inline-flex;
	align-items: center;
	min-height: 26px;
	padding: 3px 9px;
	border-radius: 999px;
	background: #eff4ff;
	color: #175cd3;
	font-size: .75rem;
	font-weight: 700;
}

.y3d-design-status.is-in_progress {
	background: #fffaeb;
	color: #b54708;
}

.y3d-design-status.is-pdf_generated {
	background: #ecfdf3;
	color: #067647;
}

.y3d-user-designs__empty {
	padding: clamp(24px, 5vw, 48px);
	text-align: center;
}

.y3d-user-designs__empty h2 {
	margin-top: 0;
}

.y3d-archive__filters {
	grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
}

.y3d-archive__actions {
	display: flex;
	gap: 8px;
}

@media (max-width: 900px) {
	.y3d-template-grid__toolbar,
	.y3d-archive__filters {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 560px) {
	.y3d-template-grid__toolbar,
	.y3d-archive__filters {
		grid-template-columns: 1fr;
	}
}
