:root {
  --bg: #f4f5f7;
  --panel: #fff;
  --text: #1c1c1c;
  --muted: #6b6f76;
  --line: #e2e4e8;
  --link: #1a1aaf;
  --accent: #c8102e;
  --accent-dark: #a00d24;
  --time: #d0021b;
  --yesterday: #8b3fa8;
  --gold: #b7791f;
  --up: #ff4500;
  --down: #7193ff;
  --flash-ok: #e8f6ec;
  --flash-err: #fdecec;
  --radius: 6px;
  --logo-x: 16px; /* left edge of the logo: header padding (+ ☰ button and gap on small screens) */
  --header-h: 100px; /* fixed logo row height (auto on phones, see the 640px media query) */
  --hover: rgba(0,0,0,.05);
  --hover-strong: rgba(0,0,0,.09);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121315; --panel: #1b1c1f; --text: #e4e5e7; --muted: #9a9ea6; --line: #2e3035;
    --link: #8fa8ff; --time: #ff6b6b; --yesterday: #c58be0; --gold: #e0b050; --flash-ok: #183222; --flash-err: #3a1c1c;
    --hover: rgba(255,255,255,.06); --hover-strong: rgba(255,255,255,.11);
  }
}
:root[data-theme="dark"] {
  --bg: #121315; --panel: #1b1c1f; --text: #e4e5e7; --muted: #9a9ea6; --line: #2e3035;
  --link: #8fa8ff; --time: #ff6b6b; --yesterday: #c58be0; --gold: #e0b050; --flash-ok: #183222; --flash-err: #3a1c1c;
  --hover: rgba(255,255,255,.06); --hover-strong: rgba(255,255,255,.11);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1 { font-size: 1.35rem; margin: .2em 0 .4em; }
h2 { font-size: 1.1rem; margin: 1.2em 0 .5em; }
.inline { display: inline; }
.muted { color: var(--muted); }
.hp { position: absolute; left: -9999px; }

/* header */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px 16px; height: var(--header-h); padding: 0 16px; background: var(--panel); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { max-height: 80px; display: block; }
.tagline { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .search { flex: 1 0 200px; max-width: 520px; margin: 0 auto; }
.top .search input { width: 100%; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--text); }
.usermenu { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.icon-link { position: relative; font-size: 18px; color: var(--text); }
.icon-link .badge { position: absolute; top: -6px; right: -10px; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: var(--radius); width: 36px; height: 36px; font-size: 18px; color: var(--text); cursor: pointer; flex: none; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 12px; text-align: center; line-height: 18px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font: inherit; }
.linkbtn:hover { text-decoration: underline; }
.btn.small { padding: 4px 12px; border-radius: 999px; }

/* blue gradient bar, matched to the kwcg.ca site navigation */
nav.primary { display: flex; flex-wrap: wrap; padding: 0 8px;
  background: linear-gradient(to bottom, #00aeef 0%, #02a0dd 35%, #0494c6 65%, #066e91 100%); }
nav.primary a { color: #fff; padding: 9px 26px 8px; font-size: 18px; line-height: 24px; letter-spacing: .02em; text-shadow: 0 1px 1px rgba(0, 40, 70, .55); }
nav.primary a:hover { background: linear-gradient(to bottom, #0290c8 0%, #035f80 100%); text-decoration: none; }
nav.primary a.hl { color: #fff3a8; }
nav.primary .nav-icons { display: flex; align-items: center; gap: 6px; margin-left: auto; padding: 0 4px; }
nav.primary a.nav-icon { display: grid; place-items: center; width: 40px; height: 32px; padding: 0; border: 1px solid #767676; border-radius: 4px;
  background: linear-gradient(to bottom, #fafafa, #e6e6e6); box-shadow: inset 0 1px 0 #fff; text-shadow: none; }
nav.primary a.nav-icon:hover { background: linear-gradient(to bottom, #fff, #d9eef6); border-color: #4f6f80; }
nav.primary a.nav-icon:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
nav.primary a.nav-icon svg { display: block; }

/* reddit-style two columns: left navigator + content */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); grid-template-areas: "nav main" "nav foot"; grid-template-rows: auto 1fr; max-width: 1360px; margin: 0 auto; }
.layout.has-rail { grid-template-columns: 260px minmax(0, 1fr) 210px; grid-template-areas: "nav main rail" "nav foot rail"; max-width: 1480px; }
.layout > .leftnav { grid-area: nav; }
.layout > .maincol { grid-area: main; }
.layout > .rightrail { grid-area: rail; }
.layout > footer.bottom { grid-area: foot; }
.leftnav { position: sticky; top: var(--header-h); align-self: start; grid-row: 1 / -1; height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 12px 12px 24px; border-right: 1px solid var(--line); scrollbar-width: thin; }
.nav-group { border-bottom: 1px solid var(--line); padding: 6px 0 10px; margin-bottom: 6px; }
.nav-group:last-of-type { border-bottom: 0; }
.nav-group summary { list-style: none; cursor: pointer; padding: 8px 12px 4px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); user-select: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after { content: "⌄"; float: right; transition: transform .15s; }
.nav-group:not([open]) summary::after { transform: rotate(-90deg); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 8px; color: var(--text); font-size: 14px; }
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.on { background: var(--hover-strong); font-weight: 700; }
.nav-item.hl .lbl { color: var(--accent); font-weight: 700; }
.nav-item .ico { width: 24px; text-align: center; font-size: 16px; flex: none; }
.nav-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .avatar { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: hsl(var(--h) 55% 45%); }
.nav-foot { font-size: 12px; color: var(--muted); padding: 8px 12px; margin: 0; }
.nav-backdrop { display: none; }
.maincol { min-width: 0; }

main { max-width: 1060px; padding: 12px 24px 24px; }
.notice { text-align: center; padding: 8px; margin-bottom: 10px; font-weight: 700; }
.flash { padding: 8px 12px; border-radius: var(--radius); margin-bottom: 10px; background: var(--flash-ok); }
.flash.error { background: var(--flash-err); }
.community-head { margin-bottom: 8px; }
.community-head p { margin: 0; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 6px 0 8px; border-bottom: 1px solid var(--line); }
.toolbar .sorts a { padding: 4px 10px; border-radius: 999px; margin-right: 2px; }
.toolbar .sorts a.on { background: var(--hover-strong); color: var(--text); }
.sorts a { margin-right: 10px; color: var(--muted); }
.sorts a.on { color: var(--accent); font-weight: 700; }
.refresh { color: var(--accent); font-weight: 600; }

/* thread list (home) */
.thread { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.thread.sticky { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.tbody { flex: 1; min-width: 0; }
.line { overflow-wrap: anywhere; }
.line .cat { font-weight: 700; color: var(--link); }
.title { color: var(--link); }
.title.strong { font-weight: 700; text-decoration: underline; }
.time { color: var(--muted); font-size: 13px; }
.time.today { color: var(--time); }
.time.latest { font-weight: 700; } /* newest reply of a thread */
.time.yesterday { color: var(--yesterday); }
.updated { color: #8b3fa8; font-size: 13px; margin-left: 4px; }
.cnt, .pid { font-size: 12px; color: var(--muted); margin-left: 6px; }
.ext { margin-left: 3px; font-weight: 700; }
.pic, .more { font-size: 12px; color: var(--muted); }
.tag { font-size: 13px; white-space: nowrap; }
.tag.red { color: var(--accent); }
.tag.gold { color: var(--gold); }
.tag.grey { color: var(--muted); }
.author { font-weight: 700; }
.author.anon { color: var(--text); }
.role { font-size: 11px; padding: 0 4px; border: 1px solid var(--gold); color: var(--gold); border-radius: 3px; margin-left: 2px; }
ul.replies { list-style: none; margin: 2px 0 0; padding-left: 18px; border-left: 1px dotted var(--line); }
ul.replies li { margin: 1px 0; }
ul.replies .rtext { color: var(--link); }
.morereplies { display: inline-block; font-size: 12px; margin: 2px 0 0 18px; }
.thread.folded ul.replies, .thread.folded .morereplies { display: none; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* votes */
.vote { display: inline-flex; flex-direction: column; align-items: center; min-width: 28px; line-height: 1; user-select: none; }
.vote button { background: none; border: 0; padding: 2px; cursor: pointer; color: var(--muted); font-size: 11px; }
.vote button:hover { color: var(--text); }
.vote .score { font-size: 12px; font-weight: 700; margin: 1px 0; }
.vote.up .v-up, .vote.up .score { color: var(--up); }
.vote.down .v-down, .vote.down .score { color: var(--down); }
.meta .vote { flex-direction: row; gap: 2px; vertical-align: middle; margin-right: 6px; }

/* post page */
.post-full, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 12px; }
.panel.narrow { max-width: 460px; margin: 20px auto; }
.post-head { display: flex; gap: 10px; align-items: flex-start; }
.crumbs { font-size: 12px; color: var(--muted); }
.meta { color: var(--muted); font-size: 13px; }
.post-body, .cbody { overflow-wrap: anywhere; }
.post-body { margin: 12px 0; font-size: 15px; }
.post-img { display: block; max-width: 100%; max-height: 800px; margin: 6px 0; border-radius: 4px; }
.smiley, .token { vertical-align: middle; }
.token { height: 18px; }
.token.rumor { height: 30px; }
blockquote { margin: 6px 0; padding: 4px 10px; border-left: 3px solid var(--line); color: var(--muted); }
blockquote cite { display: block; font-style: normal; font-weight: 700; }
pre { background: var(--bg); padding: 8px; overflow-x: auto; border-radius: 4px; }
.embed { position: relative; max-width: 640px; aspect-ratio: 16 / 9; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ext-link { margin: 10px 0 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 13px; margin-top: 4px; }
.actions select { font-size: 12px; }
.ip { color: var(--muted); font-size: 11px; }
.deleted { opacity: .65; }
.edited { font-style: italic; }

#comments { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 18px 16px; }
.comments-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
ul.comments { list-style: none; margin: 0; padding: 0; }
ul.comments ul.comments { padding-left: 16px; border-left: 2px solid var(--line); margin-left: 6px; }
.comment { margin-top: 10px; scroll-margin-top: calc(var(--header-h) + 12px); }
.comment:target > .cbox { background: color-mix(in srgb, var(--link) 8%, transparent); border-radius: 4px; }
.cbox { padding: 2px 4px; }
.cbody { margin: 2px 0; }
.cbody.gone { color: var(--muted); font-style: italic; }

/* forms */
.cform { margin: 8px 0 12px; }
.reply-focus .comment { margin-top: 0; }
.reply-focus .cform { scroll-margin-bottom: 12px; }
.post-full { scroll-margin-top: calc(var(--header-h) + 12px); }
.reply-back { font-size: 13px; }
.cform .name { display: block; margin-bottom: 4px; max-width: 260px; }
input, textarea, select { font: inherit; color: var(--text); background: var(--panel); }
input:not([type=checkbox]):not([type=file]), textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); }
textarea { resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; font-size: 13px; }
.stack label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.form-row { display: flex; gap: 10px; }
.form-row label { flex: 1 1 0; min-width: 0; }
.form-row select { flex: 1; width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); }
.captcha { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.captcha-img { flex: none; width: 140px; height: 46px; border: 1px solid #d6dbe1; border-radius: 4px; cursor: pointer; background: #f6f8fb; }
.captcha input.captcha-code { flex: 0 1 90px; width: 90px; min-width: 50px; font-size: 16px; }
.captcha-code::placeholder { font-size: 13px; }
.captcha-code::placeholder, input[name=title]::placeholder { color: var(--muted); opacity: .55; }
.captcha-refresh { flex: none; font-size: 13px; }
.formbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; }
.hint { font-size: 12px; color: var(--muted); }
.btn { display: inline-block; padding: 6px 14px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent); color: #fff; cursor: pointer; font: inherit; font-weight: 600; }
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.ghost { background: none; color: var(--accent); }
.btn.ghost:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.upload.busy { opacity: .6; pointer-events: none; }
.searchform { display: flex; gap: 6px; flex-wrap: wrap; }
.searchform input[type=search] { flex: 1; min-width: 160px; width: auto; }

/* lists & tabs */
.tabs { display: flex; gap: 14px; align-items: center; border-bottom: 1px solid var(--line); margin: 10px 0; padding-bottom: 6px; }
.tabs a.on { color: var(--accent); font-weight: 700; }
.tabs .btn { margin-left: auto; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.excerpt { font-size: 13px; color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); }
table.list .cb { width: 28px; }
tr.unread td { font-weight: 700; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; margin: 14px 0; }
.pager a, .pager span { padding: 3px 9px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.pager .cur { background: var(--accent); color: #fff; border-color: var(--accent); }
.profile .about { margin: 8px 0; }
.cms-body { font-size: 15px; }

footer.bottom { max-width: 1060px; padding: 14px 16px 30px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

@media (max-width: 1200px) {
  /* no room for three columns: 商业广场 moves under the content as a grid */
  .layout.has-rail { grid-template-columns: 260px minmax(0, 1fr); grid-template-areas: "nav main" "nav rail" "nav foot"; grid-template-rows: auto auto 1fr; max-width: 1360px; }
  .rightrail { position: static; max-height: none; overflow: visible; border-left: 0; border-top: 1px solid var(--line); margin: 0 24px; padding: 12px 0; }
  .ad-rail .ad-items { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 960px) {
  :root { --logo-x: 68px; } /* 16px padding + 36px ☰ button + 16px gap */
  .nav-toggle { display: block; }
  .layout, .layout.has-rail { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "rail" "foot"; }
  .leftnav { position: fixed; z-index: 40; top: 0; left: 0; height: 100vh; width: 280px; background: var(--panel); transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 24px rgba(0,0,0,.25); }
  body.nav-open .leftnav { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.35); }
  .tagline { display: none; }
}
@media (max-width: 640px) {
  :root { --logo-x: 56px; } /* 12px padding + 36px ☰ button + 8px gap */
  .top { padding: 6px 12px 8px; gap: 8px; }
  .brand img { max-height: 34px; }
  .top .search { display: none; }
  .usermenu { margin-left: auto; gap: 8px; }
  nav.primary a { padding: 8px 12px; font-size: 16px; }
  nav.primary .nav-icons { gap: 4px; padding: 4px 0; }
  nav.primary a.nav-icon { width: 34px; height: 30px; }
  main { padding: 10px 12px 20px; }
  .rightrail { margin: 0 12px; }
  .ad-rail .ad-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .post-full, .panel, #comments { padding: 10px 12px; }
  ul.replies, ul.comments ul.comments { padding-left: 10px; }
}

/* Google / Facebook sign-in */
.social { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 12px; }
.social-btn { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); font-weight: 600; }
.social-btn:hover { background: var(--hover); text-decoration: none; }
.social-btn .logo { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font: 700 13px/1 Arial, sans-serif; color: #fff; }
.social-btn.google .logo { background: #4285f4; }
.social-btn.facebook .logo { background: #1877f2; }
.social-btn.mini { display: inline-flex; padding: 2px 8px; border: 0; background: none; }
.social .or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.social .or::before, .social .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.identity { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* right rail (商业广场) */
.rightrail { position: sticky; top: var(--header-h); align-self: start; max-height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 12px 12px 24px; border-left: 1px solid var(--line); scrollbar-width: thin; }
.rightrail .ad { margin: 0; }
.rightrail .ad-title { font-size: 12px; letter-spacing: .06em; padding: 4px 4px 8px; margin: 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; color: var(--muted); }
.rightrail .ad-label { top: 4px; }
.ad-rail .ad-items { display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); gap: 8px; }
.ad-rail .ad-item img { display: block; width: 100%; max-width: 186px; aspect-ratio: 166 / 70; object-fit: contain; margin: 0 auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; transition: transform .12s, box-shadow .12s; }
.ad-rail .ad-item a:hover img { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.ad-rail .ad-text a { display: block; padding: 6px 8px; border-radius: 6px; }
.ad-rail .ad-text a:hover { background: var(--hover); text-decoration: none; }

/* ads */
.ad-header_ad { flex: 0 1 auto; min-width: 0; margin: 0; padding-right: 22px; }
.ad-header_ad .ad-items { display: flex; align-items: center; gap: 8px; }
.ad-header_ad .ad-item { min-width: 0; }
.ad-header_ad .ad-item img { display: block; max-height: var(--ad-img-h, 90px); max-width: min(728px, 100%); width: auto; height: auto; }
.ad-header_ad .ad-text a { white-space: nowrap; font-weight: 600; }
.ad-header_ad .ad-html { max-height: 90px; overflow: hidden; }
.ad-header_ad .ad-label { top: auto; bottom: 0; }
@media (max-width: 900px) { .ad-header_ad { display: none; } } /* too small to read beside the search box */
@media (max-width: 640px) {
  /* phones: a fixed 100px header would take most of the screen */
  .ad-header_ad { display: none; }
  .top { height: auto; }
}
.ad.ad-strip { margin: 0; padding: 0 16px 10px var(--logo-x); background: var(--panel); }
.ad-strip .ad-items { display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 8px; }
.ad-strip .ad-item, .ad-strip .ad-item > a { display: flex; align-items: center; }
.ad-strip .ad-item img { display: block; max-height: var(--ad-img-h, 90px); max-width: 100%; width: auto; height: auto; vertical-align: middle; }
.ad-strip .ad-text a { font-weight: 600; padding: 4px 10px; }
.ad-strip .ad-label { right: 16px; }
@media (max-width: 640px) { .ad.ad-strip { padding: 0 12px 8px var(--logo-x); } .ad-strip .ad-item img { max-height: 60px; } }
.ad { position: relative; margin: 10px 0; }
.ad-title { font-size: 13px; color: var(--muted); margin: 0 0 6px; font-weight: 700; }
.ad-label { position: absolute; top: 0; right: 0; font-size: 10px; color: var(--muted); opacity: .7; }
.ad-grid .ad-items { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 8px; }
.ad-grid .ad-item img { display: block; width: 100%; max-width: 166px; aspect-ratio: 166 / 70; object-fit: contain; margin: 0 auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.ad-grid .ad-text a { display: block; padding: 6px; text-align: center; border: 1px solid var(--line); border-radius: 4px; }
.ad-banner { text-align: center; }
.ad-banner .ad-items { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.ad-banner .ad-item img { max-width: 100%; max-height: var(--ad-img-h, none); width: auto; height: auto; }
.ad-html { max-width: 100%; overflow: hidden; }
.ad-html iframe { max-width: 100%; border: 0; }
.leftnav .ad { margin: 6px 12px 10px; }
.leftnav .ad-item { padding: 3px 0; font-size: 13px; }
.leftnav .ad-item img { display: block; max-width: 100%; border-radius: 4px; }
.leftnav .ad-label { top: 2px; }
.ad.ad-strip.ad-header_banner { padding-top: 10px; padding-bottom: 10px; }
.ad.ad-strip.ad-logo_strip { margin: 10px 0; } /* unchanged spacing of the strip above the bar */
.ad.ad-strip.ad-header_banner .ad-items { align-items: center; }
@media (max-width: 640px) {
  .ad-grid .ad-items { grid-template-columns: repeat(min(var(--cols, 4), 2), minmax(0, 1fr)); }
}

/* share buttons (thread page) */
.share { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 4px; }
.share-label { font-size: 13px; color: var(--muted); margin-right: 2px; }
.share-btn { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; line-height: 20px; }
.share-btn:hover { background: var(--hover); text-decoration: none; }
.share-btn svg { flex: none; }
.share-btn.x svg { color: var(--text); }
.share-pop { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 220px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); text-align: center; }
.share-pop .qr { width: 168px; height: 168px; margin: 4px auto 8px; padding: 6px; background: #fff; border-radius: 6px; box-sizing: content-box; }
.share-pop .qr img, .share-pop .qr canvas { display: block; }
.qr-tip { font-size: 12px; color: var(--muted); margin: 0; }
.share-close { position: absolute; top: 4px; right: 8px; border: 0; background: none; font-size: 18px; color: var(--muted); cursor: pointer; }
@media (max-width: 640px) { .share-btn span { display: none; } .share-btn { padding: 6px 9px; } .share-label { display: none; } }
.banned-ip { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
