/* ==========================================================================
   DebSoc admin: Instagram-style, phone-first UI (cosmetic only)
   ========================================================================== */
:root{
  --black:#000; --panel:#121212; --inset:#1c1c1c; --raise:#262626;
  --cream:#f5f5f5; --muted:#a8a8a8; --faint:#737373;
  --line:#262626; --blue:#0095f6; --blue-deep:#1877f2; --blue-soft:rgba(0,149,246,.14);
  --danger:#ff4d5e; --ok:#58c322; --pink:#ed4956;
  --serif:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --mono:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --safe-b:env(safe-area-inset-bottom,0px); --safe-t:env(safe-area-inset-top,0px);
  --navh:56px;
  --grad:linear-gradient(45deg,#feda75,#fa7e1e,#d62976,#962fbf,#4f5bd5);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html{background:var(--black);color:var(--cream);-webkit-text-size-adjust:100%}
body{margin:0;font-family:var(--serif);font-size:15px;line-height:1.45;overflow-x:hidden;min-height:100vh;min-height:100dvh;display:flex;flex-direction:column;background:var(--black)}
h1,h2,h3,h4,p{margin:0}
button,input,select,textarea{font:inherit;color:inherit}
button{touch-action:manipulation}
.hidden,[hidden]{display:none!important}
.mono{font-family:var(--mono)}
.muted{color:var(--muted)}
:focus-visible{outline:2px solid var(--blue);outline-offset:2px}

/* ---------- Top bar ---------- */
.bar{position:sticky;top:0;z-index:40;background:rgba(0,0,0,.92);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);border-bottom:1px solid var(--line);padding-top:var(--safe-t)}
.bar-inner{max-width:975px;margin:0 auto;padding:8px 16px;min-height:52px;display:flex;align-items:center;justify-content:space-between;gap:10px}
.brand{display:flex;align-items:center;gap:10px;min-width:0}
.brand img{height:30px;width:30px;object-fit:cover;border-radius:50%;padding:2px;background:var(--grad);flex:none}
.brand strong{font-size:1.05rem;font-weight:700;letter-spacing:-.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tag{font:700 10px var(--serif);background:var(--grad);color:#fff;padding:2px 8px;border-radius:99px;letter-spacing:.06em}
.bar-actions{display:flex;align-items:center;gap:8px;font-size:13px;flex:none}
.bar-actions a{color:var(--blue);text-decoration:none;font-weight:600;padding:8px 6px}
.bar-actions a:hover{color:#fff}

/* ---------- Tabs: bottom nav on phones, top row on desktop ---------- */
.tabs{display:flex;justify-content:center;border-top:1px solid var(--line);max-width:975px;margin:0 auto}
.tab{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;background:none;border:0;padding:8px 4px;min-height:var(--navh);cursor:pointer;color:var(--muted);font-size:11px;font-weight:500;white-space:nowrap;position:relative}
.tab svg{width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.tab:hover{color:var(--cream)}
.tab[aria-selected="true"]{color:var(--cream);font-weight:700}
.tab[aria-selected="true"] svg{stroke-width:2.4}
.tab[aria-selected="true"]::before{content:"";position:absolute;top:0;left:22%;right:22%;height:2px;background:var(--cream);border-radius:0 0 2px 2px}

@media(max-width:760px){
  .tabs{position:fixed;left:0;right:0;bottom:0;z-index:50;max-width:none;background:rgba(0,0,0,.94);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);border-top:1px solid var(--line);padding-bottom:var(--safe-b)}
  .bar{border-bottom:1px solid var(--line)}
  .bar .tabs{border-top:1px solid var(--line)}
  .brand strong{font-size:1rem}
  .bar-actions a{display:none}
}
@media(min-width:761px){
  .tab{flex-direction:row;gap:8px;font-size:14px;min-height:46px;max-width:200px}
  .tab svg{width:22px;height:22px}
  .tabs{border-top:0}
}

main{flex:1;width:100%;max-width:975px;margin:0 auto;padding:16px 16px calc(var(--navh) + var(--safe-b) + 40px)}
@media(min-width:761px){main{padding:28px 20px 64px}}
footer{border-top:1px solid var(--line);padding:16px 16px calc(16px + var(--navh) + var(--safe-b));text-align:center;font-size:11px;color:var(--faint)}
@media(min-width:761px){footer{padding-bottom:16px}}

/* ---------- Section head ---------- */
.head{margin-bottom:18px;display:flex;flex-direction:column;gap:6px}
.head h2{font-size:1.5rem;font-weight:700;letter-spacing:-.02em;line-height:1.2}
.head .side{display:flex;flex-direction:column;gap:12px;align-items:flex-start}
.head .side p{font-size:13px;color:var(--muted);max-width:60ch}
.head .side .btn.primary{width:100%;justify-content:center}
@media(min-width:761px){
  .head{flex-direction:row;align-items:flex-end;justify-content:space-between;gap:24px}
  .head .side{flex-direction:row;align-items:center;flex-wrap:wrap;justify-content:flex-end}
  .head .side .btn.primary{width:auto}
}

/* ---------- Buttons & fields ---------- */
.btn{border:0;background:var(--raise);padding:9px 16px;min-height:36px;cursor:pointer;font-size:14px;font-weight:600;border-radius:8px;color:var(--cream);text-decoration:none;display:inline-flex;align-items:center;justify-content:center;gap:6px;transition:background .15s,opacity .15s,transform .1s}
.btn:hover{background:#363636}
.btn:active{transform:scale(.97)}
.btn.primary{background:var(--blue);color:#fff}
.btn.primary:hover{background:var(--blue-deep)}
.btn.danger{color:var(--danger);background:rgba(255,77,94,.1)}
.btn.danger:hover{background:rgba(255,77,94,.2)}
.btn.sm{padding:6px 12px;min-height:32px;font-size:13px}
.btn:disabled{opacity:.45;cursor:not-allowed}
label.lbl,.lbl{display:block;font-size:13px;font-weight:600;color:var(--cream);margin-bottom:6px}
.in,input[type=text],input[type=url],input[type=number],input[type=datetime-local],select,textarea{width:100%;background:var(--inset);border:1px solid var(--line);border-radius:10px;padding:11px 12px;font-size:16px;min-height:44px;-webkit-appearance:none;appearance:none}
select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23a8a8a8' stroke-width='2'%3E%3Cpath d='m1 1 5 5 5-5'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 14px center;padding-right:36px}
input[type=datetime-local]{min-height:44px}
.in:focus,input:focus,select:focus,textarea:focus{outline:none;border-color:var(--blue);box-shadow:0 0 0 3px var(--blue-soft)}
::placeholder{color:var(--faint)}
textarea{resize:vertical}
.hint{font-size:12px;color:var(--faint);margin-top:6px}
.field{margin-bottom:16px}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:0 14px}
@media(max-width:560px){.row2{grid-template-columns:1fr}}

/* ---------- Overview ---------- */
.stats{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;margin-bottom:22px}
.stat{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:14px 16px}
.stat b{display:block;font-size:1.6rem;font-weight:700;line-height:1.15}
.stat.lead{grid-column:1/-1;background:var(--grad);border:0;color:#fff;padding:18px}
.stat.lead b{font-size:clamp(2.6rem,12vw,4rem);letter-spacing:-.03em}
.stat.lead span{color:rgba(255,255,255,.92)}
.stat span{font-size:12px;color:var(--muted)}
@media(min-width:761px){.stats{grid-template-columns:repeat(4,1fr)}.stat.lead{grid-column:1/-1}}
.cols{display:grid;grid-template-columns:1fr;gap:8px}
@media(min-width:861px){.cols{grid-template-columns:minmax(0,1.3fr) minmax(0,1fr);gap:28px}}
.block{margin-bottom:24px}
.block h3{font-size:1rem;font-weight:700;padding-bottom:8px;margin-bottom:2px}
/* story-like quick actions */
.quick{display:flex;gap:8px;overflow-x:auto;margin:0 -16px 22px;padding:2px 16px;scrollbar-width:none}
.quick::-webkit-scrollbar{display:none}
.quick .btn{flex:none;border-radius:99px;padding:9px 18px;white-space:nowrap}
@media(min-width:761px){.quick{margin:0 0 24px;padding:0;flex-wrap:wrap;overflow:visible}}

/* ---------- Feed rows (events, archives, codes) ---------- */
.ledger>.item{display:grid;grid-template-columns:64px minmax(0,1fr);gap:4px 14px;align-items:center;padding:14px 0;border-bottom:1px solid var(--line)}
.ledger>.item.nothumb{grid-template-columns:minmax(0,1fr)}
.thumb{width:64px;height:64px;object-fit:cover;background:var(--inset);border-radius:12px;display:block}
.item .t{font-weight:700;overflow-wrap:anywhere}
.item .m{font-size:12px;color:var(--muted);margin-top:3px;line-height:1.7}
.item .acts{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.item .acts .btn{flex:1 1 0;min-width:72px}
.ledger>.item.nothumb .acts{grid-column:auto;margin-top:6px}
.pill{display:inline-block;font-size:11px;font-weight:600;background:var(--raise);padding:1px 9px;border-radius:99px;margin-right:6px;color:var(--muted);line-height:1.6}
.pill.open{color:var(--ok);background:rgba(88,195,34,.13)}
.pill.blue{color:var(--blue);background:var(--blue-soft)}
.empty{padding:36px 8px;color:var(--faint);font-size:14px;text-align:center}

@media(min-width:761px){
  .ledger>.item{grid-template-columns:72px minmax(0,1fr) auto}
  .ledger>.item.nothumb{grid-template-columns:minmax(0,1fr) auto}
  .thumb{width:72px;height:72px}
  .item .acts,.ledger>.item.nothumb .acts{grid-column:auto;margin-top:0;justify-content:flex-end;flex-wrap:nowrap}
  .item .acts .btn{flex:none;min-width:0}
}
.tools{display:flex;flex-wrap:wrap;gap:10px;margin-bottom:10px}
.tools input{flex:1;min-width:0;border-radius:10px}
.tools select{width:auto;flex:none}
.tools input[type=text]{background-color:var(--raise);border-color:transparent}

/* ---------- Editor (full-screen sheet on phones) ---------- */
.editor{background:var(--panel);border:1px solid var(--line);border-radius:16px;padding:16px;margin-bottom:24px}
.editor-head{display:flex;justify-content:space-between;align-items:center;gap:10px;padding-bottom:12px;border-bottom:1px solid var(--line);margin-bottom:16px}
.editor-head h3{font-size:1rem;font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.editor-grid{display:grid;grid-template-columns:minmax(0,7fr) minmax(0,5fr);gap:28px}
.preview{border-left:1px solid var(--line);padding-left:24px;align-self:start;position:sticky;top:130px}
.preview .cap{font-size:12px;font-weight:600;color:var(--faint);margin-bottom:8px;text-transform:uppercase;letter-spacing:.06em}
.pv{border:1px solid var(--line);border-radius:14px;overflow:hidden;background:#000;padding-bottom:14px}
.pv>*:not(.pv-cover){margin-left:14px;margin-right:14px}
.pv-cover{width:100%;aspect-ratio:16/9;object-fit:cover;background:var(--inset);display:block;margin-bottom:12px}
.pv-cover.ph{display:grid;place-items:center;font-size:13px;color:var(--faint)}
.pv h4{font-size:1.2rem;font-weight:700;line-height:1.25;margin-top:8px;margin-bottom:4px;overflow-wrap:anywhere}
.pv .meta{font-size:12px;color:var(--muted);margin-bottom:10px}
.pv .warn{font-size:12px;color:var(--danger);margin-bottom:10px}
.pv .strip{display:grid;grid-template-columns:repeat(4,1fr);gap:2px;margin-top:12px;margin-left:0;margin-right:0}
.pv .strip img{width:100%;aspect-ratio:1;object-fit:cover}

@media(max-width:900px){
  .editor-grid{grid-template-columns:1fr}
  .preview{border-left:0;border-top:1px solid var(--line);padding:18px 0 0;position:static}
}
@media(max-width:760px){
  .editor{position:fixed;inset:0;z-index:70;margin:0;border:0;border-radius:0;overflow-y:auto;overscroll-behavior:contain;padding:0 16px calc(96px + var(--safe-b));-webkit-overflow-scrolling:touch}
  .editor-head{position:sticky;top:0;z-index:2;background:rgba(0,0,0,.94);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);margin:0 -16px 16px;padding:calc(12px + var(--safe-t)) 16px 12px}
  .editor-head h3{flex:1;text-align:center}
  .editor-head .btn{order:-1;background:none;color:var(--blue);padding:6px 0;min-width:60px;justify-content:flex-start}
  .editor-head::after{content:"";min-width:60px}
  /* save button pinned at the bottom like a "Share" bar */
  .editor>div[style*="justify-content:flex-end"]{position:fixed!important;left:0;right:0;bottom:0;z-index:3;margin:0!important;padding:12px 16px calc(12px + var(--safe-b));background:rgba(0,0,0,.94);border-top:1px solid var(--line)}
  .editor>div[style*="justify-content:flex-end"] .btn{width:100%;min-height:46px;font-size:15px}
}
@media(max-width:760px){body:has(.editor:not(.hidden)){overflow:hidden}body:has(.editor:not(.hidden)) .tabs{display:none}}

/* ---------- Rendered rich text ---------- */
.rt{font-size:14px;color:rgba(245,245,245,.88)}
.rt p,.rt ul,.rt blockquote{margin:0 0 .8em}
.rt h4{font-size:1.05rem;font-weight:700;margin:1em 0 .4em;color:var(--cream)}
.rt ul{padding-left:1.2em}.rt a{color:var(--blue)}
.rt blockquote{border-left:3px solid var(--raise);padding-left:12px;color:var(--muted)}
.rt-empty{color:var(--faint);font-size:13px}

/* ---------- Rich text editor ---------- */
.rte{border:1px solid var(--line);background:var(--inset);border-radius:10px;overflow:hidden}
.rte:focus-within{border-color:var(--blue);box-shadow:0 0 0 3px var(--blue-soft)}
.rte-bar{display:flex;gap:4px;padding:6px;border-bottom:1px solid var(--line);overflow-x:auto;scrollbar-width:none;position:sticky;top:0}
.rte-bar::-webkit-scrollbar{display:none}
.rte-bar button{flex:none;background:none;border:0;color:var(--muted);padding:6px 12px;min-height:34px;cursor:pointer;font-size:14px;border-radius:8px}
.rte-bar button:hover,.rte-bar button[aria-pressed="true"]{color:var(--cream);background:var(--raise)}
.rte-bar button:disabled{opacity:.35}
.rte-bar .sp{flex:1}
.rte textarea{border:0;box-shadow:none!important;background:transparent;min-height:170px;display:block;border-radius:0}
.rte-view{padding:12px;min-height:170px}

/* ---------- Image field ---------- */
.dz{border:1.5px dashed #4a4a4a;border-radius:14px;padding:18px 14px;text-align:center;font-size:14px;font-weight:600;color:var(--blue);cursor:pointer;background:var(--inset)}
.dz:hover,.dz.over{border-color:var(--blue);background:var(--blue-soft)}
.dz.busy{opacity:.6;pointer-events:none}
.dz.big{padding:38px 14px;font-size:15px}
.imgtools{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px;align-items:center}
.imgtools input{flex:1;min-width:140px}
.thumbs{display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:3px;margin-top:10px}
.th{position:relative;background:var(--inset);border-radius:8px;overflow:hidden}
.th.drag{opacity:.4}.th.target{outline:2px solid var(--blue)}
.th img{width:100%;aspect-ratio:1;object-fit:cover;display:block;cursor:grab}
.th .ix{position:absolute;top:6px;left:6px;background:rgba(0,0,0,.65);font-size:11px;font-weight:700;padding:1px 7px;border-radius:99px}
.th .ctl{display:flex;background:var(--raise)}
.th .ctl button{flex:1;background:none;border:0;padding:0;min-height:40px;cursor:pointer;color:var(--cream);font-size:15px}
.th .ctl button:hover:not(:disabled){background:#363636}
.th .ctl button:disabled{opacity:.25;cursor:default}
.th .ctl .rm{color:var(--danger)}

/* ---------- Awards ---------- */
.split{display:grid;grid-template-columns:1fr;gap:24px}
@media(min-width:901px){.split{grid-template-columns:minmax(0,5fr) minmax(0,7fr);gap:32px}}
.card{border:1px solid var(--line);background:var(--panel);border-radius:16px;padding:16px}
.chips{display:flex;flex-wrap:wrap;gap:6px;background:var(--inset);border:1px solid var(--line);padding:6px;border-radius:10px;min-height:46px}
.chips:focus-within{border-color:var(--blue);box-shadow:0 0 0 3px var(--blue-soft)}
.chip{display:inline-flex;align-items:center;gap:4px;background:var(--blue-soft);color:var(--blue);padding:3px 4px 3px 12px;border-radius:99px;font-size:13px;font-weight:600}
.chip button{background:none;border:0;cursor:pointer;color:var(--blue);padding:4px 8px;min-height:28px}
.chips input{flex:1;min-width:120px;border:0;background:transparent;padding:6px;box-shadow:none!important;min-height:34px}
.presets{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0 16px}
.code{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:12px 0;border-bottom:1px solid var(--line);flex-wrap:wrap}
.code code{font:700 13px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;letter-spacing:.06em;color:var(--blue);background:var(--blue-soft);padding:5px 10px;border-radius:8px;overflow-wrap:anywhere}
.sumline{display:flex;gap:20px;flex-wrap:wrap;font-size:13px;color:var(--muted);margin-bottom:10px}
.sumline b{color:var(--cream);font-size:16px}

/* ---------- Media grid (profile-style, 3 across on phones) ---------- */
.mgrid{display:grid;grid-template-columns:repeat(3,1fr);gap:3px;margin-top:16px}
@media(min-width:600px){.mgrid{grid-template-columns:repeat(4,1fr);gap:6px}}
@media(min-width:900px){.mgrid{grid-template-columns:repeat(5,1fr);gap:8px}}
.mi{position:relative;background:var(--panel);overflow:hidden;aspect-ratio:1}
.mi img{width:100%;height:100%;object-fit:cover;display:block}
.mi .info{position:absolute;top:0;left:0;right:0;padding:4px 6px;font-size:10px;color:#fff;background:linear-gradient(rgba(0,0,0,.6),transparent);opacity:0;transition:opacity .15s;pointer-events:none}
.mi:hover .info{opacity:1}
.mi .acts{position:absolute;left:0;right:0;bottom:0;display:flex;background:rgba(0,0,0,.62);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}
.mi .acts button{flex:1;background:none;border:0;min-height:34px;padding:0 2px;cursor:pointer;font-size:11px;font-weight:600;color:#fff}
.mi .acts button+button{border-left:1px solid rgba(255,255,255,.2)}
.mi .acts button:hover{background:rgba(255,255,255,.12)}
.mi .acts .del{color:#ff8a95}
.mi.pick{cursor:pointer}
.mi.sel{outline:3px solid var(--blue);outline-offset:-3px}
.mi.sel::after{content:"\2713";position:absolute;top:6px;right:6px;width:22px;height:22px;border-radius:50%;background:var(--blue);color:#fff;display:grid;place-items:center;font-size:13px;font-weight:700}

/* ---------- Picker: bottom sheet on phones ---------- */
dialog{background:var(--panel);color:var(--cream);border:1px solid var(--line);border-radius:16px;padding:0;width:min(880px,94vw);max-height:88vh;overflow:hidden}
dialog::backdrop{background:rgba(0,0,0,.72)}
.dlg{display:flex;flex-direction:column;max-height:88vh}
.dlg header,.dlg footer{padding:12px 16px;display:flex;justify-content:space-between;align-items:center;gap:10px;background:var(--panel);text-align:left;font-size:14px;font-weight:600;color:var(--cream)}
.dlg header{border-bottom:1px solid var(--line)}.dlg footer{border-top:1px solid var(--line)}
.dlg header>span:last-child{display:flex;gap:8px}
.dlg .body{padding:0 3px 16px;overflow:auto}
@media(max-width:760px){
  dialog{width:100%;max-width:100%;margin:auto 0 0;border-radius:18px 18px 0 0;border-bottom:0;max-height:92vh;padding-bottom:var(--safe-b)}
  dialog[open]{animation:sheet .22s ease-out}
  .dlg{max-height:92vh}
  .dlg header{position:relative;padding-top:18px}
  .dlg header::before{content:"";position:absolute;top:7px;left:50%;width:38px;height:4px;margin-left:-19px;border-radius:4px;background:#4a4a4a}
}
@keyframes sheet{from{transform:translateY(40px);opacity:0}to{transform:none;opacity:1}}

/* ---------- Toast ---------- */
#toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(var(--navh) + var(--safe-b) + 14px);z-index:120;padding:12px 18px;font-size:14px;font-weight:600;border-radius:12px;max-width:min(440px,92vw);text-align:center;box-shadow:0 8px 30px rgba(0,0,0,.5)}
@media(min-width:761px){#toast{bottom:24px}}
#toast.ok{background:#262626;color:#fff}
#toast.err{background:var(--pink);color:#fff}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;animation:none!important;transition:none!important}}
