/* ===== Forum (theme-switch aware) ===== */

/* Layout tokens */
.forum-archive{
  --w-replies:100px;
  --w-views:64px;
  --w-latest:240px;
  --chip-bg: var(--base-3);
}

/* ===== Breadcrumb ===== */
.topic-breadcrumb,
.forum-breadcrumb{
  display:flex; align-items:center; gap:10px; margin:.5rem 0 1rem; color:var(--muted);
}
.topic-breadcrumb .back-btn,
.forum-breadcrumb .back-btn{
  display:inline-block; padding:.45rem .7rem;
  border:1px solid var(--line); border-radius:10px;
  background:var(--base-2); color:var(--text);
  text-decoration:none; font-weight:700;
}
.topic-breadcrumb .back-btn:hover,
.forum-breadcrumb .back-btn:hover{ background:var(--base-3); }
.topic-breadcrumb .sep,
.forum-breadcrumb .sep{ color:var(--muted); }
.topic-breadcrumb .node-link,
.forum-breadcrumb .node-link{ color:var(--brand); text-decoration:none; font-weight:700; }

/* Title */
.forum-title{ font-size:2rem; font-weight:800; margin:.5rem 0 .75rem; color:var(--text); }

/* ===== Filter bar ===== */
.forum-filter,
.forum-filters{
  display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin:10px 0 18px;
}
.forum-filter .filter-input,
.forum-filters .filter-input{
  flex:1 1 280px; padding:.55rem .7rem;
  border:1px solid var(--line); border-radius:10px;
  background:var(--base-2); color:var(--text);
}
.forum-filter .filter-select,
.forum-filters .filter-select{
  flex:1 1 160px; padding:.55rem .7rem;
  border:1px solid var(--line); border-radius:10px;
  background:var(--base-2); color:var(--text);
}
.forum-filter .btn-apply,
.forum-filters .btn-apply{
  background:var(--brand); color:#fff; border:0; border-radius:10px;
  padding:.55rem .9rem; font-weight:800;
}
.forum-filter .btn-reset,
.forum-filters .btn-reset{
  padding:.5rem .8rem; border:1px solid var(--line); border-radius:10px;
  background:var(--chip-bg); color:var(--text); text-decoration:none; font-weight:700;
}

/* Responsive for filter */
@media (max-width:980px){
  .forum-filter .filter-input,
  .forum-filters .filter-input{ flex:1 1 100%; }
}
@media (max-width:640px){
  .forum-filter > *,
  .forum-filters > *{ flex:1 1 100%; }
}
.forum-archive{ width:100%; }
.forum-filter{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin:12px 0 14px; }
.visually-hidden{ position:absolute!important; width:1px; height:1px; overflow:hidden; clip:rect(1px,1px,1px,1px); }

/* ===== Tabs ===== */
.forum-tabs{ display:flex; gap:10px; margin:10px 0 18px; }
.forum-tabs a{
  display:inline-block; padding:.45rem .8rem;
  border:1px solid var(--line); border-radius:9999px;
  background:var(--chip-bg); color:var(--text);
  text-decoration:none; font-weight:600;
}
.forum-tabs a.is-active{ background:var(--brand); color:#fff; border-color:var(--brand); }

/* ===== Topic List ===== */
.topic-list{ list-style:none; margin:0; padding:0; }
.topic-row{
  display:grid; grid-template-columns:1fr auto; gap:18px; align-items:center;
  background:var(--base-2); border:1px solid var(--line); border-radius:14px;
  padding:14px 16px; box-shadow:0 2px 10px rgba(0,0,0,.04);
  margin-bottom:12px; transition:box-shadow .18s ease, transform .18s ease;
}
.topic-row:hover{ transform:translateY(-1px); box-shadow:0 6px 18px rgba(0,0,0,.08); }

.col-topic{ display:flex; gap:12px; align-items:flex-start; min-width:0; }

.topic-meta-left{ display:flex; align-items:start; }
.topic-meta-left .node-pill{
  display:inline-block; padding:.2rem .5rem; border-radius:8px;
  background:color-mix(in srgb, var(--brand) 12%, var(--base-2) 88%);
  color:var(--brand); font-weight:700; font-size:.78rem; white-space:nowrap;
}

.node-pill{
  display:inline-flex; align-items:center; gap:6px; font-weight:700; font-size:.78rem;
  padding:.25rem .5rem; border-radius:999px;
  background:var(--chip-bg); color:color-mix(in srgb, var(--brand) 30%, var(--text) 70%);
}
.node-pill.in-meta{ margin-right:8px; }

.topic-main{ min-width:0; }
.topic-title{ font-size:1rem; font-weight:800; color:var(--text); text-decoration:none; }
.topic-title:hover{ text-decoration:underline; }
.topic-prefix{
  display:inline-block; margin-right:.45rem; padding:.15rem .45rem; border-radius:6px;
  background:#fde68a; color:#7c2d12; font-weight:700; font-size:.72rem; position:relative; top:-1px;
}
.topic-prefix.lg{ font-size:.85rem; }
.topic-sub{ display:flex; align-items:center; gap:10px; margin-top:4px; color:var(--muted); font-size:.85rem; }
.dot::before{ content:"•"; }

/* ===== Right Stats ===== */
.col-stats{
  display:grid; grid-template-columns:var(--w-replies) var(--w-views) var(--w-latest);
  align-items:center; gap:16px; justify-items:center;
  color:var(--muted); white-space:nowrap;
}
.col-stats .stat{ display:flex; flex-direction:column; align-items:center; min-width:58px; line-height:1; text-align:center; }
.col-stats .stat b{ display:block; font-size:16px; font-weight:800; color:var(--text); }
.col-stats .stat em{ font-style:normal; font-size:.78rem; color:var(--muted); }

.last-activity{ display:flex; align-items:center; gap:6px; min-width:max-content; color:color-mix(in srgb, var(--text) 80%, var(--muted) 20%); font-size:.85rem; }
.last-activity time{ color:var(--muted); }
.col-stats .last-activity{
  display:grid; grid-template-columns:auto 1fr; grid-auto-rows:min-content;
  align-items:center; justify-items:end; text-align:right; row-gap:2px; white-space:normal;
}
.col-stats .last-activity em{ grid-column:1; grid-row:1; margin-right:6px; color:var(--muted); font-style:normal; }
.col-stats .last-activity time{ grid-column:2; grid-row:1; display:block; opacity:.95; }
.col-stats .last-activity .latest-who{ grid-column:2; grid-row:2; display:inline-flex; align-items:center; gap:.35rem; }
.last-activity .chip-xs img{ width:20px; height:20px; border-radius:50%; object-fit:cover; }
.user-chip .user-nick{ display:inline-block; max-width:10ch; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ===== User Chip ===== */
.user-chip{ --avatar:32px; --frame-scale:1.5; display:inline-flex; align-items:center; gap:8px; vertical-align:middle; }
.user-avatar{ position:relative; width:var(--avatar); height:var(--avatar); flex:0 0 var(--avatar); border-radius:50%; }
.user-avatar img,
.user-avatar .avatar-img{ width:var(--avatar); height:var(--avatar); display:block; object-fit:cover; border-radius:50%;}
.user-avatar .avatar-frame{ position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); width:calc(var(--avatar)*var(--frame-scale)); height:calc(var(--avatar)*var(--frame-scale)); pointer-events:none; }
.user-nick{ font-weight:600; font-size:.92rem; color:var(--text); max-width:180px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ===== Single Topic ===== */
.topic-breadcrumb{ display:flex; align-items:center; gap:10px; margin:10px 0 14px; color:var(--muted); }
.topic-breadcrumb .back-btn{
  display:inline-block; padding:.45rem .7rem; border:1px solid var(--line); border-radius:10px;
  background:var(--base-2); color:var(--text); text-decoration:none; font-weight:700;
}
.topic-breadcrumb .back-btn:hover{ background:var(--base-3); }
.topic-breadcrumb .sep{ color:var(--muted); }
.topic-breadcrumb .node-link{ color:var(--brand); text-decoration:none; font-weight:700; }

.topic-head{
  background:var(--base-2); border:1px solid var(--line); border-radius:14px;
  padding:16px 18px; box-shadow:0 2px 10px rgba(0,0,0,.04); margin-bottom:14px;
}
.topic-head .topic-title{ font-size:1.6rem; line-height:1.25; font-weight:900; margin:.25rem 0 .35rem; color:var(--text); }
.topic-head .topic-meta{ display:flex; align-items:center; gap:10px; color:var(--muted); }
.topic-head .node-pill{
  display:inline-block; padding:.2rem .5rem; border-radius:8px;
  background:color-mix(in srgb, var(--brand) 12%, var(--base-2) 88%);
  color:var(--brand); font-weight:800; font-size:.78rem;
}
.topic-single .topic-head{ margin:10px 0 12px; }
.topic-single .topic-title{ font-size:1.5rem; margin:.25rem 0 .35rem; color:var(--text); }
.topic-single .topic-byline{ color:var(--muted); display:flex; gap:.5rem; align-items:center; }

.topic-content{
  background:var(--base-2); border:1px solid var(--line); border-radius:14px; padding:18px; color:var(--text);
}
.topic-content p{ margin:0 0 1rem; }

/* ===== Pager ===== */
.topic-pager{ margin:16px 0; }
.post-navigation{ display:flex; justify-content:space-between; gap:12px; }
.post-navigation a{
  display:inline-block; padding:.5rem .8rem; border:1px solid var(--line); border-radius:10px;
  background:var(--base-2); color:var(--text); text-decoration:none;
}
.post-navigation a:hover{ background:var(--base-3); }
.topic-pager .post-navigation .nav-links{ display:flex; align-items:center; justify-content:space-between; gap:12px; width:100%; }
.topic-pager .post-navigation .nav-previous,
.topic-pager .post-navigation .nav-next{ flex:1 1 0; }
.topic-pager .post-navigation .nav-next{ text-align:right; }

/* ===== Pagination ===== */
.forum-pagination ul{ display:flex; gap:8px; list-style:none; padding:0; margin:0; }
.forum-pagination li a,
.forum-pagination li span{
  display:inline-block; padding:.45rem .7rem; border:1px solid var(--line); border-radius:8px; text-decoration:none;
  background:var(--base-2); color:var(--text);
}
.forum-pagination .current{ background:var(--brand); color:#fff; border-color:var(--brand); }

/* ===== New Topic ===== */
.forum-new{ width:100%; }
.topic-breadcrumb .back-btn{ background:var(--base-2); }
.forum-new-head{ margin:6px 0 12px; }
.forum-new-head h1{ font-size:1.6rem; font-weight:900; margin:0 0 .2rem; color:var(--text); }
.forum-new-head .sub{ color:var(--muted); margin:0; }

.card{
  background:var(--base-2); border:1px solid var(--line); border-radius:14px; padding:16px;
  box-shadow:0 2px 10px rgba(0,0,0,.04);
}
.grid{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:12px; }
.grid .col-span-2{ grid-column:span 2 / span 2; }

.f-group{ display:flex; flex-direction:column; gap:6px; margin-bottom:12px; }
.f-group label{ font-weight:700; color:var(--text); }
.f-group .hint{ color:var(--muted); font-size:.8rem; }
.f-group input[type="text"],
.f-group select{
  width:100%; padding:.6rem .7rem; border:1px solid var(--line); border-radius:10px; background:var(--base-2); color:var(--text);
}
.f-group input[type="text"]:focus,
.f-group select:focus{
  outline:2px solid color-mix(in srgb, var(--brand) 25%, transparent);
  border-color:var(--brand);
}
.f-group .checkbox{ font-weight:600; color:var(--text); }

.f-actions{ display:flex; gap:10px; margin-top:6px; }
.btn-primary{
  background:var(--brand); color:#fff; border:0; padding:.6rem .95rem; border-radius:10px; font-weight:800; text-decoration:none;
}
.btn-primary[disabled]{ opacity:.6; cursor:not-allowed; }
.btn-light{
  background:var(--chip-bg); color:var(--text); text-decoration:none;
  padding:.6rem .95rem; border-radius:10px; font-weight:700; border:1px solid var(--line);
}

/* Alerts */
.alert{ padding:.7rem .9rem; border-radius:10px; margin:10px 0; border:1px solid transparent; }
.alert-info{ background:#eff6ff; color:#1e3a8a; border-color:#bfdbfe; }
.alert-warning{ background:#fff7ed; color:#7c2d12; border-color:#fed7aa; }
.alert-danger{ background:#fef2f2; color:#991b1b; border-color:#fecaca; }
.alert-success{ background:#ecfdf5; color:#065f46; border-color:#a7f3d0; }

.rules.card{ margin-bottom:12px; }
.rules h2{ margin:.1rem 0 .4rem; font-size:1rem; font-weight:800; color:var(--text); }
.rules ul{ margin:.2rem 0 0 1rem; padding:0; color:var(--text); }
.rules li{ margin:.2rem 0; }

/* ===== Responsive ===== */
@media (max-width:920px){ .topic-row{ grid-template-columns:1fr; } }
@media (max-width:768px){
  .topic-title{
    display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2;
    overflow:hidden; white-space:normal;
  }
  .col-stats{ display:flex; gap:10px; justify-content:space-between; justify-self:normal; }
  .col-stats .stat.is-views{ display:none; }
  .col-stats .stat{ display:flex; align-items:center; min-width:48px; text-align:center; flex-direction:row; }
  .col-stats .stat b{ padding:0 5px; }
  .last-activity .latest-who{ display:none !important; }
  .topic-row{ grid-template-columns:1fr; }
}
@media (max-width:840px){
  .grid{ grid-template-columns:1fr; }
  .grid .col-span-2{ grid-column:auto; }
}
@media (max-width:720px){ .col-stats{ justify-content:space-between; } }
@media (max-width:420px){
  .topic-pager .post-navigation .nav-links{ flex-wrap:wrap; }
  .topic-pager .post-navigation .nav-previous,
  .topic-pager .post-navigation .nav-next{ flex:0 0 100%; text-align:left; }
}
