/* Threaded comments (js/components/comments.js): XHS-style list — avatar, name, text, time · 回复,
 * like on the right; replies indented under their thread with "展开 N 条回复"; one composer sheet. */

.tbc { background: var(--tb-surface); color: var(--tb-ink); }
/* Host pages (legacy detail / novel panels) style bare buttons; keep [hidden] authoritative. */
.tbc [hidden], .tbc-sheet-layer [hidden], .tbc-composer-layer [hidden] { display: none !important; }
.tbc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--tb-gutter) 6px;
}
.tbc-title { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.4; }
.tbc-title__num { margin-left: 2px; color: var(--tb-muted); font-size: 15px; font-weight: 400; }
.tbc-sort { display: flex; gap: 2px; padding: 2px; border-radius: var(--tb-radius-pill); background: var(--tb-fill); }
.tbc-sort__btn {
  height: 28px;
  margin: 0;
  padding: 0 12px;
  border: 0;
  border-radius: var(--tb-radius-pill);
  background: transparent;
  color: var(--tb-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.tbc-sort__btn[aria-selected="true"] { background: var(--tb-surface); color: var(--tb-ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 8%); }

/* "说点什么…" prompt that opens the composer */
.tbc-prompt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - var(--tb-gutter) * 2);
  height: 40px;
  margin: 6px var(--tb-gutter) 4px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--tb-radius-pill);
  background: var(--tb-fill);
  color: var(--tb-muted);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: text;
}
.tbc-prompt__text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbc-prompt__tools { display: inline-flex; gap: 10px; color: var(--tb-ink-2); }
.tbc-prompt__tools ti-icon { --ti-icon-size: 20px !important; width: 20px; height: 20px; }

/* ---------- Items ---------- */
.tbc-list { padding-bottom: 8px; }
.tbc-thread { padding: 0 var(--tb-gutter); }
.tbc-thread + .tbc-thread .tbc-item:first-child { border-top: 1px solid var(--tb-divider); }
.tbc-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-radius: 8px;
  transition: background-color .6s ease;
}
.tbc-item > .tb-avatar { --tb-avatar: 34px; margin-top: 2px; }
.tbc-item--child { padding: 8px 0; }
.tbc-item--child > .tb-avatar { --tb-avatar: 24px; }
.tbc-item { scroll-margin-top: 72px; }
.tbc-item.is-focus { background: rgb(33 150 243 / 8%); box-shadow: 0 0 0 6px rgb(33 150 243 / 8%); transition: none; }
.tbc-item__main { flex: 1 1 auto; min-width: 0; }
.tbc-item__head { display: flex; align-items: center; gap: 6px; min-width: 0; line-height: 18px; }
.tbc-name {
  min-width: 0;
  overflow: hidden;
  color: var(--tb-muted);
  font-size: 13px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (hover: hover) { a.tbc-name:hover { color: var(--tb-ink-2); } }
.tbc-badge {
  flex: none;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--tb-fill);
  color: var(--tb-ink-2);
  font-size: 11px;
  line-height: 16px;
}
.tbc-text {
  margin-top: 3px;
  color: var(--tb-ink);
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.tbc-item--child .tbc-text { font-size: 14px; }
.tbc-at { color: var(--tb-primary); text-decoration: none; }
.tbc-text .tbs-at { color: var(--tb-primary); }
.tbc-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tbc-image {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: var(--tb-bg);
  cursor: zoom-in;
}
.tbc-image > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tbc-item__meta { display: flex; align-items: center; gap: 14px; margin-top: 4px; color: var(--tb-muted); font-size: 12px; line-height: 20px; }
.tbc-meta-btn {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tb-ink-2);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.tbc-meta-btn::after { content: ""; position: absolute; inset: -12px -8px; }
.tbc-meta-btn--more { display: inline-flex; color: var(--tb-muted); }
.tbc-meta-btn--more ti-icon { --ti-icon-size: 16px !important; width: 16px; height: 16px; }
.tbc-like {
  position: relative;
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 32px;
  margin: 2px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tb-muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.tbc-like::after { content: ""; position: absolute; inset: -8px -6px; }
.tbc-like ti-icon { --ti-icon-size: 18px !important; width: 18px; height: 18px; }
.tbc-like[aria-pressed="true"] { color: var(--tbs-like, #e0245e); }
.tbc-like.is-popping ti-icon { animation: tbs-pop .32s ease; }
.tbc-like__num { min-height: 14px; line-height: 14px; font-variant-numeric: tabular-nums; }

/* Thread children sit under the root's text column. */
.tbc-children { margin: -6px 0 6px 44px; }
.tbc-expand {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  margin: 0 0 2px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tb-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.tbc-expand ti-icon { --ti-icon-size: 14px !important; width: 14px; height: 14px; }
.tbc-expand.is-loading { opacity: .6; }

.tbc-empty { margin: 0; padding: 40px var(--tb-gutter); color: var(--tb-muted); font-size: 14px; text-align: center; }
.tbc-retry { margin-left: 6px; padding: 0; border: 0; background: none; color: var(--tb-primary); font: inherit; cursor: pointer; }
.tbc-loading { display: grid; gap: 10px; padding: 16px var(--tb-gutter); }
.tbc-more {
  display: block;
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tb-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.tbc-more[aria-busy="true"]::before { content: "加载中…"; }
.tbc-more[aria-busy="true"] { font-size: 0; }
.tbc-more[aria-busy="true"]::before { font-size: 13px; }

/* ---------- Docked layout (inside a sheet): sticky head, list scrolls, prompt pinned at the bottom ---------- */
.tbc-close { --tb-icon: 22px; flex: none; margin-right: -8px; color: var(--tb-ink-2); }
.tbc--docked .tbc-head { position: sticky; top: 0; z-index: 2; padding-top: 12px; padding-bottom: 8px; background: var(--tb-surface); }
.tbc--docked .tbc-sort { margin-left: auto; }
.tbc-dock {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: auto;
  padding: 8px var(--tb-gutter) calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--tb-divider);
  background: var(--tb-surface);
}
.tbc-dock .tbc-prompt { width: 100%; margin: 0; }

/* ---------- Comment sheet (TibiuComments.openSheet) ---------- */
.tbc-sheet-layer { position: fixed; inset: 0; z-index: 1900; }
.tbc-sheet-layer:not(.is-open) { display: none; }
.tbc-sheet-layer > .tb-mask { background: rgb(0 0 0 / 36%); }
.tbc-sheet-layer.is-open > .tb-mask { animation: tbs-fade .2s ease; }
.tbc-sheet {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  height: min(78dvh, 720px);
  overflow: hidden;
  border-radius: 16px 16px 0 0;
  background: var(--tb-surface);
  box-shadow: 0 -8px 24px rgb(0 0 0 / 10%);
}
.tbc-sheet-layer.is-open > .tbc-sheet { animation: tbs-rise .24s cubic-bezier(.2, .8, .2, 1); }
.tbc-sheet__body { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.tbc-sheet__body .tbc-list { flex: none; }

/* ---------- Composer sheet ---------- */
.tbc-composer-layer { position: fixed; inset: 0; z-index: 2000; }
.tbc-composer-layer:not(.is-open) { display: none; }
.tbc-composer-layer.is-open > .tb-mask { animation: tbs-fade .2s ease; }
.tbc-composer-layer > .tb-mask { background: rgb(0 0 0 / 28%); }
.tbc-composer {
  bottom: var(--tbc-kb, 0px);
  max-height: calc(100dvh - var(--tbc-kb, 0px) - 40px);
  margin: 0;
  padding: 12px var(--tb-gutter) calc(8px + env(safe-area-inset-bottom, 0px));
  overflow: auto;
  border-radius: 16px 16px 0 0;
  overscroll-behavior: contain;
}
.tbc-composer-layer.is-open > .tbc-composer { animation: tbs-rise .22s cubic-bezier(.2, .8, .2, 1); }
.tbc-composer__target { margin: 0 0 6px; color: var(--tb-muted); font-size: 13px; }
.tbc-composer__input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 160px;
  margin: 0;
  padding: 11px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--tb-fill);
  color: var(--tb-ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  resize: none;
  outline: none;
}
.tbc-composer__input::placeholder { color: var(--tb-muted); }
.tbc-composer__images { display: flex; gap: 8px; margin-top: 10px; }
.tbc-composer__thumb { position: relative; width: 64px; height: 64px; overflow: hidden; border-radius: 8px; background: var(--tb-bg); }
.tbc-composer__thumb > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tbc-composer__thumb.is-loading > img { opacity: .5; }
.tbc-composer__progress { position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: linear-gradient(90deg, var(--tb-primary) var(--p, 0%), transparent 0); }
.tbc-composer__remove {
  position: absolute;
  top: 2px;
  right: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  cursor: pointer;
}
.tbc-composer__remove ti-icon { --ti-icon-size: 12px !important; width: 12px; height: 12px; }
.tbc-composer__bar { display: flex; align-items: center; gap: 0; margin: 6px -10px 0; }
.tbc-tool { --tb-icon: 22px; color: var(--tb-ink-2); }
.tbc-tool[aria-pressed="true"] { color: var(--tb-primary); }
.tbc-composer__count { margin-left: auto; padding-right: 10px; color: var(--tb-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tbc-composer__count.is-over { color: var(--tb-danger); }
.tbc-composer__send { margin-right: 10px; min-width: 64px; }
.tbc-composer__panel { max-height: 240px; margin: 4px calc(var(--tb-gutter) * -1) 0; overflow: auto; border-top: 1px solid var(--tb-divider); }
.tbc-composer__hint { margin: 0; padding: 24px var(--tb-gutter); color: var(--tb-muted); font-size: 13px; text-align: center; }
.tbc-emoji__tabs { position: sticky; top: 0; z-index: 1; display: flex; gap: 18px; padding: 0 var(--tb-gutter); overflow-x: auto; background: var(--tb-surface); scrollbar-width: none; }
.tbc-emoji__tab { flex: none; height: 38px; padding: 0; border: 0; background: none; color: var(--tb-muted); font: inherit; font-size: 13px; cursor: pointer; }
.tbc-emoji__tab[aria-selected="true"] { color: var(--tb-ink); font-weight: 600; }
.tbc-emoji__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); padding: 4px 8px 8px; }
.tbc-emoji__item { display: flex; align-items: center; justify-content: center; height: 44px; padding: 0; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.tbc-emoji__item > img { width: 30px; height: 30px; object-fit: contain; }
@media (hover: hover) { .tbc-emoji__item:hover { background: var(--tb-fill); } }
.tbc-mention { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 6px var(--tb-gutter); border: 0; background: none; color: var(--tb-ink); font: inherit; text-align: left; cursor: pointer; }
.tbc-mention + .tbc-mention { border-top: 1px solid var(--tb-divider); }
.tbc-mention__name { font-size: 15px; font-weight: 600; }
.tbc-mention__handle { overflow: hidden; color: var(--tb-muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) { .tbc-mention:hover { background: var(--tb-fill); } }

@media (min-width: 761px) {
  .tbc-composer {
    top: auto;
    right: auto;
    bottom: max(10vh, 48px);
    left: 50%;
    width: 560px;
    padding: 16px 20px 12px;
    border-radius: 16px;
    transform: translateX(-50%);
  }
  .tbc-composer-layer.is-open > .tbc-composer { animation: tbc-zoom .18s ease; }
  .tbc-sheet {
    top: 50%;
    right: auto;
    bottom: auto;
    left: 50%;
    width: 600px;
    height: min(80vh, 760px);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgb(0 0 0 / 18%);
    transform: translate(-50%, -50%);
  }
  .tbc-sheet-layer.is-open > .tbc-sheet { animation: tbc-pop-in .18s ease; }
  .tbc-dock { padding-bottom: 12px; }
  .tbc-composer__panel { margin-inline: -20px; }
  .tbc-thread { padding: 0 var(--tb-gutter); }
}
@keyframes tbc-zoom { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes tbc-pop-in { from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); } }
@media (prefers-reduced-motion: reduce) {
  .tbc-composer-layer.is-open > *, .tbc-sheet-layer.is-open > *, .tbc-like.is-popping ti-icon { animation: none !important; }
}
