.wb { color: #f2f2f2; }
.wb-how { margin: 12px 0 0; padding-inline-start: 1.2em; color: #d7c9cd; line-height: 1.7; }
.tool-page .wrap:has(#wbApp) { max-width: 1180px; }
.tool-page .wrap:has(#wbApp.is-editing) { max-width: min(1680px, calc(100% - 12px)); }
.tool-page:has(#wbApp.is-editing) .tool-cover,
.tool-page:has(#wbApp.is-editing) .section-head { display: none; }
.tool-page:has(#wbApp.is-editing) nav { margin-bottom: 8px !important; }
.wb-start { display: grid; gap: 22px; }
.wb-kicker { color: #d9ff00; font-weight: 700; margin: 0 0 8px; }
.wb-lead, .wb-note { color: #d7c9cd; line-height: 1.75; }
.wb-start-actions, .wb-top-actions, .wb-selbar { display: flex; flex-wrap: wrap; gap: 8px; }
.wb-btn, .wb-icon {
	min-height: 44px; border-radius: 12px; border: 1px solid rgba(242,242,242,.18);
	background: #14090c; color: #f2f2f2; padding: 8px 12px; font: inherit; cursor: pointer;
}
.wb-btn.primary { background: #d9ff00; color: #14080b; border-color: transparent; font-weight: 800; }
.wb-btn.danger { color: #ffb4b4; }
.wb-btn.is-on, .wb-icon.is-on { background: #d9ff00; color: #14080b; border-color: transparent; font-weight: 800; }
.wb-icon { width: 44px; padding: 0; }
.wb-templates, .wb-saved { display: grid; gap: 8px; }
.wb-card, .wb-saved-row { text-align: start; background: #14090c; border: 1px solid rgba(242,242,242,.12); border-radius: 14px; padding: 12px; color: inherit; }
.wb-card strong, .wb-saved-row strong { display: block; }
.wb-card span, .wb-saved-row span { color: #c3b4b8; font-size: .86rem; }
.wb-count { margin: 0 0 10px; color: #c3b4b8; font-size: .86rem; }
.wb-note a { color: #d9ff00; }
.wb-saved-row { display: flex; gap: 8px; align-items: center; }
.wb-saved-row button[data-open] { flex: 1; min-width: 0; background: transparent; border: 0; color: inherit; text-align: start; cursor: pointer; min-height: 48px; }
.wb-editor { display: flex; flex-direction: column; gap: 8px; min-height: 74vh; }
.wb-editor[hidden], .wb-side[hidden], .wb-selbar[hidden], .wb-toast[hidden], #wbSavedWrap[hidden] { display: none !important; }
.wb-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; top: 56px; z-index: 6; background: rgba(8,8,8,.94); padding: 8px 0; }
.wb-title { flex: 1 1 160px; min-width: 0; background: transparent; border: 0; border-bottom: 1px solid rgba(242,242,242,.16); color: inherit; font-weight: 800; font-size: 1.05rem; padding: 8px 2px; }
.wb-status { color: #d9ff00; background: rgba(217,255,0,.12); border-radius: 999px; padding: 4px 10px; font-size: .78rem; }
.wb-status[data-state="dirty"] { color: #f2f2f2; background: rgba(242,242,242,.1); }
.wb-status[data-state="error"] { color: #ffd0d0; background: rgba(138,9,23,.55); }
.wb-pen { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wb-pen[hidden] { display: none !important; }
.wb-swatch { width: 36px; height: 36px; border-radius: 50%; border: 2px solid rgba(242,242,242,.4); padding: 0; cursor: pointer; }
.wb-swatch.is-on { outline: 2px solid #d9ff00; outline-offset: 2px; }
.wb-main { display: grid; grid-template-columns: 92px minmax(0, 1fr) 260px; gap: 10px; min-height: 62vh; }
.wb-rail, .wb-dock { display: grid; gap: 6px; align-content: start; }
.wb-rail button, .wb-dock button { min-height: 42px; }
.wb-stage { position: relative; overflow: hidden; isolation: isolate; background: #101010; border-radius: 16px; min-height: 240px; height: max(240px, calc(var(--wb-vv, 100dvh) - 260px)); touch-action: none; overscroll-behavior: none; }
.wb-stage.has-grid { background-image: radial-gradient(rgba(255,255,255,.28) 1px, transparent 1px); background-repeat: repeat; }
.wb-stage.is-moving .wb-item { outline: none; }
.wb-stage.is-panning .wb-world { will-change: transform; }
.wb-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.wb-links, .wb-ink { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.wb-item { position: absolute; box-sizing: border-box; user-select: none; touch-action: none; }
.wb-item.is-on { outline: 2px solid #d9ff00; outline-offset: 3px; }
.wb-item.is-locked { outline-style: dashed; }
.wb-shape { border: 2px solid #8A0917; background: #fff; }
.wb-shape.is-ellipse { border-radius: 50%; }
.wb-text, .wb-sticky { background: #fff; color: #1a1214; border-radius: 12px; line-height: 1.6; overflow: visible; }
.wb-sticky { background: #fff4b8; }
.wb-body { min-height: 1.4em; white-space: pre-wrap; overflow-wrap: anywhere; }
.wb-text .wb-body, .wb-sticky .wb-body { height: 100%; box-sizing: border-box; padding: 10px 12px; overflow: hidden; touch-action: none; }
.wb-body[contenteditable="true"] { user-select: text; outline: none; font-size: 16px !important; touch-action: auto; overflow: auto; }
.wb-frame { background: transparent; border: 2px dashed rgba(217,255,0,.8); border-radius: 18px; color: #d9ff00; pointer-events: none; }
.wb-frame .wb-body, .wb-frame .wb-handle { pointer-events: auto; }
.wb-frame .wb-body { font-weight: 800; }
.wb-check { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.wb-show { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: #14090c; border: 1px solid rgba(217,255,0,.4); border-radius: 14px; padding: 8px; }
.wb-show[hidden], .wb-menu[hidden] { display: none !important; }
.wb.is-show .wb-dock, .wb.is-show .wb-selbar, .wb.is-show .wb-rail, .wb.is-show .wb-side, .wb.is-show .wb-top { display: none !important; }
.wb-menu { position: fixed; z-index: 40; display: grid; min-width: 160px; background: #14090c; border: 1px solid rgba(242,242,242,.2); border-radius: 12px; padding: 6px; }
.wb-menu button { min-height: 40px; background: transparent; color: #f2f2f2; border: 0; text-align: start; font: inherit; cursor: pointer; }
.wb-field { width: 100%; background: #0d0709; color: #f2f2f2; border: 1px solid rgba(242,242,242,.16); border-radius: 10px; padding: 8px; font: inherit; font-size: 16px; }
.wb-handle { position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #d9ff00; border: 2px solid #14080b; right: -9px; bottom: -9px; left: auto; cursor: nwse-resize; touch-action: none; z-index: 3; }
@media (pointer: coarse) {
	.wb-handle { width: 32px; height: 32px; right: -16px; bottom: -16px; inset-inline-end: auto; }
}
.wb-side { background: #12090c; border: 1px solid rgba(242,242,242,.12); border-radius: 16px; padding: 10px; overflow: auto; max-height: calc(100dvh - 180px); }
.wb-side label { display: block; margin: 8px 0 4px; color: #c3b4b8; font-size: .82rem; }
.wb-field, .wb-side select, .wb-side input[type="text"], .wb-side input[type="color"] { width: 100%; background: #0d0709; color: #f2f2f2; border: 1px solid rgba(242,242,242,.16); border-radius: 10px; padding: 8px; font: inherit; font-size: 16px; }
.wb-side input[type="color"] { height: 44px; padding: 4px; }
.wb-side-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.wb-dock { display: none; }
.wb-selbar { position: sticky; bottom: 8px; z-index: 7; background: #0c0c0c; border: 1px solid rgba(242,242,242,.16); border-radius: 14px; padding: 8px; }
.wb-file, .wb-live { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.wb-toast { position: fixed; inset-inline: 16px; bottom: 24px; z-index: 1200; margin: 0 auto; max-width: 460px; background: #1a1214; color: #f2f2f2; border: 1px solid rgba(217,255,0,.45); border-radius: 14px; padding: 12px 14px; text-align: center; }
@media (min-width: 901px) {
	#wbExport { display: none; }
	.wb-start { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: start; }
	.wb-hero { position: sticky; top: 12px; }
}
@media (max-width: 900px) {
	.wb-export { display: none !important; }
	.wb.is-export .wb-export { display: inline-flex !important; }
	.wb-main { grid-template-columns: minmax(0, 1fr); }
	.wb-rail { display: none; }
	.wb-side { display: none; position: fixed; inset-inline: 0; bottom: 0; z-index: 30; max-height: 70dvh; border-radius: 16px 16px 0 0; }
	.wb.is-side .wb-side { display: block; }
	.wb-dock { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: sticky; bottom: 0; z-index: 8; background: #0c0c0c; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
	.wb-selbar { bottom: calc(112px + env(safe-area-inset-bottom)); }
	.wb.is-more .wb-selbar { bottom: calc(200px + env(safe-area-inset-bottom)); }
	.wb-toast { bottom: calc(124px + env(safe-area-inset-bottom)); }
	.wb-top { position: static; }
	.wb-stage { height: max(220px, calc(var(--wb-vv, 100dvh) - 200px)); }
	.wb-top-actions { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
	.wb-top-actions .wb-btn,
	.wb-top-actions .wb-icon,
	.wb-top-actions .wb-check,
	.wb-top-actions .wb-status { flex: 0 0 auto; }
	.wb-dock, .wb-selbar, .wb-side { transform: translateY(calc(-1 * var(--wb-key, 0px))); }
	.wb-editor { padding-bottom: max(8px, env(safe-area-inset-bottom)); padding-inline: max(0px, env(safe-area-inset-left)) max(0px, env(safe-area-inset-right)); }
}
@media (max-width: 900px) and (orientation: landscape) {
	.wb-hint { display: none; }
	.wb-stage { height: max(160px, calc(var(--wb-vv, 100dvh) - 132px)); }
	.wb-dock { display: flex; overflow-x: auto; grid-template-columns: none; }
	.wb-dock button { flex: 0 0 auto; }
	.wb-selbar, .wb.is-more .wb-selbar { bottom: calc(64px + env(safe-area-inset-bottom)); }
}
@media (min-width: 901px) and (max-width: 1199px) {
	.wb-main { grid-template-columns: 88px minmax(0, 1fr); }
	.wb-side { display: none; position: fixed; inset-inline-end: 12px; top: 72px; bottom: 12px; width: min(340px, 42vw); z-index: 20; max-height: none; }
	.wb.is-side .wb-side { display: block; }
}
@media (max-width: 359px) {
	.wb-btn { padding: 8px; font-size: .85rem; }
	.wb-dock { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.wb-dock button { font-size: .75rem; padding: 6px 2px; }
}
@media print { .wb { display: none !important; } }

/* الوضع الفاتح. اللوحة نفسها تبقى بألوان عناصرها، والواجهة تتبع العظمي. */
body.light-mode .wb { color: #1a1214; color-scheme: light; }
body.light-mode .wb-lead,
body.light-mode .wb-note,
body.light-mode .wb-hint,
body.light-mode .wb-card span,
body.light-mode .wb-saved-row span,
body.light-mode .wb-count,
body.light-mode .wb-side label { color: #3d3438; }
body.light-mode .wb-kicker,
body.light-mode .wb-note a { color: #6E0712; }
body.light-mode .wb-btn,
body.light-mode .wb-icon,
body.light-mode .wb-card,
body.light-mode .wb-saved-row,
body.light-mode .wb-menu,
body.light-mode .wb-show,
body.light-mode .wb-field,
body.light-mode .wb-side select,
body.light-mode .wb-side input[type="text"],
body.light-mode .wb-title {
	background: #fff;
	color: #1a1214;
	border-color: rgba(5, 5, 5, .16);
}
body.light-mode .wb-saved-row button[data-open],
body.light-mode .wb-menu button { color: #1a1214; background: transparent; }
body.light-mode .wb-btn.primary,
body.light-mode .wb-btn.is-on,
body.light-mode .wb-icon.is-on {
	background: #d9ff00;
	color: #14080b;
	border-color: transparent;
}
body.light-mode .wb-btn.danger { color: #8A0917; }
body.light-mode .wb-top,
body.light-mode .wb-selbar,
body.light-mode .wb-dock,
body.light-mode .wb-side,
body.light-mode .wb-toast {
	background: #f7f4f2;
	color: #1a1214;
	border-color: rgba(5, 5, 5, .12);
}
body.light-mode .wb-stage { background: #ece7e3; }
body.light-mode .wb-stage.has-grid { background-image: radial-gradient(rgba(0, 0, 0, .22) 1px, transparent 1px); }
body.light-mode .wb-status { color: #14080b; background: rgba(217, 255, 0, .55); }
body.light-mode .wb-status[data-state="dirty"] { color: #1a1214; background: rgba(5, 5, 5, .08); }
body.light-mode .wb-status[data-state="error"] { color: #fff; background: #8A0917; }
body.light-mode .wb-how { color: #3d3438; }
body.light-mode .wb-item.is-on { outline-color: #8A0917; }
body.light-mode .wb-swatch { border-color: rgba(5, 5, 5, .35); }
body.light-mode .wb-swatch.is-on { outline-color: #8A0917; }
body.light-mode .wb-check input { accent-color: #8A0917; }
body.light-mode .wb-field::placeholder { color: #6b5e63; }
