/* Infinite Board */

html.ib-lock, html.ib-lock body { overflow: hidden !important; }

.ib-root, .ib-root * { box-sizing: border-box; }
.ib-root {
	position: relative;
	overflow: hidden;
	width: 100%;
	font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: #0f172a;
	background: #f4f5f8;
	-webkit-font-smoothing: antialiased;
}
.ib-root.ib-fullscreen { position: fixed; inset: 0; z-index: 999999; width: auto; }
body.admin-bar .ib-root.ib-fullscreen { top: 32px; }
@media (max-width: 782px) { body.admin-bar .ib-root.ib-fullscreen { top: 46px; } }

.ib-root button, .ib-root input, .ib-root a { font: inherit; letter-spacing: normal; text-transform: none; text-shadow: none; }

/* ---------- Полотно ---------- */

.ib-vp {
	position: absolute; inset: 0; overflow: hidden; z-index: 1;
	background-color: #f4f5f8;
	background-image: radial-gradient(circle, #c3c9d6 1.2px, transparent 1.5px);
	touch-action: none; user-select: none; -webkit-user-select: none;
	cursor: default;
}
.ib-vp.ib-nogrid { background-image: none; }
.ib-vp.ib-panning { cursor: grabbing; }
.ib-world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }
.ib-overlay { pointer-events: none; z-index: 2; }

/* ---------- Объекты ---------- */

.ib-obj { position: absolute; cursor: move; user-select: none; -webkit-user-select: none; }
.ib-obj img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; -webkit-user-drag: none; }

.ib-card { border-radius: 3px; box-shadow: 0 1px 2px rgba(15,23,42,.18), 0 6px 14px rgba(15,23,42,.10); }
.ib-dot  { border-radius: 50%; box-shadow: 0 1px 2px rgba(15,23,42,.25), 0 3px 8px rgba(15,23,42,.12); }
.ib-text { background: transparent; }
.ib-text:hover { outline: 1px dashed #94a3b8; }
.ib-text.ib-editing { outline: 1px dashed #2563eb; }
.ib-image { box-shadow: 0 1px 3px rgba(15,23,42,.25); background: #fff; }

.ib-box { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.ib-card .ib-box { padding: 14px; }
.ib-text .ib-box { padding: 4px 6px; }

.ib-t {
	flex: 0 0 auto; width: 100%;
	font-size: 24px; font-weight: 500; line-height: 1.2;
	white-space: pre-wrap; overflow-wrap: normal; word-break: normal;
	outline: none; cursor: inherit; text-align: center;
}
.ib-text .ib-t { text-align: left; color: #111827; }
.ib-editing { cursor: text; }
.ib-editing .ib-t { user-select: text; -webkit-user-select: text; cursor: text; }
.ib-editing .ib-t:empty::before { content: attr(data-ph); opacity: .4; }

/* ---------- Рамка выделения и ручки ресайза ---------- */

.ib-sel { position: absolute; pointer-events: none; border: calc(2px * var(--iz, 1)) solid #2563eb; }
.ib-h {
	position: absolute; pointer-events: auto; z-index: 1;
	background: transparent; border: 0;
}
.ib-h-nw, .ib-h-ne, .ib-h-sw, .ib-h-se {
	z-index: 3; width: calc(11px * var(--iz, 1)); height: calc(11px * var(--iz, 1));
	background: #fff; border: calc(1.5px * var(--iz, 1)) solid #2563eb; border-radius: calc(2px * var(--iz, 1));
}
.ib-h-nw { left: 0; top: 0; transform: translate(-50%, -50%); cursor: nwse-resize; }
.ib-h-se { left: 100%; top: 100%; transform: translate(-50%, -50%); cursor: nwse-resize; }
.ib-h-ne { left: 100%; top: 0; transform: translate(-50%, -50%); cursor: nesw-resize; }
.ib-h-sw { left: 0; top: 100%; transform: translate(-50%, -50%); cursor: nesw-resize; }

.ib-h-n, .ib-h-s { left: 0; width: 100%; height: calc(12px * var(--iz, 1)); cursor: ns-resize; }
.ib-h-n { top: 0; transform: translateY(-50%); }
.ib-h-s { top: 100%; transform: translateY(-50%); }
.ib-h-e, .ib-h-w { top: 0; height: 100%; width: calc(12px * var(--iz, 1)); cursor: ew-resize; }
.ib-h-e { left: 100%; transform: translateX(-50%); }
.ib-h-w { left: 0; transform: translateX(-50%); }

.ib-h-n::after, .ib-h-s::after, .ib-h-e::after, .ib-h-w::after {
	content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
	background: #fff; border: calc(1.5px * var(--iz, 1)) solid #2563eb; border-radius: calc(3px * var(--iz, 1));
}
.ib-h-n::after, .ib-h-s::after { width: calc(20px * var(--iz, 1)); height: calc(7px * var(--iz, 1)); }
.ib-h-e::after, .ib-h-w::after { width: calc(7px * var(--iz, 1)); height: calc(20px * var(--iz, 1)); }

/* ---------- Панель цветов над объектом ---------- */

.ib-tb {
	position: absolute; left: 50%; bottom: 100%;
	margin-bottom: calc(14px * var(--iz, 1));
	transform: translateX(-50%) scale(var(--iz, 1)); transform-origin: 50% 100%;
	display: flex; align-items: center; gap: 5px; padding: 6px 8px;
	background: #fff; border-radius: 10px; box-shadow: 0 4px 18px rgba(15,23,42,.22);
	pointer-events: auto; white-space: nowrap; z-index: 5;
}
.ib-sw {
	width: 22px; height: 22px; padding: 0; border-radius: 50%; cursor: pointer;
	border: 2px solid rgba(15,23,42,.14); outline: none;
}
.ib-sw:hover { transform: scale(1.12); }
.ib-sw.on { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.25); }
.ib-swc {
	-webkit-appearance: none; appearance: none;
	width: 22px; height: 22px; padding: 0; border: 2px dashed rgba(15,23,42,.35); border-radius: 50%;
	background: none; cursor: pointer; overflow: hidden;
}
.ib-swc::-webkit-color-swatch-wrapper { padding: 0; }
.ib-swc::-webkit-color-swatch { border: 0; border-radius: 50%; }
.ib-swc::-moz-color-swatch { border: 0; border-radius: 50%; }

/* ---------- Интерфейс поверх доски ---------- */

.ib-pre .ib-ui { display: none !important; }
.ib-ui { position: absolute; z-index: 10; }

.ib-panel {
	left: 16px; top: 50%; transform: translateY(-50%);
	display: flex; flex-direction: column; gap: 4px; padding: 8px;
	background: #fff; border-radius: 14px; box-shadow: 0 4px 20px rgba(15,23,42,.16);
}
.ib-pitem {
	width: 66px; padding: 9px 4px 7px; text-align: center; font-size: 12px; color: #475569;
	border-radius: 10px; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
}
.ib-pitem:hover { background: #eff6ff; color: #1d4ed8; }
.ib-pitem span { display: block; margin-top: 5px; }
.ib-ico { width: 38px; height: 38px; margin: 0 auto; }
.ib-ico-card { background: #fff59d; border-radius: 3px; box-shadow: 0 1px 2px rgba(15,23,42,.3), 0 3px 7px rgba(15,23,42,.12); }
.ib-ico-dot { width: 26px; height: 26px; margin: 6px auto; background: #2563eb; border-radius: 50%; box-shadow: 0 1px 3px rgba(15,23,42,.35); }
.ib-ico-text { border: 1.5px dashed #94a3b8; border-radius: 4px; text-align: center; font: 700 22px/35px Georgia, serif; color: #334155; }

.ib-ghost {
	position: fixed; display: none; z-index: 1000002; pointer-events: none;
	transform: translate(-50%, -50%); opacity: .85;
}
.ib-ghost-card { background: #fff59d; border-radius: 3px; box-shadow: 0 8px 22px rgba(15,23,42,.3); }
.ib-ghost-dot  { background: #2563eb; border-radius: 50%; box-shadow: 0 6px 16px rgba(15,23,42,.35); }
.ib-ghost-text { border: 1.5px dashed #64748b; border-radius: 3px; background: rgba(255,255,255,.4); }

.ib-titlebar {
	left: 16px; top: 16px; display: flex; align-items: center; gap: 10px;
	padding: 6px 8px 6px 6px; background: #fff; border-radius: 12px; box-shadow: 0 4px 20px rgba(15,23,42,.16);
	max-width: calc(100% - 330px);
}
.ib-back {
	width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px;
	color: #334155; text-decoration: none; font-size: 18px; background: #f1f5f9;
}
.ib-back:hover { background: #e2e8f0; }
.ib-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ib-presence { right: 16px; top: 16px; display: flex; align-items: center; gap: 6px; }
.ib-avatar {
	width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
	font-size: 13px; font-weight: 700; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(15,23,42,.25);
	user-select: none; cursor: default;
}
.ib-avatar.ib-me { box-shadow: 0 0 0 2px #2563eb, 0 2px 8px rgba(15,23,42,.25); }
.ib-avatar.ib-more { background: #e2e8f0; color: #334155; }
.ib-avatar.ib-pop { animation: ib-pop .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes ib-pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.ib-zoom {
	right: 16px; bottom: 16px; display: flex; align-items: center; gap: 2px; padding: 4px;
	background: #fff; border-radius: 12px; box-shadow: 0 4px 20px rgba(15,23,42,.16);
}
.ib-zbtn {
	min-width: 34px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px;
	background: transparent; color: #334155; font-size: 16px; cursor: pointer; line-height: 1;
}
.ib-zbtn:hover { background: #f1f5f9; }
.ib-zpct { font-size: 13px; min-width: 54px; }

.ib-hint { left: 16px; bottom: 16px; max-width: calc(100% - 330px); font-size: 12px; color: #64748b; pointer-events: none; }

/* ---------- Контекстное меню ---------- */

.ib-menu {
	position: fixed; z-index: 1000001; min-width: 220px; padding: 4px;
	background: #fff; border-radius: 10px; box-shadow: 0 8px 30px rgba(15,23,42,.28), 0 0 0 1px rgba(15,23,42,.06);
	font-size: 14px; user-select: none;
}
.ib-mi {
	position: relative; display: flex; align-items: center; gap: 6px;
	padding: 7px 10px 7px 6px; border-radius: 6px; cursor: pointer; color: #0f172a;
}
.ib-mi:hover { background: #eff6ff; }
.ib-mi.ib-danger { color: #dc2626; }
.ib-mi.ib-danger:hover { background: #fef2f2; }
.ib-mcheck { width: 16px; text-align: center; color: #2563eb; font-weight: 700; }
.ib-mlabel { flex: 1; white-space: nowrap; }
.ib-marrow { color: #94a3b8; font-size: 16px; }
.ib-msep { height: 1px; margin: 4px 2px; background: #e5e7eb; }
.ib-mhead { padding: 6px 10px 2px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: #94a3b8; }
.ib-menu.ib-sub-menu { display: none; position: absolute; left: calc(100% - 2px); top: -5px; }
.ib-mi:hover > .ib-sub-menu { display: block; }
.ib-ctx.ib-flip .ib-sub-menu { left: auto; right: calc(100% - 2px); }

/* ---------- Окна ---------- */

.ib-backdrop {
	position: absolute; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
	background: rgba(15,23,42,.38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); padding: 16px;
}
.ib-backdrop.ib-flat { background: #f4f5f8; -webkit-backdrop-filter: none; backdrop-filter: none; overflow: auto; }
.ib-modal {
	width: min(440px, 100%); max-height: 100%; overflow: auto; padding: 28px;
	background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(15,23,42,.35);
}
.ib-modal h2 { margin: 0 0 6px; font-size: 22px; line-height: 1.25; color: #0f172a; }
.ib-modal h3 { margin: 22px 0 8px; font-size: 14px; color: #475569; }
.ib-sub { margin: 0 0 18px; color: #64748b; }
.ib-label { display: block; margin-bottom: 6px; font-weight: 600; }
.ib-input {
	display: block; width: 100%; padding: 11px 14px; font-size: 16px; color: #0f172a; background: #fff;
	border: 1px solid #cbd5e1; border-radius: 10px; outline: none; box-shadow: none; height: auto;
}
.ib-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.ib-btn {
	display: inline-block; padding: 10px 18px; border: 0; border-radius: 10px; cursor: pointer;
	background: #e2e8f0; color: #0f172a; font-weight: 600; text-decoration: none;
}
.ib-btn:hover { background: #cbd5e1; }
.ib-btn.ib-small { padding: 6px 12px; font-size: 13px; font-weight: 500; }
.ib-btn.ib-primary { background: #2563eb; color: #fff; }
.ib-btn.ib-primary:hover { background: #1d4ed8; }
.ib-btn:disabled { opacity: .6; cursor: default; }
.ib-modal form > .ib-btn { width: 100%; margin-top: 14px; }
.ib-row { display: flex; gap: 8px; }
.ib-row .ib-btn { white-space: nowrap; }
.ib-err { min-height: 20px; margin-top: 8px; color: #dc2626; font-size: 13px; }
.ib-muted { color: #94a3b8; }
.ib-link { display: inline-block; margin-top: 16px; color: #64748b; text-decoration: none; font-size: 13px; }
.ib-link:hover { color: #2563eb; }

.ib-boards { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.ib-board-link {
	display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: 8px;
	background: #f8fafc; color: #0f172a; text-decoration: none; border: 1px solid #eef2f7;
}
.ib-board-link:hover { background: #eff6ff; border-color: #bfdbfe; }
.ib-online { color: #16a34a; font-size: 12px; }

.ib-small-modal { width: min(400px, 100%); }
.ib-props { margin: 14px 0 6px; }
.ib-prow { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid #eef2f7; }
.ib-pk { width: 130px; flex: none; color: #64748b; }
.ib-pv { flex: 1; font-weight: 500; }
.ib-author { display: inline-flex; align-items: center; gap: 7px; }
.ib-pdot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.ib-actions { margin-top: 18px; text-align: right; }

/* ---------- Уведомления ---------- */

.ib-toast {
	position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); z-index: 200;
	padding: 10px 18px; border-radius: 999px; background: #0f172a; color: #fff; font-size: 14px;
	box-shadow: 0 6px 24px rgba(15,23,42,.35); max-width: 90%;
}
.ib-offline {
	position: absolute; left: 50%; top: 16px; transform: translateX(-50%); z-index: 200;
	padding: 8px 16px; border-radius: 999px; background: #fef3c7; color: #92400e; font-size: 13px;
	box-shadow: 0 4px 16px rgba(15,23,42,.2);
}

@media (max-width: 640px) {
	.ib-hint { display: none; }
	.ib-titlebar { max-width: calc(100% - 32px); top: 64px; }
}

/* ---------- Защита от стилей темы и тёмных режимов ----------
   Окна входа всегда светлые: белый фон и тёмный текст, что бы ни задавала тема. */

.ib-root { color-scheme: light; }
.ib-root .ib-modal { background: #fff !important; color: #0f172a !important; }
.ib-root .ib-modal h2,
.ib-root .ib-modal h3 { color: #0f172a !important; background: none !important; border: 0 !important; text-shadow: none !important; }
.ib-root .ib-modal h3 { color: #475569 !important; }
.ib-root .ib-modal .ib-sub { color: #64748b !important; }
.ib-root .ib-modal .ib-label { color: #0f172a !important; }
.ib-root .ib-modal .ib-muted { color: #94a3b8 !important; }
.ib-root .ib-modal .ib-err { color: #dc2626 !important; }
.ib-root .ib-modal .ib-link { color: #64748b !important; background: none !important; }
.ib-root .ib-modal .ib-pk { color: #64748b !important; }

.ib-root .ib-input,
.ib-root .ib-input:hover,
.ib-root .ib-input:focus {
	background: #fff !important; background-color: #fff !important;
	color: #0f172a !important; -webkit-text-fill-color: #0f172a !important; caret-color: #0f172a;
	border: 1px solid #cbd5e1 !important; box-shadow: none !important; opacity: 1 !important;
}
.ib-root .ib-input:focus { border-color: #2563eb !important; box-shadow: 0 0 0 3px rgba(37,99,235,.18) !important; }
.ib-root .ib-input::placeholder { color: #94a3b8 !important; -webkit-text-fill-color: #94a3b8 !important; opacity: 1; }
.ib-root .ib-input:-webkit-autofill,
.ib-root .ib-input:-webkit-autofill:focus {
	-webkit-text-fill-color: #0f172a !important;
	-webkit-box-shadow: 0 0 0 100px #fff inset !important; box-shadow: 0 0 0 100px #fff inset !important;
}

.ib-root .ib-btn { background: #e2e8f0 !important; color: #0f172a !important; border: 0 !important; box-shadow: none !important; }
.ib-root .ib-btn:hover { background: #cbd5e1 !important; }
.ib-root .ib-btn.ib-primary { background: #2563eb !important; color: #fff !important; }
.ib-root .ib-btn.ib-primary:hover { background: #1d4ed8 !important; }
.ib-root .ib-board-link { background: #f8fafc !important; color: #0f172a !important; }
.ib-root .ib-board-link:hover { background: #eff6ff !important; }

/* Панели на самой доске */
.ib-root .ib-title { color: #0f172a !important; }
.ib-root .ib-back { color: #334155 !important; background: #f1f5f9 !important; }
.ib-root .ib-pitem { color: #475569 !important; }
.ib-root .ib-zbtn { color: #334155 !important; background: transparent !important; }
.ib-root .ib-zbtn:hover { background: #f1f5f9 !important; }
.ib-root .ib-menu, .ib-root .ib-menu .ib-mi { color: #0f172a !important; }
.ib-root .ib-menu .ib-mi.ib-danger { color: #dc2626 !important; }
.ib-root .ib-modal .ib-online { color: #16a34a !important; }
.ib-root .ib-modal .ib-board-link span:first-child { color: #0f172a !important; }
.ib-mhint { margin-left: 18px; color: #94a3b8; font-size: 12px; }
.ib-root .ib-menu .ib-mhint { color: #94a3b8 !important; }

/* ---------- Группа выделенных объектов, рамка выделения ---------- */

.ib-picked { outline: calc(2px * var(--iz, 1)) solid #2563eb; outline-offset: 0; }
.ib-gsel {
	position: absolute; pointer-events: none;
	border: calc(1.5px * var(--iz, 1)) dashed #2563eb; background: rgba(37,99,235,.05);
	margin: calc(-6px * var(--iz, 1)); padding: calc(6px * var(--iz, 1)); box-sizing: content-box;
}
.ib-marquee {
	position: absolute; z-index: 6; pointer-events: none;
	border: 1px solid #2563eb; background: rgba(37,99,235,.12);
}
.ib-vp.ib-selmode { cursor: crosshair; }

/* ---------- Панель инструментов: режим выделения ---------- */

.ib-psep { height: 1px; margin: 4px 8px; background: #e5e7eb; }
.ib-pmode.on { background: #dbeafe; color: #1d4ed8 !important; }
.ib-ico-sel { width: 30px; height: 26px; margin: 6px auto; border: 2px dashed #2563eb; border-radius: 3px; background: rgba(37,99,235,.10); }

/* ---------- Отмена/возврат ---------- */

.ib-zsep { width: 1px; height: 20px; margin: 0 4px; background: #e5e7eb; }
.ib-root .ib-zbtn:disabled { opacity: .3; cursor: default; background: transparent !important; }

/* ---------- Панель рамки текстового блока ---------- */

.ib-tbl { font-size: 12px; color: #64748b; margin-right: 2px; }
.ib-root .ib-tb .ib-tbl { color: #64748b !important; }
.ib-tbsep { width: 1px; height: 20px; margin: 0 3px; background: #e5e7eb; }
.ib-bwb {
	min-width: 28px; height: 24px; padding: 0 6px; border: 1px solid #cbd5e1; border-radius: 6px;
	background: #fff; color: #334155; font-size: 12px; cursor: pointer; line-height: 1;
}
.ib-root .ib-tb .ib-bwb { background: #fff !important; color: #334155 !important; }
.ib-root .ib-tb .ib-bwb.on { background: #2563eb !important; color: #fff !important; border-color: #2563eb; }

/* Закреплённые объекты */
.ib-obj.ib-locked { cursor: default; }
.ib-obj.ib-locked::after { content: "\1F512"; position: absolute; right: 4px; top: 4px; font-size: 14px; line-height: 1; pointer-events: none; opacity: .75; }
.ib-sel[data-locked="1"] .ib-h { display: none !important; }
.ib-sel[data-locked="1"] { border-style: dashed !important; }

.ib-ico-img { width: 30px; height: 24px; margin: 7px auto; border: 2px solid #64748b; border-radius: 3px; background: linear-gradient(135deg, transparent 55%, #94a3b8 55%) , #e2e8f0; }
