.ps { color: #f2f2f2; max-width: 100%; }
.ps-start, .ps-hero, .ps-library, .ps-editor, .ps-body, .ps-stage, .ps-sheet-wrap, .ps-top, .ps-bar, .ps-saved, .ps-templates { min-width: 0; max-width: 100%; }
.ps * { box-sizing: border-box; }
.ps button, .ps input, .ps select, .ps textarea { font-family: inherit; color: inherit; }
.ps-kicker { color: #d9ff00; margin: 0 0 8px; font-weight: 700; }
.ps-start { display: grid; gap: 22px; }
.ps-hero h2, .ps-library h3, .ps-side h3, .ps-dialog h3 { margin: 0 0 8px; }
.ps-lead, .ps-note { color: #c3b4b8; line-height: 1.8; }
.ps-lead { max-width: 42rem; }
.ps-start-actions, .ps-row, .ps-top-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ps-start-actions { margin: 16px 0 8px; }
.ps-btn, .ps-icon {
	border: 1px solid rgba(242, 242, 242, 0.16);
	background: #241015;
	border-radius: 12px;
	min-height: 44px;
	padding: 8px 14px;
	cursor: pointer;
}
.ps-btn.primary { background: #d9ff00; color: #14080b; font-weight: 800; border-color: transparent; }
.ps-btn.ps-quiet, .ps-back { background: transparent; }
.ps-icon { width: 44px; padding: 0; font-weight: 800; }
.ps-filters { display: flex; gap: 8px; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; margin: 8px 0 14px; padding-bottom: 4px; }
.ps-filters .ps-btn { flex: 0 0 auto; border-radius: 999px; min-height: 38px; }
.ps-filters .is-on { background: #d9ff00; color: #14080b; border-color: transparent; font-weight: 800; }
.ps-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.ps-card {
	display: grid;
	gap: 6px;
	text-align: start;
	background: #14090c;
	border: 1px solid rgba(242,242,242,0.12);
	border-radius: 16px;
	padding: 12px;
	cursor: pointer;
	min-height: 148px;
}
.ps-card:hover, .ps-card:focus-visible { border-color: #d9ff00; }
.ps-card-page { display: block; height: 72px; border-radius: 8px; background: linear-gradient(#fff, #fff) 0 0 / 100% 18px no-repeat, linear-gradient(#8A0917, #8A0917) 12px 28px / 46% 8px no-repeat, linear-gradient(#e7e0e2, #e7e0e2) 12px 42px / 70% 4px no-repeat, linear-gradient(#e7e0e2, #e7e0e2) 12px 52px / 58% 4px no-repeat, #f6f3f4; }
.ps-card strong { font-size: 1rem; }
.ps-card span, .ps-saved span { color: #c3b4b8; font-size: 0.84rem; }
.ps-saved { display: grid; gap: 8px; margin-bottom: 18px; }
.ps-saved-row { display: flex; gap: 8px; align-items: center; min-width: 0; background: #14090c; border: 1px solid rgba(242,242,242,.12); border-radius: 14px; padding: 6px; }
.ps-saved-row button[data-open] { flex: 1; min-width: 0; text-align: start; background: transparent; border: 0; min-height: 48px; cursor: pointer; }
.ps-saved-row button[data-del] { flex: 0 0 auto; }
.ps-saved-row strong, .ps-saved-row span { display: block; overflow-wrap: anywhere; }
.ps-editor { display: flex; flex-direction: column; gap: 10px; min-height: 74vh; }
.ps-editor[hidden], .ps-modal[hidden], #psSavedWrap[hidden], .ps-toast[hidden] { display: none !important; }
.ps-preview-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: #1c0d12; border: 1px solid rgba(217,255,0,.4); border-radius: 14px; padding: 10px; }
.ps-preview-bar[hidden] { display: none !important; }
.ps-preview-bar p { margin: 0; flex: 1 1 180px; color: #f2f2f2; }
.ps.is-preview .ps-bar,
.ps.is-preview .ps-side,
.ps.is-preview .ps-mobile,
.ps.is-preview .ps-top-actions,
.ps.is-preview .ps-tools,
.ps.is-preview .ps-pick,
.ps.is-preview .ps-photo p,
.ps.is-preview .ps-block.is-on::before { display: none !important; }
.ps.is-preview .ps-photo { border: 0 !important; background: transparent !important; padding: 0 !important; }
.ps.is-preview .ps-block { pointer-events: none; }
.ps-hint { display: none; margin: 0 0 8px; color: #c3b4b8; line-height: 1.7; }
.ps-view { display: flex; gap: 8px; align-items: center; max-width: 100%; overflow-x: auto; }
.ps-view .is-on { background: #d9ff00; color: #14080b; border-color: transparent; font-weight: 800; }
#psZoom { display: flex; gap: 6px; }
#psZoom[hidden] { display: none !important; }
.ps.is-preview .ps-hint, .ps.is-preview .ps-view { display: none !important; }
.ps-page-guides { position: absolute; inset: 0; pointer-events: none; }
.ps-guide { position: absolute; inset-inline: 0; border-top: 1px dashed #8A0917; color: #8A0917; font-size: 11px; line-height: 1; padding-top: 3px; text-align: center; background: transparent; }
.ps-top, .ps-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ps-top { position: sticky; top: 56px; z-index: 5; background: rgba(8,8,8,.92); backdrop-filter: blur(8px); padding: 8px 0; }
.ps-title { flex: 1 1 180px; min-width: 0; background: transparent; border: 0; border-bottom: 1px solid rgba(242,242,242,.16); font-weight: 800; font-size: 1.08rem; padding: 8px 2px; }
.ps-title:focus { outline: none; border-bottom-color: #d9ff00; }
.ps-status { color: #d9ff00; background: rgba(217,255,0,.12); border-radius: 999px; padding: 4px 10px; font-size: 0.78rem; max-width: 100%; overflow-wrap: anywhere; }
.ps-status[data-state="dirty"] { color: #f2f2f2; background: rgba(242,242,242,.1); }
.ps-status[data-state="saving"] { color: #f2f2f2; background: rgba(242,242,242,.08); }
.ps-status[data-state="error"] { color: #ffd0d0; background: rgba(138,9,23,.55); }
.ps-bar-name { flex: 1 1 100%; color: #d9ff00; font-size: 0.84rem; }
.ps-block-actions { display: none; flex-wrap: wrap; gap: 6px; width: 100%; }
.ps-block-actions[hidden] { display: none !important; }
.ps-bar [data-bar-act="del"] { color: #ffb4b4; }
.ps-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.ps-stage { overflow-x: hidden; overflow-y: auto; background: #101010; border-radius: 18px; padding: 28px 16px 36px; max-height: calc(100dvh - 190px); max-width: 100%; }
.ps-sheet-wrap { display: flex; justify-content: center; width: 100%; max-width: 100%; overflow: hidden; }
.ps-page-meta { margin: 12px 0 0; text-align: center; color: #b7a8ac; font-size: 0.82rem; }
.ps-sheet {
	position: relative;
	background: #fff;
	color: #1a1214;
	width: var(--ps-w, 210mm);
	min-height: var(--ps-h, 297mm);
	padding: var(--ps-m, 16mm);
	box-shadow: 0 18px 50px rgba(0,0,0,.45);
	transform-origin: top center;
	font-family: "IBM Plex Arabic", Tahoma, sans-serif;
	line-height: 1.8;
}
.ps-sheet[dir="ltr"] { font-family: Georgia, "IBM Plex Arabic", Tahoma, serif; }
.ps-runhead, .ps-runfoot { color: #5c4f53; font-size: 0.78rem; display: flex; justify-content: space-between; gap: 8px; }
.ps-runhead { border-bottom: 1px solid #e4d8dc; margin-bottom: 16px; padding-bottom: 6px; }
.ps-runfoot { border-top: 1px solid #e4d8dc; margin-top: 20px; padding-top: 6px; }
.ps-block { position: relative; margin: 0 0 12px; padding: 2px 0; }
.ps-block.is-on { outline: 2px solid #8A0917; outline-offset: 3px; border-radius: 6px; }
.ps-block.is-on::before { content: ""; position: absolute; inset-inline-start: -10px; top: 2px; bottom: 2px; width: 3px; border-radius: 3px; background: #8A0917; }
.ps-more { margin-top: 10px; }
.ps-more summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: #d9ff00; }
.ps-block h1, .ps-block h2, .ps-block h3, .ps-block p, .ps-block li, .ps-block blockquote, .ps-callout { margin: 0; }
.ps-block h1 { font-size: 1.75rem; line-height: 1.35; color: var(--ps-accent, #8a0917); }
.ps-block h2 { font-size: 1.28rem; color: var(--ps-accent, #8a0917); }
.ps-block h3 { font-size: 1.05rem; }
.ps-block [contenteditable="true"]:focus { outline: none; }
.ps-block blockquote { border-inline-start: 3px solid var(--ps-accent, #8a0917); padding-inline-start: 12px; color: #3d3336; }
.ps-callout { background: #f8f1f3; border-radius: 10px; padding: 10px 12px; }
.ps-callout.warn { background: #fff4e8; }
.ps-table { width: 100%; border-collapse: collapse; }
.ps-table td, .ps-table th { border: 1px solid #d9cfd2; padding: 6px 8px; vertical-align: top; }
.ps-table th { background: #f6eef0; }
.ps-photo { border: 1.5px dashed #8A0917; border-radius: 14px; padding: 22px 14px; text-align: center; background: #fbf7f8; }
.ps-pick { display: flex; align-items: center; justify-content: center; min-height: 48px; width: min(100%, 280px); margin: 0 auto; padding: 10px 14px; border: 0; border-radius: 12px; background: #8A0917; color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.ps-photo p { margin: 8px 0 0; color: #5c4f53; font-size: 0.9rem; }
.ps-shot { max-width: 100%; height: auto; display: block; }
.ps-figure { margin: 4px 0 0; }
.ps-figure.is-right { text-align: right; }
.ps-figure.is-center { text-align: center; }
.ps-figure.is-left { text-align: left; }
.ps-figure.is-right .ps-shot { margin-left: auto; margin-right: 0; }
.ps-figure.is-center .ps-shot { margin-left: auto; margin-right: auto; }
.ps-figure.is-left .ps-shot { margin-left: 0; margin-right: auto; }
.ps-figure.is-line .ps-shot { border: 1px solid #d9cfd2; padding: 4px; }
.ps-figure figcaption { margin-top: 6px; color: #5c4f53; font-size: 0.88rem; min-height: 1.4em; }
.ps-figure figcaption:empty::before { content: "تعليق تحت الصورة، اختياري"; color: #a8989c; }
.ps-img-tools { display: none; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.ps-block.is-on .ps-img-tools { display: flex; }
.ps-img-tools label { display: flex; align-items: center; gap: 6px; color: #5c4f53; font-size: 0.82rem; }
.ps-img-tools input[type="range"] { width: min(42vw, 160px); }
.ps-img-tools button { min-height: 36px; padding: 4px 10px; border-radius: 999px; border: 1px solid #e4d8dc; background: #fff; color: #1a1214; cursor: pointer; }
.ps-img-tools button.is-on { background: #8A0917; color: #fff; border-color: transparent; }
.ps-range { display: flex; align-items: center; gap: 8px; }
.ps-range input[type="range"] { flex: 1; }
.ps.is-preview .ps-img-tools { display: none !important; }
.ps-shot + .ps-pick { margin-top: 8px; background: #1a1214; }
.ps-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.ps-add-grid .ps-btn { min-height: 52px; }
.ps-add-grid .primary { grid-column: 1 / -1; }
.ps-rule { border: 0; border-top: 1px solid #d9cfd2; margin: 8px 0; }
.ps-break { border-top: 1px dashed #c9b8bc; color: #8a7c80; font-size: 0.75rem; text-align: center; padding-top: 4px; }
.ps-chart { display: grid; gap: 6px; }
.ps-chart div { display: grid; grid-template-columns: minmax(4.5em, 8.5em) 1fr; gap: 8px; align-items: center; font-size: 0.86rem; }
.ps-chart i { display: block; height: 10px; background: var(--ps-accent, #8a0917); border-radius: 6px; }
.ps-tools { display: none; gap: 6px; margin-top: 8px; }
.ps-block.is-on .ps-tools { display: flex; flex-wrap: wrap; }
.ps-tools button { min-height: 36px; padding: 4px 10px; border-radius: 999px; border: 1px solid #e4d8dc; background: #fff; color: #1a1214; cursor: pointer; }
.ps-tools button[data-act="del"] { color: #8A0917; }
.ps-side { background: #12090c; border: 1px solid rgba(242,242,242,.12); border-radius: 16px; padding: 8px; max-height: calc(100dvh - 190px); overflow: auto; }
.ps-panel { background: rgba(255,255,255,.03); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.ps-side label, .ps-dialog label { display: block; margin: 10px 0 4px; color: #c3b4b8; font-size: 0.82rem; }
.ps-check { display: flex !important; align-items: center; gap: 8px; min-height: 44px; }
.ps-color { display: flex; gap: 8px; align-items: center; }
.ps-color input[type="color"] { width: 44px; height: 44px; padding: 0; border: 0; background: transparent; }
.ps-field, .ps-side select, .ps-side textarea, .ps-side input[type="text"], .ps-side input[type="number"], .ps-dialog input {
	width: 100%; background: #0d0709; border: 1px solid rgba(242,242,242,.16); border-radius: 10px; padding: 10px; font-size: 16px;
}
.ps-side-head, .ps-mobile { display: none; }
.ps-file { position: fixed; width: 1px; height: 1px; opacity: 0; inset-inline-start: 0; bottom: 0; }
.ps-live { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.ps-toast { position: fixed; inset-inline: 16px; bottom: 84px; z-index: 1100; margin: 0 auto; max-width: 420px; background: #1a1214; color: #f2f2f2; border: 1px solid rgba(217,255,0,.4); border-radius: 14px; padding: 12px 14px; text-align: center; }
.ps-modal { position: fixed; inset: 0; background: rgba(0,0,0,.68); z-index: 1100; display: grid; place-items: end center; padding: 16px; }
.ps-modal[hidden] { display: none; }
.ps-dialog { width: min(520px, 100%); background: #1c0d12; border-radius: 18px 18px 14px 14px; padding: 16px; max-height: min(86dvh, 720px); overflow: auto; }
@media (min-width: 901px) {
	.ps-start { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); align-items: start; }
	.ps-hero { position: sticky; top: 12px; }
	.ps-modal { place-items: center; }
	.ps-dialog { border-radius: 18px; }
}
@media (max-width: 900px) {
	.ps-templates { grid-template-columns: 1fr; }
	.ps-editor { padding-bottom: calc(148px + env(safe-area-inset-bottom)); }
	.ps:not(.is-preview):not(.is-page) .ps-sheet { width: 100% !important; min-height: auto !important; padding: 18px 14px !important; }
	.ps.is-page .ps-stage { overflow: auto; background: #101010; padding: 16px 8px 28px; }
	.ps.is-page .ps-sheet-wrap { overflow: visible; justify-content: center; }
	.ps-body { grid-template-columns: minmax(0, 1fr); }
	.ps-side { display: none; position: fixed; inset-inline: 0; bottom: 0; z-index: 1100; max-height: min(78dvh, calc(100dvh - 72px)); border-radius: 18px 18px 0 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
	.ps.is-side .ps-side { display: block; }
	.ps-hint { display: block; }
	.ps-block-actions:not([hidden]) { display: flex; }
	.ps-tools { display: none !important; }
	.ps-top #psProject, .ps-top #psExport { display: none; }
	.ps-side-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 4px 6px 8px; }
	.ps-side-head::before { content: ""; flex: 1 0 100%; height: 4px; width: 42px; max-width: 42px; margin: 2px auto 8px; border-radius: 4px; background: rgba(242,242,242,.28); }
	.ps-mobile { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; position: fixed; inset-inline: 10px; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 1000; background: #0c0c0c; border: 1px solid rgba(242,242,242,.14); border-radius: 16px; padding: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.4); }
	.ps-stage { max-height: none; padding: 12px 0 8px; background: transparent; }
	.ps-top { position: static; }
	.ps-title { flex: 1 1 120px; }
	.ps-status { flex: 0 1 auto; }
	.ps-top-actions, .ps-preview-bar, .ps-start-actions { width: 100%; max-width: 100%; }
	.ps-bar { position: sticky; top: 48px; z-index: 4; width: 100%; max-width: 100%; flex-wrap: wrap; overflow-x: auto; overscroll-behavior-x: contain; background: #0c0c0c; padding: 4px 0 8px; }
	.ps-bar-name { flex: 1 0 100%; }
	.ps-block-actions { width: 100%; flex: 1 0 100%; flex-wrap: wrap; }
	.ps-block-actions:not([hidden]) { display: flex; }
	.ps-block-actions .ps-btn { flex: 1 1 calc(25% - 6px); }
	.ps-bar .ps-btn { flex: 0 0 auto; max-width: none; }
	.ps-preview-bar .ps-btn, .ps-mobile .ps-btn { max-width: 100%; }
	.ps-bar [data-open-add] { display: none; }
}
@media (max-width: 780px) {
	.ps-toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
	.ps-start { padding-bottom: 12px; }
}
@media print {
	body.ps-printing > *:not(.ps-print-root) { display: none !important; }
	body.ps-printing .ps-print-root { display: block !important; }
	.ps-print-root .ps-sheet { box-shadow: none !important; transform: none !important; width: auto !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; }
	.ps-tools, .ps-img-tools, .ps-break span, .ps-pick, .ps-photo p, .ps-page-meta, .ps-page-guides { display: none !important; }
	.ps-block.is-on { outline: none !important; }
	.ps-figure figcaption:empty { display: none !important; }
	.ps-photo { border: 0 !important; padding: 0 !important; background: transparent !important; }
	.ps-block.is-on::before { content: none !important; }
	.ps-break { break-before: page; border: 0; height: 0; margin: 0; padding: 0; }
	.ps-block h1, .ps-block h2, .ps-block table { break-after: avoid; }
	.ps-block tr, .ps-block img { break-inside: avoid; }
}
body.light-mode .ps-card, body.light-mode .ps-saved-row, body.light-mode .ps-side, body.light-mode .ps-dialog { background: #fff; color: #1a1214; }
body.light-mode .ps-btn, body.light-mode .ps-icon { background: #fff; color: #1a1214; }
body.light-mode .ps-btn.primary, body.light-mode .ps-filters .is-on { background: #d9ff00; color: #14080b; }
body.light-mode .ps-field, body.light-mode .ps-side select, body.light-mode .ps-side textarea, body.light-mode .ps-side input, body.light-mode .ps-dialog input { background: #fff; color: #1a1214; }
body.light-mode .ps-stage { background: #ece7e8; }
body.light-mode .ps-title, body.light-mode .ps-lead { color: #1a1214; }
