.bmg-app {
	--bmg-accent: #3a2c5a;
	--bmg-accent-2: #6b4fa0;
	--bmg-border: #e4e1ec;
	--bmg-bg: #faf9fc;
	--bmg-text: #1e1b2e;
	--bmg-muted: #6b6880;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--bmg-text);
	display: block;
	max-width: 1400px;
	margin: 0 auto;
	box-sizing: border-box;
}
.bmg-app *, .bmg-app *::before, .bmg-app *::after { box-sizing: border-box; }
.bmg-loading, .bmg-empty { padding: 40px 24px; color: var(--bmg-muted); text-align: center; }
.bmg-error { padding: 24px; color: #a3282d; }

/* ---------- Gallery ---------- */
.bmg-gallery-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.bmg-gallery-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.bmg-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.bmg-app .bmg-filter {
	appearance: none; -webkit-appearance: none;
	height: auto; line-height: 1.4; min-width: 190px;
	padding: 12px 44px 12px 18px; border: 1px solid var(--bmg-border); border-radius: 999px;
	background: #fff url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6880' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 15px center;
	font-size: 15px; color: var(--bmg-text); cursor: pointer;
}
.bmg-filter:focus { outline: 2px solid var(--bmg-accent-2); outline-offset: 1px; }

.bmg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.bmg-card {
	display: flex; flex-direction: column; text-align: left; padding: 0; cursor: pointer;
	background: #fff; border: 1px solid var(--bmg-border); border-radius: 14px; overflow: hidden;
	transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.bmg-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(58, 44, 90, 0.14); border-color: var(--bmg-accent-2); }
.bmg-card:focus-visible { outline: 2px solid var(--bmg-accent-2); outline-offset: 2px; }
.bmg-card-thumb { aspect-ratio: 4 / 3; background: #ece9f3; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.bmg-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.bmg-card-noimg { color: var(--bmg-muted); font-size: 13px; padding: 12px; text-align: center; }
.bmg-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.bmg-card-name { font-size: 15px; font-weight: 600; line-height: 1.3; }
.bmg-card-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bmg-chip { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: #efeaf7; color: var(--bmg-accent); }
.bmg-chip-line { background: #eef4ee; color: #3a5a3f; }
.bmg-card-select { margin-top: 2px; font-size: 13px; font-weight: 600; color: var(--bmg-accent-2); }

/* ---------- Generator ---------- */
.bmg-back {
	appearance: none; border: 0; background: none; color: var(--bmg-accent-2);
	font-size: 14px; font-weight: 600; cursor: pointer; padding: 4px 0; margin-bottom: 16px;
}
.bmg-back:hover { text-decoration: underline; }
/* Break the generator out of the narrow (shrink-wrapped) content column to page width. */
.bmg-generator { position: relative; left: 50%; transform: translateX(-50%); width: 92vw; max-width: 1180px; }
.bmg-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 36px; align-items: start; }
.bmg-panel-form { width: 100%; max-width: none; }
.bmg-panel-preview, .bmg-frame-block, .bmg-preview-wrap { width: 100%; min-width: 0; }
@media (max-width: 800px) {
	.bmg-generator { left: auto; transform: none; width: 100%; }
	.bmg-layout { grid-template-columns: 1fr; }
	.bmg-panel-form { max-width: 440px; }
}

.bmg-panel-form { background: var(--bmg-bg); border: 1px solid var(--bmg-border); border-radius: 16px; padding: 22px; }
.bmg-title { margin: 0 0 18px; font-size: 18px; font-weight: 700; }
.bmg-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.bmg-row label { font-size: 13px; font-weight: 600; color: #4a4560; }
.bmg-control {
	width: 100%; padding: 10px 12px; border: 1px solid var(--bmg-border); border-radius: 10px;
	font-size: 14px; background: #fff;
}
.bmg-control:focus { outline: 2px solid var(--bmg-accent-2); outline-offset: 0; border-color: var(--bmg-accent-2); }

.bmg-controls { margin-top: 20px; display: flex; flex-direction: column; gap: 14px; }
.bmg-outline-toggle { font-size: 13px; color: #4a4560; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.bmg-btn {
	padding: 12px 18px; border: 0; border-radius: 10px; background: var(--bmg-accent);
	color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; transition: filter .12s ease;
}
.bmg-btn:hover { filter: brightness(1.1); }
.bmg-btn:disabled { opacity: .6; cursor: default; }
.bmg-btn-ghost { background: #fff; color: var(--bmg-accent); border: 1px solid var(--bmg-border); }

.bmg-preview-wrap { border: 1px solid var(--bmg-border); border-radius: 14px; overflow: hidden; background: #ece9f3; }
.bmg-stage { position: relative; width: 100%; overflow: hidden; }
.bmg-plate { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.bmg-field { position: absolute; box-sizing: border-box; overflow: hidden; }
.bmg-field-text { display: flex; align-items: center; line-height: 1.15; white-space: nowrap; text-decoration: none; }
.bmg-field-img { display: flex; align-items: center; }
.bmg-logo { max-width: 100%; max-height: 100%; object-fit: contain; }
.bmg-show-outlines .bmg-field { outline: 1px dashed rgba(220, 40, 40, .9); background: rgba(220, 40, 40, .10); }

.bmg-frame-block { margin-bottom: 24px; }
.bmg-frame-block:last-child { margin-bottom: 0; }
.bmg-frame-caption { font-size: 13px; font-weight: 700; color: #4a4560; margin: 0 0 8px; }
.bmg-frame-block .bmg-btn { margin-top: 10px; }
