/* GLEAN — the chat (chat.js). Shared by / and /issue-02; both define the tokens
   (--bg, --bg-soft, --ink, --ink-dim, --accent, --accent-ink, --line, --read). */

/* ── the body, wherever it is hosted ──────────────────────────────────────── */
.gc-body { padding-bottom: 8px; }
.gc-body .hidden { display: none !important; }
.gc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.gc-body label {
  display: block; margin: 0 0 8px; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-dim);
}
.gc-body input, .gc-body textarea {
  width: 100%; background: var(--bg-soft); color: var(--ink); border: 0.5px solid var(--line);
  border-radius: 10px; padding: 13px 15px; resize: none;
  font-family: var(--read); font-size: 16px; line-height: 1.5; /* 16px floor: iOS zooms below it */
}
.gc-body input::placeholder, .gc-body textarea::placeholder { color: var(--ink-dim); font-style: italic; }
.gc-body input:focus, .gc-body textarea:focus, .gc-select:focus { outline: none; border-color: var(--accent); }

.gc-pinned { margin-top: 4px; }
.gc-pinned:empty { display: none; }

/* The composer: one line until you start writing, then name, town and piece. */
.gc-form { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.gc-form textarea { min-height: 52px; }
.gc-count { margin-top: -6px; text-align: right; font-size: 10px; letter-spacing: 0.1em; color: var(--ink-dim); display: none; }
.gc-form.open .gc-count { display: block; }
.gc-count.low { color: var(--accent); }
.gc-extra { display: none; flex-direction: column; gap: 12px; }
.gc-form.open .gc-extra { display: flex; }
.gc-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.gc-meta > div { flex: 1; min-width: 150px; }
.gc-select {
  width: 100%; font-family: var(--read); font-size: 16px; color: var(--ink);
  background: var(--bg-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 15px center;
  border: 0.5px solid var(--line); border-radius: 10px; padding: 13px 40px 13px 15px; min-height: 50px;
  -webkit-appearance: none; appearance: none;
}
.gc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.gc-send {
  align-self: flex-end; min-width: 108px; min-height: 44px; padding: 0 22px; border: none; border-radius: 999px;
  background: var(--accent); color: #0b0b0c; cursor: pointer;
  font-family: 'Geist Mono', monospace; font-size: 13px; font-weight: 500; letter-spacing: 0.06em;
}
.gc-send:disabled { opacity: 0.5; }
.gc-status { font-size: 12px; letter-spacing: 0.03em; color: var(--ink-dim); text-align: right; }
.gc-status:empty { display: none; }
.gc-status.err { color: var(--accent); }
.gc-quote-draft { display: flex; gap: 10px; align-items: flex-start; }
.gc-quote-draft blockquote { flex: 1; }
.gc-quote-draft button {
  background: none; border: none; color: var(--ink-dim); font-size: 22px; line-height: 1;
  min-width: 44px; min-height: 44px; cursor: pointer;
}

/* The prioritised group: threads on the piece being read. */
.gc-group { margin-top: 22px; }
.gc-group-h, .gc-day {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-dim);
}
.gc-group-h { color: var(--accent-ink); margin-bottom: 12px; }
.gc-group-list { display: flex; flex-direction: column; gap: 14px; }

.gc-feed { margin-top: 26px; display: flex; flex-direction: column; gap: 14px; }
.gc-feed.after-group { padding-top: 22px; border-top: 0.5px solid var(--line); }
.gc-day { display: flex; align-items: center; gap: 12px; margin: 8px 0 -2px; }
.gc-day::before, .gc-day::after { content: ''; flex: 1; border-top: 0.5px solid var(--line); }
.gc-empty { font-family: var(--read); font-style: italic; font-size: 15px; color: var(--ink-dim); text-align: center; padding: 12px 0; }
.gc-more { margin-top: 18px; text-align: center; }
.gc-sentinel { height: 1px; }
.gc-earlier {
  background: none; border: 0.5px solid var(--line); border-radius: 999px; color: var(--ink);
  font-family: 'Geist Mono', monospace; font-size: 12px; letter-spacing: 0.06em; padding: 0 22px; min-height: 44px; cursor: pointer;
}

/* ── a thread: the idea, then the back-and-forth ──────────────────────────── */
.gc-thread {
  display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 18px;
  background: rgba(233, 228, 219, 0.025); border: 0.5px solid var(--line);
  transition: transform 0.15s ease, border-color 0.4s;
}
.gc-thread.pin { border-color: var(--accent); background: rgba(232, 84, 43, 0.05); }
.gc-thread.flash { border-color: var(--accent); }
.gc-bubble {
  align-self: flex-start; max-width: 92%;
  background: var(--bg-soft); border: 0.5px solid var(--line);
  border-radius: 16px 16px 16px 5px; padding: 9px 13px 10px;
}
.gc-bubble.root { max-width: 100%; align-self: stretch; border-radius: 14px; }
.gc-thread.pin .gc-bubble.root { background: transparent; border: none; padding: 2px 2px 4px; }
.gc-bubble.mine:not(.root) { align-self: flex-end; border-radius: 16px 16px 5px 16px; border-color: rgba(232, 84, 43, 0.55); }
.gc-who { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; font-size: 11px; letter-spacing: 0.04em; color: var(--ink-dim); }
.gc-who b { font-weight: 500; color: var(--ink); letter-spacing: 0.02em; }
.gc-meta-t { margin-left: auto; padding-left: 8px; font-size: 10px; letter-spacing: 0.06em; white-space: nowrap; }
.gc-mono {
  width: 20px; height: 20px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Geist Mono', monospace; font-size: 10px; color: #eee;
}
.gc-text {
  font-family: var(--read); font-size: 16px; line-height: 1.5; color: var(--ink);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.gc-link { color: var(--accent-ink); text-decoration: none; border-bottom: 0.5px solid currentColor; }
.gc-pull, .gc-quote-draft blockquote {
  margin: 2px 0 8px; padding: 2px 0 2px 12px; border-left: 2px solid var(--accent);
  font-family: var(--read); font-style: italic; font-size: 15px; line-height: 1.5; color: var(--ink-dim);
}
.gc-foot { margin-top: 7px; }
.gc-piece { font-size: 11px; letter-spacing: 0.04em; color: var(--accent-ink); text-decoration: none; border-bottom: 0.5px solid currentColor; }
.gc-more-replies {
  align-self: flex-start; background: none; border: none; padding: 4px 2px; min-height: 32px; cursor: pointer;
  font-family: 'Geist Mono', monospace; font-size: 11px; letter-spacing: 0.06em; color: var(--accent-ink);
}
.gc-tbar { display: flex; align-items: center; gap: 4px; margin: 0 -4px -6px; }
.gc-tbar button {
  background: none; border: none; cursor: pointer; min-height: 40px; padding: 0 8px;
  font-family: 'Geist Mono', monospace; font-size: 11px; letter-spacing: 0.06em; color: var(--ink-dim);
}
.gc-tbar .gc-reply { color: var(--ink); }
.gc-tbar button:hover { color: var(--accent-ink); }

/* Replying in place, inside the thread. */
.gc-rbox { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.gc-rrow { display: flex; gap: 8px; align-items: flex-end; }
.gc-rrow textarea { min-height: 46px; padding: 11px 14px; border-radius: 22px; }
.gc-rrow button {
  flex: none; min-height: 46px; min-width: 64px; border: none; border-radius: 999px; background: var(--accent); color: #0b0b0c;
  font-family: 'Geist Mono', monospace; font-size: 12px; font-weight: 500; cursor: pointer;
}

/* ── the sheet (phone) / side panel (desktop) ─────────────────────────────── */
.gc-scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(11, 10, 12, 0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.18s ease;
}
.gc-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  height: min(88svh, 900px); display: flex; flex-direction: column;
  background: #141216; border-top: 0.5px solid var(--line); border-radius: 18px 18px 0 0;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.45);
  transform: translateY(105%); transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), border-radius 0.18s;
  visibility: hidden;
}
/* Full screen: dragged up by the handle (chat.js). */
html.gc-full .gc-sheet { height: 100svh; border-radius: 0; border-top: none; }
html.gc-full .gc-head { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
html.gc-full .gc-grip { top: calc(7px + env(safe-area-inset-top, 0px)); }
html.gc-open .gc-sheet { transform: none; visibility: visible; }
html.gc-open .gc-scrim { opacity: 1; pointer-events: auto; }
.gc-head { position: relative; flex: none; padding: 8px 16px 10px; display: flex; align-items: center; touch-action: none; cursor: grab; }
.gc-grip { position: absolute; top: 7px; left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; }
.gc-grip span { width: 38px; height: 4px; border-radius: 4px; background: rgba(233, 228, 219, 0.22); }
.gc-title { margin-top: 12px; font-family: 'Bodoni Moda', Georgia, serif; font-weight: 700; font-size: 24px; color: var(--ink); }
.gc-title .dot { color: var(--accent); }
.gc-x {
  margin: 10px -8px 0 auto; background: none; border: none; color: var(--ink-dim); cursor: pointer;
  font-size: 28px; line-height: 1; min-width: 44px; min-height: 44px;
}
.gc-scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 2px 16px calc(28px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 1000px) {
  .gc-scrim { display: none; }
  .gc-sheet {
    left: auto; top: 0; height: auto; width: min(440px, 36vw); border-radius: 0;
    border-top: none; border-left: 0.5px solid var(--line); box-shadow: -18px 0 50px rgba(0, 0, 0, 0.4);
    transform: translateX(105%);
  }
  .gc-grip { display: none; }
  html.gc-full .gc-sheet { height: auto; }
  .gc-head { cursor: default; }
  .gc-head { padding: 14px 22px 10px; }
  .gc-title { margin-top: 0; }
  .gc-x { margin-top: 0; }
  .gc-scroll { padding: 2px 22px 32px; }
}
@media (prefers-reduced-motion: reduce) { .gc-sheet, .gc-scrim { transition: none; } }

/* ── in the reader: the way in, the peek, and "Bring to the chat" ─────────── */
.gc-pill {
  position: fixed; right: 14px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 7;
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 15px; border-radius: 999px;
  background: rgba(17, 16, 19, 0.86); backdrop-filter: blur(10px); border: 0.5px solid rgba(233, 228, 219, 0.18);
  color: var(--ink); cursor: pointer; font-family: 'Geist Mono', monospace; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  transition: opacity 0.2s;
}
.gc-pill b { font-weight: 500; color: var(--accent-ink); text-transform: none; letter-spacing: 0.02em; }
body.card-open .gc-pill, body.sheet-open .gc-pill, html.gc-open .gc-pill, html.gc-peeking .gc-pill { opacity: 0; pointer-events: none; }
.gc-peek {
  position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 8;
  width: min(380px, calc(100vw - 24px)); transform: translate(-50%, 140%);
  display: flex; flex-direction: column; gap: 4px; padding: 10px 14px 11px; border-radius: 16px; text-align: left;
  background: rgba(20, 18, 22, 0.94); backdrop-filter: blur(12px); border: 0.5px solid rgba(232, 84, 43, 0.5);
  color: var(--ink); cursor: pointer; transition: transform 0.22s ease, opacity 0.22s; opacity: 0;
}
@media (min-width: 1000px) { .gc-peek { left: auto; right: 16px; transform: translateY(140%); } }
html.gc-peeking .gc-peek { transform: translate(-50%, 0); opacity: 1; }
@media (min-width: 1000px) { html.gc-peeking .gc-peek { transform: none; } }
html.gc-peeking .counter { opacity: 0; }
.gc-peek .gc-who { margin: 0; }
.gc-peek-line { font-family: var(--read); font-size: 15px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gc-peek-go { font-family: 'Geist Mono', monospace; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-ink); }
.gc-bring {
  position: fixed; z-index: 40; transform: translate(-50%, -100%); margin-top: -10px;
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--accent); color: #0b0b0c; font-family: 'Geist Mono', monospace; font-size: 12px; font-weight: 500;
  letter-spacing: 0.04em; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); white-space: nowrap;
}
