/*
 * Emoji / comment / bookmark / share / embed UI (js/content-social.js):
 * floating bottom bar, Send Emoji popover, share + embed dialogs and the
 * shared /reactions and /comments pages.
 */

/* ---------- Floating bottom bar ---------- */

.cs-bar {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 1100;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100vw - 16px);
  padding: 4px 8px;
  border-radius: var(--r-pill);
  background: #fff;
  box-shadow: 0 4px 18px rgba(11, 46, 34, .18), 0 0 0 1px rgba(11, 46, 34, .05);
  font-family: var(--font);
  color: var(--c-text);
}
.cs-bar__grp { display: flex; align-items: center; }
.cs-bar__grp + .cs-bar__grp { margin-left: 6px; padding-left: 6px; border-left: 1px solid var(--c-line); }
.cs-bar__btn {
  display: inline-grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--c-text);
  cursor: pointer;
  text-decoration: none;
}
.cs-bar__btn[hidden] { display: none; }
.cs-bar__btn .icon { width: 24px; height: 24px; }
.cs-bar__btn:hover { background: var(--c-bg-2); }
.cs-bar__btn.is-on { color: var(--c-text); }
.cs-bar__btn[data-cs="emoji"].is-on { color: var(--c-forest-700); }
.cs-bar__count {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: var(--touch);
  padding: 0 8px 0 2px;
  color: var(--c-text-2);
  font-size: var(--fs-sm);
  text-decoration: none;
  white-space: nowrap;
}
.cs-bar__count b { color: var(--c-text); font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.cs-bar__count:hover b { text-decoration: underline; }
.cs-bar :focus-visible { outline: 3px solid var(--c-focus); outline-offset: 1px; }
@media (max-width: 380px) {
  .cs-bar { padding: 2px 4px; }
  .cs-bar__btn { width: 40px; }
  .cs-bar__grp + .cs-bar__grp { margin-left: 2px; padding-left: 2px; }
}
body.cs-has-bar .site-footer[data-shell] .sh-foot { padding-bottom: 96px; }
body.cs-has-bar .site-main { padding-bottom: 72px; }
body.cs-has-bar .tm-toast-host { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

/* Count links in the activity / moment summary rows. */
.ex-social__link { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; color: inherit; text-decoration: none; }
.ex-social__link:hover b { color: var(--c-forest-700); text-decoration: underline; }

/* ---------- Send Emoji popover ---------- */

.cs-emoji {
  position: fixed;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 120px));
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--shadow-3), 0 0 0 1px rgba(11, 46, 34, .06);
  font-family: var(--font);
  color: var(--c-text);
  line-height: 1.5;
}
.cs-emoji--sheet {
  left: 0 !important;
  right: 0;
  bottom: 0 !important;
  top: auto !important;
  width: 100%;
  max-height: 72vh !important;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.cs-emoji__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 6px 18px; border-bottom: 1px solid var(--c-line); }
.cs-emoji__head h2 { margin: 0; font-size: var(--fs-base); font-weight: 800; }
.cs-emoji__close {
  width: var(--touch);
  height: var(--touch);
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: #666;
  cursor: pointer;
}
.cs-emoji__body { overflow-y: auto; padding: 8px 14px 14px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.cs-emoji__group h3 { margin: 10px 0 6px; font-size: var(--fs-xs); font-weight: 700; color: var(--c-text-2); }
.cs-emoji__sent { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-emoji__empty { margin: 0; font-size: var(--fs-sm); }
.cs-emoji__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 2px; }
.cs-emo {
  display: grid;
  place-items: center;
  height: 44px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", var(--font);
}
.cs-emo:hover { background: var(--c-bg-2); }
.cs-emo.is-on { background: #E3F2FD; box-shadow: inset 0 0 0 1.5px #64B5F6; }
.cs-emoji :focus-visible { outline: 3px solid var(--c-focus); outline-offset: 1px; }

/* Emoji count chips (popover "sent" row, comment reactions). */
.cs-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--c-text);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.cs-chip__e { font-size: 18px; line-height: 1; }
.cs-chip b { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 700; }
.cs-chip.is-on { background: #E3F2FD; border-color: #90CAF9; }
.cs-chip:disabled { cursor: default; }
.cs-chip--add { color: var(--c-text-2); }
.cs-chip--add .icon { width: 18px; height: 18px; }

.cs-muted { color: var(--c-muted); }

/* ---------- Share / embed dialogs ---------- */

.cs-modal .modal__title { text-align: center; margin: 0 40px var(--sp-4); }
.cs-share { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--sp-4); margin: var(--sp-2) 0 var(--sp-4); padding: 0; list-style: none; }
.cs-share__item {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 72px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--c-text);
  font-size: var(--fs-sm);
  text-decoration: none;
  cursor: pointer;
}
.cs-share__ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; color: #fff; }
.cs-share__ic svg { width: 28px; height: 28px; }
.cs-share__ic--line { background: #06C755; }
.cs-share__ic--x { background: #000; }
.cs-share__ic--x svg { width: 22px; height: 22px; }
.cs-share__ic--facebook { background: #1877F2; }
.cs-share__ic--link { background: var(--c-rock-100); color: var(--c-text); box-shadow: inset 0 0 0 1px var(--c-line); }
.cs-share__ic--link svg { width: 24px; height: 24px; }
.cs-share__item:hover .cs-share__ic { filter: brightness(.94); }
.cs-share__url input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  background: var(--c-bg-2);
  font-size: var(--fs-sm);
  color: var(--c-text-2);
}

.cs-modal--embed .modal__panel { width: min(600px, 100%); }
.cs-embed__code {
  display: block;
  width: 100%;
  min-height: 132px;
  padding: 10px 12px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  background: var(--c-bg-2);
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--c-text);
  resize: vertical;
}
.cs-embed__mode { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin: var(--sp-3) 0 0; padding: 0; border: 0; }
.cs-embed__mode legend { float: left; margin-right: var(--sp-3); font-weight: 700; font-size: var(--fs-sm); line-height: 44px; }
.cs-embed__mode label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer; }
.cs-embed__mode input { width: 18px; height: 18px; accent-color: var(--c-forest-700); }
.cs-embed__preview { margin-top: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-md); background: var(--c-bg-2); }
.cs-embed__preview iframe { display: block; width: 100%; max-width: 440px; height: 420px; margin: 0 auto; border: 0; border-radius: 12px; background: #fff; }
.cs-embed__help { margin: var(--sp-3) 0 0; font-size: var(--fs-sm); }

/* ---------- Shared /reactions and /comments pages ---------- */

.cs-page { max-width: 720px; margin: 0 auto; padding: var(--sp-4) 0 var(--sp-7); }
.cs-page__head { display: grid; grid-template-columns: var(--touch) minmax(0, 1fr) var(--touch); align-items: center; margin-bottom: var(--sp-3); }
.cs-page__head h1 { margin: 0; text-align: center; font-size: var(--fs-lg); font-weight: 800; }
.cs-back {
  display: inline-grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  border-radius: 50%;
  color: var(--c-text);
  text-decoration: none;
}
.cs-back:hover { background: var(--c-bg-2); }
.cs-back svg { width: 24px; height: 24px; }
.cs-target {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--c-bg-2);
  color: inherit;
  text-decoration: none;
}
.cs-target:hover { background: var(--c-moss-100); }
.cs-target .avatar { width: 36px; height: 36px; flex: none; }
.cs-target__txt { min-width: 0; }
.cs-target__title { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-target__sub { display: block; font-size: var(--fs-xs); color: var(--c-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-state { padding: var(--sp-7) var(--sp-4); text-align: center; color: var(--c-text-2); }
.cs-state .btn { margin: var(--sp-2) 4px 0; }
.cs-foot { display: flex; justify-content: center; margin-top: var(--sp-6); }
.cs-foot .btn { min-width: 240px; }

/* Reactions: tabs + people */
.cs-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 var(--sp-3); padding: 2px 2px 8px; scrollbar-width: thin; }
.cs-tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--c-text);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.cs-tab b { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.cs-tab .cs-chip__e { font-size: 18px; }
.cs-tab[aria-selected="true"] { background: var(--c-forest-900); border-color: var(--c-forest-900); color: #fff; }
.cs-people { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--c-line); }
.cs-person { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: var(--sp-3); align-items: start; padding: var(--sp-4) 0; border-bottom: 1px solid var(--c-line); }
.cs-person .avatar { width: 52px; height: 52px; }
.cs-person__name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 700; color: var(--c-text); text-decoration: none; }
.cs-person__name:hover { text-decoration: underline; }
.cs-person__meta { margin-top: 2px; font-size: var(--fs-xs); color: var(--c-muted); }
.cs-person__bio { margin-top: 4px; font-size: var(--fs-sm); color: var(--c-text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cs-person__emojis { margin-top: 6px; font-size: 20px; line-height: 1.3; letter-spacing: 2px; word-break: break-all; }
.cs-person .btn { min-height: 36px; padding: 6px 14px; font-size: var(--fs-sm); }
.cs-person .btn.is-following { background: var(--c-bg-2); }

/* Comments */
.cs-comments { margin: 0; padding: 0; list-style: none; }
.cs-c { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: var(--sp-3); padding: var(--sp-3) 0; }
.cs-c > .avatar { width: 44px; height: 44px; }
.cs-c .cs-comments { margin-top: var(--sp-2); padding-left: 0; }
.cs-c .cs-c { grid-template-columns: 34px minmax(0, 1fr); padding: var(--sp-2) 0; }
.cs-c .cs-c > .avatar { width: 34px; height: 34px; }
.cs-c__meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: var(--fs-sm); }
.cs-c__meta a { color: var(--c-text); font-weight: 700; text-decoration: none; }
.cs-c__meta a:hover { text-decoration: underline; }
.cs-c__meta time { color: var(--c-muted); font-size: var(--fs-xs); }
.cs-c__owner { padding: 0 8px; border-radius: var(--r-pill); background: var(--c-moss-100); color: var(--c-forest-700); font-size: 11px; font-weight: 700; }
.cs-c__bubble { position: relative; margin-top: 4px; padding: var(--sp-3) 52px var(--sp-3) var(--sp-4); border-radius: 4px var(--r-md) var(--r-md) var(--r-md); background: var(--c-bg-2); }
.cs-c__text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.75; }
.cs-c__hidden { margin-top: 4px; font-size: var(--fs-xs); color: var(--c-caution); }
.cs-c__react {
  position: absolute;
  right: 4px;
  top: 4px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--c-text-2);
  cursor: pointer;
}
.cs-c__react:hover { background: rgba(0, 0, 0, .05); color: var(--c-text); }
.cs-c__react .icon { width: 20px; height: 20px; }
.cs-c__rx { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cs-c__rx .cs-chip { min-height: 30px; padding: 0 8px; font-size: var(--fs-xs); }
.cs-c__rx .cs-chip__e { font-size: 16px; }
.cs-c__acts { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin-top: 2px; }
.cs-c__acts button {
  min-height: 36px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--c-text-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  cursor: pointer;
}
.cs-c__acts button:hover { color: var(--c-text); text-decoration: underline; }
.cs-c__acts .sh-report-link { margin-left: auto; font-weight: 400; }

.cs-empty { display: grid; justify-items: center; gap: var(--sp-2); padding: var(--sp-6) var(--sp-4) var(--sp-5); text-align: center; }
.cs-empty img { width: min(240px, 70%); height: auto; }
.cs-empty h2 { margin: var(--sp-2) 0 0; font-size: var(--fs-base); font-weight: 800; }
.cs-empty p { margin: 0; color: var(--c-muted); font-size: var(--fs-sm); }

.cs-compose { margin-top: var(--sp-5); padding: var(--sp-4); border-radius: var(--r-md); background: #fff; box-shadow: var(--shadow-1), 0 0 0 1px var(--c-line); }
.cs-compose__row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--sp-3); align-items: start; }
.cs-compose .avatar { width: 40px; height: 40px; }
.cs-compose textarea {
  display: block;
  width: 100%;
  min-height: 88px;
  padding: 10px 12px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  background: #fff;
  line-height: 1.7;
  resize: vertical;
}
.cs-compose textarea:focus { border-color: var(--c-forest-500); outline: none; box-shadow: 0 0 0 3px rgba(31, 138, 91, .18); }
.cs-compose__reply { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: var(--fs-sm); color: var(--c-text-2); }
.cs-compose__reply[hidden] { display: none; }
.cs-compose__reply button { min-height: 32px; padding: 0 8px; border: 0; border-radius: var(--r-pill); background: var(--c-bg-2); cursor: pointer; font-size: var(--fs-xs); }
.cs-compose__foot { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3); margin-top: var(--sp-2); }
.cs-compose__count { font-size: var(--fs-xs); color: var(--c-muted); font-variant-numeric: tabular-nums; }
.cs-compose__count.is-over { color: var(--c-danger); font-weight: 700; }
.cs-compose__note { margin: 0; text-align: center; color: var(--c-text-2); font-size: var(--fs-sm); }
.cs-compose__note .btn { margin: var(--sp-3) 4px 0; }
