/* Конструктор Древо Рода — Релиз 1 (Web-to-Print, без оплаты). */

/* display:flex у модалки перекрывает UA-стиль [hidden] — возвращаем. */
.rd-designer [hidden] { display: none !important; }

.rd-designer {
	--rd-ds-green: #5f7f6a;
	--rd-ds-green-dark: #22302a;
	--rd-ds-accent: #9fd8b5;
	--rd-ds-line: #d8e4dc;
	font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
	color: #1d2b24;
	max-width: 1280px;
	margin: 0 auto;
	border: 1px solid var(--rd-ds-line);
	border-radius: 12px;
	overflow: hidden;
	background: #fff;
}

.rd-ds-top {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
	align-items: center;
	padding: 10px 14px;
	background: linear-gradient(160deg, #f2f5f3, #e6ede9);
	border-bottom: 1px solid var(--rd-ds-line);
}
.rd-ds-brand { font-weight: 700; color: var(--rd-ds-green-dark); margin-right: 4px; }
.rd-ds-formats, .rd-ds-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.rd-ds-btn {
	border: 1px solid var(--rd-ds-line);
	background: #fff;
	color: #1d2b24;
	border-radius: 8px;
	padding: 6px 12px;
	font-size: 13px;
	cursor: pointer;
	line-height: 1.2;
}
.rd-ds-btn:hover { border-color: var(--rd-ds-green); background: #f6faf8; }
.rd-ds-btn.rd-ds-primary { background: var(--rd-ds-green); border-color: var(--rd-ds-green); color: #fff; }
.rd-ds-btn.rd-ds-primary:hover { background: #4e6b58; }
.rd-ds-btn.rd-ds-sm { padding: 4px 8px; font-size: 12px; }
.rd-ds-btn.rd-ds-danger { color: #a33; border-color: #e3c9c9; }
.rd-ds-btn.rd-ds-fmt.active { background: var(--rd-ds-green-dark); border-color: var(--rd-ds-green-dark); color: #fff; }

.rd-ds-main { display: flex; min-height: 640px; }
.rd-ds-side {
	width: 250px;
	flex: 0 0 250px;
	border-right: 1px solid var(--rd-ds-line);
	background: #fafcfb;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	overflow-y: auto;
	position: relative;
	z-index: 2; /* кнопки панелей перекрывались сценой холста */
}
.rd-ds-panel h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: #4a554e; }
.rd-ds-layers { list-style: none; margin: 0; padding: 0; max-height: 200px; overflow: auto; }
.rd-ds-layers li {
	padding: 5px 8px;
	border: 1px solid transparent;
	border-radius: 6px;
	font-size: 13px;
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.rd-ds-layers li:hover { background: #f0f5f2; }
.rd-ds-layers li.selected { border-color: var(--rd-ds-green); background: #e9f2ed; }
.rd-ds-layers li.hidden-obj { opacity: .45; }
.rd-ds-layer-btns { display: flex; gap: 6px; margin-top: 8px; }

.rd-ds-panel label { display: block; font-size: 12px; color: #4a554e; margin-bottom: 8px; }
.rd-ds-panel input[type="number"], .rd-ds-panel input[type="color"], .rd-ds-panel textarea {
	width: 100%;
	border: 1px solid var(--rd-ds-line);
	border-radius: 6px;
	padding: 5px 7px;
	font-size: 13px;
	margin-top: 3px;
	box-sizing: border-box;
}
.rd-ds-panel input[type="color"] { height: 34px; padding: 2px; }
.rd-ds-muted { font-size: 12px; color: #8a958e; }

.rd-ds-stage {
	flex: 1;
	position: relative;
	background: repeating-conic-gradient(#eef2f0 0% 25%, #ffffff 0% 50%) 50% / 28px 28px;
	overflow: auto;
	padding: 28px;
	display: flex;
	justify-content: center;
	align-items: flex-start;
}
.rd-ds-canvas-wrap { position: relative; box-shadow: 0 10px 30px rgba(0,0,0,.18); background: #fff; }
.rd-ds-canvas-wrap .canvas-container { background: #fff; }

.rd-ds-dropzone-hint {
	position: absolute;
	inset: 14px;
	border: 3px dashed var(--rd-ds-green);
	border-radius: 12px;
	background: rgba(233, 242, 237, .92);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	color: var(--rd-ds-green-dark);
	pointer-events: none;
	z-index: 5;
}

.rd-ds-modal {
	position: fixed;
	inset: 0;
	background: rgba(16, 24, 21, .55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	padding: 20px;
}
.rd-ds-modal-box {
	background: #fff;
	border-radius: 12px;
	max-width: 720px;
	width: 100%;
	max-height: 82vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.rd-ds-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--rd-ds-line); }
.rd-ds-modal-head h3 { margin: 0; font-size: 16px; }
.rd-ds-modal-body { padding: 14px 16px; overflow: auto; }

.rd-ds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.rd-ds-tpl {
	border: 1px solid var(--rd-ds-line);
	border-radius: 10px;
	padding: 10px;
	cursor: pointer;
	text-align: center;
	background: #fafcfb;
}
.rd-ds-tpl:hover { border-color: var(--rd-ds-green); }
.rd-ds-tpl .rd-ds-tpl-name { font-size: 13px; margin-top: 6px; }
.rd-ds-tpl .rd-ds-tpl-mini {
	height: 90px;
	border-radius: 6px;
	background: #fff;
	border: 1px solid var(--rd-ds-line);
	position: relative;
	overflow: hidden;
}
.rd-ds-tpl-mini::after {
	content: "";
	position: absolute;
	inset: 14%;
	border: 2px solid var(--rd-ds-accent);
	border-radius: 4px;
}

.rd-ds-thumb {
	border: 1px solid var(--rd-ds-line);
	border-radius: 8px;
	overflow: hidden;
	background: #fff;
	cursor: grab;
}
.rd-ds-thumb img { display: block; width: 100%; height: 110px; object-fit: cover; }
.rd-ds-thumb .rd-ds-thumb-cap { font-size: 11px; padding: 4px 6px; color: #4a554e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rd-ds-toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--rd-ds-green-dark);
	color: #fff;
	font-size: 14px;
	padding: 10px 20px;
	border-radius: 22px;
	z-index: 1100;
	max-width: 90vw;
}

/* Книги и Альбомы: рабочая колонка + нижняя панель страниц. */

.rd-ds-workcol { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rd-ds-spread { display: flex; gap: 0; align-items: flex-start; justify-content: center; }
.rd-ds-spread-page {
	position: relative;
	box-shadow: 0 10px 30px rgba(0,0,0,.18);
	background: #fff;
	margin-right: 2px;
}
.rd-ds-spread-page img { display: block; }
.rd-ds-spread-label {
	position: absolute;
	top: -20px;
	left: 0;
	font-size: 11px;
	color: #4a554e;
}

/* Структура книги: корешок между половинами разворота. */
.rd-ds-spine {
	flex: 0 0 auto;
	width: 26px;
	align-self: stretch;
	background: repeating-linear-gradient(45deg, #d8d2c6, #d8d2c6 4px, #cfc8ba 4px, #cfc8ba 8px);
	border-left: 1px solid #b9b1a1;
	border-right: 1px solid #b9b1a1;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 120px;
}
.rd-ds-spine span {
	writing-mode: vertical-rl;
	transform: rotate(180deg);
	font-size: 10px;
	letter-spacing: 2px;
	color: #6b6353;
	text-transform: uppercase;
	user-select: none;
}

/* Ярлык над холстом: чем является текущая страница. */
.rd-ds-stage-badge {
	position: absolute;
	top: -24px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 12px;
	font-weight: 600;
	color: #33413a;
	background: #e7efe9;
	border: 1px solid #c4d4ca;
	border-radius: 12px;
	padding: 2px 12px;
	white-space: nowrap;
	z-index: 5;
	user-select: none;
}

/* Лента страниц: пары-развороты. */
.rd-ds-spread-pair { display: flex; flex: 0 0 auto; }
.rd-ds-spread-pair .rd-ds-thumb-page { border-radius: 0; }
.rd-ds-spread-pair .rd-ds-thumb-page:first-child { border-right-width: 1px; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.rd-ds-spread-pair .rd-ds-thumb-page:last-child { border-left-width: 1px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.rd-ds-pair-spine {
	flex: 0 0 auto;
	width: 6px;
	background: #b9b1a1;
	cursor: default;
}

.rd-ds-pages {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 14px;
	background: linear-gradient(0deg, #f2f5f3, #eef2ef);
	border-top: 1px solid var(--rd-ds-line);
	min-height: 86px;
}
.rd-ds-pages-label { font-size: 12px; color: #4a554e; white-space: nowrap; }
.rd-ds-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px; flex: 1; }
.rd-ds-thumb-page {
	position: relative;
	border: 2px solid var(--rd-ds-line);
	border-radius: 6px;
	overflow: hidden;
	cursor: pointer;
	flex: 0 0 auto;
	background: #fff;
	line-height: 0;
}
.rd-ds-thumb-page.active { border-color: var(--rd-ds-green); box-shadow: 0 0 0 2px rgba(95,127,106,.25); }
.rd-ds-thumb-page.is-master { border-style: dashed; }
.rd-ds-thumb-page img { width: 44px; height: auto; display: block; }
.rd-ds-thumb-page .rd-ds-thumb-num {
	position: absolute;
	bottom: 0;
	left: 0;
	background: rgba(34,48,42,.75);
	color: #fff;
	font-size: 9px;
	padding: 1px 4px;
	line-height: 1.3;
}
.rd-ds-thumb-page .rd-ds-thumb-x {
	position: absolute;
	top: 0;
	right: 0;
	border: none;
	background: rgba(170,51,51,.85);
	color: #fff;
	font-size: 10px;
	line-height: 1;
	padding: 3px 4px;
	cursor: pointer;
	border-radius: 0 0 0 4px;
}
.rd-ds-thumb-page .rd-ds-thumb-copy {
	position: absolute;
	top: 0;
	left: 0;
	border: none;
	background: rgba(95,127,106,.85);
	color: #fff;
	font-size: 10px;
	line-height: 1;
	padding: 3px 4px;
	cursor: pointer;
	border-radius: 0 0 4px 0;
}
.rd-ds-thumb-page.drag-over { border-color: var(--rd-ds-accent); }
.rd-ds-page-add { font-size: 18px; width: 40px; height: 56px; }

.rd-ds-mode-hint { margin-top: 6px; }
.rd-ds-modes { display: flex; gap: 6px; flex-wrap: wrap; }
.rd-ds-mode.active { background: var(--rd-ds-green-dark); border-color: var(--rd-ds-green-dark); color: #fff; }
.rd-ds-theme-pick { font-size: 13px; color: #4a554e; }
.rd-ds-theme-pick select {
	border: 1px solid var(--rd-ds-line);
	border-radius: 8px;
	padding: 5px 7px;
	font-size: 13px;
	background: #fff;
}

/* Модалка персон: кнопка «Собрать страницу». */
.rd-ds-person-row {
	display: flex;
	gap: 10px;
	align-items: center;
	border: 1px solid var(--rd-ds-line);
	border-radius: 10px;
	padding: 8px;
	margin-bottom: 8px;
	background: #fff;
}
.rd-ds-person-row img { width: 52px; height: 64px; object-fit: cover; border-radius: 6px; flex: 0 0 52px; }
.rd-ds-person-info { flex: 1; min-width: 0; }
.rd-ds-person-name { font-size: 14px; font-weight: 600; color: #1d2b24; }
.rd-ds-person-years { font-size: 12px; color: #4a554e; }
.rd-ds-person-bio { font-size: 12px; color: #8a958e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rd-ds-tabs { display: flex; gap: 8px; margin-bottom: 12px; border-bottom: 1px solid var(--rd-ds-line); }
.rd-ds-tab {
	border: none;
	background: none;
	font-size: 14px;
	padding: 6px 10px;
	cursor: pointer;
	color: #4a554e;
	border-bottom: 2px solid transparent;
}
.rd-ds-tab.active { color: var(--rd-ds-green-dark); border-bottom-color: var(--rd-ds-green); font-weight: 600; }

@media (max-width: 900px) {
	.rd-ds-main { flex-direction: column; }
	.rd-ds-side { width: auto; flex: none; border-right: none; border-top: 1px solid var(--rd-ds-line); }
	.rd-ds-stage { padding: 14px; }
}

/* Блок Д: AR-плеер книги. */
.rd-ar-reader { position: relative; min-height: 100vh; background: #000; }
.rd-ar-reader #rd-ar-canvas { position: fixed; inset: 0; display: block; width: 100vw; height: 100dvh; }
.rd-ar-reader #rd-ar-status {
	position: fixed; top: calc(env(safe-area-inset-top) + 16px); left: 50%; transform: translateX(-50%);
	background: rgba(0,0,0,.6); color: #fff; font: 14px system-ui, sans-serif;
	padding: 8px 16px; border-radius: 20px; z-index: 1; text-align: center; max-width: 90vw;
}
.rd-ar-reader #rd-ar-help {
	position: fixed; bottom: calc(env(safe-area-inset-bottom) + 16px); left: 50%; transform: translateX(-50%);
	background: rgba(0,0,0,.55); color: #d8e4dc; font: 12px system-ui, sans-serif;
	padding: 8px 14px; border-radius: 12px; z-index: 1; text-align: center; max-width: 92vw;
}
.rd-ds-ar { border-color: #9fd8b5; color: #2c5; }
