/* Posts (.message) — metrics copied from voz.vn, plus the BBCode renderer. */

.message {
  background: var(--content-bg);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.message:last-child { margin-bottom: 0; }
.message:target { outline: 2px solid var(--nav-active); }
.message-inner { display: flex; gap: 0; }

/* The thread block is transparent so the dark page background separates posts. */
.block--messages { background: transparent; }
.block--messages .block-body { background: transparent; }
.block--messages > .block-header { background: transparent; padding: 7px 0; }

.bbWrapper img.smilie { display: inline-block; vertical-align: text-bottom; max-width: none; margin: 0; }

.member-card { position: fixed; z-index: 150; width: 360px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto; background: var(--content-bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow-card); font-size: calc(14px * var(--ui-scale)); }
.member-card-header { display: flex; gap: 12px; padding: 12px; background: var(--quote-bg); }
.member-card-header > div { min-width: 0; overflow-wrap: anywhere; }
.member-card-header .avatar { flex: 0 0 80px; width: 80px; height: 80px; }
.member-card-name { font-size: calc(20px * var(--ui-scale)); font-weight: var(--fw-bold); }
.member-card-stats { display: flex; justify-content: space-around; text-align: center; padding: 12px 6px; color: var(--dimmed); }
.member-card-stats strong { display: block; font-size: calc(18px * var(--ui-scale)); font-weight: 400; color: var(--text); }
.member-card-actions { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-top: 1px solid var(--border); }

/* Top row above the first post: page navigator. */
.block-outer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.block-outer--bottom { padding: 6px 0 10px; }
.block-outer-main { flex: 1 1 auto; min-width: 0; }
.block-outer .pageNav { padding: 0; }

/* Icon button inside the blue block header (watch / unwatch). */
.block-header-title { flex: 1 1 auto; min-width: 0; }
.block-header-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: var(--overlay-header);
  color: var(--block-header-fg);
  cursor: pointer;
  line-height: 1;
}
.block-header-icon:hover { background: var(--overlay-header-strong); }
.block-header-icon.is-on { background: var(--nav-active); color: var(--on-dark); }
.block-header-icon[aria-disabled="true"] { opacity: .6; cursor: default; }
.block-header-icon svg { display: block; }

.message-cell { padding: 10px; }
.message-cell--user {
  flex: 0 0 140px;
  background: var(--quote-bg);
  border-radius: 3px 0 0 3px;
}
.message-cell--main {
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 0 3px 3px 0;
}
.message-main { display: flex; flex-direction: column; min-height: 100%; }

/* Inline edit: the message body is swapped for the editor inside the same cell. */
.message-cell--main.is-editing { padding: 10px; }
.message-main[hidden] { display: none !important; }
.inline-edit { display: block; }
.inline-edit .rich-editor { border-radius: var(--radius); }
.inline-edit .editor-visual,
.inline-edit .rich-editor .editor-source { min-height: 140px; }
.inline-edit-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.inline-edit-actions .button { font-size: calc(14px * var(--ui-scale)); }

.message-user { text-align: center; }
.message-avatar { margin-bottom: 8px; }
.message-avatar .avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--surface-raised);
  display: block;
  margin: 0 auto;
}
.message-userDetails { margin-bottom: 6px; }
.message-userMeta { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; }
.message-userMeta .userTitle { flex-basis: 100%; }
.user-badge { display: inline-block; padding: 1px 6px; border: 1px solid color-mix(in srgb, var(--badge-fg) 20%, var(--badge-bg)); border-radius: 2px; background: var(--badge-bg); color: var(--badge-fg); font-size: calc(12px * var(--ui-scale)); font-weight: 400; line-height: 1.5; white-space: nowrap; }
.member-card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.message-name {
  margin: 0;
  font-size: calc(16px * var(--ui-scale));
  font-weight: var(--fw-bold);
  line-height: 1.5;
  word-break: break-word;
}
.message-name .username { color: var(--link); }
.message-name .username:hover { color: var(--link-hover); }
.userTitle {
  display: block;
  font-size: calc(12px * var(--ui-scale));
  line-height: 1.5;
  color: var(--text);
}
.message-userStats {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: calc(12px * var(--ui-scale));
  line-height: 1.5;
  color: var(--dimmed);
  text-align: left;
}
.message-userStats li { display: flex; justify-content: space-between; gap: 6px; }
.message-userStats b { color: var(--text); font-weight: var(--fw-bold); }

.post-bookmark { display: inline-flex; align-items: center; justify-content: center; padding: 3px; border: 0; background: transparent; color: var(--dimmed); cursor: pointer; vertical-align: middle; }
.post-bookmark svg { width: 16px; height: 16px; }
.post-bookmark:hover, .post-bookmark[aria-pressed="true"] { color: var(--link); }
.post-bookmark[aria-pressed="true"] svg { fill: currentColor; }
.post-bookmark:disabled { opacity: .5; cursor: wait; }

.message-attribution {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 3px;
  margin: 0;
  font-size: calc(12px * var(--ui-scale));
  line-height: 1.5;
  color: var(--dimmed);
}
.message-attribution-main,
.message-attribution-opposite {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.message-attribution-opposite { margin-left: auto; }
.message-attribution a { color: var(--dimmed); }
.message-attribution a:hover { color: var(--link-hover); }
.message-postNumber {
  font-weight: var(--fw-bold);
  font-size: calc(13px * var(--ui-scale));
  color: var(--link) !important;
}
.message-postNumber:hover { color: var(--link-hover) !important; }

/* The share menu behind a post number. Fixed rather than absolute so it escapes the post's
   stacking context, and `z-index` above the sticky chrome but below the toast. */
.post-share-popup {
  position: fixed;
  z-index: 300;
  min-width: 210px;
  padding: 4px 0;
  background: var(--content-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow-menu);
}
.post-share-option {
  display: block;
  width: 100%;
  padding: 7px 12px;
  border: 0;
  background: none;
  font: inherit;
  font-size: calc(13px * var(--ui-scale));
  color: var(--text);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.post-share-option:hover,
.post-share-option:focus-visible { background: var(--content-bg-alt); outline: none; }

.message-content { display: flex; flex-direction: column; flex: 1 1 auto; }
.message-userContent { margin-top: 10px; }
.message-body {
  font-size: calc(16px * var(--post-scale));
  line-height: 1.5;
  overflow-wrap: anywhere;
  /* Anything nested inside a post — a quote card, a code block, a spoiler summary — is part
     of the post's prose, so it must scale with --post-scale rather than with the page. */
  --ui-scale: var(--post-scale);
}
.message-body img { border-radius: 3px; }
/* Mirrors voz.vn's `.bbImageWrapper`: an inline-block on the text baseline with an inline
   image inside. `vertical-align: top` (the previous value) lifted a tall image above its own
   line and made it overlap the line above, which is what broke the layout. */
.downloadable-image {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: baseline;
}
.downloadable-image > img,
.downloadable-image > picture > img { display: inline; }
.image-download-button {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 4px;
  background: rgba(16, 33, 56, .5);
  color: #fff;
  opacity: .6;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(2px);
  transition: opacity .15s ease, background-color .15s ease;
}
.image-download-button svg { display: block; }
.image-download-button:hover,
.image-download-button:focus-visible { opacity: 1; background: rgba(16, 33, 56, .82); }
.image-download-button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.image-download-button.is-loading { cursor: wait; opacity: .35; }
.image-download-button.is-saved { opacity: 1; background: rgba(22, 128, 67, .9); border-color: rgba(255, 255, 255, .6); }

/* Per-post screenshot control. It sits in the attribution row next to the bookmark rather
   than floating over the post, so it can never cover the #number. */
.post-screenshot-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--dimmed);
  opacity: .6;
  cursor: pointer;
  vertical-align: middle;
  touch-action: manipulation;
  transition: opacity .15s ease, color .15s ease, background-color .15s ease;
}
.post-screenshot-button svg { display: block; width: 16px; height: 16px; }
.post-screenshot-button:hover,
.post-screenshot-button:focus-visible { opacity: 1; color: var(--link); background: var(--surface-raised); }
.post-screenshot-button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.post-screenshot-button.is-loading { cursor: wait; opacity: .35; }
.post-screenshot-button.is-saved { opacity: 1; color: var(--link); }
/* No hover on touch, so the control must stay findable. */
@media (hover: none) {
  .post-screenshot-button { opacity: .75; }
}

/* Off-screen capture sheet: the wrapper drawn into the PNG, plus the thread title band. */
.screenshot-sheet { color: var(--text); }
.screenshot-title {
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  font-size: calc(20px * var(--ui-scale));
  font-weight: var(--fw-bold);
  line-height: 1.35;
  color: var(--text);
}
.screenshot-sheet .message { margin: 0; overflow: visible; }
.screenshot-sheet .message-inner { align-items: flex-start; }
/* Touch devices have no hover, so the control must stay visible enough to find. */
@media (hover: none) {
  .image-download-button { opacity: .75; }
}

.message-footer {
  margin: auto 0 0;
  padding: 0;
  font-size: calc(16px * var(--ui-scale));
  color: var(--text);
}
.message-actionBar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
}
.actionBar-set { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.actionBar-set--right { margin-left: auto; }
.actionBar-action {
  display: inline-block;
  padding: 3px;
  border-radius: var(--radius);
  font-size: calc(14px * var(--ui-scale));
  line-height: 1.5;
  color: var(--link);
  white-space: nowrap;
}
.actionBar-action:hover { color: var(--link-hover); }
.actionBar-action--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
}
.actionBar-action--icon svg { display: block; }
:root[data-theme="dark"] .actionBar-action { color: var(--text); }
:root[data-theme="dark"] .actionBar-set--left .actionBar-action { color: var(--text); }
.actionBar-set--left .actionBar-action { color: var(--dimmed); }
.actionBar-set--left .actionBar-action:hover { color: var(--link-hover); }
.actionBar-set--left .actionBar-action--danger:hover { color: var(--danger-text-strong); }

.message-signature {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: calc(12px * var(--post-scale));
  color: var(--dimmed);
  max-height: 5em;
  overflow: hidden;
}
.message-signature.is-expanded { max-height: none; }
.signature-toggle:not([hidden]) {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--dimmed);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

/* Grey strip listing who reacted, like voz.vn. */
.reactionsBar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  padding: 6px;
  background: var(--quote-bg);
  border-radius: 3px;
  font-size: calc(12px * var(--ui-scale));
  line-height: 1.5;
  color: var(--dimmed);
}
.reactionsBar-icons { display: inline-flex; align-items: center; gap: 2px; }
.reactionsBar-icons .reaction-image { width: calc(16px * var(--ui-scale)); height: calc(16px * var(--ui-scale)); }
.reactionsBar-users { color: var(--dimmed); }
.reactionsBar-user { color: var(--link); }
.reactionsBar-user:hover { color: var(--link-hover); }
.reactionsBar-loading { color: var(--dimmed); }

/* ---------- bbcode rendering ---------- */
.post-spoiler { margin: 8px 0; }
.post-spoiler > summary { display: list-item; width: fit-content; max-width: 100%; padding: 5px 10px; border: 1px solid var(--border); border-radius: 3px; background: var(--quote-bg); color: var(--link); font-size: calc(13px * var(--ui-scale)); cursor: pointer; }
.post-spoiler[open] { padding-bottom: 8px; }
.post-spoiler[open] > summary { margin-bottom: 10px; }
.post-spoiler > .post-spoiler { margin-left: 10px; }
.bbWrapper blockquote {
  margin: 0 0 10px;
  padding: 8px 12px;
  background: var(--quote-bg);
  border-left: 3px solid var(--quote-border);
  border-radius: 0 3px 3px 0;
  font-size: calc(15px * var(--ui-scale));
  color: var(--text);
}
.bbWrapper blockquote .bbCodeBlock-title,
.bbWrapper blockquote[data-name]::before {
  content: attr(data-name);
  display: block;
  font-size: calc(12px * var(--ui-scale));
  font-weight: var(--fw-bold);
  color: var(--dimmed);
  margin-bottom: 4px;
}
.bbWrapper blockquote[data-name=""]::before,
.bbWrapper blockquote.has-quote-source::before { content: none; }
.bbWrapper .quote-source { display: block; margin-bottom: 4px; font-size: calc(12px * var(--ui-scale)); font-weight: var(--fw-bold); }

/* Long quotes are clipped to 800px with a fade, matching voz.vn's `.bbCodeBlock--expandable`.
   Only quotes that actually overflow get the wrapper, so short ones are untouched. */
.bbWrapper blockquote.is-expandable { position: relative; }
.bbWrapper blockquote .quote-expand-content { max-height: 800px; overflow: hidden; }
.bbWrapper blockquote.is-expanded .quote-expand-content { max-height: none; }
.bbWrapper blockquote .quote-expand-link {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 400px;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(rgba(0, 0, 0, 0) 0%, var(--quote-bg) 80%);
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--link);
  cursor: pointer;
}
.bbWrapper blockquote .quote-expand-link span {
  display: block;
  width: 100%;
  padding-bottom: 6px;
  text-align: center;
}
.bbWrapper blockquote .quote-expand-link:hover span { text-decoration: underline; }
.bbWrapper blockquote.is-expanded .quote-expand-link { display: none; }
.bbWrapper blockquote .quote-expand-link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.bbWrapper h2, .bbWrapper h3, .bbWrapper h4 { margin: 12px 0 6px; font-size: calc(18px * var(--ui-scale)); }
.bbWrapper ul, .bbWrapper ol { margin: 6px 0; padding-left: 22px; }
.bbWrapper code {
  background: var(--surface-raised);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: Consolas, "Courier New", monospace;
  font-size: calc(14px * var(--ui-scale));
}
.bbWrapper pre {
  background: var(--chip-bg);
  color: var(--chip-fg);
  padding: 10px 12px;
  border-radius: var(--radius);
  overflow-x: auto;
}
.bbWrapper pre code { background: none; color: inherit; padding: 0; }
.bbWrapper .bbCodeBlock {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 8px 0;
  overflow: hidden;
}
.bbWrapper .bbCodeBlock-title {
  background: var(--content-bg-alt);
  padding: 5px 10px;
  font-size: calc(13px * var(--ui-scale));
  font-weight: var(--fw-bold);
  color: var(--dimmed);
}
.bbWrapper .bbCodeBlock-content { padding: 8px 10px; }
.bbWrapper .bbImage { max-width: 100%; height: auto; }
.bbWrapper img:not(.smilie) { max-width: 100%; height: auto; }
.bbWrapper .smilie { vertical-align: middle; }
.bbWrapper .username { color: var(--link); font-weight: var(--fw-bold); }
