/* ==========================================================================
   TWEET THREAD «twd» — Views/Tweets/ShowTweet.cshtml (loaded after tweets.css,
   which supplies .tw-page, .tw-side, .tw-card, .tw-rules, .tw-tools).
   Replies keep their own partials (_RenderReplies / _TweetReplyCard).
   ========================================================================== */
/* .tw-page sits on the aside only: its `svg:not(.icon)` stroke rule would repaint the like hearts and reply/badge glyphs. */
.twd { --tw-ac: hsl(199 89% 52%); --tw-ac2: hsl(250 80% 64%); padding: .25rem 0 2.5rem; color: var(--ds-text); }
.twd-side.tw-page { padding-bottom: 0; }
.twd-crumbs { display: flex; justify-content: center; margin-bottom: clamp(10px, 6px + 1vw, 18px); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.twd-crumbs::-webkit-scrollbar { display: none; }
.twd-crumbs nav, .twd-crumbs ol { margin: 0 !important; }
.twd-grid { display: grid; grid-template-columns: minmax(0, 46rem) 300px; justify-content: center; gap: 1rem clamp(20px, 10px + 2vw, 40px); align-items: start; }
.twd-main { display: grid; gap: 1rem; min-width: 0; }

.twd-alert { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: var(--ds-r-lg); font-size: var(--ds-fs-sm); font-weight: 800; }
.twd-alert .icon { width: 18px; height: 18px; flex: none; }
.twd-alert--ok { color: var(--ds-up-ink); background: var(--ds-up-soft); }
.twd-alert--warn { color: hsl(32 95% 34%); background: hsl(38 92% 50% / .14); }
html.dark-theme .twd-alert--warn { color: hsl(38 92% 62%); }

/* ---------- post ---------- */
.twd-post { position: relative; display: grid; gap: 14px; padding: clamp(16px, 12px + 1.2vw, 26px); border-radius: var(--ds-r-xl); background: var(--ds-surface-1); border: 1px solid var(--ds-line); box-shadow: var(--ds-shadow-2); overflow: clip; }
.twd-post::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--tw-ac2, hsl(250 80% 64%)), var(--tw-ac, hsl(199 89% 52%))); opacity: .85; }
html.dark-theme .twd-post { background: hsl(222 40% 10% / .75); border-color: hsl(0 0% 100% / .08); }
.twd-post__head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.twd-post__av { flex: none; text-decoration: none; }
.twd-post__who { display: grid; gap: 2px; min-width: 0; flex: 1; }
.twd-post__name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--ds-fs-body); font-weight: 900; color: var(--ds-text); text-decoration: none; overflow-wrap: anywhere; }
a.twd-post__name:hover { color: var(--ds-link); }
.twd-post__name.is-anon { cursor: not-allowed; }
.twd-post__date { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px; font-size: var(--ds-fs-2xs); font-weight: 600; color: var(--ds-text-2); }
.twd-post__date .icon { width: 13px; height: 13px; }
.twd-edited { font-weight: 700; }
.twd-post__own { display: flex; gap: 4px; flex: none; }
.twd-post__own form { margin: 0; }
.twd-del:hover { color: var(--ds-down-ink) !important; background: var(--ds-down-soft) !important; }
.twd-title { margin: 0; font-size: clamp(1.25rem, 1.02rem + 1vw, 1.7rem); font-weight: 900; line-height: 1.6; color: var(--ds-text); text-wrap: balance; overflow-wrap: anywhere; }
.twd-text { white-space: pre-line; overflow-wrap: anywhere; font-size: clamp(.95rem, .92rem + .15vw, 1.04rem); line-height: 2.05; color: var(--ds-text); }
.twd-text a { color: var(--ds-link); text-decoration: underline; text-underline-offset: 3px; }
.twd-text img { max-width: 100%; height: auto; border-radius: var(--ds-r-md); }
.twd-media { margin: 0; border-radius: var(--ds-r-lg); overflow: hidden; background: hsl(222 47% 7%); border: 1px solid var(--ds-line); }
.twd-media img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: contain; cursor: zoom-in; }
.twd-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.twd-tags a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: var(--ds-r-pill); font-size: var(--ds-fs-xs); font-weight: 800; text-decoration: none;
  color: var(--ds-primary-ink); background: var(--ds-primary-soft); }
html.dark-theme .twd-tags a { color: hsl(199 89% 72%); }
.twd-tags a:hover { background: hsl(199 89% 48% / .2); }
.twd-tags a.is-generic { color: var(--ds-text-2); background: var(--ds-surface-2); }

.twd-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 14px; border-top: 1px solid var(--ds-line-soft); }
html.dark-theme .twd-bar { border-top-color: hsl(0 0% 100% / .07); }
.twd-act { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: var(--ds-r-pill); font: inherit; font-size: var(--ds-fs-xs); font-weight: 800;
  color: var(--ds-text-2); background: transparent; border: 1px solid var(--ds-line); cursor: pointer; text-decoration: none; transition: border-color .2s ease, color .2s ease, background-color .2s ease; }
html.dark-theme .twd-act { border-color: hsl(0 0% 100% / .1); }
.twd-act .icon { width: 16px; height: 16px; }
.twd-act .num { color: var(--ds-text); font-weight: 900; font-variant-numeric: tabular-nums; }
a.twd-act:hover, button.twd-act:hover { color: var(--ds-link); border-color: hsl(199 89% 48% / .5); }
.twd-act.is-static { cursor: default; }
.twd-like { display: inline-flex; align-items: center; gap: 2px; margin-inline-start: auto; padding-inline-start: 12px; border-radius: var(--ds-r-pill); border: 1px solid var(--ds-line); }
html.dark-theme .twd-like { border-color: hsl(0 0% 100% / .1); }
.twd-like .num { min-width: 1.2em; text-align: center; font-size: var(--ds-fs-xs); font-weight: 900; color: var(--ds-text); font-variant-numeric: tabular-nums; }
.twd-like__btn { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; transition: background-color .2s ease; }
.twd-like__btn:hover { background: var(--ds-down-soft); }
.twd-like__btn form { margin: 0; line-height: 0; }
.twd-like:has(.heart-container[data-liked="1"]) { border-color: hsl(351 89% 52% / .35); background: var(--ds-down-soft); }
.twd-like:has(.heart-container[data-liked="1"]) .num { color: var(--ds-down-ink); }

/* ---------- likers ---------- */
.twd-likers { border-radius: var(--ds-r-xl); background: var(--ds-surface-1); border: 1px solid var(--ds-line); overflow: hidden; }
html.dark-theme .twd-likers { background: hsl(0 0% 100% / .025); border-color: hsl(0 0% 100% / .08); }
.twd-likers__btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 16px; font: inherit; color: var(--ds-text); background: transparent; border: 0; cursor: pointer; text-align: start; }
.twd-likers__btn:hover { background: var(--ds-surface-2); }
html.dark-theme .twd-likers__btn:hover { background: hsl(0 0% 100% / .03); }
.twd-likers__btn:focus-visible { outline: 2px solid var(--ds-link); outline-offset: -2px; }
.twd-likers__t { display: inline-flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.twd-likers__t h2 { margin: 0; font-size: var(--ds-fs-sm); font-weight: 900; }
.twd-likers__t .icon { width: 17px; height: 17px; color: var(--ds-down-ink); }
.twd-likers__stack { order: 2; display: flex; }
.twd-likers__caret { order: 3; display: flex; color: var(--ds-text-2); }
.twd-avs { display: flex; }
.twd-avs:empty { display: none; }
#liked-avatars-preview > * { display: inline-flex !important; align-items: center; justify-content: center; width: 26px !important; height: 26px !important; margin-inline-start: -7px; border-radius: 50%; overflow: hidden;
  font-size: 10px; font-weight: 900; color: #fff; box-shadow: 0 0 0 2px var(--ds-surface-1); background-color: var(--ds-surface-3); }
#liked-avatars-preview > *:first-child { margin-inline-start: 0; }
#liked-avatars-preview img { width: 100%; height: 100%; object-fit: cover; }
.twd-likers__body { padding: 14px 16px 16px; border-top: 1px solid var(--ds-line-soft); }
html.dark-theme .twd-likers__body { border-top-color: hsl(0 0% 100% / .07); }
.twd-likers__list { display: flex; flex-wrap: wrap; gap: 8px; }
.twd-likers__list .text-secondary { margin: 0; font-size: var(--ds-fs-xs); color: var(--ds-text-2) !important; }

/* ---------- composer / guest ---------- */
.twd-h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--ds-fs-body); font-weight: 900; color: var(--ds-text); }
.twd-h2 .icon { width: 18px; height: 18px; color: var(--tw-ac, var(--ds-link)); }
.twd-h2__n { padding: 1px 9px; border-radius: var(--ds-r-pill); font-size: var(--ds-fs-2xs); font-weight: 900; color: var(--ds-text-2); background: var(--ds-surface-2); }
html.dark-theme .twd-h2__n { background: hsl(0 0% 100% / .06); }
.twd-compose { display: grid; gap: 12px; padding: clamp(14px, 10px + 1vw, 20px); border-radius: var(--ds-r-xl); background: var(--ds-surface-1); border: 1px solid var(--ds-line); }
html.dark-theme .twd-compose { background: hsl(0 0% 100% / .025); border-color: hsl(0 0% 100% / .08); }
.twd-compose form { display: grid; gap: 10px; margin: 0; }
.twd .twd-ta { display: block; width: 100%; min-height: 104px; padding: 12px 14px; border-radius: var(--ds-r-lg); font: inherit; font-size: var(--ds-fs-sm); line-height: 1.9; resize: vertical;
  color: var(--ds-text); background: var(--ds-surface-2); border: 1px solid var(--ds-line); transition: border-color .2s ease, box-shadow .2s ease; }
html.dark-theme .twd .twd-ta { background: hsl(222 47% 6% / .6); border-color: hsl(0 0% 100% / .1); }
.twd .twd-ta:focus { outline: none; border-color: hsl(199 89% 48% / .6); box-shadow: 0 0 0 3px hsl(199 89% 48% / .18); }
.twd-compose__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.twd-attach { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; max-width: 100%; padding: 0 14px; border-radius: var(--ds-r-md); font-size: var(--ds-fs-xs); font-weight: 700; cursor: pointer;
  color: var(--ds-text-2); border: 1px dashed var(--ds-line-strong); }
.twd-attach:hover, .twd-attach:focus-visible { color: var(--ds-link); border-color: hsl(199 89% 48% / .5); outline: none; }
.twd-attach span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.twd-guest { border-radius: var(--ds-r-xl); overflow: hidden; }

/* ---------- replies ---------- */
.twd-replies { display: grid; gap: 12px; }
.twd-replies #replies-container { display: grid; gap: 0; }
.twd-empty { margin: 0; padding: 28px 16px; border-radius: var(--ds-r-xl); text-align: center; font-size: var(--ds-fs-sm); color: var(--ds-text-2) !important; border: 1px dashed var(--ds-line-strong); }

/* ---------- aside ---------- */
.twd-back { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--ds-r-xl); text-decoration: none; color: var(--ds-text); background: var(--ds-surface-1); border: 1px solid var(--ds-line); box-shadow: var(--ds-shadow-1); }
.twd-back .icon { width: 18px; height: 18px; flex: none; color: var(--tw-ac, var(--ds-link)); }
.twd-back span { display: grid; gap: 1px; }
.twd-back b { font-size: var(--ds-fs-sm); font-weight: 900; }
.twd-back small { font-size: var(--ds-fs-2xs); color: var(--ds-text-2); }
.twd-back:hover { border-color: hsl(199 89% 48% / .45); }

@media (max-width: 1023px) {
  .twd-grid { grid-template-columns: minmax(0, 46rem); }
  .twd-side { grid-template-columns: 1fr 1fr; }
  .twd-back { grid-column: 1 / -1; }
}
@media (max-width: 720px) { .twd-side { grid-template-columns: 1fr; } }
@media (max-width: 420px) {
  .twd-act { padding: 0 11px; }
  .twd-like { margin-inline-start: 0; }
}
