/* Owner-only Google Sites–style editor & dynamic portfolio blocks.
   #cms-pencil, #cms-bar, #cms-drawer, and .cms-item-actions are only created/shown
   when authenticated as an allowed owner (enforced by Firestore rules). */

#cms-pencil{position:fixed;left:18px;bottom:18px;z-index:99999;width:54px;height:54px;border-radius:50%;border:2px solid #fbbf24;background:#0b1020;color:#fbbf24;font-size:24px;cursor:pointer;box-shadow:0 0 0 4px rgba(251,191,36,.18),0 6px 22px rgba(0,0,0,.6);display:grid;place-items:center}
#cms-pencil:hover{background:#fbbf24;color:#0b1020}
#cms-pencil .dot{position:absolute;top:2px;right:2px;width:12px;height:12px;border-radius:50%;background:#f97316;border:2px solid #0b1020}

#cms-bar{position:fixed;left:0;right:0;top:0;z-index:99999;display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:10px 14px;background:#0b1020;border-bottom:2px solid #fbbf24;font:600 13px ui-monospace,Menlo,Consolas,monospace;color:#e5e7eb;box-shadow:0 8px 24px rgba(0,0,0,.55)}
#cms-bar .st{flex:1;min-width:170px;color:#fbbf24}
#cms-bar .sz{font-size:11px;color:#94a3b8;padding:4px 8px;border:1px solid rgba(148,163,184,.3);border-radius:8px}
#cms-bar button{font:inherit;padding:7px 12px;border-radius:9px;border:1px solid #38bdf8;background:#111b33;color:#e5e7eb;cursor:pointer}
#cms-bar button.pub{background:#fbbf24;color:#0b1020;border-color:#fbbf24}
#cms-bar button.ins{background:#0f766e;border-color:#2dd4bf;color:#ecfeff}
#cms-bar button:hover{filter:brightness(1.2)}

body.cms-editing{padding-top:64px}
body.cms-editing [data-eid]{outline:1px dashed rgba(251,191,36,.55);outline-offset:3px;cursor:text}
body.cms-editing [data-eid]:focus{outline:2px solid #fbbf24;background:rgba(251,191,36,.08)}

/* Google Sites–style Insert Sidebar Drawer (Owner only) */
#cms-drawer{position:fixed;top:64px;right:14px;bottom:14px;width:min(330px,92vw);z-index:99998;display:none;flex-direction:column;background:rgba(11,16,32,.97);border:2px solid #38bdf8;border-radius:16px;padding:14px;color:#e5e7eb;box-shadow:0 18px 42px rgba(0,0,0,.75);overflow-y:auto;backdrop-filter:blur(10px)}
#cms-drawer.open{display:flex}
#cms-drawer .dr-head{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid rgba(56,189,248,.3);padding-bottom:10px;margin-bottom:10px}
#cms-drawer .dr-head h3{margin:0;font-size:15px;color:#fbbf24;font-family:system-ui,sans-serif}
#cms-drawer .dr-close{background:transparent;border:1px solid rgba(148,163,184,.4);color:#e5e7eb;border-radius:8px;padding:4px 9px;cursor:pointer;font-weight:700}
#cms-drawer .dr-grp{margin:10px 0 6px;font:700 11px ui-monospace,Menlo,Consolas,monospace;text-transform:uppercase;letter-spacing:.06em;color:#38bdf8}
#cms-drawer .dr-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
#cms-drawer .dr-tile{display:flex;flex-direction:column;align-items:flex-start;gap:3px;padding:10px;border-radius:11px;border:1px solid rgba(56,189,248,.35);background:#10192e;color:#f8fafc;cursor:pointer;text-align:left;font-family:system-ui,sans-serif;transition:border-color .15s,transform .12s}
#cms-drawer .dr-tile:hover{border-color:#fbbf24;transform:translateY(-1px)}
#cms-drawer .dr-tile strong{font-size:12.5px;color:#fbbf24}
#cms-drawer .dr-tile span{font-size:11px;color:#cbd5e1;line-height:1.3}
#cms-drawer .dr-tip{margin-top:14px;padding:10px;border-radius:10px;background:rgba(251,191,36,.08);border:1px dashed rgba(251,191,36,.45);font:12px/1.45 system-ui,sans-serif;color:#fde68a}

/* Modals (Settings, Add/Edit Item, Story Reader) */
.cms-modal{position:fixed;inset:0;z-index:100000;display:none;align-items:center;justify-content:center;padding:16px;background:rgba(0,0,0,.74)}
.cms-modal.open{display:flex}
.cms-modal .box{width:min(620px,95vw);max-height:90vh;overflow-y:auto;background:#0b1020;border:2px solid #fbbf24;border-radius:16px;padding:20px;color:#e5e7eb;font:14px system-ui,sans-serif;box-shadow:0 20px 50px rgba(0,0,0,.75)}
.cms-modal h3{margin:0 0 4px;color:#fbbf24}
.cms-modal label{display:block;margin:12px 0 4px;color:#fbbf24;font-weight:700;font-size:13px}
.cms-modal input,.cms-modal textarea,.cms-modal select{width:100%;box-sizing:border-box;padding:9px 10px;border-radius:8px;border:1px solid #38bdf8;background:#111b33;color:#e5e7eb;font:14px system-ui,sans-serif}
.cms-modal textarea{min-height:110px;resize:vertical;line-height:1.5}
.cms-modal small{color:#9ca3af;display:block;line-height:1.4}
.cms-modal .row{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;margin-top:16px}
.cms-modal button{padding:8px 14px;border-radius:9px;border:1px solid #38bdf8;background:#111b33;color:#e5e7eb;cursor:pointer;font-weight:600}
.cms-modal button.primary{background:#fbbf24;color:#0b1020;border-color:#fbbf24}
.cms-modal .img-row{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-top:6px}
.cms-modal .img-preview{margin-top:8px;max-height:180px;max-width:100%;border-radius:10px;border:1px solid rgba(56,189,248,.4);display:none;object-fit:contain;background:#050811}

/* Toast notification (e.g. non-owner denial) */
#cms-toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);z-index:100001;background:#0b1020;color:#fbbf24;border:1.5px solid #f97316;border-radius:12px;padding:10px 16px;font:600 13px system-ui,sans-serif;box-shadow:0 12px 30px rgba(0,0,0,.65)}

/* Dynamic Portfolio Cards (Public & Owner Views) */
.cms-card-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(270px,1fr));gap:16px}
.cms-card{position:relative;background:#0b1120;border:1.5px solid rgba(56,189,248,.42);border-radius:18px;padding:18px;display:flex;flex-direction:column;gap:10px;box-shadow:0 10px 26px rgba(0,0,0,.45);overflow:visible}
.cms-card.amber{border-color:rgba(251,191,36,.52)}
/* object-fit:contain shows the FULL image with no cropping — important for certificates */
.cms-card-img{width:100%;height:auto;max-height:none;object-fit:contain;border-radius:12px;border:1px solid rgba(148,163,184,.28);background:#050811;display:block}
/* On mobile screens make sure images never overflow their card */
@media(max-width:600px){.cms-card-img{width:100%;height:auto}}
.cms-card-top{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;flex-wrap:wrap}
.cms-card-title{margin:0;font-size:1.08rem;color:#f8fafc}
.cms-card-sub{font:600 0.82rem ui-monospace,Menlo,Consolas,monospace;color:#38bdf8}
.cms-card-body{margin:0;color:#e2e8f0;font-size:0.94rem;line-height:1.55;white-space:pre-wrap}
.cms-poem-body{font-family:var(--font-bengali,Georgia,serif);font-size:1rem;line-height:1.75;color:#fef3c7;white-space:pre-wrap;background:rgba(251,191,36,.06);border:1px solid rgba(251,191,36,.25);border-radius:12px;padding:14px}
.cms-about-note{margin-top:12px;padding:12px 14px;border-radius:12px;background:rgba(56,189,248,.08);border:1px solid rgba(56,189,248,.35);position:relative}
.cms-about-note h4{margin:0 0 4px;color:#fbbf24;font-size:0.95rem}
.cms-about-note p{margin:0;color:#e2e8f0;font-size:0.92rem;white-space:pre-wrap}

/* Owner-only per-card edit/move/delete controls */
.cms-item-actions{display:none;gap:6px;flex-wrap:wrap;margin-top:auto;padding-top:8px;border-top:1px dashed rgba(251,191,36,.35)}
body.cms-editing .cms-item-actions{display:flex}
.cms-item-actions button{font:600 11.5px ui-monospace,Menlo,Consolas,monospace;padding:4px 9px;border-radius:7px;border:1px solid #38bdf8;background:#111b33;color:#e5e7eb;cursor:pointer}
.cms-item-actions button.del{border-color:#f97316;color:#fdba74}
.cms-item-actions button:hover{filter:brightness(1.2)}

/* Empty-section hint shown ONLY in edit mode */
.cms-empty-hint{display:none;padding:16px;border-radius:14px;border:1.5px dashed rgba(251,191,36,.45);background:rgba(251,191,36,.05);color:#fde68a;font-size:0.9rem;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
body.cms-editing .cms-empty-hint{display:flex}
.cms-empty-hint button{padding:7px 12px;border-radius:9px;border:1px solid #fbbf24;background:#fbbf24;color:#0b1020;font-weight:700;cursor:pointer}
