/* لوحة التحكم — مبنية على نظام تصميم مضبوط (madbout.css) */
html, body { height: 100%; }
body { display: flex; flex-direction: column; background: var(--neutral\.50); }
button { font-family: inherit; }

/* الشريط العلوي */
.top { display: flex; align-items: center; gap: var(--space\.3); height: 64px; padding-inline: var(--space\.5); background: var(--white); border-bottom: 1px solid var(--neutral\.200); flex: none; }
.brand { display: inline-flex; align-items: center; gap: var(--space\.3); color: var(--neutral\.950); text-decoration: none; border-radius: var(--radius\.sm); }
.brand img { height: 28px; width: auto; display: block; }
.brand span { font: 600 15px/1.3 var(--font-sans); padding-inline-start: var(--space\.3); border-inline-start: 1px solid var(--neutral\.200); white-space: nowrap; }
.save { display: inline-flex; align-items: center; gap: var(--space\.2); height: 28px; padding-inline: var(--space\.3); border-radius: var(--radius\.full); font: var(--text-caption); color: var(--neutral\.600); background: var(--neutral\.100); white-space: nowrap; }
.save .md-dot { color: var(--success); }
.save[data-s="busy"] .md-dot { color: var(--brand\.primary); animation: pulse 1s ease-in-out infinite; }
.save[data-s="err"] { background: #fef2f2; color: var(--error); }
.save[data-s="err"] .md-dot { color: var(--error); }
@keyframes pulse { 50% { opacity: .3; } }
.top .grow { flex: 1; }
.top .md-badge { white-space: nowrap; }
.top .acts { display: flex; align-items: center; gap: var(--space\.2); }
.top .md-btn { height: 40px; }
#pub[data-live="1"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px #dcfce7; }

/* التخطيط */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 460px 1fr; }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--white); border-inline-end: 1px solid var(--neutral\.200); }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space\.1); padding: var(--space\.3) var(--space\.4) 0; border-bottom: 1px solid var(--neutral\.200); flex: none; }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--space\.2) var(--space\.1) var(--space\.3); border: 0; background: none; color: var(--neutral\.600); font: 600 13px/1.4 var(--font-sans); cursor: pointer; position: relative; border-radius: var(--radius\.sm) var(--radius\.sm) 0 0; transition: color var(--dur-base) ease, background-color var(--dur-base) ease; }
.tabs button .md-icon { width: 20px; height: 20px; }
.tabs button:hover { color: var(--neutral\.950); background: var(--neutral\.50); }
.tabs button.on { color: var(--neutral\.950); }
.tabs button.on::after { content: ""; position: absolute; inset: auto 12px -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand\.primary); animation: tab-in .3s var(--ease-out); }
@keyframes tab-in { from { scale: 0 1; } }
#pane { overflow: auto; padding: var(--space\.5); flex: 1; scrollbar-gutter: stable; }
#pane > div { animation: pane-in .3s var(--ease-out); }
@keyframes pane-in { from { opacity: 0; translate: 0 6px; } }

/* عناوين اللوحة */
.ph { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space\.3); margin: 0 0 var(--space\.4); }
.ph h3 { margin: 0; font: 700 18px/1.4 var(--font-sans); }
.ph p { margin: 2px 0 0; color: var(--neutral\.600); font: var(--text-body-small); }
.grp + .grp { margin-top: var(--space\.8); padding-top: var(--space\.6); border-top: 1px solid var(--neutral\.200); }
.mut { color: var(--neutral\.600); font: var(--text-body-small); margin: 0; }
.stack { display: grid; gap: var(--space\.4); }
.acts { display: flex; gap: var(--space\.2); flex-wrap: wrap; align-items: center; }
.chk { display: flex; gap: var(--space\.2); align-items: center; font: 500 14px/1.5 var(--font-sans); cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--neutral\.950); }

/* بطاقات التصاميم: معاينة مصغّرة مرسومة بالـ CSS لكل تصميم */
.tplg { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space\.3); }
.tpl { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; border: 1px solid var(--neutral\.200); border-radius: var(--radius\.lg); background: var(--white); overflow: hidden; transition: border-color var(--dur-base) ease, box-shadow var(--dur-base) var(--ease-out), translate var(--dur-base) var(--ease-out); }
.tpl:hover { border-color: var(--neutral\.400); translate: 0 -2px; box-shadow: var(--shadow-md); }
.tpl:focus-visible { outline: 2px solid var(--neutral\.950); outline-offset: 2px; }
.tpl.on { border-color: var(--neutral\.950); box-shadow: var(--shadow-brand); translate: -2px -2px; }
.tpl .cap { display: flex; align-items: center; gap: var(--space\.2); padding: var(--space\.2) var(--space\.3); font: 600 14px/1.5 var(--font-sans); }
.tpl .cap .sw { margin-inline-start: auto; display: flex; }
.tpl .cap .sw i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--white); margin-inline-start: -5px; box-shadow: 0 0 0 1px rgba(0,0,0,.1); }
.tpl .tick { width: 18px; height: 18px; border-radius: 50%; background: var(--brand\.primary); display: none; place-items: center; color: var(--neutral\.950); }
.tpl .tick .md-icon { width: 12px; height: 12px; stroke-width: 3; }
.tpl.on .tick { display: grid; animation: md-pop .3s var(--ease-back); }
.art { height: 92px; position: relative; overflow: hidden; border-bottom: 1px solid var(--neutral\.200); }
.art i, .art b { position: absolute; display: block; }
.art-kids { background: radial-gradient(rgba(255,255,255,.8) 1.5px, transparent 2px) 0 0 / 12px 12px, linear-gradient(#bfe8ff, #e6f6ff); }
.art-kids i:nth-child(1) { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 4px solid #ffd966; top: 12px; left: calc(50% - 17px); }
.art-kids i:nth-child(2) { width: 40px; height: 13px; border-radius: 9px; background: #fff; top: 14px; right: 12px; }
.art-kids i:nth-child(3) { width: 50px; height: 26px; border-radius: 9px; background: #ff8fb1; bottom: 8px; right: 14px; rotate: -4deg; }
.art-kids i:nth-child(4) { width: 50px; height: 26px; border-radius: 9px; background: #7ccdf5; bottom: 8px; left: 14px; rotate: 3deg; }
.art-kids b { width: 46px; height: 7px; border-radius: 4px; background: #c63d73; top: 54px; left: calc(50% - 23px); }
.art-glass { background: linear-gradient(135deg, #e6e0ff, #ffe3f0 50%, #d9f6ea); }
.art-glass i:nth-child(1) { width: 70px; height: 70px; border-radius: 50%; background: #b9a6ff; filter: blur(14px); top: -18px; right: -10px; }
.art-glass i:nth-child(2) { inset: 14px 14px 14px 14px; border-radius: 14px; background: rgba(255,255,255,.6); border: 1px solid #fff; }
.art-glass i:nth-child(3) { width: 60px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #4b2fd0, #c03a8b); top: 30px; right: 26px; }
.art-glass i:nth-child(4) { width: 36px; height: 6px; border-radius: 3px; background: #c9bfff; top: 46px; right: 26px; }
.art-luxury { background: radial-gradient(ellipse at 50% -20%, #1b3d34, #0b1a17 70%); }
.art-luxury i:nth-child(1) { inset: 0; background: repeating-radial-gradient(circle at 50% -40%, transparent 0 16px, rgba(200,168,98,.18) 17px 18px); }
.art-luxury i:nth-child(2) { width: 70px; height: 8px; background: #f4eedf; top: 32px; left: calc(50% - 35px); border-radius: 1px; }
.art-luxury i:nth-child(3) { width: 40px; height: 1px; background: #c8a862; top: 52px; left: calc(50% - 20px); }
.art-luxury i:nth-child(4) { width: 7px; height: 7px; background: #c8a862; rotate: 45deg; top: 49px; left: calc(50% - 3.5px); }
.art-sunny { background: #fff9f0; }
.art-sunny i:nth-child(1) { width: 46px; height: 46px; border-radius: 50%; background: #ff6b57; top: 10px; left: 18px; }
.art-sunny i:nth-child(2) { width: 30px; height: 30px; border-radius: 8px; background: #3ddbb0; top: 8px; left: 58px; rotate: 16deg; }
.art-sunny i:nth-child(3) { width: 46px; height: 23px; border-radius: 46px 46px 0 0; background: #ffc93c; bottom: 10px; left: 36px; }
.art-sunny i:nth-child(4) { width: 64px; height: 9px; border-radius: 3px; background: #16213e; top: 30px; right: 16px; }
.art-sunny b { width: 40px; height: 12px; border-radius: 9px; background: #ffc93c; top: 12px; right: 16px; }
.art-pop { background: radial-gradient(rgba(20,20,20,.2) 1px, transparent 1.2px) 0 0 / 8px 8px, #fff1b8; }
.art-pop i:nth-child(1) { width: 34px; height: 34px; border-radius: 50%; background: #4cc9f0; border: 2px solid #141414; top: 10px; left: 12px; }
.art-pop i:nth-child(2) { width: 46px; height: 30px; border-radius: 8px; background: #ff6fb5; border: 2px solid #141414; box-shadow: 3px 3px 0 #141414; bottom: 10px; right: 14px; rotate: -3deg; }
.art-pop i:nth-child(3) { width: 46px; height: 30px; border-radius: 8px; background: #6be08f; border: 2px solid #141414; box-shadow: 3px 3px 0 #141414; bottom: 10px; right: 70px; rotate: 2deg; }
.art-pop i:nth-child(4) { width: 70px; height: 12px; background: #141414; top: 14px; right: 14px; border-radius: 2px; rotate: -2deg; }
.art-modern { background: #f6f1e9; }
.art-modern i:nth-child(1) { inset: 0 auto 0 0; width: 34%; background: #1d2a35; right: auto; left: auto; inset-inline-start: 0; }
.art-modern i:nth-child(2) { width: 54%; height: 40px; border-radius: 10px; background: #e9d8b4; top: 10px; inset-inline-end: 8px; }
.art-modern i:nth-child(3) { width: 16px; height: 16px; border-radius: 5px; background: #c8553d; top: 30px; inset-inline-end: 20px; rotate: 18deg; }
.art-modern i:nth-child(4) { width: 25%; height: 26px; border-radius: 8px; background: #c8553d; bottom: 8px; inset-inline-end: 8px; }
.art-modern b { width: 25%; height: 26px; border-radius: 8px; background: #a9c7d6; bottom: 8px; inset-inline-end: calc(25% + 14px); }

/* الألوان */
.colors { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space\.3); }
.color { display: flex; align-items: center; gap: var(--space\.3); padding: var(--space\.2) var(--space\.3); border: 1px solid var(--neutral\.200); border-radius: var(--radius\.md); cursor: pointer; transition: border-color var(--dur-base) ease; }
.color:hover { border-color: var(--neutral\.400); }
.color input { appearance: none; -webkit-appearance: none; width: 32px; height: 32px; border: 0; padding: 0; border-radius: 50%; cursor: pointer; background: none; flex: none; }
.color input::-webkit-color-swatch-wrapper { padding: 0; }
.color input::-webkit-color-swatch { border: 3px solid var(--white); border-radius: 50%; box-shadow: 0 0 0 1px var(--neutral\.200); }
.color input::-moz-color-swatch { border: 3px solid var(--white); border-radius: 50%; }
.color span { font: 500 14px/1.4 var(--font-sans); }
.color small { display: block; color: var(--neutral\.600); font: 400 12px/1.4 var(--font-sans); direction: ltr; text-align: end; }

/* صفوف الأقسام */
.rows { display: grid; gap: var(--space\.2); }
.row { display: flex; gap: var(--space\.2); align-items: center; padding: var(--space\.2); padding-inline-start: var(--space\.2); border: 1px solid var(--neutral\.200); border-radius: var(--radius\.md); background: var(--white); transition: border-color var(--dur-base) ease, box-shadow var(--dur-base) ease, opacity var(--dur-base) ease; }
.row:hover { border-color: var(--neutral\.400); }
.row:focus-within { border-color: var(--neutral\.950); }
.row.off { background: var(--neutral\.50); }
.row.off .md-input:not(.ic) { color: var(--neutral\.400); text-decoration: line-through; }
.row .md-input { height: 40px; box-shadow: none; border-color: transparent; padding-inline: var(--space\.2); font-weight: 500; }
.row .md-input:hover { border-color: var(--neutral\.200); }
.row .md-input:focus { border-color: var(--neutral\.950); box-shadow: none; }
.row .ic { width: 44px; flex: none; text-align: center; padding: 0; font-size: 20px; background: var(--neutral\.50); }
.row .kind { flex: none; }
.row .open { height: 36px; padding-inline: var(--space\.3); font-size: 14px; }
.row .mv { display: flex; flex-direction: column; }
.row .mv .md-icon-btn { width: 28px; height: 18px; border-radius: 4px; }
.row .mv .md-icon-btn .md-icon { width: 14px; height: 14px; }
.row.flash { animation: flash .6s var(--ease-out); }
@keyframes flash { from { box-shadow: 0 0 0 4px var(--brand\.primary); } }
.adds { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space\.2); }
.add { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: var(--space\.3); padding: var(--space\.3); border: 1.5px dashed var(--neutral\.200); border-radius: var(--radius\.md); font: 600 14px/1.4 var(--font-sans); transition: border-color var(--dur-base) ease, background-color var(--dur-base) ease; }
.add small { display: block; font: 400 12px/1.5 var(--font-sans); color: var(--neutral\.600); }
.add .md-icon { width: 20px; height: 20px; flex: none; padding: 6px; box-sizing: content-box; border-radius: var(--radius\.sm); background: var(--brand\.soft); }
.add:hover { border-color: var(--neutral\.950); background: var(--neutral\.50); }
.add:focus-visible { outline: 2px solid var(--neutral\.950); outline-offset: 2px; }

/* رجوع وعنوان المحرر */
.crumb { display: flex; align-items: center; gap: var(--space\.2); margin-bottom: var(--space\.4); }
.crumb .md-btn { height: 32px; padding-inline: var(--space\.2) var(--space\.3); font-size: 14px; }

/* بطاقات المحتوى */
.card { border: 1px solid var(--neutral\.200); border-radius: var(--radius\.lg); padding: var(--space\.4); background: var(--white); display: grid; gap: var(--space\.3); }
.card + .card, .stackc > * + * { margin-top: var(--space\.3); }
.card .md-input { box-shadow: none; }
.card-h { display: flex; align-items: center; gap: var(--space\.2); margin: calc(var(--space\.1) * -1) 0 0; }
.card-h b { font: 600 14px/1.5 var(--font-sans); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-h .n { width: 24px; height: 24px; border-radius: var(--radius\.sm); background: var(--neutral\.100); display: grid; place-items: center; font: 600 12px/1 var(--font-sans); color: var(--neutral\.600); flex: none; }
.card.new { animation: md-pop .4s var(--ease-back); border-color: var(--neutral\.950); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space\.3); }

/* المرفقات */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: var(--space\.2); }
.fl { position: relative; aspect-ratio: 1; border-radius: var(--radius\.md); overflow: hidden; background: var(--neutral\.100); border: 1px solid var(--neutral\.200); display: grid; place-items: center; color: var(--neutral\.600); }
.fl img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fl .ti { display: grid; justify-items: center; gap: 2px; padding: var(--space\.1); text-align: center; }
.fl .ti small { font: 500 11px/1.3 var(--font-sans); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 76px; }
.fl .x { position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(23,23,23,.75); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity var(--dur-base) ease, scale var(--dur-fast) ease-out; }
.fl .x .md-icon { width: 14px; height: 14px; }
.fl:hover .x, .fl .x:focus-visible { opacity: 1; }
.fl .x:active { scale: .9; }
@media (hover: none) { .fl .x { opacity: 1; } }
.drop { all: unset; box-sizing: border-box; cursor: pointer; aspect-ratio: 1; border: 1.5px dashed var(--neutral\.400); border-radius: var(--radius\.md); display: grid; place-items: center; align-content: center; gap: 2px; color: var(--neutral\.600); font: 600 12px/1.3 var(--font-sans); text-align: center; transition: border-color var(--dur-base) ease, background-color var(--dur-base) ease, color var(--dur-base) ease; }
.drop:hover, .drop.over { border-color: var(--neutral\.950); background: var(--brand\.soft); color: var(--neutral\.950); }
.drop:focus-visible { outline: 2px solid var(--neutral\.950); outline-offset: 2px; }

/* الصورة الشخصية */
.avatar { display: flex; align-items: center; gap: var(--space\.4); }
.avatar .pic { width: 72px; height: 72px; border-radius: 50%; background: var(--brand\.soft); display: grid; place-items: center; font-size: 34px; overflow: hidden; flex: none; border: 3px solid var(--white); box-shadow: 0 0 0 1px var(--neutral\.200); }
.avatar .pic img { width: 100%; height: 100%; object-fit: cover; }

/* المساحة */
.quota { padding: var(--space\.4); border-radius: var(--radius\.lg); background: var(--neutral\.950); color: var(--white); display: grid; gap: var(--space\.2); }
.quota b { font: 700 26px/1.2 var(--font-sans); }
.quota b small { font: 400 14px/1 var(--font-sans); color: var(--neutral\.400); }
.q { height: 10px; border-radius: var(--radius\.full); background: rgba(255,255,255,.14); overflow: hidden; }
.q i { display: block; height: 100%; border-radius: inherit; background: var(--brand\.primary); animation: grow .9s var(--ease-out); transform-origin: right; }
.q.hi i { background: #f87171; }
@keyframes grow { from { scale: 0 1; } }
.quota p { margin: 0; font: var(--text-body-small); color: var(--neutral\.400); }
.flist { display: grid; gap: var(--space\.1); }
.fi { display: flex; align-items: center; gap: var(--space\.3); padding: var(--space\.2); border-radius: var(--radius\.md); transition: background-color var(--dur-base) ease; }
.fi:hover { background: var(--neutral\.50); }
.fi .th { width: 44px; height: 44px; border-radius: var(--radius\.sm); background: var(--neutral\.100); overflow: hidden; display: grid; place-items: center; flex: none; color: var(--neutral\.600); }
.fi .th img { width: 100%; height: 100%; object-fit: cover; }
.fi .nm { flex: 1; min-width: 0; }
.fi .nm b { display: block; font: 500 14px/1.5 var(--font-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fi .nm small { color: var(--neutral\.600); font: 400 12px/1.4 var(--font-sans); }

/* المعاينة */
.pv { display: flex; flex-direction: column; min-height: 0; padding: var(--space\.4) var(--space\.5) var(--space\.5); gap: var(--space\.3); background: var(--neutral\.100); }
.pvbar { display: flex; gap: var(--space\.3); align-items: center; }
.addr { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space\.2); height: 40px; padding-inline: var(--space\.3); background: var(--white); border: 1px solid var(--neutral\.200); border-radius: var(--radius\.full); color: var(--neutral\.600); font: 400 13px/1 var(--font-sans); }
.addr .md-icon { width: 16px; height: 16px; flex: none; }
.addr bdi { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--neutral\.950); }
.addr .md-badge { flex: none; }
.addr a { color: inherit; display: grid; place-items: center; border-radius: 50%; width: 28px; height: 28px; }
.addr a:hover { background: var(--neutral\.100); color: var(--neutral\.950); }
#pvs { flex: 1; min-height: 0; display: flex; justify-content: center; }
.device { width: 100%; height: 100%; background: var(--white); border-radius: var(--radius\.lg); box-shadow: 0 0 0 1px var(--neutral\.200), var(--shadow-lg); overflow: hidden; transition: width .45s var(--ease-out), border-radius .45s var(--ease-out), box-shadow .45s ease; }
.device.mob { width: 390px; border-radius: 36px; box-shadow: 0 0 0 10px var(--neutral\.950), 0 24px 48px rgba(0,0,0,.2); margin-block: 10px; height: calc(100% - 20px); }
#frame { width: 100%; height: 100%; border: 0; display: block; background: var(--white); }

/* حوار البداية */
.presets { display: grid; gap: var(--space\.3); margin-top: var(--space\.5); }
.preset { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: var(--space\.4); padding: var(--space\.4); border: 1px solid var(--neutral\.200); border-radius: var(--radius\.lg); transition: border-color var(--dur-base) ease, box-shadow var(--dur-base) var(--ease-out), translate var(--dur-base) var(--ease-out); }
.preset:hover, .preset:focus-visible { border-color: var(--neutral\.950); box-shadow: var(--shadow-brand); translate: -2px -2px; outline: none; }
.preset .e { width: 52px; height: 52px; border-radius: var(--radius\.md); background: var(--brand\.soft); display: grid; place-items: center; font-size: 28px; flex: none; }
.preset b { display: block; font: 600 17px/1.5 var(--font-sans); }
.preset small { color: var(--neutral\.600); font: var(--text-body-small); }
.preset > .md-icon { margin-inline-start: auto; color: var(--neutral\.400); }

.mtog { display: none; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 400px 1fr; }
  .top .md-badge, .brand span { display: none; }
}
@media (max-width: 900px) {
  .top { padding-inline: var(--space\.3); gap: var(--space\.2); }
  .save { display: none; }
  .top .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .top .md-btn { padding-inline: var(--space\.3); }
  .layout { grid-template-columns: 1fr; }
  .pv { display: none; padding: var(--space\.3); }
  .layout.showpv .side { display: none; }
  .layout.showpv .pv { display: flex; }
  .mtog { display: inline-flex; }
  #pane { padding: var(--space\.4); }
  .pvbar .md-seg { display: none; }
  .device.mob { width: 100%; border-radius: var(--radius\.lg); box-shadow: 0 0 0 1px var(--neutral\.200); margin: 0; height: 100%; }
}
@media (max-width: 420px) {
  .adds, .two, .colors { grid-template-columns: 1fr; }
}
