.bma {
	--ink: #24180f;
	--ink-soft: #5a4636;
	--rule: #d7c4a8;
	--paper: #f6edd9;
	--leaf: #7a1f1a;
	--leaf-deep: #5c1410;
	--gold: #b9893a;
	--good: #2f6b45;
	--miss: #9b2c2c;
	--blank: #c9ae82;
	color: var(--ink);
	background:
		radial-gradient(900px 280px at 8% -8%, rgba(185, 137, 58, 0.14), transparent 55%),
		linear-gradient(180deg, #fbf6ea 0%, var(--paper) 100%);
	border: 1px solid #e2d2b4;
	border-radius: 18px;
	padding: 16px 14px 18px;
	font-family: "Source Sans 3", "Segoe UI", sans-serif;
	line-height: 1.45;
	box-shadow: 0 18px 40px rgba(48, 28, 10, 0.12);
	max-width: 720px;
	margin: 0 auto;
	padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
	touch-action: manipulation;
	-ms-touch-action: manipulation;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

.bma *,
.bma *::before,
.bma *::after {
	box-sizing: border-box;
	touch-action: manipulation;
	-ms-touch-action: manipulation;
}

.bma a,
.bma button,
.bma input,
.bma select,
.bma summary,
.bma textarea,
.bma label {
	touch-action: manipulation;
	-webkit-tap-highlight-color: rgba(122, 31, 26, 0.12);
}

.bma-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
}

.bma-masthead {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 12px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--rule);
}

.bma-mark {
	width: 40px;
	height: 40px;
	flex: 0 0 40px;
	border-radius: 10px;
	display: grid;
	place-items: center;
	color: #f6edd9;
	background: linear-gradient(160deg, #8b2a22, #4a100c);
}

.bma-heading {
	min-width: 0;
}

.bma-kicker {
	margin: 0;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	font-size: 10px;
	color: var(--gold);
	font-weight: 700;
}

.bma-title,
.bma-ref,
.bma-picker summary span,
.bma-history-card h3 {
	font-family: "Cormorant Garamond", Georgia, serif;
	margin: 0;
	font-weight: 600;
	letter-spacing: -0.02em;
}

.bma-title {
	font-size: 22px;
	line-height: 1.1;
}

.bma-account {
	margin-left: auto;
	font-size: 13px;
	text-align: right;
	max-width: 42%;
}

.bma-account a,
.bma-text-btn {
	color: var(--leaf);
	background: none;
	border: 0;
	padding: 0;
	font: inherit;
	cursor: pointer;
	text-decoration: none;
}

.bma-userpill {
	display: block;
	color: var(--ink-soft);
	font-size: 12px;
	margin-bottom: 2px;
}

.bma-picker {
	background: rgba(255, 251, 242, 0.8);
	border: 1px solid #ead9bb;
	border-radius: 14px;
	margin-bottom: 14px;
}

.bma-picker summary {
	list-style: none;
	cursor: pointer;
	padding: 12px 14px;
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 10px;
}

.bma-picker summary::-webkit-details-marker {
	display: none;
}

.bma-picker summary span {
	font-size: 18px;
}

.bma-picker summary strong {
	font-size: 13px;
	font-weight: 600;
	color: var(--ink-soft);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bma-picker-body {
	padding: 0 14px 14px;
}

.bma-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 10px;
	font-size: 12px;
	color: var(--ink-soft);
	font-weight: 600;
}

.bma-field select,
#bma-fill {
	width: 100%;
	border: 1px solid #d3bf9d;
	background: #fffaf0;
	color: var(--ink);
	border-radius: 10px;
	padding: 12px 10px;
	font: inherit;
	font-size: 16px;
}

.bma-row {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	gap: 8px;
}

.bma-load-row {
	display: grid;
	grid-template-columns: minmax(0, 1.3fr) minmax(118px, 0.9fr);
	gap: 8px;
	align-items: end;
	margin: 2px 0 12px;
}

.bma-load-row .bma-btn {
	width: 100%;
	margin: 0;
}

.bma-load-row .bma-field {
	margin-bottom: 0;
}

.bma-btn {
	border: 1px solid #d3bf9d;
	background: #fffaf0;
	color: var(--ink);
	border-radius: 12px;
	padding: 12px 14px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	min-height: 46px;
}

.bma-btn-primary {
	background: linear-gradient(180deg, #8f2d25, var(--leaf-deep));
	border-color: #4a100c;
	color: #f8eed8;
}

.bma-btn-primary:disabled {
	opacity: 0.45;
	filter: none;
}

.bma-btn-primary:not(:disabled):hover {
	filter: brightness(1.06);
}

.bma-chips {
	display: flex;
	flex-wrap: nowrap;
	gap: 8px;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin: 12px 0;
	padding-bottom: 4px;
}

.bma-chips button {
	flex: 0 0 auto;
	border: 1px solid #d7c4a8;
	background: #fff8ea;
	border-radius: 999px;
	padding: 8px 12px;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
	color: var(--ink);
}

.bma-history-card h3 {
	font-size: 18px;
}

.bma-history-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 8px;
}

.bma-hint,
.bma-status,
.bma-empty {
	font-size: 14px;
	color: var(--ink-soft);
	margin: 8px 0 10px;
}

.bma-status {
	margin: 0 0 12px;
}

.bma-history {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 220px;
	overflow: auto;
}

.bma-history li {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 6px;
	align-items: center;
}

.bma-hist-open {
	text-align: left;
	border: 1px solid #e0ccaa;
	background: #fffaf0;
	border-radius: 10px;
	padding: 10px 12px;
	cursor: pointer;
	font: inherit;
	min-height: 46px;
}

.bma-hist-open strong,
.bma-hist-open span {
	display: block;
}

.bma-hist-open span {
	font-size: 12px;
	color: var(--ink-soft);
}

.bma-hist-del {
	border: 0;
	background: transparent;
	color: var(--ink-soft);
	cursor: pointer;
	font-size: 22px;
	padding: 8px 10px;
}

.bma-refbar {
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	gap: 12px;
	margin-bottom: 8px;
}

.bma-ref {
	font-size: 28px;
	line-height: 1;
}

.bma-progress-wrap {
	min-width: 118px;
	text-align: right;
	font-size: 12px;
	font-weight: 700;
	color: var(--ink-soft);
}

.bma-meter {
	height: 7px;
	background: #e7d5b4;
	border-radius: 99px;
	margin-top: 6px;
	overflow: hidden;
}

.bma-meter i {
	display: block;
	height: 100%;
	width: 0;
	background: linear-gradient(90deg, var(--gold), var(--leaf));
}

.bma-verse {
	font-family: "Cormorant Garamond", Georgia, serif;
	font-size: 23px;
	line-height: 1.55;
	color: #2a1c12;
}

.bma-verse p {
	margin: 0 0 14px;
}

.bma-vn {
	font-size: 0.62em;
	font-weight: 700;
	color: var(--gold);
	margin-right: 0.3em;
	font-family: "Source Sans 3", sans-serif;
	vertical-align: super;
}

.bma-word {
	display: inline;
}

.bma-word em,
.bma-verse em {
	font-style: italic;
	font-weight: 500;
}

.bma-blank {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 34px;
	margin: 0 0.08em 0.16em;
	padding: 0 0.45em;
	border: 0;
	border-bottom: 2px solid var(--blank);
	border-radius: 4px 4px 0 0;
	background: rgba(255, 250, 240, 0.9);
	color: var(--ink);
	font: inherit;
	font-size: 0.92em;
	line-height: 1;
	vertical-align: baseline;
	cursor: pointer;
	touch-action: manipulation;
}

.bma-blank.is-focused {
	border-bottom-color: var(--leaf);
	box-shadow: 0 0 0 3px rgba(122, 31, 26, 0.12);
}

.bma-blank.is-ok {
	border-bottom-color: var(--good);
	background: rgba(47, 107, 69, 0.12);
	color: var(--good);
}

.bma-blank.is-miss {
	border-bottom-color: var(--miss);
	background: rgba(155, 44, 44, 0.1);
	color: var(--miss);
}

.bma-verse.is-shake {
	animation: bma-shake 0.35s ease;
}

@keyframes bma-shake {
	25% { transform: translateX(-4px); }
	50% { transform: translateX(4px); }
	75% { transform: translateX(-3px); }
}

.bma-dock {
	position: sticky;
	bottom: calc(76px + env(safe-area-inset-bottom, 0px));
	background: #fff8ea;
	border: 1px solid #e0ccaa;
	border-radius: 14px;
	padding: 10px 12px 8px;
	margin: 8px 0;
	box-shadow: 0 10px 30px rgba(48, 28, 10, 0.12);
	z-index: 2;
}

.bma-dock-label {
	margin: 0 0 8px;
	font-size: 12px;
	font-weight: 700;
	color: var(--ink-soft);
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.bma-dock-form {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 8px;
}

.bma-dock .bma-text-btn {
	margin-top: 8px;
	font-size: 13px;
}

.bma-actions {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	gap: 8px;
	padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
	background: linear-gradient(180deg, rgba(246, 237, 217, 0.2), #f3e6c8 28%);
	border-top: 1px solid #e2d2b4;
	z-index: 3;
}

.bma-actions .bma-btn {
	flex: 1;
}

.bma-actions .bma-btn-primary {
	flex: 1.4;
}

@media (min-width: 720px) {
	.bma {
		padding: 22px 22px 28px;
		padding-bottom: calc(28px + 8px);
	}
	.bma-title {
		font-size: 26px;
	}
	.bma-ref {
		font-size: 32px;
	}
	.bma-verse {
		font-size: 26px;
	}
	.bma-actions {
		position: static;
		background: transparent;
		border: 0;
		padding: 16px 0 0;
	}
	.bma-dock {
		position: static;
	}
}

@media (max-width: 420px) {
	.bma-title {
		font-size: 20px;
	}
	.bma-account {
		font-size: 12px;
	}
}
