/* Admin-only styles */

.admin-shell {
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 20px 18px 40px;
	display: grid;
	grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(260px, 340px);
	gap: 20px;
}

/* Layout modes */
.admin-shell.layout-boxed {
	max-width: 1200px;
	margin-left: auto;
	margin-right: auto;
	padding-left: 20px;
	padding-right: 20px;
}

.admin-shell.layout-2col {
	grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
}
.admin-shell.layout-2col .admin-panel {
	display: none;
}

.admin-shell.layout-3col {
	grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(260px, 340px);
}

/* Active state for layout buttons */
.toolbar-group .button[data-layout-active],
.toolbar-group .button.is-active {
	background: linear-gradient(180deg,#2e84d2,#1e6db4);
	color: #fff;
	box-shadow: 0 4px 10px rgba(23,70,105,0.18);
}

.admin-sidebar,
.admin-main {
	display: grid;
	gap: 16px;
	align-content: start;
}

.admin-panel {
	display: grid;
	gap: 16px;
	align-content: start;
}

/* Drag handle cursor on headers */
.category-head[draggable="true"], .section-heading[draggable="true"], .hero-block[draggable="true"] {
	cursor: grab;
}
.category-head[draggable="true"]:active, .section-heading[draggable="true"]:active, .hero-block[draggable="true"]:active {
	cursor: grabbing;
}

/* Hover-only drag icon for movable boxes */
.sidebar-block, .preview-card, .editor-card, .timeline-card {
	position: relative;
}
.sidebar-block .drag-icon,
.preview-card .drag-icon,
.editor-card .drag-icon,
.timeline-card .drag-icon {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 34px;
	height: 34px;
	border-radius: 6px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 0;
	color: rgba(18,49,75,0.7);
	opacity: 0;
	pointer-events: none;
	transition: opacity 120ms ease, background 120ms ease;
}
.sidebar-block:hover .drag-icon,
.preview-card:hover .drag-icon,
.editor-card:hover .drag-icon,
.timeline-card:hover .drag-icon {
	opacity: 1;
	pointer-events: auto;
}
.drag-icon[draggable="true"] {
	cursor: grab;
}
.drag-icon[draggable="true"]:active {
	cursor: grabbing;
}
.drag-icon svg { width: 14px; height: 14px; }

/* Drag image helper: force a solid appearance for the custom drag image clone */
.drag-image-fix {
	background: #fff !important;
	opacity: 1 !important;
	color: inherit !important;
	filter: none !important;
	-webkit-filter: none !important;
	pointer-events: none !important;
}
.drag-image-fix * {
	opacity: 1 !important;
	filter: none !important;
	-webkit-filter: none !important;
}

/* Visual feedback for drop targets and dragging state */
.is-drop-target {
	outline: 2px dashed rgba(34, 132, 196, 0.18);
	transition: outline-color 120ms ease;
}

.is-dragging {
	opacity: 1 !important; /* ensure dragged items stay solid */
	transform: translateZ(0) scale(0.998);
	box-shadow: 0 18px 40px rgba(23, 70, 105, 0.18);
}

.preview-card,
.editor-card,
.timeline-card,
.sidebar-block {
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.86));
	border: 1px solid rgba(33, 72, 107, 0.16);
	border-radius: 10px;
	box-shadow: 0 8px 24px rgba(23, 70, 105, 0.1);
	padding: 16px;
}

.hero-block {
	background: linear-gradient(135deg, rgba(255, 245, 203, 0.95), rgba(236, 249, 255, 0.92));
}

.hero-block .stack-row {
	margin-top: 10px;
}

/* Hero layout controls: grouped and compact */
.layout-controls-hero {
	display: flex;
	align-items: center;
	gap: 8px;
}

.layout-settings {
	width: 100%;
}
.layout-settings-label {
	font-size: 0.78rem;
	font-weight: 700;
	color: rgba(18,49,75,0.9);
	margin: 6px 0 6px 0;
	letter-spacing: 0.02em;
}
.layout-controls-hero .layout-group {
	display: flex;
	gap: 4px;
	align-items: center;
}
.hero-separator {
	display: block;
	width: 100%;
	height: 1px;
	background: rgba(33,72,107,0.06);
	margin: 8px 0;
	border-radius: 1px;
}

/* Make the hero buttons more compact than regular toolbar */
.hero-group .button.tiny {
	padding: 5px 7px;
	font-size: 0.76rem;
	font-weight: 700;
	border-radius: 6px;
}

/* More compact layout buttons specifically */
.layout-mode-btn {
	padding: 4px 6px;
	font-size: 0.72rem;
	min-width: auto;
}

/* Ensure uniform compact sizing for all layout buttons (prevent 2/3 columns from growing) */
.layout-controls-hero .layout-group .button,
.layout-controls-hero .layout-group .layout-mode-btn {
	padding: 4px 6px;
	font-size: 0.72rem;
	min-width: 64px;
	white-space: nowrap;
	text-align: center;
}

/* Slight visual grouping for the layout controls */
.layout-controls-hero .layout-group + .layout-group {
	margin-left: 8px;
	padding-left: 8px;
	border-left: 1px solid rgba(33,72,107,0.06);
}

.admin-sidebar h1 {
	margin: 0;
	font-family: 'Baloo 2', sans-serif;
	font-size: clamp(2rem, 4vw, 3rem);
	line-height: 0.95;
	color: #1d4469;
}

.admin-sidebar p {
	margin: 8px 0 0;
	color: rgba(18, 49, 75, 0.82);
}

.category-block {
	display: grid;
	gap: 12px;
}

.category-head {
	display: grid;
	gap: 4px;
	padding-bottom: 10px;
	border-bottom: 1px solid rgba(33, 72, 107, 0.12);
}

.category-head h2 {
	margin: 0;
	font-size: 1rem;
	font-weight: 800;
	letter-spacing: 0.02em;
	color: #1f466d;
}

.category-head p {
	margin: 0;
	font-size: 0.86rem;
	color: rgba(18, 49, 75, 0.66);
}

.inner-head {
	margin-top: 8px;
}

.form-grid {
	display: grid;
	gap: 10px;
}

.form-grid.two-up {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.audio-range-row {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
	align-items: start;
}

.audio-range-row label {
	display: grid;
	gap: 6px;
}

.form-grid label,
.editor-item,
.layer-block {
	display: grid;
	gap: 6px;
}

.form-grid span,
.section-heading h2,
.section-heading h3 {
	font-weight: 700;
	color: #21486b;
}

.section-heading {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	margin-bottom: 8px;
}

.section-heading.tight {
	margin-bottom: 4px;
}

.section-heading h2,
.section-heading h3 {
	margin: 0;
	font-size: 0.95rem;
}

.stack-row {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.stack-row.full-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: stretch;
}

input,
select,
textarea {
	width: 100%;
	border: 1px solid rgba(33, 72, 107, 0.2);
	border-radius: 6px;
	background: #ffffff;
	color: var(--ink);
	padding: 10px 12px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Small text/number inputs used in compact areas */
.admin-shell .form-grid input[type="text"],
.admin-shell .form-grid input[type="number"],
.admin-shell .input-with-button input[type="text"],
.admin-shell .input-with-button input[type="number"],
.editor-section input[type="text"],
.editor-section input[type="number"] {
	padding: 6px 8px;
	font-size: 0.85rem;
	height: 36px;
	line-height: 1;
}

input:focus,
select:focus,
textarea:focus {
	outline: none;
	border-color: #2f7cc8;
	box-shadow: 0 0 0 3px rgba(47, 124, 200, 0.15);
}

textarea {
	resize: vertical;
	min-height: 92px;
}

.input-with-button {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 8px;
}

.import-export-card {
	background: linear-gradient(135deg, rgba(242, 252, 255, 0.97), rgba(242, 255, 246, 0.94));
	border-color: rgba(33, 72, 107, 0.2);
	position: relative;
	overflow: hidden;
}

.import-export-card::after {
	content: '';
	position: absolute;
	width: 180px;
	height: 180px;
	right: -60px;
	top: -80px;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(96, 182, 230, 0.24), rgba(96, 182, 230, 0));
	pointer-events: none;
}

.import-export-actions {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
	position: relative;
	z-index: 1;
}

.import-export-actions .button {
	width: 100%;
	justify-content: center;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

#exportBookHtmlButton {
	grid-column: 1 / -1;
}

#exportBookZipButton {
	background: linear-gradient(180deg, #2ca56a, #238d5a);
	border-color: rgba(16, 102, 63, 0.35);
	box-shadow: 0 4px 14px rgba(32, 129, 83, 0.18);
}

#exportBookZipButton:hover {
	box-shadow: 0 6px 18px rgba(32, 129, 83, 0.24);
}

.import-export-hint {
	margin: 0;
	font-size: 0.8rem;
	color: rgba(18, 49, 75, 0.72);
	position: relative;
	z-index: 1;
}

.admin-shell .button,
.admin-shell .page-pill {
	border-radius: 4px;
}

.admin-shell .button {
	padding: 10px 14px;
	background: linear-gradient(180deg, #2e84d2, #1e6db4);
	color: #fff;
	font-weight: 700;
	border: 1px solid rgba(15, 75, 126, 0.3);
	box-shadow: 0 2px 8px rgba(23, 70, 105, 0.16);
	cursor: pointer;
	transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.admin-shell .button:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 10px rgba(23, 70, 105, 0.2);
	filter: brightness(1.03);
}

.admin-shell .button:active {
	transform: translateY(0);
	box-shadow: 0 2px 6px rgba(23, 70, 105, 0.2);
}

.admin-shell .button.ghost {
	background: #f4f8fc;
	color: #1f466d;
	border-color: rgba(33, 72, 107, 0.22);
	box-shadow: none;
}

.admin-shell .button.danger {
	background: linear-gradient(180deg, #df6262, #c94f4f);
	border-color: rgba(128, 24, 24, 0.3);
}

.admin-shell .button.tiny {
	padding: 8px 10px;
	font-size: 0.82rem;
}

/* Make the Save Book button appear green */
#saveBookButton {
	background: linear-gradient(180deg, #34c759, #28a745);
	border-color: rgba(20, 120, 40, 0.28);
	box-shadow: 0 2px 8px rgba(34, 139, 34, 0.12);
	color: #ffffff;
}
#saveBookButton:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 10px rgba(34, 139, 34, 0.2);
	filter: brightness(1.03);
}
#saveBookButton:active {
	transform: translateY(0);
	box-shadow: 0 2px 6px rgba(34, 139, 34, 0.2);
}

.page-list,
.editor-list {
	display: grid;
	gap: 10px;
}

.page-pill-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 40px;
	gap: 8px;
	align-items: stretch;
}

.page-pill {
	width: 100%;
	padding: 10px 12px;
	background: #f7fafd;
	color: #20486c;
	font-weight: 700;
	text-align: left;
	cursor: pointer;
	border: 1px solid rgba(33, 72, 107, 0.16);
	touch-action: none;
}

.page-list .page-pill {
	cursor: grab;
}

.page-pill-delete {
	border: 1px solid rgba(191, 74, 74, 0.35);
	border-radius: 4px;
	background-color: #fff3f3;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b54b4b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2'/%3E%3Cpath d='M19 6l-1 14a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1L5 6'/%3E%3Cline x1='10' y1='11' x2='10' y2='17'/%3E%3Cline x1='14' y1='11' x2='14' y2='17'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 18px 18px;
	cursor: pointer;
}

.page-pill-delete:hover {
	background-color: #ffe7e7;
	filter: brightness(0.99);
}

.page-list.is-sorting .page-pill {
	cursor: grabbing;
}

.page-pill-row-placeholder {
	height: 44px;
	border: 1px dashed rgba(33, 72, 107, 0.3);
	background: rgba(216, 240, 255, 0.35);
	border-radius: 4px;
}

/* Compact Save/Delete buttons in the sidebar */
.admin-sidebar .stack-row.compact .button {
	padding: 6px 10px;
	font-size: 0.85rem;
	min-width: 96px;
	height: 36px;
}

.admin-sidebar .stack-row.compact .button.danger {
	padding: 6px 10px;
	min-width: 96px;
	height: 36px;
}

/* Generic compact button utility for selected controls */
.button.compact {
	padding: 6px 10px;
	font-size: 0.85rem;
	height: 36px;
	line-height: 1;
	min-width: 80px;
}

.button.compact.ghost {
	padding: 6px 10px;
}

.button.compact.danger {
	padding: 6px 10px;
}

/* Compact inputs and selects in the sidebar to match the compact buttons */
.admin-sidebar .stack-row input,
.admin-sidebar .stack-row select,
.admin-sidebar .input-with-button input {
	padding: 6px 8px;
	font-size: 0.85rem;
	height: 36px;
	line-height: 1;
}

.admin-sidebar .stack-row select {
	min-width: 120px;
}

.page-pill.is-active {
	background: linear-gradient(180deg, #ffe19a, #ffd069);
	border-color: rgba(155, 107, 9, 0.3);
	color: #5f3a00;
}

.preview-toolbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	margin-bottom: 10px;
}

/* Toolbar grouping and separators for preview toolbar */
.toolbar {
	align-items: center;
	gap: 6px;
}

.toolbar-group {
	display: flex;
	align-items: center;
	gap: 6px;
}

.toolbar-separator {
	display: inline-block;
	width: 1px;
	height: 24px;
	background: rgba(33, 72, 107, 0.12);
	border-radius: 1px;
	margin: 0 4px;
}

/* Smaller buttons specifically for the preview toolbar */
.preview-toolbar .toolbar .button.tiny {
	padding: 6px 8px;
	font-size: 0.75rem;
	min-width: 32px;
	height: 32px;
	line-height: 1;
}

.preview-toolbar .toolbar .button.tiny.ghost {
	padding: 6px 8px;
}

.preview-toolbar .toolbar .button.tiny.danger {
	padding: 6px 10px;
}

.canvas-zoom-controls {
	position: absolute;
	bottom: 14px;
	right: 14px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 6px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.9);
	border: 1px solid rgba(33, 72, 107, 0.14);
	box-shadow: 0 10px 22px rgba(23, 70, 105, 0.14);
	z-index: 10;
	cursor: move;
	user-select: none;
}

.canvas-zoom-controls .button {
	border-radius: 999px;
	min-width: 38px;
	height: 38px;
	padding: 0 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-weight: 800;
	line-height: 1;
}

#zoomInCanvasButton,
#zoomOutCanvasButton {
	width: 38px;
	padding: 0;
	font-size: 1.1rem;
}

#resetCanvasZoomButton {
	padding: 0 14px;
}

.canvas-zoom-controls span {
	min-width: 48px;
	text-align: center;
	font-size: 0.78rem;
	font-weight: 700;
	color: #1f466d;
}

.preview-toolbar strong {
	font-size: 0.95rem;
	color: #1f466d;
}

body.admin-browser-fullscreen {
	overflow: hidden;
}

body.admin-browser-fullscreen .admin-shell {
	width: 100%;
	margin: 0;
	padding: 0;
	display: block;
}

body.admin-browser-fullscreen .admin-sidebar,
body.admin-browser-fullscreen .admin-main > :not(#adminPreviewCard) {
	display: none;
}

body.admin-browser-fullscreen .admin-main {
	display: block;
	gap: 0;
}

body.admin-browser-fullscreen #adminPreviewCard {
	position: fixed;
	inset: 0;
	z-index: 9999;
	width: 100vw;
	height: 100vh;
	padding: 16px;
	margin: 0;
	border-radius: 0;
	border: 0;
	box-shadow: none;
	background: linear-gradient(180deg, rgba(245, 252, 255, 0.98), rgba(243, 252, 241, 0.98));
	display: grid;
	grid-template-rows: auto auto minmax(0, 1fr);
	align-content: start;
	overflow: hidden;
}

/* In fullscreen, keep preview toolbar visible; hide audio timeline header/meta */
body.admin-browser-fullscreen #audioTimelineCard .category-head,
body.admin-browser-fullscreen #audioTimelineCard .audio-timeline-meta {
    display: none !important;
}

/* Hide preview card heading only in fullscreen */
body.admin-browser-fullscreen #adminPreviewCard .category-head {
	display: none !important;
}

/* When timeline is moved into the fullscreen preview, pin it to the bottom
   and reserve space in the canvas viewport so it doesn't cover interactive elements. */
body.admin-browser-fullscreen #audioTimelineCard.in-fullscreen-preview {
	position: absolute;
	left: 16px;
	right: 16px;
	bottom: 16px;
	z-index: 99999;
	width: auto;
	margin: 0;
}

body.admin-browser-fullscreen #adminPreviewCard .preview-canvas-viewport {
	padding-bottom: 160px; /* reserve space for timeline */
}


body.admin-browser-fullscreen #adminPreviewCard .preview-toolbar {
	position: sticky;
	top: 0;
	z-index: 6;
	padding: 8px 0;
	background: linear-gradient(180deg, rgba(245, 252, 255, 0.98), rgba(245, 252, 255, 0.92));
	align-items: flex-start;
}

body.admin-browser-fullscreen #adminPreviewCard .preview-canvas-viewport {
	height: 100%;
	min-height: 0;
	max-height: none;
	display: grid;
}

body.admin-browser-fullscreen #adminPreviewCard .preview-canvas-scroll {
	height: 100%;
	max-height: none;
	display: grid;
	place-items: center;
	padding: 20px;
}

body.admin-browser-fullscreen #adminPreviewCard .preview-canvas {
	max-height: none;
	height: 100%;
	min-height: 0;
	margin: auto;
}

body.admin-browser-fullscreen #adminPreviewCard .preview-canvas img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center center;
	background: #f3f7fb;
}

.preview-canvas-viewport {
	position: relative;
	overflow: hidden;
	padding: 12px;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.36);
	max-width: 100%;
	max-height: min(78vh, 900px);
	cursor: default;
}

.preview-canvas-scroll {
	overflow: auto;
	max-width: 100%;
	max-height: calc(min(78vh, 900px) - 24px);
	cursor: default;
	display: grid;
	place-items: center;
}

.preview-canvas-scroll.is-panning {
	cursor: grabbing;
}

.preview-canvas {
	position: relative;
	overflow: hidden;
	border-radius: 8px;
	aspect-ratio: 16 / 9;
	background: linear-gradient(180deg, #d9efff, #f2ffe3);
	container-type: size;
	touch-action: none;
	border: 1px solid rgba(33, 72, 107, 0.14);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	max-width: none;
	margin: auto;
}

.preview-canvas img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center center;
	background: #f3f7fb;
}

/* Responsive layout: collapse third column on smaller screens */
@media (max-width: 1099px) {
	.admin-shell {
		grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
	}
	.admin-panel {
		grid-column: 1 / -1;
	}
}

@media (max-width: 699px) {
	.admin-shell {
		grid-template-columns: 1fr;
		padding: 12px;
		gap: 12px;
	}
	.admin-sidebar {
		order: 1;
	}
	.admin-main {
		order: 2;
	}
	.admin-panel {
		order: 3;
	}
	.admin-sidebar,
	.admin-main,
	.admin-panel {
		grid-column: 1 / -1;
	}
}

.preview-layer {
	position: absolute;
	inset: 0;
	z-index: 3;
	pointer-events: none;
}

#adminWordBlockLayer {
	pointer-events: none;
}

.preview-canvas.is-draw-word-block #adminWordBlockLayer {
	pointer-events: auto;
}

.preview-text-item {
	position: absolute;
	padding: 1cqw 1.2cqw;
	border-radius: 1.7cqw;
	font-size: 1.35cqw;
	line-height: 1.35;
	background: rgba(255, 255, 255, 0.84);
	box-shadow: 0 4px 14px rgba(23, 70, 105, 0.16);
	overflow: hidden;
}

/* Allow interaction with items and resizable handles inside the preview layer */
.preview-layer .preview-text-item,
.preview-layer .preview-word-block-item,
.preview-layer .preview-hotspot-item,
.preview-layer .text-resize-handle {
	pointer-events: auto;
}

.preview-word-block-item {
	position: absolute;
	border: 2px solid rgba(42, 111, 169, 0.45);
	background: rgba(56, 147, 219, 0.1);
	border-radius: 6px;
	font-size: 11px;
	line-height: 1.2;
	padding: 2px 4px;
	overflow: hidden;
	color: #11304b;
	z-index: 7;
	cursor: grab;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.preview-word-block-item:hover {
	background: rgba(56, 147, 219, 0.2);
	border-color: rgba(42, 111, 169, 0.65);
}

.preview-word-block-item.ui-draggable-dragging {
	cursor: grabbing;
}

.preview-word-block-item.is-locked {
	cursor: not-allowed;
	border-style: dashed;
	background: rgba(126, 145, 165, 0.22);
}

.preview-word-block-item.is-locked::before {
	content: '';
	position: absolute;
	right: 7px;
	top: 5px;
	width: 8px;
	height: 6px;
	border: 2px solid rgba(17, 48, 75, 0.82);
	border-bottom: 0;
	border-radius: 8px 8px 0 0;
	background: transparent;
	pointer-events: none;
}

.preview-word-block-item.is-locked::after {
	content: '';
	position: absolute;
	right: 5px;
	top: 10px;
	width: 12px;
	height: 10px;
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.9);
	border: 2px solid rgba(17, 48, 75, 0.82);
	pointer-events: none;
}

.preview-word-block-item .ui-resizable-handle {
	position: absolute;
	font-size: 0.1px;
	display: block;
	pointer-events: auto;
}

.preview-word-block-item .ui-resizable-se {
	cursor: se-resize;
	width: 12px;
	height: 12px;
	right: -6px;
	bottom: -6px;
	background: radial-gradient(circle, rgba(42, 111, 169, 0.8) 30%, transparent 70%);
	border-radius: 50%;
}

.word-block-resize-handle {
	position: absolute;
	bottom: 0;
	right: 0;
	width: 14px;
	height: 14px;
	cursor: se-resize;
	background: radial-gradient(circle, rgba(42, 111, 169, 0.9) 45%, transparent 70%);
	border-radius: 50%;
	margin: 2px;
	pointer-events: auto;
	touch-action: none;
}

.word-block-resize-handle:hover {
	background: radial-gradient(circle, rgba(42, 111, 169, 1) 45%, transparent 70%);
}

.word-block-context-menu {
	position: fixed;
	left: 0;
	top: 0;
	display: none;
	min-width: 148px;
	padding: 6px;
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.96);
	border: 1px solid rgba(33, 72, 107, 0.2);
	box-shadow: 0 14px 26px rgba(23, 70, 105, 0.2);
	z-index: 99999;
	backdrop-filter: blur(4px);
}

.word-block-context-menu.is-visible {
	display: grid;
	gap: 4px;
}

.word-block-context-menu button {
	border: 0;
	border-radius: 8px;
	padding: 8px 10px;
	text-align: left;
	font-size: 0.86rem;
	font-weight: 700;
	color: #12314b;
	background: transparent;
	cursor: pointer;
}

.word-block-context-menu button:hover {
	background: rgba(33, 72, 107, 0.1);
}

.word-block-context-menu button.danger {
	color: #b12338;
}

.word-block-context-menu button.danger:hover {
	background: rgba(201, 48, 77, 0.14);
}
.preview-word-block-item.is-active {
	box-shadow: 0 0 0 2px rgba(255, 213, 101, 0.8);
}

.preview-word-block-item.is-audio-focused {
	border-color: rgba(42, 180, 90, 0.9);
	background: rgba(42, 180, 90, 0.18);
	box-shadow: 0 0 0 3px rgba(42, 180, 90, 0.35);
	transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.preview-canvas.is-draw-word-block {
	cursor: crosshair;
}

.word-block-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}

.floating-field {
	position: relative;
	display: block;
	margin-bottom: 3px;
}

.floating-field > input,
.floating-field > textarea,
.floating-field > select {
	padding-top: 16px;
	padding-bottom: 8px;
}

.floating-field > span {
	position: absolute;
	left: 11px;
	top: 50%;
	transform: translateY(-50%);
	font-size: 0.84rem;
	line-height: 1;
	color: rgba(18, 49, 75, 0.66);
	background: #ffffff;
	padding: 0 4px;
	pointer-events: none;
	transition: top 0.14s ease, transform 0.14s ease, font-size 0.14s ease, color 0.14s ease;
}

.floating-field > input:focus + span,
.floating-field > input:not(:placeholder-shown) + span,
.floating-field > select:focus + span,
.floating-field > textarea:focus + span,
.floating-field > textarea:not(:placeholder-shown) + span {
	top: 0;
	transform: translateY(-50%);
	font-size: 0.72rem;
	color: #2f7cc8;
}

.floating-field-select > span {
	top: 0;
	transform: translateY(-50%);
	font-size: 0.72rem;
	color: rgba(18, 49, 75, 0.8);
}

.floating-field-textarea > span {
	top: 14px;
	transform: none;
}

.floating-field-textarea > textarea {
	padding-top: 20px;
}

.preview-layer .text-resize-handle {
	z-index: 60;
	touch-action: none;
}

.preview-hotspot-item {
	position: absolute;
	width: 2.4cqw;
	height: 2.4cqw;
	margin-left: -1.2cqw;
	margin-top: -1.2cqw;
	border-radius: 50%;
	background: rgba(255, 110, 110, 0.92);
	border: 0.35cqw solid rgba(255, 255, 255, 0.82);
	box-shadow: 0 0 0 0.85cqw rgba(255, 110, 110, 0.12);
}

.preview-text-item,
.preview-hotspot-item {
	cursor: grab;
	user-select: none;
	touch-action: none;
	pointer-events: auto;
	z-index: 4;
}

.preview-text-item .text-resize-se {
	width: 12px;
	height: 12px;
	right: -6px;
	bottom: -6px;
	cursor: se-resize;
	touch-action: none;
	border-radius: 3px;
	background: #2f7cc8;
	border: 1px solid rgba(255, 255, 255, 0.9);
	box-shadow: 0 2px 6px rgba(23, 70, 105, 0.25);
}

.preview-text-item .text-resize-e {
	width: 10px;
	height: 100%;
	right: -5px;
	top: 0;
	cursor: e-resize;
	touch-action: none;
}

.preview-text-item .text-resize-s {
	height: 10px;
	width: 100%;
	left: 0;
	bottom: -5px;
	cursor: s-resize;
	touch-action: none;
}

.text-resize-handle {
	position: absolute;
	display: block;
	user-select: none;
	-webkit-user-select: none;
}

/* Canvas text-block selection & inline edit states */
.preview-text-item.is-selected {
	outline: 2px solid #2f7cc8;
	outline-offset: 2px;
	z-index: 10;
}

.preview-text-item.is-editing {
	cursor: text !important;
	user-select: text !important;
	overflow: auto;
}

/* Floating canvas text-format toolbar */
#textBlockToolbar {
	position: fixed;
	z-index: 9999;
	display: none;
	align-items: center;
	gap: 4px;
	background: rgba(255, 255, 255, 0.96);
	backdrop-filter: blur(8px);
	border: 1px solid rgba(33, 72, 107, 0.18);
	border-radius: 12px;
	padding: 4px;
	box-shadow: 0 10px 30px rgba(23, 70, 105, 0.2);
	pointer-events: auto;
	white-space: nowrap;
}

#textBlockToolbar.is-visible {
	display: flex;
}

/* Shared toolbar button (canvas toolbar + sidebar format bar) */
.tb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border: 1px solid rgba(33, 72, 107, 0.18);
	border-radius: 7px;
	background: #ffffff;
	cursor: pointer;
	font-size: 0.82rem;
	font-family: inherit;
	color: #12314b;
	padding: 0;
	transition: background 0.12s, border-color 0.12s, transform 0.12s;
	flex-shrink: 0;
}

.tb-btn:hover {
	background: rgba(33, 72, 107, 0.08);
	border-color: rgba(33, 72, 107, 0.34);
}

.tb-btn.is-active {
	background: rgba(47, 124, 200, 0.14);
	border-color: rgba(47, 124, 200, 0.4);
	color: #1e5fa8;
}

.tb-btn:active {
	transform: translateY(1px);
}

.tb-btn.tb-delete {
	color: #b34700;
	font-size: 0.88rem;
}

.tb-btn[data-fmt="reset"] {
	font-size: 1rem;
}

.tb-btn[data-fmt="shadow"] {
	font-size: 0.84rem;
}

.tb-btn.tb-delete:hover {
	background: rgba(179, 71, 0, 0.1);
	border-color: rgba(179, 71, 0, 0.35);
}

.tb-btn.tb-close {
	color: #a9382e;
	font-size: 0.95rem;
}

.tb-btn.tb-close:hover {
	background: rgba(192, 57, 43, 0.1);
	border-color: rgba(192, 57, 43, 0.35);
}

.tb-sep {
	width: 1px;
	height: 18px;
	background: linear-gradient(180deg, rgba(33, 72, 107, 0.08), rgba(33, 72, 107, 0.2), rgba(33, 72, 107, 0.08));
	margin: 0 1px;
	flex-shrink: 0;
}

/* Color-picker swatch label */
.tb-color-label {
	position: relative;
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border: 1px solid rgba(33, 72, 107, 0.2);
	border-radius: 7px;
	background: #ffffff;
	cursor: pointer;
	overflow: hidden;
	flex-shrink: 0;
	transition: border-color 0.12s, background 0.12s;
}

.tb-color-label:hover {
	border-color: #2f7cc8;
	background: rgba(47, 124, 200, 0.06);
}

.tb-color-label input[type="color"] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
	border: none;
	padding: 0;
}

.tb-icon {
	font-size: 0.66rem;
	font-weight: 700;
	color: #12314b;
	line-height: 1;
	flex-shrink: 0;
	margin-bottom: 4px;
}

.tb-color-swatch {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: 5px;
}

.tb-spectrum {
	display: none;
}

#textBlockToolbar .sp-original-input-container {
	position: relative;
	display: inline-flex !important;
	align-items: center;
	margin: 0 !important;
	flex-shrink: 0;
}

#textBlockToolbar .sp-original-input-container .sp-colorize-container.sp-add-on {
	position: relative;
	width: 26px !important;
	height: 26px;
	border: 1px solid rgba(33, 72, 107, 0.2) !important;
	border-radius: 7px;
	background: #ffffff;
	overflow: hidden;
	cursor: pointer;
}

#textBlockToolbar .sp-original-input-container .sp-colorize-container.sp-add-on::before {
	position: absolute;
	top: 6px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 0.66rem;
	font-weight: 800;
	line-height: 1;
	color: #12314b;
	pointer-events: none;
	z-index: 2;
	content: '';
}

#textBlockToolbar .tb-spectrum-text-wrap .sp-colorize-container.sp-add-on::before {
	content: 'A';
}

#textBlockToolbar .tb-spectrum-bg-wrap .sp-colorize-container.sp-add-on::before {
	content: '\25A0';
}

#textBlockToolbar .sp-original-input-container .sp-colorize {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	top: auto !important;
	height: 6px !important;
	border-radius: 0 !important;
	z-index: 1;
}

#textBlockToolbar .sp-original-input-container > input.tb-spectrum {
	position: absolute;
	width: 1px !important;
	height: 1px !important;
	opacity: 0;
	pointer-events: none;
	border: 0;
	padding: 0;
}

#textBlockToolbar .sp-original-input-container .sp-colorize-container.sp-add-on:hover {
	border-color: #2f7cc8 !important;
}

#textBlockToolbar .tb-spectrum-replacer.sp-replacer {
	position: relative;
	padding: 0;
	width: 26px;
	height: 26px;
	border: 1px solid rgba(33, 72, 107, 0.2);
	border-radius: 7px;
	background: #ffffff;
	overflow: hidden;
	flex-shrink: 0;
}

#textBlockToolbar .tb-spectrum-replacer.sp-replacer::before {
	position: absolute;
	top: 6px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 0.66rem;
	font-weight: 800;
	line-height: 1;
	color: #12314b;
	pointer-events: none;
	z-index: 2;
	content: '';
}

#textBlockToolbar .tb-spectrum-text.sp-replacer::before {
	content: 'A';
}

#textBlockToolbar .tb-spectrum-bg.sp-replacer::before {
	content: '\25A0';
}

#textBlockToolbar .tb-spectrum-replacer .sp-preview {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	width: 100%;
	height: 6px;
	margin: 0;
	border: 0;
	border-radius: 0;
}

#textBlockToolbar .tb-spectrum-replacer .sp-dd {
	display: none;
}

#textBlockToolbar .tb-spectrum-replacer.sp-replacer:hover {
	border-color: #2f7cc8;
}

.tb-spectrum-container.sp-container {
	z-index: 10010 !important;
}

/* Sidebar text-block format bar */
.text-format-bar {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 8px;
	padding: 6px;
	border-radius: 10px;
	background: linear-gradient(180deg, rgba(245, 250, 255, 0.95), rgba(237, 246, 255, 0.9));
	border: 1px solid rgba(33, 72, 107, 0.14);
}

.preview-canvas.is-dragging .preview-text-item,
.preview-canvas.is-dragging .preview-hotspot-item {
	cursor: grabbing;
}

.editor-grid {
	display: grid;
	gap: 20px;
	grid-template-columns: 1fr;
	align-items: start;
}

.audio-timeline-meta {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 10px;
	font-size: 0.84rem;
	font-weight: 700;
	color: rgba(18, 49, 75, 0.75);
}

#audioTimelineCurrent,
#audioTimelineDuration {
	font-variant-numeric: tabular-nums;
	font-family: 'Nunito', sans-serif;
	letter-spacing: 0.02em;
}

#audioTimelineCurrent {
	justify-self: center;
	color: #1f466d;
}

#audioTimelineDuration {
	justify-self: end;
}

.audio-timeline-stage {
	position: relative;
	height: 100px;
	border-radius: 0;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(241, 249, 255, 0.96));
	border: 1px solid rgba(33, 72, 107, 0.15);
	overflow-x: auto;
	overflow-y: hidden;
	cursor: pointer;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
	transition: height 0.15s ease;
}

.audio-timeline-inner {
	position: relative;
	height: 100%;
	min-width: 100%;
	will-change: width;
}

.audio-timeline-ruler {
	position: absolute;
	left: 10px;
	right: 10px;
	top: 4px;
	height: 16px;
	pointer-events: auto;
	cursor: grab;
	z-index: 4;
}

.audio-timeline-stage.is-ruler-panning,
.audio-timeline-stage.is-ruler-panning .audio-timeline-ruler {
	cursor: grabbing;
}

.audio-timeline-ruler-mark {
	position: absolute;
	top: 0;
	width: 1px;
	height: 12px;
	background: linear-gradient(180deg, rgba(33, 72, 107, 0.12), rgba(33, 72, 107, 0.28));
}

.audio-timeline-ruler-mark span {
	position: absolute;
	top: -1px;
	left: 4px;
	font-size: 0.74rem;
	font-weight: 700;
	color: rgba(18, 49, 75, 0.9);
	font-variant-numeric: tabular-nums;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
	transform: none;
	white-space: nowrap;
}

.audio-timeline-segments {
	position: absolute;
	inset: 24px 10px 14px;
	border-radius: 0;
	background: linear-gradient(180deg, rgba(222, 238, 250, 0.5), rgba(213, 234, 248, 0.78));
	border: 1px solid rgba(33, 72, 107, 0.12);
	overflow: visible;
}

.audio-timeline-segment {
	position: absolute;
	border: 1px solid rgba(15, 90, 145, 0.34);
	border-radius: 0;
	background: linear-gradient(180deg, rgba(76, 167, 229, 0.92), rgba(37, 126, 200, 0.9));
	box-shadow: 0 3px 8px rgba(23, 70, 105, 0.18);
	cursor: grab;
	padding: 0;
	min-width: 2px;
	overflow: hidden;
	transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.audio-timeline-segment:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 10px rgba(23, 70, 105, 0.26);
	filter: brightness(1.03);
}

.audio-timeline-segment::after {
	content: '';
	position: absolute;
	left: 3px;
	right: 3px;
	top: 2px;
	height: 30%;
	border-radius: 0;
	background: rgba(255, 255, 255, 0.28);
	pointer-events: none;
}

.audio-segment-handle {
	position: absolute;
	top: 50%;
	width: 18px;
	height: calc(100% + 10px);
	transform: translateY(-50%);
	border-radius: 0;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(226, 242, 252, 0.96));
	border: 1px solid rgba(20, 82, 132, 0.5);
	box-shadow: 0 2px 6px rgba(23, 70, 105, 0.22);
	cursor: ew-resize;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
}

.audio-segment-handle::before {
	content: '';
	position: absolute;
	inset: 5px 6px;
	border-radius: 0;
	background: repeating-linear-gradient(
		90deg,
		rgba(20, 82, 132, 0.6) 0,
		rgba(20, 82, 132, 0.6) 1px,
		transparent 1px,
		transparent 3px
	);
}

.audio-segment-handle.start {
	left: -9px;
}

.audio-segment-handle.end {
	right: -9px;
}

.audio-timeline-segment:active {
	cursor: grabbing;
}

.audio-timeline-segment.is-selected {
	border-color: rgba(255, 213, 101, 0.95);
	box-shadow: 0 0 0 2px rgba(255, 213, 101, 0.55), 0 3px 8px rgba(23, 70, 105, 0.18);
	filter: brightness(1.1);
}

.audio-timeline-rubber-band {
	position: absolute;
	border: 1.5px solid rgba(42, 111, 169, 0.8);
	background: rgba(42, 111, 169, 0.1);
	pointer-events: none;
	z-index: 10;
	border-radius: 2px;
}

.audio-timeline-playhead {
	position: absolute;
	top: 8px;
	bottom: 10px;
	width: 2px;
	left: 10px;
	background: linear-gradient(180deg, rgba(255, 97, 72, 0.96), rgba(226, 63, 34, 0.96));
	box-shadow: 0 0 0 2px rgba(255, 97, 72, 0.14);
	pointer-events: none;
	transition: left 0.08s linear;
	border-radius: 0;
	z-index: 3;
}

.audio-timeline-foot {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.audio-timeline-foot p {
	margin: 0;
	font-size: 0.82rem;
	color: rgba(18, 49, 75, 0.75);
}

.audio-timeline-controls {
	display: inline-flex;
	gap: 6px;
	align-items: center;
}

.audio-timeline-controls .button {
	min-width: 34px;
	height: 34px;
	padding: 0;
	font-size: 1.05rem;
	line-height: 1;
	font-weight: 800;
	display: inline-flex;
	justify-content: center;
	align-items: center;
}

#timelineUndoButton,
#timelineRedoButton {
	min-width: auto;
	padding: 0 10px;
	font-size: 0.75rem;
	font-weight: 700;
}

#audioTimelineResizeToggle {
	min-width: auto;
	padding: 0 10px;
	font-size: 0.76rem;
	font-weight: 700;
	letter-spacing: 0.01em;
}

#audioTimelineResizeToggle.is-active {
	background: rgba(33, 72, 107, 0.18);
	border-color: rgba(20, 82, 132, 0.42);
}

#audioTimelineStopButton {
	font-size: 1.3rem;
}

/* Slot Play toggle removed */

.audio-timeline-separator {
	display: inline-block;
	width: 1px;
	height: 18px;
	background: rgba(33, 72, 107, 0.12);
	border-radius: 1px;
	margin: 0 4px;
	vertical-align: middle;
}

.audio-timeline-zoom-group {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-left: 0;
	padding-left: 0;
	border-left: none;
}

.audio-timeline-group {
 	display: inline-flex;
 	align-items: center;
 	gap: 4px;
}

/* Ensure anchor-style buttons inside .stack-row are centered like <button> elements */
.stack-row .button,
.stack-row a.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: normal;
}

.audio-timeline-segments.is-resize-disabled .audio-segment-handle {
	display: none;
}

.audio-timeline-zoom-label {
	font-size: 0.78rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: rgba(18, 49, 75, 0.75);
	min-width: 2.4em;
	text-align: center;
}

.audio-timeline-stage::-webkit-scrollbar {
	height: 5px;
}

.audio-timeline-stage::-webkit-scrollbar-track {
	background: rgba(33, 72, 107, 0.06);
}

.audio-timeline-stage::-webkit-scrollbar-thumb {
	background: rgba(33, 72, 107, 0.25);
	border-radius: 3px;
}

.editor-item.is-timeline-focused {
	border-color: rgba(47, 124, 200, 0.46);
	box-shadow: 0 0 0 3px rgba(47, 124, 200, 0.16);
	transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.layer-block {
	padding: 10px;
	border-radius: 8px;
	background: rgba(245, 250, 255, 0.75);
	border: 1px solid rgba(33, 72, 107, 0.12);
}

.layer-block > .section-heading.is-accordion-head {
	cursor: pointer;
	user-select: none;
	position: relative;
	padding-right: 28px;
}

/* Replace simple unicode arrows with Heroicons (SVG) for better visibility */
.layer-block > .section-heading.is-accordion-head::after {
	content: '';
	position: absolute;
	right: 6px;
	top: 50%;
	transform: translateY(-50%);
	width: 16px;
	height: 16px;
	display: inline-block;
	background-repeat: no-repeat;
	background-position: center;
	background-size: 16px 16px;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2321486b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 5l7 7-7 7'/></svg>");
	opacity: 0.9;
}

.layer-block:not(.is-collapsed) > .section-heading.is-accordion-head::after {
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2321486b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M19 9l-7 7-7-7'/></svg>");
}

.layer-block.is-collapsed .editor-list {
	display: none;
}

.editor-item {
	padding: 10px;
	border-radius: 8px;
	background: #ffffff;
	border: 1px solid rgba(33, 72, 107, 0.12);
}

.mini-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}

.text-metrics-grid {
	margin-bottom: 8px;
}

@media (max-width: 1180px) {
	.editor-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 980px) {
	.admin-shell {
		grid-template-columns: 1fr;
	}

	.form-grid.two-up {
		grid-template-columns: 1fr;
	}

	.editor-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 720px) {
	.admin-shell {
		width: min(100% - 16px, 100%);
	}

	.stack-row.full-row {
		grid-template-columns: 1fr;
	}

	.import-export-actions {
		grid-template-columns: 1fr;
	}

	.preview-toolbar,
	.section-heading {
		flex-direction: column;
		align-items: flex-start;
	}

	.audio-timeline-meta {
		grid-template-columns: 1fr;
		gap: 4px;
	}

	#audioTimelineCurrent,
	#audioTimelineDuration {
		justify-self: start;
	}

	.audio-timeline-foot {
		align-items: flex-start;
	}
}
/* ===== Word Block Edit Popup ===== */
.wb-edit-swal-popup {
	overflow: visible !important;
}

/* Edit modal: three-column layout for audio start, end and play button */
.wb-edit-cols-3 {
	display: grid;
	grid-template-columns: 1fr 1fr auto;
	gap: 12px;
	align-items: center; /* vertically center inputs and button */
}

.wb-edit-play {
	display: flex;
	align-items: center;
	justify-content: flex-start;
}

.wb-edit-play .button {
	width: 40px !important;
	height: 40px !important;
	padding: 0 !important;
	margin: 0 !important; /* override inline margin */
	border-radius: 50% !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	box-shadow: none !important;
}

.wb-edit-play .button:hover {
	transform: none;
}

.size-6 {
	width: 20px;
	height: 20px;
	display: block;
}

/* Ensure SVG inside the swal play button is centered and sized */
.swal2-container .wb-edit-play .button svg,
.swal2-container .wb-edit-play .button .size-6 {
	width: 20px !important;
	height: 20px !important;
	display: block !important;
}

.wb-edit-swal-html {
	overflow-y: auto !important;
	max-height: 68vh;
	text-align: left !important;
	padding: 0 !important;
}

.wb-edit-form {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 4px 20px 12px;
}

.wb-edit-row {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

/* When the row is also the 3-column layout, force grid (higher specificity) */
.wb-edit-row.wb-edit-cols-3 {
	display: grid;
	grid-template-columns: 1fr 1fr auto;
	gap: 12px;
	align-items: center;
}

.wb-edit-cols-2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
}

.wb-edit-cols-4 {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr 1fr;
	gap: 10px;
}

.wb-edit-label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 0.72rem;
	font-weight: 700;
	color: rgba(18, 49, 75, 0.55);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.wb-edit-label > .swal2-input {
	margin: 0 !important;
	width: 100% !important;
	height: 36px;
	font-size: 0.88rem;
	box-sizing: border-box;
}

/* Quill editor inside the edit popup */
#wbeQuillEditor .ql-editor {
	min-height: 160px;
	font-size: 0.9rem;
	font-family: 'Nunito', sans-serif;
}

#wbeQuillEditor .ql-container.ql-snow {
	border-color: rgba(33, 72, 107, 0.22);
	border-radius: 0 0 4px 4px;
}

.wb-edit-swal-html .ql-toolbar.ql-snow {
	border-color: rgba(33, 72, 107, 0.22);
	border-radius: 4px 4px 0 0;
}

.ql-snow .ql-picker-options {
	z-index: 99999 !important;
}

.ql-snow .ql-tooltip {
	z-index: 99999 !important;
}

/* Audio button in Quill toolbar */
.ql-audio::before {
	content: '\1F50A'; /* 🔊 */
	font-size: 0.95rem;
	line-height: 1;
}

.ql-audio {
	width: auto !important;
	padding: 2px 5px !important;
}

/* HTML source button in Quill toolbar */
.ql-html::before {
	content: '</>';
	font-size: 0.78rem;
	font-weight: 800;
	line-height: 1;
	font-family: 'Nunito', sans-serif;
}

.ql-html {
	width: auto !important;
	padding: 2px 6px !important;
}

.wb-edit-html-source-popup {
	max-width: min(94vw, 960px) !important;
}

.wb-edit-html-source-input {
	font-family: Consolas, 'Courier New', monospace !important;
	min-height: 52vh !important;
	line-height: 1.45 !important;
}

/* ── Feature Modes ──────────────────────────────────────────────────────── */

.feature-modes-fieldset {
	border-top: 1px solid rgba(33, 72, 107, 0.12);
	padding-top: 12px;
	display: grid;
	gap: 8px;
}

.feature-modes-head {
	display: flex;
	align-items: baseline;
	gap: 8px;
}

.feature-modes-title {
	font-weight: 700;
	font-size: 0.9rem;
	color: #21486b;
}

.feature-modes-hint {
	font-size: 0.78rem;
	color: rgba(18, 49, 75, 0.6);
}

.feature-modes-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 14px;
}

.feature-toggle {
	display: flex;
	align-items: center;
	gap: 5px;
	cursor: pointer;
	user-select: none;
	font-size: 0.84rem;
	font-weight: 600;
	color: #2c547a;
}

/* Vertical stacked toggle for color inputs */
.feature-toggle.color-vertical {
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
}

.feature-toggle.color-vertical .sp-original-input-container {
	display: flex;
	align-items: center;
	gap: 8px;
}

.feature-toggle.color-vertical .sp-original-input-container .sp-colorize-container {
	width: 28px !important;
	height: 28px !important;
	border-radius: 6px !important;
}

.feature-toggle.color-vertical .setting-spectrum {
	max-width: 140px;
	padding: 6px 8px;
	height: 32px;
	font-size: 0.88rem;
}

.feature-toggle.color-vertical .feature-toggle-label {
	font-size: 0.78rem;
	color: rgba(18, 49, 75, 0.9);
	font-weight: 600;
}

.feature-toggle input[type="checkbox"] {
	accent-color: #2563eb;
	width: 14px;
	height: 14px;
	cursor: pointer;
	flex-shrink: 0;
}

/* ── Feature Visibility ─────────────────────────────────────────────────── */

body:not(.feature-text) [data-feature-section="text"],
body:not(.feature-text) [data-feature-btn="text"] { display: none !important; }

body:not(.feature-audio) [data-feature-section="audio"],
body:not(.feature-audio) #audioTimelineCard,
body:not(.feature-audio) .wb-audio-row { display: none !important; }

body:not(.feature-blocks) [data-feature-section="blocks"],
body:not(.feature-blocks) [data-feature-btn="blocks"] { display: none !important; }

body:not(.feature-dictionary) [data-feature-section="dictionary"],
body:not(.feature-dictionary) #addDictionaryButton { display: none !important; }

body:not(.feature-animation) [data-feature-section="animation"],
body:not(.feature-animation) [data-feature-btn="animation"] { display: none !important; }
