/* ==========================================================================
   CircleGram — feed, gallery, multi-select and the manage-post sheet.
   Shares the palette with Chat, Hub and Coaches so the app reads as one thing.
   ========================================================================== */
:root{
  --cg-bg:#0E1014; --cg-surface:#161A20; --cg-surface2:#1E232B; --cg-line:#272B34;
  --cg-text:#F2F4F8; --cg-muted:#AEB5C2; --cg-dim:#868D9C;
  --cg-accent:#F2C14E; --cg-danger:#FF6673; --cg-ink:#1A1408;
}

/* ── opting out of the legacy element styles ────────────────────────────────
   public/styles.css loads first and styles bare tags: `nav` becomes a fixed,
   blurred bar pinned to the top of the viewport, and `header` becomes an
   inline-block gradient pill. Semantic markup inside this component has to
   opt out of both explicitly — a class selector only wins for properties it
   actually declares, and those rules set properties this file otherwise
   never mentions. */
.cg-overlay header, .cg-overlay nav{
  position:static; top:auto; left:auto; right:auto; bottom:auto; width:auto;
  background:none; backdrop-filter:none; -webkit-backdrop-filter:none;
  z-index:auto; transition:none; border-radius:0; text-transform:none;
  color:inherit; font-size:inherit; font-weight:inherit; box-shadow:none;
}

.cg-overlay{
  position:fixed; inset:0; z-index:9999; background:var(--cg-bg);
  display:flex; flex-direction:column; overflow:hidden;
  color:var(--cg-text); font-family:'Poppins',system-ui,-apple-system,sans-serif;
}

/* The floating dock launcher is hidden while this overlay is open: the header
   carries its own way back, and in select mode the dot covered Delete. */
body.cg-open #dockLauncher,
body.cg-open #dockLauncherBackdrop,
body.cg-open #dockLauncherMenu{ display:none !important; }

/* ── header ─────────────────────────────────────────────────────────────── */
.cg-back{
  flex:none; display:inline-flex; align-items:center; gap:5px; align-self:flex-start;
  margin:calc(env(safe-area-inset-top,14px) + 14px) 0 0 20px; padding:0;
  background:none; border:0; cursor:pointer; font-family:inherit;
  font-size:13px; font-weight:500; color:var(--cg-dim);
}
.cg-back svg{ width:14px; height:14px; stroke:currentColor; stroke-width:2; fill:none;
  stroke-linecap:round; stroke-linejoin:round; }
.cg-back:hover{ color:var(--cg-muted); }
/* With a back control above it the header no longer needs the safe-area inset. */
.cg-overlay .cg-back + .cg-head{ padding-top:10px; }

.cg-head{
  flex:none; padding:calc(env(safe-area-inset-top,14px) + 14px) 20px 0;
  display:flex; align-items:flex-start; gap:12px;
}
.cg-title{ font-size:26px; font-weight:700; letter-spacing:-.03em; line-height:1.08; margin:0; }
.cg-sub{ font-size:12.5px; color:var(--cg-dim); margin-top:3px; }
.cg-head-acts{ margin-left:auto; display:flex; gap:10px; flex:none; }
.cg-hbtn{
  width:46px; height:46px; min-width:46px; border-radius:14px; cursor:pointer;
  display:grid; place-items:center; padding:0;
  background:none; border:1px solid var(--cg-line); color:var(--cg-muted);
}
.cg-hbtn svg{ width:20px; height:20px; stroke:currentColor; stroke-width:1.8; fill:none;
  stroke-linecap:round; stroke-linejoin:round; }
.cg-hbtn.on{ background:var(--cg-accent); border-color:var(--cg-accent); color:var(--cg-ink); }
.cg-hbtn.primary{ background:var(--cg-accent); border-color:var(--cg-accent); color:var(--cg-ink); }

/* ── tabs ───────────────────────────────────────────────────────────────── */
.cg-tabs{
  flex:none; display:flex; gap:26px; padding:18px 20px 0;
  border-bottom:1px solid var(--cg-line);
}
.cg-tab{
  position:relative; background:none; border:0; padding:0 0 11px; cursor:pointer;
  font-family:inherit; font-size:17px; font-weight:600; letter-spacing:-.018em;
  color:var(--cg-dim); display:flex; align-items:flex-start; gap:5px; margin-bottom:-1px;
  border-bottom:2.5px solid transparent;
}
.cg-tab.on{ color:var(--cg-text); border-bottom-color:var(--cg-accent); }
.cg-tab .ct{ font-size:10.5px; font-weight:600; color:var(--cg-dim); line-height:1.1; }

.cg-body{ flex:1; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; }

/* ── feed ───────────────────────────────────────────────────────────────── */
.cg-post{ border-bottom:1px solid var(--cg-line); }
.cg-post-head{ display:flex; align-items:center; gap:12px; padding:14px 20px; }
.cg-av{
  width:40px; height:40px; border-radius:50%; flex:none; overflow:hidden;
  background:var(--cg-surface2); display:grid; place-items:center;
  font-weight:700; font-size:14px; color:var(--cg-muted);
}
.cg-av img{ width:100%; height:100%; object-fit:cover; display:block; }
.cg-who{ min-width:0; flex:1; }
.cg-name{ font-size:15px; font-weight:600; letter-spacing:-.018em; display:flex; align-items:center; gap:7px; }
.cg-youpill{
  font-size:9.5px; font-weight:700; letter-spacing:.06em; padding:2px 7px; border-radius:5px;
  color:var(--cg-accent); border:1px solid rgba(242,193,78,.5);
}
.cg-meta{ font-size:12px; color:var(--cg-dim); margin-top:2px;
  display:flex; align-items:center; gap:6px; }
.cg-meta svg{ width:14px; height:14px; stroke:currentColor; stroke-width:1.8; fill:none; }
.cg-more{
  margin-left:auto; flex:none; min-width:44px; min-height:44px; border:0; background:none;
  color:var(--cg-dim); font-size:20px; cursor:pointer; letter-spacing:1px;
}

.cg-stage{ position:relative; background:#000; aspect-ratio:1/1; overflow:hidden; }
.cg-stage img{ width:100%; height:100%; object-fit:cover; display:block; }
.cg-count{
  position:absolute; top:14px; right:14px; padding:6px 12px; border-radius:999px;
  background:rgba(10,11,15,.66); backdrop-filter:blur(6px);
  font-size:13px; font-weight:700; font-variant-numeric:tabular-nums;
}
.cg-dots{ position:absolute; left:0; right:0; bottom:12px; display:flex; justify-content:center; gap:6px; }
.cg-dots i{ width:6px; height:6px; border-radius:50%; background:rgba(255,255,255,.34); }
.cg-dots i.on{ background:#fff; }
/* Tap targets for paging sit over the image edges, and are invisible. */
.cg-nav{ position:absolute; top:0; bottom:0; width:32%; border:0; background:none; cursor:pointer; }
.cg-nav.prev{ left:0; } .cg-nav.next{ right:0; }

.cg-acts{ display:flex; align-items:center; gap:22px; padding:14px 20px 0; }
.cg-act{
  display:flex; align-items:center; gap:7px; background:none; border:0; padding:0;
  min-height:44px; cursor:pointer; color:var(--cg-muted);
  font-family:inherit; font-size:14px; font-weight:600;
}
.cg-act svg{ width:21px; height:21px; stroke:currentColor; stroke-width:1.9; fill:none;
  stroke-linecap:round; stroke-linejoin:round; }
.cg-act.on{ color:var(--cg-accent); }
.cg-act.on svg{ fill:var(--cg-accent); stroke:var(--cg-accent); }
.cg-act.save{ margin-left:auto; }

.cg-caption{ padding:8px 20px 0; font-size:14.5px; line-height:1.5; color:var(--cg-text); }
.cg-caption b{ font-weight:700; margin-right:6px; }
.cg-when{
  padding:9px 20px 16px; font-size:10.5px; font-weight:600; letter-spacing:.07em;
  text-transform:uppercase; color:var(--cg-dim);
}

/* ── gallery ────────────────────────────────────────────────────────────── */
.cg-month{
  display:flex; align-items:baseline; padding:20px 20px 10px;
  font-size:12px; font-weight:700; letter-spacing:.09em; text-transform:uppercase;
  color:var(--cg-muted);
}
.cg-month .n{ margin-left:auto; font-size:12px; font-weight:500; letter-spacing:0;
  text-transform:none; color:var(--cg-dim); }
.cg-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:3px; }
.cg-cell{
  position:relative; aspect-ratio:1/1; overflow:hidden; cursor:pointer;
  background:var(--cg-surface2); border:0; padding:0;
}
.cg-cell img{ width:100%; height:100%; object-fit:cover; display:block; }
.cg-stack{
  position:absolute; top:9px; right:9px; width:22px; height:22px;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.6));
}
.cg-stack svg{ width:100%; height:100%; stroke:#fff; stroke-width:1.9; fill:none; }

/* selection */
.cg-cell.sel{ outline:3px solid var(--cg-accent); outline-offset:-3px; }
.cg-check{
  position:absolute; top:9px; right:9px; width:28px; height:28px; border-radius:50%;
  border:2px solid rgba(255,255,255,.9); display:grid; place-items:center;
  background:rgba(10,11,15,.28);
}
.cg-cell.sel .cg-check{ background:var(--cg-accent); border-color:var(--cg-accent); }
.cg-check svg{ width:15px; height:15px; stroke:var(--cg-ink); stroke-width:3; fill:none;
  stroke-linecap:round; stroke-linejoin:round; opacity:0; }
.cg-cell.sel .cg-check svg{ opacity:1; }

/* ── select mode chrome ─────────────────────────────────────────────────── */
.cg-selbar{
  flex:none; display:flex; align-items:center; gap:14px;
  padding:calc(env(safe-area-inset-top,14px) + 14px) 20px 14px;
}
.cg-selbar .x{
  width:46px; height:46px; min-width:46px; border-radius:14px; cursor:pointer;
  background:none; border:1px solid var(--cg-line); color:var(--cg-text);
  display:grid; place-items:center; padding:0;
}
.cg-selbar .x svg{ width:18px; height:18px; stroke:currentColor; stroke-width:2; fill:none;
  stroke-linecap:round; }
.cg-selcount{ font-size:19px; font-weight:700; letter-spacing:-.025em; }
.cg-selhint{ font-size:11.5px; color:var(--cg-dim); margin-top:2px; line-height:1.35; }
.cg-selall{
  margin-left:auto; flex:none; min-height:44px; padding:10px 16px; border-radius:12px;
  background:none; border:1px solid rgba(242,193,78,.5); color:var(--cg-accent);
  font-family:inherit; font-size:13.5px; font-weight:600; cursor:pointer; white-space:nowrap;
}
.cg-actionbar{
  flex:none; display:flex; border-top:1px solid var(--cg-line); background:var(--cg-bg);
  padding:14px 8px calc(env(safe-area-inset-bottom,14px) + 14px);
  position:relative; z-index:2;
}
.cg-abtn{
  flex:1; min-height:56px; background:none; border:0; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; gap:7px;
  color:var(--cg-muted); font-family:inherit; font-size:12px; font-weight:600;
}
.cg-abtn svg{ width:21px; height:21px; stroke:currentColor; stroke-width:1.8; fill:none;
  stroke-linecap:round; stroke-linejoin:round; }
.cg-abtn.danger{ color:var(--cg-danger); }
.cg-abtn[disabled]{ opacity:.4; cursor:default; }

/* ── manage post sheet ──────────────────────────────────────────────────── */
.cg-scrim{
  position:fixed; inset:0; z-index:10040; background:rgba(6,7,12,.7);
  opacity:0; pointer-events:none; transition:opacity .18s ease;
}
.cg-scrim.on{ opacity:1; pointer-events:auto; }
.cg-sheet{
  position:fixed; left:0; right:0; bottom:0; z-index:10041; max-width:560px; margin:0 auto;
  background:var(--cg-surface); border-top:1px solid var(--cg-line);
  border-radius:24px 24px 0 0; max-height:92vh; overflow-y:auto;
  padding:10px 0 calc(env(safe-area-inset-bottom,14px) + 18px);
  transform:translateY(100%); transition:transform .22s cubic-bezier(.32,.72,0,1);
}
.cg-sheet.on{ transform:translateY(0); }
.cg-grab{ width:44px; height:5px; border-radius:3px; background:#3A4152; margin:0 auto 16px; }
.cg-sheet h3{ font-size:22px; font-weight:700; letter-spacing:-.028em; padding:0 22px; margin:0; }
.cg-lab{
  font-size:12px; font-weight:700; letter-spacing:.08em; text-transform:uppercase;
  color:var(--cg-dim); padding:22px 22px 10px;
}
.cg-thumbs{ display:flex; gap:11px; padding:0 22px; overflow-x:auto; scrollbar-width:none; }
.cg-thumbs::-webkit-scrollbar{ display:none; }
.cg-thumb{
  position:relative; width:92px; height:92px; flex:none; border-radius:14px; overflow:hidden;
  background:var(--cg-surface2); cursor:grab;
}
.cg-thumb img{ width:100%; height:100%; object-fit:cover; display:block; }
.cg-thumb.dragging{ opacity:.4; }
.cg-thumb.over{ outline:2px solid var(--cg-accent); outline-offset:-2px; }
.cg-cover{
  position:absolute; left:0; right:0; bottom:0; background:var(--cg-accent); color:var(--cg-ink);
  font-size:11px; font-weight:800; letter-spacing:.06em; text-align:center; padding:3px 0;
}
.cg-rm{
  position:absolute; top:6px; right:6px; width:26px; height:26px; border-radius:50%;
  background:rgba(10,11,15,.78); border:0; color:#fff; cursor:pointer;
  display:grid; place-items:center; padding:0;
}
.cg-rm svg{ width:13px; height:13px; stroke:currentColor; stroke-width:2.4; fill:none; stroke-linecap:round; }
.cg-addtile{
  width:92px; height:92px; flex:none; border-radius:14px; cursor:pointer;
  border:1.5px dashed var(--cg-line); background:none; color:var(--cg-dim);
  display:grid; place-items:center; font-size:26px; font-weight:300;
}
.cg-field{
  margin:0 22px; width:calc(100% - 44px); min-height:64px; border-radius:14px;
  border:1px solid var(--cg-line); background:var(--cg-surface2); color:var(--cg-text);
  padding:14px 16px; font-family:inherit; font-size:16px; line-height:1.45; resize:none; outline:none;
}
.cg-field:focus{ border-color:rgba(242,193,78,.5); }
.cg-row{
  display:flex; align-items:center; gap:14px; width:100%; min-height:60px;
  padding:18px 22px; margin-top:18px; background:none; cursor:pointer;
  border:0; border-top:1px solid var(--cg-line); color:var(--cg-text);
  font-family:inherit; font-size:17px; text-align:left;
}
.cg-row+.cg-row{ margin-top:0; }
.cg-row>svg{ width:22px; height:22px; stroke:var(--cg-muted); stroke-width:1.8; fill:none;
  stroke-linecap:round; stroke-linejoin:round; flex:none; }
.cg-row .v{ margin-left:auto; color:var(--cg-dim); font-size:16px; }
.cg-row .chev{ color:var(--cg-dim); flex:none; }
.cg-save{
  display:block; width:calc(100% - 44px); margin:22px 22px 0; min-height:60px; padding:18px;
  border-radius:16px; border:0; background:var(--cg-accent); color:var(--cg-ink);
  font-family:inherit; font-size:18px; font-weight:800; cursor:pointer;
}
.cg-del{
  display:block; width:calc(100% - 44px); margin:8px 22px 0; min-height:56px; padding:16px;
  border-radius:16px; border:0; background:none; color:var(--cg-danger);
  font-family:inherit; font-size:17px; font-weight:700; cursor:pointer;
}

/* ── comments ───────────────────────────────────────────────────────────────
   A sheet rather than a browser prompt: prompt() cannot be styled, blocks the
   page, and shows none of the thread it is replying to. */
.cg-clist{ max-height:46vh; overflow-y:auto; }
.cg-crow{ display:flex; gap:11px; padding:13px 22px; border-top:1px solid var(--cg-line); }
.cg-crow:first-child{ border-top:0; }
.cg-cav{
  width:34px; height:34px; border-radius:50%; flex:none; overflow:hidden;
  background:var(--cg-surface2); display:grid; place-items:center;
  font-size:13px; font-weight:700; color:var(--cg-muted);
}
.cg-cav img{ width:100%; height:100%; object-fit:cover; display:block; }
.cg-cbody{ min-width:0; flex:1; }
.cg-cwho{ font-size:13.5px; font-weight:600; letter-spacing:-.015em; }
.cg-cwhen{ font-size:11px; color:var(--cg-dim); margin-left:7px; font-weight:400; }
.cg-ctext{ font-size:14.5px; line-height:1.45; color:var(--cg-text); margin-top:2px;
  overflow-wrap:anywhere; }
.cg-cdel{
  flex:none; min-width:36px; min-height:36px; border:0; background:none; cursor:pointer;
  color:var(--cg-dim); font-size:15px; padding:0;
}
.cg-cempty{ padding:34px 22px; text-align:center; color:var(--cg-dim); font-size:14px; }
.cg-cbar{
  display:flex; align-items:flex-end; gap:9px; padding:12px 22px 4px;
  border-top:1px solid var(--cg-line);
}
.cg-cinput{
  flex:1; min-height:44px; max-height:120px; border-radius:13px; resize:none;
  border:1px solid var(--cg-line); background:var(--cg-surface2); color:var(--cg-text);
  padding:12px 14px; font-family:inherit; font-size:15px; line-height:1.35; outline:none;
}
.cg-cinput:focus{ border-color:rgba(242,193,78,.5); }
.cg-csend{
  width:44px; height:44px; min-width:44px; border-radius:13px; flex:none; cursor:pointer;
  display:grid; place-items:center; padding:0;
  background:var(--cg-surface2); border:1px solid var(--cg-line); color:var(--cg-dim);
  transition:background .15s ease, border-color .15s ease;
}
.cg-csend svg{ width:18px; height:18px; stroke:currentColor; stroke-width:2; fill:none;
  stroke-linecap:round; stroke-linejoin:round; }
.cg-csend.on{ background:var(--cg-accent); border-color:var(--cg-accent); color:var(--cg-ink); }

/* ── states ─────────────────────────────────────────────────────────────── */
.cg-empty{ padding:70px 30px; text-align:center; color:var(--cg-dim); font-size:15px; line-height:1.55; }
.cg-empty .ic{ display:block; font-size:38px; margin-bottom:12px; opacity:.5; }
.cg-skel{ aspect-ratio:1/1; background:var(--cg-surface2); position:relative; overflow:hidden; }
.cg-skel::after{
  content:""; position:absolute; inset:0; transform:translateX(-100%);
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.05),transparent);
  animation:cg-shimmer 1.1s infinite;
}
@keyframes cg-shimmer{ to{ transform:translateX(100%) } }
.cg-toast{
  position:fixed; left:50%; bottom:calc(env(safe-area-inset-bottom,20px) + 90px);
  transform:translateX(-50%); z-index:10050; background:#EDEFF4; color:#14161B;
  font-weight:600; font-size:14px; padding:12px 20px; border-radius:12px;
  opacity:0; pointer-events:none; transition:opacity .18s ease;
}
.cg-toast.on{ opacity:1; }
@media (prefers-reduced-motion:reduce){
  .cg-skel::after{ animation:none }
  .cg-sheet,.cg-scrim,.cg-toast{ transition:none }
}
