/* ─────────────────────────────────────────────────────────────────────────
   PipChat! Web — Posts (reading deck) and Groups (shelves).

   Two rules carry the whole look:
     1. Every post has a --tone taken from its own type, and both the rail
        entry and the reader inherit it, so the page recolours as you read.
     2. Every group has a generated --c1/--c2 gradient keyed off its name, so
        a group looks the same everywhere it appears without any stored art.

   Reminder (see app.css): icons are inline <svg> with a viewBox and no
   width/height, so every component here declares its own svg size.
   ───────────────────────────────────────────────────────────────────────── */

.tone-talk  { --tone: var(--orange);    --tone-soft: var(--orange-soft); --tone-ink: var(--orange-deep); }
.tone-alert { --tone: var(--red);       --tone-soft: var(--red-soft);    --tone-ink: var(--red); }
.tone-civic { --tone: var(--type-gov);  --tone-soft: var(--type-gov-soft); --tone-ink: var(--type-gov-2); }
.tone-deal  { --tone: var(--amber);     --tone-soft: var(--amber-soft);  --tone-ink: #9A5F00; }
.tone-event { --tone: var(--blue);      --tone-soft: var(--blue-soft);   --tone-ink: var(--type-biz-2); }
.tone-help  { --tone: var(--green);     --tone-soft: var(--green-soft);  --tone-ink: var(--green); }

/* ── Sort bar ─────────────────────────────────────────────────────────── */
.sortbar {
  display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none;
  padding-bottom: 3px; margin-bottom: 18px;
}
.sortbar::-webkit-scrollbar { display: none; }
.sortchip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: 999px; font-size: 13px; font-weight: 700;
  color: var(--muted); background: var(--paper); border: 1px solid var(--hairline);
  white-space: nowrap; transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}
.sortchip svg { width: 14px; height: 14px; }
.sortchip:hover { color: var(--ink); box-shadow: var(--shadow-sm); }
.sortchip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ── The deck ─────────────────────────────────────────────────────────── */
.deck {
  display: grid; grid-template-columns: minmax(290px, 372px) 1fr;
  gap: 20px; align-items: start; margin-bottom: 64px;
}

.deck-rail {
  position: sticky; top: 80px; max-height: calc(100vh - 104px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 8px;
}
.rail-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 12px;
  font-size: 11.5px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.rail-head svg { width: 14px; height: 14px; }
.rail-hint { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--subtle); }
.rail-list { display: flex; flex-direction: column; gap: 2px; }
.rail-more { padding: 10px 4px 4px; }
.rail-end { text-align: center; padding: 14px 8px 8px; font-size: 12px; color: var(--subtle); }

.entry {
  display: flex; gap: 11px; padding: 11px 11px; border-radius: 13px;
  border: 1px solid transparent; transition: background .12s, border-color .12s;
}
.entry:hover { background: var(--bg-2); }
.entry.on {
  background: var(--tone-soft); border-color: color-mix(in srgb, var(--tone) 26%, #fff);
}
.entry-spine {
  position: relative; width: 3px; flex-shrink: 0; align-self: stretch;
  border-radius: 999px; background: var(--divider); overflow: hidden;
}
/* Share of the post's lifetime still to run — it drains as the post ages. */
.entry-spine::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--life, 0%); background: var(--tone); border-radius: 999px;
}
.entry-tx { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.entry-top { display: flex; align-items: center; gap: 7px; font-size: 11px; min-width: 0; }
.entry-type {
  font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--tone-ink); white-space: nowrap;
}
.entry-grp {
  display: inline-flex; align-items: center; gap: 4px; color: var(--muted);
  font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.entry-grp svg { width: 11px; height: 11px; }
.entry-when { margin-left: auto; color: var(--subtle); font-weight: 600; white-space: nowrap; }
.entry-title {
  font-size: 13.5px; font-weight: 700; color: var(--ink); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.entry.on .entry-title { color: var(--ink); }
.entry-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--muted); font-weight: 600;
}
.entry-meta span { display: inline-flex; align-items: center; gap: 3px; min-width: 0; }
.entry-meta svg { width: 11px; height: 11px; }
.entry-who { color: var(--body); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }

/* ── Reader ───────────────────────────────────────────────────────────── */
.deck-read {
  position: sticky; top: 80px; max-height: calc(100vh - 104px); overflow-y: auto;
  overscroll-behavior: contain; background: var(--paper);
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.read-blank {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 90px 24px; color: var(--subtle); text-align: center;
}
.read-blank svg { width: 30px; height: 30px; }

.read-bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 9px;
  padding: 13px 18px; border-bottom: 1px solid var(--divider);
  background: linear-gradient(var(--tone-soft), var(--tone-soft));
}
.read-bar-tx { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.read-type {
  font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .07em;
  color: var(--tone-ink); white-space: nowrap;
}
.read-sub { font-size: 12px; color: var(--body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.read-act {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  color: var(--tone-ink); flex-shrink: 0;
}
.read-act:hover { background: color-mix(in srgb, var(--tone) 16%, transparent); }
.read-act svg { width: 15px; height: 15px; }
.read-x { display: none; }

.read-body { padding: 20px 22px 24px; }
.read-grp {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px;
  border-radius: 999px; background: var(--bg-2); border: 1px solid var(--hairline);
  font-size: 12px; font-weight: 700; color: var(--body); margin-bottom: 12px;
}
.read-grp:hover { color: var(--ink); background: var(--paper); box-shadow: var(--shadow-sm); }
.read-grp svg { width: 13px; height: 13px; color: var(--muted); }
.read-title { font-size: 23px; font-weight: 900; letter-spacing: -.024em; color: var(--ink); line-height: 1.22; }

.read-who { display: flex; align-items: center; gap: 11px; margin: 15px 0 16px; }
.read-who-tx { min-width: 0; flex: 1; }
.read-who-name { font-weight: 800; color: var(--ink); font-size: 14px; }
.read-who-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.read-life { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.read-life-bar { flex: 1; height: 5px; border-radius: 999px; background: var(--divider); overflow: hidden; }
.read-life-bar span { display: block; height: 100%; border-radius: 999px; background: var(--tone); }
.read-life-tx { font-size: 11.5px; font-weight: 800; color: var(--tone-ink); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }

.read-media { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.read-media.one { grid-template-columns: 1fr; }
.read-img {
  padding: 0; border-radius: var(--r-md); overflow: hidden; background: var(--bg-2);
  aspect-ratio: 16 / 10; display: block;
}
.read-media.one .read-img { aspect-ratio: 16 / 9; }
.read-img img { width: 100%; height: 100%; object-fit: cover; }

.read-text { font-size: 15px; line-height: 1.66; color: var(--body); white-space: pre-wrap; word-break: break-word; }
.read-link {
  display: flex; align-items: center; gap: 9px; margin-top: 16px; padding: 11px 13px;
  border-radius: var(--r-md); background: var(--bg-2); border: 1px solid var(--hairline);
  font-size: 12.5px; font-weight: 600; color: var(--body);
}
.read-link:hover { background: var(--paper); box-shadow: var(--shadow-sm); }
.read-link span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.read-link svg { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }

.read-tags { margin-top: 16px; }
.read-stats {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 18px 0 16px;
  padding-top: 15px; border-top: 1px solid var(--divider);
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.read-stats span { display: inline-flex; align-items: center; gap: 5px; }
.read-stats svg { width: 13px; height: 13px; }
.read-note {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 16px;
  font-size: 12px; color: var(--subtle); line-height: 1.5;
}
.read-note svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

/* ── Poll (read-only) ─────────────────────────────────────────────────── */
.poll { margin-top: 18px; border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 14px; background: var(--bg-2); }
.poll-head { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--ink); font-size: 13.5px; margin-bottom: 11px; }
.poll-head svg { width: 15px; height: 15px; color: var(--tone-ink); }
.poll-opt {
  position: relative; display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 9px; background: var(--paper);
  border: 1px solid var(--hairline); margin-bottom: 6px; overflow: hidden;
}
.poll-opt.on { border-color: var(--tone); }
.poll-fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--tone) 15%, transparent); }
.poll-tx { position: relative; flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.poll-tx svg { width: 13px; height: 13px; color: var(--tone-ink); }
.poll-pct { position: relative; font-size: 12px; font-weight: 800; color: var(--body); font-variant-numeric: tabular-nums; }
.poll-foot { font-size: 11.5px; color: var(--muted); margin-top: 9px; }

/* ── Reaction rail ────────────────────────────────────────────────────── */
.rx { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rx.busy { opacity: .55; pointer-events: none; }
.rx-votes { display: inline-flex; align-items: center; gap: 4px; padding: 3px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--hairline); }
.rx-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px;
  border-radius: 999px; font-size: 12.5px; font-weight: 800; color: var(--muted);
  transition: background .12s, color .12s;
}
.rx-btn svg { width: 14px; height: 14px; }
.rx-btn:hover { background: var(--paper); color: var(--ink); }
.rx-btn.on { background: var(--paper); color: var(--green); box-shadow: var(--shadow-sm); }
.rx-btn.on.down { color: var(--red); }
.rx-btn.on.star { color: var(--star); }
.rx-n { font-variant-numeric: tabular-nums; }

.rx-strip { display: inline-flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.rx-emo {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px;
  border-radius: 999px; border: 1px solid transparent; font-size: 12px; font-weight: 800;
  color: var(--muted); transition: background .12s, border-color .12s, transform .12s;
}
.rx-gly { font-size: 15px; line-height: 1; }
.rx-emo:hover { background: var(--bg-2); transform: translateY(-1px); }
.rx-emo.on { background: var(--tone-soft, var(--orange-soft)); border-color: color-mix(in srgb, var(--tone, var(--orange)) 34%, #fff); color: var(--tone-ink, var(--orange-deep)); }

.rx.compact { gap: 0; }
.rx.compact .rx-votes { background: none; border: none; padding: 0; gap: 0; }
.rx.compact .rx-btn { padding: 5px 7px; font-size: 11.5px; }
.rx.compact .rx-btn svg { width: 13px; height: 13px; }

/* ── Groups: spotlight ────────────────────────────────────────────────── */
.spot {
  position: relative; display: grid; grid-template-columns: 200px 1fr; gap: 24px;
  align-items: center; padding: 26px; margin-bottom: 34px;
  border-radius: var(--r-xl); overflow: hidden;
  background: var(--paper); border: 1px solid var(--hairline); box-shadow: var(--shadow-md);
}
.spot-art, .ghero-art, .gtile-cover {
  background-image: linear-gradient(var(--tilt), var(--c1), var(--c2));
}
.spot-art {
  aspect-ratio: 1; border-radius: var(--r-lg); display: grid; place-items: center;
  color: #fff; font-size: 56px; font-weight: 900; letter-spacing: -.03em;
  box-shadow: var(--shadow-md); user-select: none;
}
.spot-tx { min-width: 0; }
.spot-kicker {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 900;
  text-transform: uppercase; letter-spacing: .08em; color: var(--orange-deep);
}
.spot-kicker svg { width: 13px; height: 13px; }
.spot-name { font-size: 27px; font-weight: 900; letter-spacing: -.028em; color: var(--ink); margin: 7px 0 6px; line-height: 1.15; }
.spot-desc {
  color: var(--body); font-size: 14px; max-width: 62ch;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.spot-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 13px 0; }
.spot-acts { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* ── Groups: shelves ──────────────────────────────────────────────────── */
.shelf { margin-bottom: 34px; }
.shelf-head { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }
.shelf-ic {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--hairline); color: var(--orange-deep);
  box-shadow: var(--shadow-sm); flex-shrink: 0;
}
.shelf-ic svg { width: 17px; height: 17px; }
.shelf-tx { flex: 1; min-width: 0; }
.shelf-tx h3 { font-size: 16px; font-weight: 800; color: var(--ink); letter-spacing: -.018em; }
.shelf-tx p { font-size: 12.5px; color: var(--muted); }
.shelf-nav { display: flex; gap: 6px; flex-shrink: 0; }
.shelf-btn {
  width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--hairline); color: var(--body);
  box-shadow: var(--shadow-sm);
}
.shelf-btn:hover { background: var(--bg-2); color: var(--ink); }
.shelf-btn svg { width: 15px; height: 15px; }
.shelf-rail {
  display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x proximity;
  scrollbar-width: none; padding: 4px 4px 10px; margin: -4px -4px -10px;
}
.shelf-rail::-webkit-scrollbar { display: none; }

.gtile {
  flex: 0 0 226px; scroll-snap-align: start; background: var(--paper);
  border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform .14s, box-shadow .14s;
  display: flex; flex-direction: column;
}
.gtile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.gtile-cover {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9;
  color: #fff; font-size: 30px; font-weight: 900; letter-spacing: -.02em; user-select: none;
}
.gtile-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gtile-mono { position: relative; }
.gtile-flag {
  position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.92); color: var(--green);
  font-size: 10.5px; font-weight: 800;
}
.gtile-flag svg { width: 11px; height: 11px; }
.gtile-tx { padding: 11px 12px 10px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.gtile-name {
  font-size: 13.5px; font-weight: 800; color: var(--ink); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gtile-name:hover { color: var(--orange-deep); }
.gtile-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gtile-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; padding-top: 9px; }
.gtile-count { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 800; color: var(--body); }
.gtile-count svg { width: 12px; height: 12px; color: var(--muted); }

/* ── Group detail ─────────────────────────────────────────────────────── */
.ghero {
  display: grid; grid-template-columns: 148px 1fr; gap: 22px; align-items: center;
  padding: 24px; margin: 26px 0 18px; border-radius: var(--r-xl);
  background: var(--paper); border: 1px solid var(--hairline); box-shadow: var(--shadow-md);
}
.ghero-art {
  aspect-ratio: 1; border-radius: var(--r-lg); display: grid; place-items: center;
  color: #fff; font-size: 44px; font-weight: 900; box-shadow: var(--shadow-md); user-select: none;
}
.ghero-tx { min-width: 0; }
.ghero-top { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 9px; }
.ghero-name { font-size: 28px; font-weight: 900; letter-spacing: -.03em; color: var(--ink); line-height: 1.13; }
.ghero-desc { color: var(--body); font-size: 14px; margin-top: 8px; max-width: 70ch; }
.ghero-acts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 15px; }

.gstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 22px; }
.gstat {
  background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--r-md);
  padding: 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-sm);
}
.gstat-ic { color: var(--muted); }
.gstat-ic svg { width: 15px; height: 15px; }
.gstat-v { font-size: 20px; font-weight: 900; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.gstat-l { font-size: 11.5px; color: var(--muted); font-weight: 700; }

.glayout { display: grid; grid-template-columns: 1fr 330px; gap: 20px; align-items: start; margin-bottom: 64px; }
.gside { position: sticky; top: 80px; }

.kv-list { display: flex; flex-direction: column; gap: 3px; }
.gkv {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  transition: background .12s;
}
.gkv:not(.static):hover { background: var(--bg-2); }
.gkv > svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.gkv .lr-go, .gkv > svg:last-child { color: var(--subtle); }
.gkv-tx { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.gkv-k { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.gkv-v { font-size: 13.5px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }

.gnote { padding: 13px 16px; border-bottom: 1px solid var(--divider); }
.gnote:last-child { border-bottom: none; }
.gnote-t { font-weight: 800; color: var(--ink); font-size: 13.5px; margin-bottom: 3px; }
.gnote-b { font-size: 13px; color: var(--body); line-height: 1.5; white-space: pre-wrap; }
.gnote-w { font-size: 11.5px; color: var(--subtle); margin-top: 5px; }

.grow { display: flex; align-items: center; gap: 12px; padding: 13px 17px; border-bottom: 1px solid var(--divider); transition: background .12s; }
.grow:last-child { border-bottom: none; }
.grow:hover { background: var(--bg-2); }
.grow-tx { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.grow-title { font-size: 13.5px; font-weight: 700; color: var(--ink); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; }
.grow-meta { font-size: 11.5px; color: var(--muted); }
.grow .lr-go { color: var(--subtle); flex-shrink: 0; }
.grow .lr-go svg { width: 16px; height: 16px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .glayout { grid-template-columns: 1fr; }
  .gside { position: static; }
}

@media (max-width: 979px) {
  /* The reader stops being a pane and becomes a sheet over the rail — opened
     by picking an entry, closed by the × in its own bar. */
  .deck { grid-template-columns: 1fr; }
  .deck-rail { position: static; max-height: none; }
  .deck-read { display: none; }
  .deck.open .deck-read {
    display: block; position: fixed; inset: 0; z-index: 120;
    max-height: none; height: 100%; border-radius: 0; border: none;
    animation: sheet-up .2s cubic-bezier(.2,.9,.3,1);
  }
  @keyframes sheet-up { from { opacity: 0; transform: translateY(18px); } }
  .read-x { display: grid; }
  .read-bar { padding: 14px 16px; }
  .read-body { padding: 18px 16px 40px; }
}

@media (max-width: 780px) {
  .spot { grid-template-columns: 1fr; gap: 16px; padding: 18px; }
  .spot-art { aspect-ratio: 16 / 7; font-size: 42px; }
  .spot-name { font-size: 22px; }
  .ghero { grid-template-columns: 1fr; gap: 16px; padding: 18px; }
  .ghero-art { aspect-ratio: 16 / 7; font-size: 38px; }
  .ghero-name { font-size: 23px; }
  .gstats { grid-template-columns: repeat(2, 1fr); }
  .read-title { font-size: 20px; }
  .read-media { grid-template-columns: 1fr; }
}
