/* ==========================================================================
   HMI Library — community forum (/forum/ list page + /forum/t/{slug} topic page)
   Loaded after /styles.css: reuses its tokens (--g-*, --p1..--p4, --run,
   --radius*, --shadow*, --font-sans, --font-mono). Self-contained otherwise
   (does not depend on community.css). Industrial calm gray; state colours only
   where they carry meaning (accepted answer = --run, errors = --p1).
   All forum-specific classes are prefixed fm- or scoped to #forum-list /
   #topic-page so they never leak into other pages.
   ========================================================================== */

/* ---------- base / utilities ------------------------------------------- */

#forum-list [hidden],
#topic-page [hidden],
.fm-modal[hidden],
.fm-toasts[hidden] { display: none !important; }

.fm-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

body.fm-modal-open { overflow: hidden; }

/* Buttons (independent of styles.css so SSR buttons without .btn match). */
.fm-btn,
#topic-page .topic-actions > button,
#topic-page .reply-meta > button,
#topic-page #reply-form button,
#topic-page .btn-vote-reply,
#forum-list #topics-more {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  font-size: 14px; font-weight: 600; line-height: 1.2;
  color: var(--g-900);
  background: #fff;
  border: 1px solid var(--g-300);
  border-radius: var(--radius, 8px);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.fm-btn:hover,
#topic-page .topic-actions > button:hover,
#topic-page #reply-form button:hover,
#forum-list #topics-more:hover { background: var(--g-100); border-color: var(--g-500); }

.fm-btn--primary,
#topic-page #reply-form button[type="submit"] {
  background: var(--g-900); color: var(--g-50); border-color: var(--g-900);
}
.fm-btn--primary:hover,
#topic-page #reply-form button[type="submit"]:hover {
  background: var(--g-800); border-color: var(--g-800); color: var(--g-50);
  transform: translateY(-1px);
}
.fm-btn--ghost,
#topic-page .topic-actions > #btn-report-topic,
#topic-page .reply-meta > button {
  background: transparent; border-color: transparent;
  color: var(--g-600); font-weight: 500;
  padding: 6px 10px;
}
.fm-btn--ghost:hover,
#topic-page .topic-actions > #btn-report-topic:hover,
#topic-page .reply-meta > button:hover { background: var(--g-100); color: var(--g-900); border-color: transparent; }
.fm-btn--sm { padding: 6px 12px; font-size: 13px; }

.fm-btn:disabled, .fm-btn.is-busy,
#topic-page button:disabled, #topic-page button.is-busy,
#forum-list button:disabled, #forum-list button.is-busy { opacity: .55; cursor: progress; transform: none; }

.fm-btn:focus-visible,
#forum-list button:focus-visible, #forum-list a:focus-visible, #forum-list input:focus-visible, #forum-list select:focus-visible, #forum-list textarea:focus-visible,
#topic-page button:focus-visible, #topic-page a:focus-visible, #topic-page textarea:focus-visible,
.fm-modal button:focus-visible, .fm-modal a:focus-visible, .fm-modal input:focus-visible, .fm-modal select:focus-visible, .fm-modal textarea:focus-visible {
  outline: 2px solid var(--p4, #1976D2); outline-offset: 2px;
}

/* ---------- toast ------------------------------------------------------ */

.fm-toasts {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, calc(100vw - 48px));
  pointer-events: none;
}
.fm-toast {
  background: var(--g-900); color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius, 8px);
  font-size: 14px; font-weight: 500; line-height: 1.4;
  box-shadow: var(--shadow-lg, 0 16px 40px rgba(0,0,0,.10));
  animation: fm-slide-in .25s ease-out;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto;
}
.fm-toast--success { background: var(--run, #2E7D32); }
.fm-toast--error   { background: var(--p1, #D32F2F); }
.fm-toast.is-leaving { opacity: 0; transform: translateX(12px); }
@keyframes fm-slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fm-fade     { from { opacity: 0; } to { opacity: 1; } }
@keyframes fm-up       { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- modal (ask a question / auth CTA) -------------------------- */

.fm-modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(26,26,24,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fm-fade .15s ease-out;
  overflow-y: auto;
}
.fm-card {
  position: relative;
  width: 100%; max-width: 440px;
  background: #fff;
  border-radius: var(--radius-lg, 14px);
  padding: 32px;
  box-shadow: var(--shadow-lg, 0 16px 40px rgba(0,0,0,.10));
  animation: fm-up .2s ease-out;
  margin: auto;
}
.fm-card--wide { max-width: 680px; }
.fm-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent; border: 0;
  border-radius: var(--radius-sm, 4px);
  color: var(--g-600); cursor: pointer;
  font-size: 18px; line-height: 1;
}
.fm-close:hover { background: var(--g-100); color: var(--g-900); }
.fm-kicker {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--g-600); margin: 0 0 8px;
}
.fm-card h2, .fm-card h3 {
  font-size: 22px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em;
  color: var(--g-900); margin: 0 0 8px; padding-right: 28px;
}
.fm-card .fm-text { font-size: 14px; line-height: 1.55; color: var(--g-600); margin: 0 0 20px; }
.fm-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.fm-actions > .fm-btn { flex: 1 1 0; min-width: 120px; }
.fm-foot { font-size: 12px; color: var(--g-600); margin: 16px 0 0; text-align: center; }
.fm-foot a { color: var(--g-900); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- form fields ------------------------------------------------ */

.fm-field { margin-bottom: 16px; }
.fm-field label {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-size: 13px; font-weight: 600; color: var(--g-700); margin-bottom: 6px;
}
.fm-field .fm-hint { font-weight: 400; color: var(--g-600); font-size: 12px; }
.fm-field .fm-count {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 500; font-size: 11px; color: var(--g-600);
  font-variant-numeric: tabular-nums;
}
.fm-field .fm-count.is-bad { color: var(--p1, #D32F2F); }
.fm-field input[type="text"],
.fm-field select,
.fm-field textarea,
#topic-page #reply-body,
#topic-page .fm-edit textarea {
  width: 100%; padding: 10px 12px;
  font: inherit; font-size: 14px; line-height: 1.5;
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  color: var(--g-900);
  background: #fff;
  border: 1px solid var(--g-200);
  border-radius: var(--radius, 8px);
  transition: border-color .15s, box-shadow .15s;
}
.fm-field select {
  -webkit-appearance: none; appearance: none;
  padding-right: 34px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B68' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.fm-field textarea, #topic-page #reply-body, #topic-page .fm-edit textarea { resize: vertical; min-height: 140px; }
/* --g-400 (#A8A8A6) sobre el fondo --g-50 del campo da 2,22:1. El texto de
   marcador de posición es texto y le aplica el 4,5:1 de AA: --g-600 da 4,99. */
.fm-field input::placeholder, .fm-field textarea::placeholder, #topic-page #reply-body::placeholder { color: var(--g-600); }
.fm-field input:focus, .fm-field select:focus, .fm-field textarea:focus,
#topic-page #reply-body:focus, #topic-page .fm-edit textarea:focus {
  outline: none; border-color: var(--g-900);
  box-shadow: 0 0 0 3px rgba(26,26,24,.08);
}
.fm-field input[aria-invalid="true"], .fm-field textarea[aria-invalid="true"] { border-color: var(--p1, #D32F2F); }
.fm-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--g-700); margin: -4px 0 18px; cursor: pointer; }
.fm-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--g-900); }
.fm-error {
  margin: 0 0 14px; padding: 10px 12px;
  font-size: 13px; line-height: 1.45;
  color: var(--p1, #D32F2F);
  background: rgba(211,47,47,.06);
  border: 1px solid rgba(211,47,47,.35);
  border-radius: var(--radius, 8px);
}
.fm-error:empty { display: none; }
.fm-form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }
.fm-form-actions .fm-note { margin-right: auto; font-size: 12px; color: var(--g-600); }
.fm-form-actions .fm-note a { color: var(--g-700); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- shared atoms (both pages) ---------------------------------- */

.fm-avatar {
  flex: 0 0 28px; width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  background: var(--g-200); color: var(--g-700);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px; font-weight: 600;
  overflow: hidden; vertical-align: middle;
}
.fm-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fm-avatar--sm { flex-basis: 22px; width: 22px; height: 22px; font-size: 10px; }

.fm-author {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--g-800);
  text-decoration: none; min-width: 0;
}
.fm-author:hover { color: var(--g-900); text-decoration: underline; text-underline-offset: 3px; }
.fm-author .fm-username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cat-chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--g-700);
  background: var(--g-100);
  border: 1px solid var(--g-200);
  border-radius: 999px;
  text-decoration: none; white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
a.cat-chip:hover { border-color: var(--g-500); color: var(--g-900); background: #fff; }

.solved-mark {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--run, #2E7D32);
  white-space: nowrap;
}
.solved-mark::before {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  background: var(--run, #2E7D32);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center/12px no-repeat, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center/12px no-repeat, linear-gradient(#000 0 0);
}
.fm-time {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px; color: var(--g-600); white-space: nowrap;
}

/* ---------- LIST PAGE (#forum-list) ------------------------------------ */

#forum-list .forum-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  margin: 0 0 28px;
}
#forum-list .forum-head > div { min-width: 0; }
#forum-list .forum-head .fm-btn--primary { flex-shrink: 0; padding: 12px 22px; }

#forum-list .forum-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

/* categories */
#forum-list .forum-cats { position: sticky; top: 84px; }
#forum-list .forum-cats h2 {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--g-600); margin: 0 0 10px;
}
#forum-list .forum-cats ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#forum-list .forum-cats button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 8px 10px;
  font: 500 14px/1.3 var(--font-sans, 'Inter', system-ui, sans-serif);
  color: var(--g-700);
  background: transparent; border: 0;
  border-radius: var(--radius, 8px);
  text-align: left; cursor: pointer;
  transition: background .15s, color .15s;
}
#forum-list .forum-cats button:hover { background: var(--g-100); color: var(--g-900); }
#forum-list .forum-cats button[aria-pressed="true"] { background: var(--g-900); color: var(--g-50); }
#forum-list .forum-cats .cat-count {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; font-weight: 600; color: var(--g-600);
  font-variant-numeric: tabular-nums;
}
#forum-list .forum-cats button[aria-pressed="true"] .cat-count { color: var(--g-300); }
#forum-list .forum-cats .cat-desc { display: none; }
#forum-list .forum-aside-note {
  margin: 22px 0 0; padding: 14px 0 0;
  border-top: 1px solid var(--g-150);
  font-size: 13px; line-height: 1.55; color: var(--g-600);
}
#forum-list .forum-aside-note p { margin: 0 0 6px; }
#forum-list .forum-aside-note a { color: var(--g-800); text-decoration: underline; text-underline-offset: 3px; }
#forum-list .forum-aside-note a:hover { color: var(--g-900); }

/* toolbar: tabs + search */
#forum-list .forum-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--g-200);
  margin: 0 0 4px;
}
#forum-list .forum-tabs { display: flex; gap: 2px; flex-wrap: wrap; }
#forum-list .forum-tabs button {
  padding: 8px 12px;
  font: 600 13px/1.2 var(--font-sans, 'Inter', system-ui, sans-serif);
  color: var(--g-600);
  background: transparent; border: 0;
  border-radius: var(--radius, 8px);
  cursor: pointer;
  transition: background .15s, color .15s;
}
#forum-list .forum-tabs button:hover { background: var(--g-100); color: var(--g-900); }
#forum-list .forum-tabs button[aria-selected="true"] { background: var(--g-900); color: var(--g-50); }

#forum-list .forum-search { position: relative; flex: 0 1 300px; min-width: 200px; }
#forum-list .forum-search > svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--g-600); pointer-events: none;
}
#forum-list .forum-search input {
  width: 100%; padding: 9px 34px 9px 34px;
  font: 500 14px/1.4 var(--font-sans, 'Inter', system-ui, sans-serif);
  color: var(--g-900);
  background: #fff;
  border: 1px solid var(--g-200);
  border-radius: var(--radius, 8px);
  -webkit-appearance: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
#forum-list .forum-search input::placeholder { color: var(--g-600); }
#forum-list .forum-search input:focus { outline: none; border-color: var(--g-900); box-shadow: 0 0 0 3px rgba(26,26,24,.08); }
#forum-list .forum-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
#forum-list .forum-search .fm-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; padding: 0;
  display: none; place-items: center;
  border: 0; background: transparent; color: var(--g-600);
  border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1;
}
#forum-list .forum-search.has-value .fm-clear { display: grid; }
#forum-list .forum-search .fm-clear:hover { background: var(--g-100); color: var(--g-900); }

#forum-list .forum-status {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 30px; padding: 6px 0;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px; color: var(--g-600);
  text-transform: uppercase; letter-spacing: .06em;
}

/* topic rows */
#forum-list .topic-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--g-150); }
#forum-list .topic-list[aria-busy="true"] { opacity: .6; }
#forum-list .topic-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 24px;
  align-items: center;
  padding: 16px 4px;
  border-bottom: 1px solid var(--g-150);
  transition: background .15s;
}
#forum-list .topic-row:hover { background: rgba(255,255,255,.7); }
#forum-list .topic-row-main { min-width: 0; }
#forum-list .topic-row-title {
  display: inline; margin: 0;
  font-size: 16px; font-weight: 600; line-height: 1.35; letter-spacing: -0.005em;
  color: var(--g-900); text-decoration: none;
  overflow-wrap: anywhere;
}
#forum-list .topic-row-title:hover { text-decoration: underline; text-underline-offset: 3px; }
/* Stretched link: the whole row is clickable, nested author links / chips stay on top. */
#forum-list .topic-row { position: relative; }
#forum-list .topic-row-title::after { content: ''; position: absolute; inset: 0; }
#forum-list .topic-row a:not(.topic-row-title), #forum-list .topic-row button { position: relative; z-index: 1; }
#forum-list .topic-row-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
#forum-list .topic-row-meta {
  display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap;
  margin-top: 7px;
  font-size: 13px; color: var(--g-600);
}
#forum-list .topic-row-meta .fm-sep { color: var(--g-400); }
#forum-list .topic-row-closed {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--g-600);
}
#forum-list .topic-stats {
  display: flex; gap: 18px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px; color: var(--g-600);
  font-variant-numeric: tabular-nums;
}
#forum-list .topic-stats span {
  display: flex; flex-direction: column; align-items: center; min-width: 44px;
  line-height: 1.2;
}
#forum-list .topic-stats b { font-size: 15px; font-weight: 600; color: var(--g-800); }
#forum-list .topic-stats .is-zero b { color: var(--g-600); font-weight: 500; }
#forum-list .topic-stats .has-accepted b { color: var(--run, #2E7D32); }
#forum-list .topic-stats small { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }

/* empty state + load more */
#forum-list .forum-empty {
  margin: 0; padding: 56px 24px;
  text-align: center;
  background: #fff;
  border: 1px dashed var(--g-300);
  border-radius: var(--radius-lg, 14px);
}
#forum-list .forum-empty .fm-kicker { margin-bottom: 10px; }
#forum-list .forum-empty h2 { font-size: 22px; letter-spacing: -0.01em; margin: 0 0 10px; color: var(--g-900); }
#forum-list .forum-empty p { font-size: 14px; line-height: 1.6; color: var(--g-600); margin: 0 auto 22px; max-width: 520px; }
#forum-list .forum-empty ul {
  list-style: none; margin: 0 auto 24px; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 600px;
}
#forum-list .forum-empty li {
  font-size: 13px; color: var(--g-700);
  padding: 7px 12px;
  background: var(--g-100);
  border: 1px solid var(--g-200);
  border-radius: 999px;
}
#forum-list .forum-empty--filtered { padding: 40px 24px; }
#forum-list .forum-more { display: flex; justify-content: center; margin: 24px 0 0; }
#forum-list #topics-more { min-width: 160px; }
#forum-list .forum-noscript {
  margin: 0; padding: 28px; text-align: center;
  background: #fff; border: 1px solid var(--g-200); border-radius: var(--radius-lg, 14px);
  font-size: 14px; color: var(--g-700);
}

/* ask modal specifics */
#ask-modal .fm-card { max-width: 680px; }
#ask-auth { text-align: left; }

/* ---------- TOPIC PAGE (#topic-page) ----------------------------------- */

#topic-page {
  max-width: 880px;
  margin: 0 auto;
}
#topic-page .topic-title {
  font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em;
  color: var(--g-900);
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}
#topic-page.is-solved .topic-title::before,
#topic-page[data-accepted-reply-id]:not([data-accepted-reply-id=""]) .topic-title::before {
  /* Label text comes from JS (localizeTopicStatic sets --solved-label to the
     localised T('solved_mark') string) so the badge is never hardcoded English.
     No fallback: if JS has not set it yet the badge simply does not render. */
  content: var(--solved-label);
  display: inline-block; vertical-align: 4px;
  margin-right: 10px; padding: 3px 8px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--run, #2E7D32);
  border: 1px solid var(--run, #2E7D32);
  border-radius: 999px;
}
#topic-page .topic-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: 0 0 22px;
  font-size: 13px; color: var(--g-600);
}
#topic-page .topic-meta a { color: var(--g-800); font-weight: 500; text-decoration: none; }
#topic-page .topic-meta a:hover { color: var(--g-900); text-decoration: underline; text-underline-offset: 3px; }
#topic-page .topic-meta time,
#topic-page .topic-meta .views {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px; color: var(--g-600);
}
#topic-page .topic-status-chip {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--g-600); padding: 2px 8px;
  border: 1px solid var(--g-300); border-radius: 999px;
}
#topic-page .topic-body {
  font-size: 16px; line-height: 1.7; color: var(--g-800);
  padding: 24px 28px;
  background: #fff;
  border: 1px solid var(--g-200);
  border-radius: var(--radius-lg, 14px);
  overflow-wrap: anywhere;
}
#topic-page .topic-body a,
#topic-page .reply-body a { color: var(--g-900); text-decoration: underline; text-underline-offset: 3px; word-break: break-all; }
#topic-page .topic-body a:hover, #topic-page .reply-body a:hover { color: var(--p4, #1976D2); }

#topic-page .topic-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 14px 0 0;
}
#topic-page .topic-actions > #btn-report-topic { margin-left: auto; }
#topic-page #btn-vote-topic,
#topic-page .btn-vote-reply {
  gap: 6px; padding: 8px 14px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
#topic-page #btn-vote-topic[aria-pressed="true"],
#topic-page .btn-vote-reply[aria-pressed="true"] {
  background: var(--g-900); color: var(--g-50); border-color: var(--g-900);
}
#topic-page #btn-vote-topic:active, #topic-page .btn-vote-reply:active { transform: scale(.97); }

/* inline editor (author) */
#topic-page .fm-edit { display: flex; flex-direction: column; gap: 10px; margin: 0; }
#topic-page .fm-edit textarea { min-height: 180px; font-size: 15px; }
#topic-page .fm-edit .fm-edit-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
#topic-page .fm-edit .fm-count {
  margin-right: auto;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; color: var(--g-600); font-variant-numeric: tabular-nums;
}
#topic-page .fm-edit .fm-count.is-bad { color: var(--p1, #D32F2F); }

/* replies */
#topic-page #replies { margin: 44px 0 0; padding: 28px 0 0; border-top: 1px solid var(--g-200); }
#topic-page #replies h2 {
  font-size: 20px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--g-900); margin: 0 0 18px;
}
#topic-page #replies-list { display: flex; flex-direction: column; gap: 12px; }
#topic-page #replies-list[aria-busy="true"] { opacity: .6; }
#topic-page .replies-empty { font-size: 14px; color: var(--g-600); margin: 0; padding: 10px 0 6px; }

#topic-page .reply {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 16px;
  padding: 18px 20px 14px 14px;
  background: #fff;
  border: 1px solid var(--g-200);
  border-radius: var(--radius-lg, 14px);
  transition: border-color .15s, box-shadow .15s;
}
#topic-page .reply:target { border-color: var(--g-500); box-shadow: 0 0 0 3px rgba(26,26,24,.08); }
#topic-page .reply[data-accepted="true"] {
  border-color: var(--run, #2E7D32);
  box-shadow: 0 0 0 1px var(--run, #2E7D32) inset;
}
#topic-page .reply-votes { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#topic-page .btn-vote-reply {
  flex-direction: column; gap: 2px;
  width: 56px; padding: 8px 6px;
  line-height: 1.1;
}
#topic-page .reply-main { min-width: 0; }
#topic-page .reply-body {
  font-size: 15px; line-height: 1.65; color: var(--g-800);
  overflow-wrap: anywhere;
  margin: 0 0 12px;
}
#topic-page .reply-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  font-size: 13px; color: var(--g-600);
  padding-top: 10px;
  border-top: 1px solid var(--g-150);
}
#topic-page .reply-meta a { color: var(--g-800); font-weight: 500; text-decoration: none; }
#topic-page .reply-meta a:hover { color: var(--g-900); text-decoration: underline; text-underline-offset: 3px; }
#topic-page .reply-meta time { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; color: var(--g-600); }
#topic-page .reply-meta .fm-sep { color: var(--g-400); }
#topic-page .reply-meta > .btn-report-reply { margin-left: auto; }
#topic-page .reply-meta > .btn-accept {
  color: var(--g-800); border-color: var(--g-300); background: #fff; font-weight: 600;
}
#topic-page .reply-meta > .btn-accept:hover { border-color: var(--run, #2E7D32); color: var(--run, #2E7D32); background: #fff; }
#topic-page .accepted-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 7px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: #fff; background: var(--run, #2E7D32);
  border-radius: 999px;
}
#topic-page .accepted-badge::before {
  content: ''; width: 12px; height: 12px; flex: 0 0 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center/12px no-repeat;
}

/* reply form / gates */
#topic-page #reply-form {
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  margin: 24px 0 0;
}
#topic-page #reply-form label { align-self: flex-start; font-size: 14px; font-weight: 600; color: var(--g-800); }
#topic-page #reply-body { min-height: 140px; font-size: 15px; }
#topic-page .reply-form-foot { display: flex; align-items: center; gap: 12px; width: 100%; }
#topic-page .reply-form-foot .fm-count {
  margin-right: auto;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; color: var(--g-600); font-variant-numeric: tabular-nums;
}
#topic-page .reply-form-foot .fm-count.is-bad { color: var(--p1, #D32F2F); }
#topic-page #reply-auth-cta,
#topic-page #topic-closed-note {
  margin: 24px 0 0;
  padding: 16px;
  text-align: center;
  font-size: 14px; font-weight: 500; color: var(--g-600);
  border: 1px dashed var(--g-300);
  border-radius: var(--radius, 8px);
}
#topic-page #reply-auth-cta { cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
#topic-page #reply-auth-cta:hover { border-color: var(--g-500); color: var(--g-900); background: #fff; }
#topic-page #topic-closed-note { color: var(--g-600); background: var(--g-100); border-style: solid; border-color: var(--g-200); }

/* back link under the thread */
#topic-page .topic-back { margin: 36px 0 0; font-size: 14px; }
#topic-page .topic-back a { color: var(--g-700); text-decoration: none; font-weight: 500; }
#topic-page .topic-back a:hover { color: var(--g-900); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- reputation badge (shared: SSR + client-inserted) ----------- */
/* Mirrors the Worker's base .rep-badge so SSR topic/reply badges and the
   client-rendered list/top-contributor badges share one look. forum.css loads
   after the Worker's inline base CSS on topic pages, and is the only source on
   the static list page. */
.rep-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--g-100); border: 1px solid var(--g-200); color: var(--g-700);
  vertical-align: middle; white-space: nowrap;
}
.rep-badge .rep-dot { color: var(--g-400); font-weight: 400; }
.rep-badge .rep-points { color: var(--g-600); font-weight: 700; }
.rep-badge--sm { font-size: 11px; padding: 2px 8px; gap: 5px; }
.rep-tier--contributor { color: var(--g-800); }
.rep-tier--advanced { color: var(--g-900); border-color: var(--g-300); }
.rep-tier--expert { color: var(--g-900); border-color: var(--p4, #1976D2); }
.rep-tier--expert .rep-points { color: var(--p4, #1976D2); }

/* topic-page meta extras (author headline, language, country) */
#topic-page .topic-author-headline { font-size: 12px; color: var(--g-600); }
#topic-page .topic-lang,
#topic-page .topic-country {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px; color: var(--g-600);
}

/* ---------- language + country filters (list page) --------------------- */

#forum-list .forum-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px;
  padding: 12px 0 2px; margin: 0;
}
#forum-list .forum-filter { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
#forum-list .forum-filter-label {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--g-600);
}
#forum-list .forum-lang-chips { display: flex; flex-wrap: wrap; gap: 4px; }
#forum-list .forum-lang-chips button {
  padding: 4px 9px;
  font: 600 12px/1.2 var(--font-mono, ui-monospace, monospace);
  color: var(--g-600);
  background: transparent; border: 1px solid var(--g-200); border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
#forum-list .forum-lang-chips button:hover { border-color: var(--g-500); color: var(--g-900); }
#forum-list .forum-lang-chips button[aria-pressed="true"] { background: var(--g-900); color: var(--g-50); border-color: var(--g-900); }
/* the chip for the current UI language stays subtly marked even when "All" is active */
#forum-list .forum-lang-chips button.is-current { box-shadow: inset 0 -2px 0 var(--p4, #1976D2); }
#forum-list #forum-country-filter {
  -webkit-appearance: none; appearance: none;
  padding: 6px 30px 6px 12px; max-width: 220px;
  font: 500 13px/1.3 var(--font-sans, 'Inter', system-ui, sans-serif);
  color: var(--g-900);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B68' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--g-200); border-radius: 999px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
#forum-list #forum-country-filter:focus { outline: none; border-color: var(--g-900); box-shadow: 0 0 0 3px rgba(26,26,24,.08); }

/* ---------- top contributors panel (list aside) ----------------------- */

#forum-list .forum-top { margin: 22px 0 0; padding: 16px 0 0; border-top: 1px solid var(--g-150); }
#forum-list .forum-top h2 {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--g-600); margin: 0 0 10px;
}
#forum-list .forum-top-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#forum-list .forum-top-link {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--radius, 8px);
  text-decoration: none; transition: background .15s;
}
#forum-list .forum-top-link:hover { background: var(--g-100); }
#forum-list .forum-top-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#forum-list .forum-top-name {
  font-size: 13px; font-weight: 600; color: var(--g-800);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#forum-list .forum-top-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#forum-list .forum-top-country { font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; color: var(--g-600); }

/* ---------- ask modal: two-column field row ---------------------------- */

.fm-field-row { display: flex; gap: 16px; }
.fm-field-row .fm-field { flex: 1 1 0; min-width: 0; }

/* ---------- responsive ------------------------------------------------- */

@media (max-width: 960px) {
  #forum-list .forum-layout { grid-template-columns: 1fr; gap: 20px; }
  #forum-list .forum-cats { position: static; }
  #forum-list .forum-cats ul { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  #forum-list .forum-cats button {
    width: auto; padding: 7px 12px;
    font-size: 13px;
    border: 1px solid var(--g-200); border-radius: 999px; background: #fff;
  }
  #forum-list .forum-cats button .cat-count { margin-left: 2px; }
  #forum-list .forum-aside-note { display: none; }
  #forum-list .forum-top { display: none; }
}
@media (max-width: 640px) {
  /* Safari en iOS amplía la página al enfocar un campo de menos de 16px y no
     deshace el zoom al salir. Afecta a abrir tema, responder y buscar. */
  .fm-field input[type="text"],
  .fm-field input,
  .fm-field select,
  .fm-field textarea,
  #topic-page #reply-body,
  #topic-page .fm-edit textarea,
  #forum-list .forum-search input,
  #forum-list #forum-country-filter { font-size: 16px; }

  #forum-list .forum-head .fm-btn--primary { width: 100%; }
  #forum-list .forum-search { flex-basis: 100%; }
  #forum-list .topic-row { grid-template-columns: 1fr; gap: 10px; padding: 14px 0; }
  #forum-list .topic-stats { gap: 14px; }
  #forum-list .topic-stats span { flex-direction: row; gap: 5px; min-width: 0; align-items: baseline; }
  #forum-list .topic-stats b { font-size: 13px; }
  #topic-page .topic-title { font-size: 24px; }
  #topic-page .topic-body { padding: 18px; font-size: 15px; }
  #topic-page .reply { grid-template-columns: 1fr; gap: 10px; padding: 14px; }
  #topic-page .reply-votes { flex-direction: row; justify-content: flex-start; }
  #topic-page .btn-vote-reply { flex-direction: row; width: auto; padding: 6px 12px; }
  #topic-page .topic-actions > #btn-report-topic { margin-left: 0; }
  .fm-card { padding: 24px; }
  .fm-actions > .fm-btn { flex-basis: 100%; }
  .fm-toasts { left: 16px; right: 16px; bottom: 16px; max-width: none; }
  .fm-field-row { flex-direction: column; gap: 0; }
  #forum-list #forum-country-filter { max-width: 100%; width: 100%; }
  #forum-list .forum-filter { width: 100%; }

  /* Áreas táctiles. Medido a 375px: los 6 botones de categoría y los 4 de
     orden medían 32px de alto, y los chips de idioma 24x34px — la mitad del
     mínimo. Y las etiquetas de filtro (11px) y los rótulos de estadística
     (10px) quedaban por debajo del mínimo de 13-14px de CLAUDE.md. */
  #forum-list .forum-cats button { min-height: 44px; padding: 10px 14px; }
  #forum-list .forum-tabs button { min-height: 44px; padding: 12px 14px; }
  #forum-list .forum-lang-chips button { min-height: 40px; padding: 9px 14px; font-size: 13px; }
  #forum-list .forum-filter-label { font-size: 12px; }
  #forum-list .topic-stats small { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .fm-toast, .fm-modal, .fm-card, #forum-list .topic-row, #topic-page .reply,
  .fm-btn, #topic-page button { animation: none; transition: none; }
}
