/* ── KLAS Forum Styles ── */
/* Inline-SVG icon (replaces dead Tabler ti font) — sizes to parent font-size */
.ti-svg{width:1em;height:1em;display:inline-block;flex-shrink:0;vertical-align:-.125em;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.kf-chip .ti-svg,.kf-tile-label .ti-svg{width:14px;height:14px;}
.klas-sidebar-btn .ti-svg,.klas-new-post-btn .ti-svg{width:16px;height:16px;}
.kf-upgrade-hint .ti-svg{width:14px;height:14px;}
.klas-dialog-icon .ti-svg{width:24px;height:24px;}
.klas-page-btn .ti-svg{width:16px;height:16px;}
.klas-empty .ti-svg{width:32px;height:32px;}

/* ══════════════════════════════════════
   KLAS Header — 2026 Edition
   ══════════════════════════════════════ */
.klas-header {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid rgba(228,230,234,0.7);
  height: 64px;
  display: flex;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  transition: top 0.32s cubic-bezier(0.4,0,0.2,1),
              opacity 0.32s cubic-bezier(0.4,0,0.2,1),
              background 0.2s;
  will-change: top, opacity;
  contain: layout;
}
.klas-header.header--hidden {
  top: -74px;
  opacity: 0;
  pointer-events: none;
}
/* Push content below fixed header */
body.klas-has-header { padding-top: 64px !important; }
/* WordPress admin bar offset */
body.admin-bar .klas-header { top: 32px; }
body.admin-bar .klas-header.header--hidden { top: calc(-74px + 32px); }
body.admin-bar.klas-has-header { padding-top: 64px !important; }
@media (max-width: 782px) {
  body.admin-bar .klas-header { top: 46px; }
  body.admin-bar .klas-header.header--hidden { top: calc(-74px + 46px); }
  body.admin-bar.klas-has-header { padding-top: 64px !important; }
}
[data-theme="dark"] .klas-header {
  background: rgba(26,29,36,0.88);
  border-bottom-color: rgba(42,45,53,0.7);
}

.header-inner {
  display: flex;
  align-items: center;
  max-width: 1160px;
  width: 100%;
  margin: 0 auto;
  padding: 0 40px;
  box-sizing: border-box;
}

/* Logo */
.header-logo {
  display: flex; align-items: center;
  text-decoration: none; flex-shrink: 0;
  margin-right: auto;
}
.header-logo svg {
  height: 15px; width: auto; display: block;
  color: var(--text-1);
  transition: opacity 0.15s;
}
.header-logo:hover svg { opacity: 0.7; }

/* Nav — DS 1.0 pill rail */
.header-nav {
  display: flex; align-items: center; gap: 2px;
  position: absolute; left: 50%; transform: translateX(-50%);
  background: var(--bg); border-radius: 999px; padding: 3px;
}
[data-theme="dark"] .header-nav { background: rgba(255,255,255,.07); }
.nav-link {
  display: flex; align-items: center; padding: 5px 14px; border-radius: 999px;
  color: var(--text-3); background: transparent; text-decoration: none;
  transition: background .2s, color .18s, box-shadow .2s;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-label {
  font-size: 12.5px; font-weight: 500;
  max-width: 0; opacity: 0; overflow: hidden; white-space: nowrap; margin-left: 0;
  transition: max-width .26s ease, opacity .2s ease, margin-left .26s ease;
}
.nav-link:hover .nav-label { max-width: 80px; opacity: 1; margin-left: 5px; }
/* 當前頁 active：永遠顯示 icon + 文字 */
.nav-link.active .nav-label { max-width: 90px; opacity: 1; margin-left: 5px; }
.nav-link:hover { background: var(--surface); color: var(--text-1); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.nav-link.active { background: var(--blue); color: #fff; }
.nav-link.active:hover { box-shadow: 0 2px 10px rgba(30,100,255,.28); }
[data-theme="dark"] .nav-link { color: rgba(255,255,255,.45); }
[data-theme="dark"] .nav-link:hover { background: rgba(255,255,255,.10); color: rgba(255,255,255,.9); }
[data-theme="dark"] .nav-link.active { background: rgba(255,255,255,.9); color: var(--blue); }
[data-theme="dark"] .nav-link.active:hover { background: #fff; }

/* Right controls */
.header-right {
  display: flex; align-items: center; gap: 16px;
  margin-left: auto; flex-shrink: 0;
}

/* Icon buttons — DS 1.0 .icon-btn */
/* !important needed to override Astra's dynamic button CSS */
.icon-btn {
  width: 30px; height: 30px;
  border: none !important; background: transparent !important;
  background-color: transparent !important;
  outline: none !important;
  color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .15s, color .15s;
  padding: 0 !important; text-decoration: none;
  position: relative; border-radius: 8px;
  -webkit-appearance: none; appearance: none;
  box-shadow: none !important;
  min-width: unset !important; min-height: unset !important;
  font-size: unset !important; font-weight: unset !important;
  letter-spacing: unset !important; text-transform: unset !important;
}
.icon-btn:hover { background: var(--bg) !important; color: var(--text-1); }
[data-theme="dark"] .icon-btn { color: rgba(255,255,255,.5); }
[data-theme="dark"] .icon-btn:hover { background: rgba(255,255,255,.08) !important; color: #fff; }
.icon-btn svg { pointer-events: none; width: 16px; height: 16px; }

/* Cart badge */
.cart-dot {
  position: absolute; top: 1px; right: 1px;
  width: 12px; height: 12px;
  background: var(--blue); color: #fff;
  font-size: 7px; font-weight: 700;
  border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid #fff;
}
[data-theme="dark"] .cart-dot { background: #fff; color: var(--blue); border-color: transparent; }

/* Tier badge — DS 1.0 bordered pill, no fill */
.hbadge {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 999px; border: 1.5px solid;
  white-space: nowrap; margin-right: 13px; /* 同 avatar 保持呼吸空間；同 icon 嘅距離由 .header-right gap 統一控制 */
}
.hbadge.freebie { color: #9DA3AE; border-color: #9DA3AE; }
.hbadge.pro     { color: #0057FF; border-color: #0057FF; }
.hbadge.advance { color: #7C3AED; border-color: #7C3AED; }
[data-theme="dark"] .hbadge.freebie { color: #B8BEC9; border-color: #B8BEC9; }
[data-theme="dark"] .hbadge.pro     { color: #3B82F6; border-color: #3B82F6; }
[data-theme="dark"] .hbadge.advance { color: #B48CFF; border-color: #B48CFF; }

/* Avatar — DS 1.0 tier-based solid colour */
.havatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  margin-left: 5px; flex-shrink: 0;
  transition: opacity .15s; cursor: default;
}
.havatar:hover { opacity: .85; }
.havatar.freebie { background: #9DA3AE; }
.havatar.pro     { background: #0057FF; }
.havatar.advance { background: #7C3AED; }
[data-theme="dark"] .havatar.freebie { background: #B8BEC9; color: #111318; }
[data-theme="dark"] .havatar.pro     { background: #3B82F6; }
[data-theme="dark"] .havatar.advance { background: #a78bfa; }

/* Profile dropdown */
.klas-profile { position: relative; }
.klas-profile-trigger {
  display: flex; align-items: center; gap: 0;
  background: none; border: 0; padding: 0; cursor: pointer;
  border-radius: 999px; transition: opacity .15s;
}
.klas-profile-trigger:hover { opacity: .9; }
.klas-profile-menu {
  position: absolute; top: calc(100% + 12px); right: 0; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 14px 38px rgba(16,19,24,.16); padding: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .16s, transform .16s; z-index: 1000;
}
.klas-profile.open .klas-profile-menu { opacity: 1; visibility: visible; transform: none; }
.klas-pm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500; color: var(--text-1);
  text-decoration: none !important; transition: background .14s, color .14s;
}
.klas-pm-item svg { width: 16px; height: 16px; color: var(--text-2); flex-shrink: 0; transition: color .14s; }
.klas-pm-item:hover { background: #EEF3FF; color: #0057FF; }
.klas-pm-item:hover svg { color: #0057FF; }
.klas-pm-item.danger { color: #DC2626; }
.klas-pm-item.danger svg { color: #DC2626; }
.klas-pm-item.danger:hover { background: #FEECEC; color: #DC2626; }
.klas-pm-sep { height: 1px; background: var(--border); margin: 5px 8px; }
[data-theme="dark"] .klas-pm-item:hover { background: rgba(96,179,255,.14); color: #6AA8FF; }
[data-theme="dark"] .klas-pm-item:hover svg { color: #6AA8FF; }
[data-theme="dark"] .klas-pm-item.danger:hover { background: rgba(248,113,113,.14); }

/* Login button */
.header-login-btn {
  font-size: 12.5px; font-weight: 500;
  color: var(--text-1) !important; text-decoration: none !important;
  padding: 5px 13px; border-radius: 7px;
  border: 0.5px solid var(--border); background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.header-login-btn:hover { border-color: var(--text-3); background: var(--bg); }

/* ── Footer ── */
.klas-footer { background: var(--surface); border-top: none; padding: 0 0 28px; margin-top: 0; }
.footer-inner { max-width: 1160px; margin: 0 auto 40px; padding: 0 40px; display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 40px; border-top: 0.5px solid var(--border); padding-top: 48px; box-sizing: border-box; }
.footer-logo { display: flex; align-items: center; margin-bottom: 12px; }
.footer-logo svg { height: 16px; width: auto; display: block; color: var(--text-1); }
.footer-tagline { font-size: 13px; color: var(--text-2); line-height: 1.55; max-width: 220px; margin-bottom: 16px; }
.footer-social { display: flex; gap: 8px; margin-left: -7px; }
.social-btn { width: 32px; height: 32px; border: none; background: none; display: flex; align-items: center; justify-content: center; color: var(--text-3) !important; text-decoration: none !important; transition: color .15s; padding: 0; }
.social-btn:hover { color: var(--text-1) !important; }
.social-btn svg { width: 18px; height: 18px; }
.footer-col-title { font-size: 12px; font-weight: 700; color: var(--text-1); margin-bottom: 12px; }
.footer-links { display: flex; flex-direction: column; gap: 8px; }
.footer-link { font-size: 13px; color: var(--text-3) !important; text-decoration: none !important; transition: color .15s; }
.footer-link:hover { color: var(--blue) !important; }
/* Dark: beat global a{color!important} so default = grey, hover = blue */
[data-theme="dark"] .klas-footer .footer-link { color: var(--text-3) !important; }
[data-theme="dark"] .klas-footer .footer-link:hover { color: var(--blue) !important; }
[data-theme="dark"] .klas-footer .footer-legal a { color: var(--text-3) !important; }
[data-theme="dark"] .klas-footer .footer-legal a:hover { color: var(--blue) !important; }
[data-theme="dark"] .klas-footer .social-btn { color: var(--text-3) !important; }
[data-theme="dark"] .klas-footer .social-btn:hover { color: var(--blue) !important; }
.footer-bottom { max-width: 1160px; margin: 0 auto; padding: 20px 40px 0; border-top: 0.5px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; box-sizing: border-box; }
.footer-copy { font-size: 12px; color: var(--text-3); }
.footer-legal { display: flex; gap: 16px; }
.footer-legal a { font-size: 12px; color: var(--text-3) !important; text-decoration: none !important; }
.footer-legal a:hover { color: var(--text-2) !important; }

/* ── Hide Hostinger / third-party injected UI elements ── */
#bottomBar,
#hostinger-reach-widget,
.hostinger-reach-widget,
#ast-scroll-top { display: none !important; }

@media (max-width: 900px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  /* 品牌區獨佔一行，學習／社群／支援 3 組並排一行，唔再全部打直逐組疊 */
  .footer-inner { grid-template-columns: repeat(3, 1fr); gap: 28px 14px; }
  .footer-inner > div:first-child { grid-column: 1 / -1; }
  .footer-tagline { max-width: 100%; }
  .footer-links { gap: 9px; }
}

/* ── Mobile header: logo left + hamburger right + text menu ── */
.klas-burger {
  display: none; background: none; border: 0; cursor: pointer;
  color: var(--text-1); padding: 7px; margin-left: 2px; border-radius: 9px;
  align-items: center; justify-content: center; transition: background .15s;
}
.klas-burger:hover { background: var(--bg); }
/* morphing menu↔close icon */
.klas-burger-icon { transition: transform .5s ease-in-out; }
.klas-burger-icon .klas-burger-top {
  stroke-dasharray: 12 63;
  transition: stroke-dasharray .5s ease-in-out, stroke-dashoffset .5s ease-in-out;
}
.klas-burger.is-open .klas-burger-icon { transform: rotate(-45deg); }
.klas-burger.is-open .klas-burger-icon .klas-burger-top {
  stroke-dasharray: 20 300;
  stroke-dashoffset: -32.42px;
}
@media (prefers-reduced-motion: reduce) {
  .klas-burger-icon, .klas-burger-icon .klas-burger-top { transition: none; }
}
.klas-mmenu { display: none; }

@media (max-width: 900px) {
  .header-nav { display: none !important; }
  .klas-burger { display: inline-flex; }
  .header-right .icon-btn,
  .header-right #klas-theme-toggle,
  .header-right .klas-profile,
  .header-right .header-login-btn { display: none !important; }

  .klas-mmenu {
    display: block;
    position: fixed; left: 0; right: 0; top: 60px; bottom: 0;
    background: var(--surface);
    transform: translateY(-10px); opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .22s ease, transform .22s ease, visibility .22s;
    z-index: 999; overflow-y: auto; -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }
  body:has(#wpadminbar) .klas-mmenu { top: 92px; }
  body.klas-mmenu-on .klas-mmenu { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
  body.klas-mmenu-on { overflow: hidden; }

  /* 左右 padding 26px + 列內 14px = 內容對齊 header logo（40px gutter） */
  .klas-mm-inner {
    display: flex; flex-direction: column; gap: 6px;
    padding: 16px 26px calc(20px + env(safe-area-inset-bottom)); box-sizing: border-box;
  }
  .klas-mm-group { display: flex; flex-direction: column; gap: 4px; }

  /* nav row: icon tile + label + chevron */
  .klas-mm-link {
    display: flex; align-items: center; gap: 14px;
    min-height: 58px; padding: 10px 14px;
    font-size: 18px; font-weight: 600; line-height: 1.2;
    color: var(--text-1); text-decoration: none;
    border-radius: 14px;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
    -webkit-tap-highlight-color: transparent;
    /* staggered reveal on open */
    opacity: 0; transform: translateY(10px);
  }
  .klas-mm-ic {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg); color: var(--text-2);
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
  }
  .klas-mm-tx { flex: 1 1 auto; }
  .klas-mm-ch { flex: 0 0 auto; color: var(--text-3); }
  .klas-mm-link:active { background: var(--bg); }
  .klas-mm-link.active {
    color: var(--blue); background: rgba(0,87,255,.07);
    box-shadow: inset 0 0 0 1px rgba(0,87,255,.16);
  }
  .klas-mm-link.active .klas-mm-ic {
    background: var(--blue); color: #fff;
    box-shadow: 0 0 0 4px rgba(0,87,255,.12);
  }
  .klas-mm-link.active .klas-mm-ch { color: var(--blue); }
  .klas-mm-logout { color: #DC2626; }
  .klas-mm-logout .klas-mm-ic { color: #DC2626; background: rgba(220,38,38,.08); }

  /* section divider + label */
  .klas-mm-sep { height: 1px; background: var(--border); margin: 12px 14px; }
  .klas-mm-label {
    font-size: 13px; font-weight: 700; letter-spacing: .04em;
    color: var(--text-3); padding: 0 14px 6px;
  }

  /* guest CTA buttons */
  .klas-mm-cta { display: flex; flex-direction: column; gap: 10px; padding: 4px 14px 0; }
  .klas-mm-btn {
    display: flex; align-items: center; justify-content: center;
    min-height: 54px; border-radius: 14px;
    font-size: 17px; font-weight: 600; text-decoration: none;
    transition: background .15s ease, border-color .15s ease, transform .12s ease;
    opacity: 0; transform: translateY(10px);
  }
  .klas-mm-btn:active { transform: scale(.985); }
  .klas-mm-btn.primary { background: var(--blue); color: #fff; }
  .klas-mm-btn.primary:active { background: var(--blue-h, #0046CC); }
  .klas-mm-btn.ghost { background: transparent; color: var(--text-1); border: 1px solid var(--border); }

  /* reveal animation */
  body.klas-mmenu-on .klas-mm-link,
  body.klas-mmenu-on .klas-mm-btn {
    opacity: 1; transform: none;
    transition: opacity .4s ease, transform .4s cubic-bezier(.16,1,.3,1),
                background .15s ease, color .15s ease, border-color .15s ease;
    transition-delay: calc(var(--i, 0) * 45ms);
  }
  @media (prefers-reduced-motion: reduce) {
    .klas-mmenu { transition: opacity .15s, visibility .15s; }
    .klas-mm-link, .klas-mm-btn { opacity: 1; transform: none; }
    body.klas-mmenu-on .klas-mm-link,
    body.klas-mmenu-on .klas-mm-btn { transition-delay: 0s; }
  }
}
/* ── DS 1.0 Design Tokens ── */
:root {
  /* Brand blue scale */
  --klas-blue-50:  #EEF3FF;
  --klas-blue-100: #D4E2FF;
  --klas-blue-200: #A9C5FF;
  --klas-blue-300: #7EA8FF;
  --klas-blue-400: #538BFF;
  --klas-blue-500: #2870FF;
  --klas-blue-600: #0057FF;
  --klas-blue-700: #0046D6;
  --klas-blue-800: #0035AD;

  /* Ink / neutrals */
  --ink-950: #0A0B0F;
  --ink-900: #0B1020;
  --ink-850: #14161D;
  --ink-800: #1B1E27;
  --ink-700: #252836;
  --ink-600: #373B4D;

  /* Gradients */
  --klas-grad-blue:   #0057FF;
  --klas-grad-azure:  #0057FF;
  --klas-grad-indigo: linear-gradient(135deg, #7C3AED 0%, #818CF8 100%);
  --klas-grad-accent: linear-gradient(90deg, #0057FF 0%, #7C3AED 100%);
  --klas-grad-aurora: linear-gradient(135deg, #0057FF 0%, #0A0B0F 100%);
  --klas-glow-blue:   radial-gradient(ellipse 60% 40% at 50% 0%, rgba(0,87,255,.06) 0%, transparent 100%);

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:  0 1px 4px rgba(0,0,0,.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.12);
  --shadow-xl:  0 16px 40px rgba(0,0,0,.14);
  --shadow-blue:      0 4px 16px rgba(0,87,255,.20);
  --shadow-blue-glow: 0 0 0 3px rgba(0,87,255,.15), 0 8px 24px rgba(0,87,255,.20);
  --shadow-indigo:    0 4px 16px rgba(124,58,237,.20);

  /* Radius scale */
  --r-2xl: 28px; --r-xl: 20px; --r-lg: 16px;
  --r-md: 12px; --r-sm: 8px; --r-xs: 6px; --r-pill: 999px;

  /* Legacy aliases (backward compat) */
  --blue:       #0057FF;
  --blue-light: #EEF3FF;
  --blue-dark:  #0A2D6E;
  --blue-soft:  #60B3FF;
  --text-1:     #111318;
  --text-2:     #5A6070;
  --text-3:     #9DA3AE;
  --border:     #E4E6EA;
  --surface:    #FFFFFF;
  --bg:         #F3F4F6;
  --beige:      #F4F1EC;
  --r: 14px;
  --shadow-hover: var(--shadow-blue);
  --sidebar-w: 220px;
}

[data-theme="dark"] {
  --text-1: #F4F6FA; --text-2: #C2C8D4; --text-3: #9098A8;
  --border: #2A2D35; --surface: #14161D; --bg: #0A0B0F; --beige: #1A1C16;
  --blue: #6AA8FF;
  --blue-light: rgba(106,168,255,0.14);
  --blue-dark: #93C8FF;
}

/* ── Global body font — DS 1.0: Outfit + Noto Sans TC ── */
body {
  font-family: 'Outfit', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', -apple-system, BlinkMacSystemFont, sans-serif !important;
  -webkit-font-smoothing: antialiased;
}

/* ── Forum page body（html 都要上色：Mac 慣性滾動 rubber-band 位會露出 html 背景，透明=白色）── */
html:has(.klas-forum-page), body:has(.klas-forum-page) { background: var(--bg); }
.klas-forum-page {
  background: var(--bg);
  min-height: 100vh;
  font-family: inherit;
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}
.klas-forum-page > *:last-child {
  margin-bottom: 0 !important;
}

/* ── Hide Astra/bbPress default elements ── */
.bbp-forum-title,
.bbp-forum-content,
.entry-header .entry-title,
.ast-single-post-order .entry-header,
h1.bbp-forum-title,
.bbp-breadcrumb,
.forum-description,
.entry-header { display: none !important; }

/* ── Hide Astra original header (replaced by KLAS header) ── */
.site-header,
.ast-site-header-wrap,
#masthead { display: none !important; }

/* ── Hide bbPress next/prev forum navigation ── */
.bbp-forum-pagination,
.bbp-forum-pagination-count,
.forum-nav-links,
div.bbp-template-notice.info { display: none !important; }

/* ── Hide Astra post navigation (NEXT/PREV) ── */
nav.navigation.post-navigation,
.post-navigation {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
}

/* ── Remove Astra container padding on bbPress only ── */
.bbpress .ast-container,
.bbpress .site-content .ast-container,
.bbpress #content .ast-container { max-width: 100% !important; padding: 0 !important; }

.bbpress .entry-content { padding: 0 !important; margin: 0 !important; }
.bbpress .ast-article-single { padding: 0 !important; }

/* ── Remove Astra #primary padding on bbPress ── */
.bbpress .ast-separate-container #primary,
.forum .ast-separate-container #primary,
.bbpress #primary,
.forum #primary { padding: 0 !important; margin: 0 !important; }

/* ── WooCommerce: restore content padding, align with KLAS header ── */
.woocommerce .ast-container,
.woocommerce-page .ast-container {
  max-width: 1180px !important;
  margin: 0 auto !important;
  padding: 0 24px !important;
}

.woocommerce #primary,
.woocommerce-page #primary {
  padding: 32px 0 !important;
}

/* WooCommerce inner container — align with KLAS header (override Astra max-width:none) */
body.woocommerce .ast-woocommerce-container,
body.woocommerce-page .ast-woocommerce-container {
  max-width: 1180px !important;
  width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 24px !important;
  padding-right: 24px !important;
  box-sizing: border-box !important;
}

/* WooCommerce description + tabs padding */
.woocommerce div.product .woocommerce-tabs,
.woocommerce div.product .woocommerce-tabs .panel,
.woocommerce div.product .woocommerce-product-details__short-description,
.woocommerce .entry-summary {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.woocommerce-tabs ul.tabs,
.woocommerce-tabs ul.tabs li { padding-left: 0 !important; }

/* Fix description text not inheriting container padding */
.woocommerce div.product .woocommerce-tabs #tab-description {
  padding: 24px 0 48px !important;
}

/* ── bbPress pagination → KLAS style ── */
.bbp-pagination,
.bbp-pagination-count { display: none; }

/* ── Hide bbPress default text ── */
.bbp-forum-content > p:first-of-type,
.bbp-template-notice,
.bbp-body > p,
p.bbp-forum-content { display: none; }

/* ── Hide "Viewing X topics" ── */
.bbp-pagination-count,
.topic-count-text,
div.bbp-topic-count { display: none; }

/* ── Make tags lowercase ── */
.klas-tag { text-transform: none !important; }

/* ── New topic button fix ── */
.klas-sidebar a.klas-new-post-btn,
.klas-sidebar a.klas-new-post-btn:link,
.klas-sidebar a.klas-new-post-btn:visited,
.klas-sidebar a.klas-new-post-btn:hover,
.klas-sidebar a.klas-new-post-btn:focus,
button.klas-new-post-btn {
  color: #fff !important;
  text-decoration: none !important;
  font-family: 'Inter', sans-serif !important;
}
.klas-sidebar a.klas-new-post-btn i,
button.klas-new-post-btn i { color: #fff !important; }

/* ══════════════════════════════════════
   BENTO 2026 — 新設計
══════════════════════════════════════ */
.kf-bento-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 66px 40px 0;
  box-sizing: border-box;
}
.kf-bento {
  display: grid;
  grid-template-columns: 1.5fr 1fr 168px;
  grid-template-rows: auto auto;
  gap: 12px;
  margin-bottom: 24px;
}

/* ── Base tile ── */
.kf-tile {
  border-radius: 16px;
  padding: 22px 24px;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  will-change: transform;
  contain: layout style;
}
.kf-tile:hover { transform: translateY(-2px); }

/* ── Tile label ── */
.kf-tile-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--text-2);
  margin-bottom: 14px;
}
.kf-tile-label i { font-size: 13px; }

/* ── Announce tile (col 1, rowspan 2) ── */
.kf-announce {
  grid-column: 1/2; grid-row: 1/3;
  background: #0057FF;
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 230px;
  position: relative; overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,87,255,.25);
}
.kf-announce-content { position: relative; z-index: 1; }
.kf-announce-footer {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: rgba(255,255,255,.55);
  padding-top: 14px; margin-top: 16px;
  border-top: 0.5px solid rgba(255,255,255,.15);
}
.kf-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.18);
  border: 0.5px solid rgba(255,255,255,.25);
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
  padding: 4px 12px; border-radius: 999px;
  color: rgba(255,255,255,.9); margin-bottom: 16px; width: fit-content;
}
.kf-announce-title {
  font-size: 20px; font-weight: 800; color: #fff;
  letter-spacing: -.4px; line-height: 1.3; margin-bottom: 10px;
}
.kf-announce-body {
  font-size: 13.5px; color: rgba(255,255,255,.72);
  line-height: 1.65;
}

/* ── Announce carousel (col 1, rowspan 2) ── */
.kf-carousel {
  grid-column: 1/2; grid-row: 1/3;
  position: relative; overflow: hidden; padding: 0;
  min-height: 260px; border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,87,255,.25);
}
.kf-slides { position: absolute; inset: 0; }
.kf-slide {
  position: absolute; inset: 0; opacity: 0;
  transition: opacity .6s ease;
  background: #0057FF;
  background-size: cover; background-position: center;
  display: flex; align-items: flex-end;
}
.kf-slide.active { opacity: 1; }
.kf-slide-ph {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  color: rgba(255,255,255,.5); font-size: 13px; font-weight: 600; letter-spacing: 1px;
}
.kf-slide-overlay {
  position: relative; z-index: 1; width: 100%; padding: 24px;
  background: linear-gradient(to top, rgba(0,12,40,.82) 0%, rgba(0,12,40,.32) 55%, transparent 100%);
}
.kf-dots { position: absolute; bottom: 14px; right: 20px; z-index: 2; display: flex; gap: 6px; }
.kf-dot {
  width: 7px; height: 7px; border-radius: 50%; border: none; padding: 0;
  background: rgba(255,255,255,.4); cursor: pointer;
  transition: background .2s, width .2s;
}
.kf-dot.active { background: #fff; width: 18px; border-radius: 99px; }

/* ── Rules tile (col 2, row 1) ── */
.kf-rules {
  grid-column: 2/3; grid-row: 1/2;
  background: var(--surface);
  border: 0.5px solid var(--border);
}
.kf-rule-list { display: flex; flex-direction: column; gap: 10px; }
.kf-rule-item {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; color: var(--text-2); line-height: 1.5;
}
.kf-rule-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--blue); flex-shrink: 0; margin-top: 5px;
}

/* ── Stats tile (col 3, rowspan 2) ── */
.kf-stats {
  grid-column: 3/4; grid-row: 1/3;
  background: var(--surface);
  border: 0.5px solid var(--border);
  display: flex; flex-direction: column;
}
.kf-stats-list { display: flex; flex-direction: column; gap: 14px; margin-top: 2px; }
.kf-stat-row { display: flex; flex-direction: column; }
.kf-stat-num {
  font-family: 'Montserrat','Noto Sans TC',sans-serif;
  font-size: 30px; font-weight: 800; color: var(--blue);
  letter-spacing: -1px; line-height: 1.05;
}
.kf-stat-lbl { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ── News tile (col 2, row 2) ── */
.kf-news {
  grid-column: 2/3; grid-row: 2/3;
  background: #F4F1EC;
  border: 0.5px solid rgba(0,0,0,.06);
}
.kf-news-list { display: flex; flex-direction: column; gap: 12px; }
.kf-news-item {
  display: flex; align-items: flex-start; gap: 10px;
}
.kf-news-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3); flex-shrink: 0; margin-top: 5px;
}
.kf-news-dot.active { background: var(--blue); }
.kf-news-text { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.kf-news-time { font-size: 10px; color: var(--text-3); margin-top: 3px; }

/* ── Upgrade hint (sidebar) ── */
.kf-upgrade-hint {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-3);
  margin-top: 10px; padding: 8px 10px;
  background: var(--bg); border-radius: var(--r-sm);
  border: 0.5px solid var(--border);
}
.kf-upgrade-hint i { font-size: 13px; color: var(--text-3); }

/* ── Main content header ── */
.kf-main {}
.kf-main-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px; gap: 12px;
}
.kf-main-title { font-size: 18px; font-weight: 700; color: var(--text-1); letter-spacing: -.3px; }
.kf-main-count { font-size: 12px; color: var(--text-2); margin-top: 3px; }

/* ── Dark mode ── */
[data-theme="dark"] .kf-rules {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] .kf-tile-label { color: var(--text-3) !important; }
[data-theme="dark"] .kf-rule-item { color: var(--text-3) !important; }
[data-theme="dark"] .kf-news {
  background: #1E2028 !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] .kf-news-text { color: var(--text-3) !important; }
[data-theme="dark"] .kf-stats { background: var(--surface) !important; border-color: var(--border) !important; }
[data-theme="dark"] .kf-stat-lbl { color: var(--text-3) !important; }
[data-theme="dark"] .kf-announce-body { color: rgba(255,255,255,.72) !important; }
[data-theme="dark"] .kf-main-title { color: #F0F1F3 !important; }
[data-theme="dark"] .kf-upgrade-hint { background: rgba(255,255,255,.04) !important; border-color: var(--border) !important; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .kf-bento-wrap { padding: 20px 20px 0; }
  .kf-bento { grid-template-columns: 1fr 1fr; grid-template-rows: auto; }
  .kf-carousel { grid-column: 1/3; grid-row: 1/2; min-height: 200px; }
  .kf-rules   { grid-column: 1/2; grid-row: 2/3; }
  .kf-stats   { grid-column: 2/3; grid-row: 2/3; }
  .kf-news    { grid-column: 1/3; grid-row: 3/4; }
}
@media (max-width: 560px) {
  .kf-bento { grid-template-columns: 1fr; }
  .kf-carousel,.kf-rules,.kf-stats,.kf-news { grid-column: 1/2; grid-row: auto; }
}

/* ── Page shell ── */
.klas-page-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  align-items: start;
  gap: 20px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 66px 40px 66px; /* top == header對下(kf-bento-wrap 66) == footer對上 */
  box-sizing: border-box;
  align-items: start;
}

/* ── Sidebar ── */
.klas-sidebar {
  align-self: start;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  padding: 20px 14px;
}
.klas-sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 0.5px solid var(--border); }
.klas-sidebar-avatar { width: 38px; height: 38px; border-radius: 50%; background: #9DA3AE; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex-shrink: 0; }
.klas-sidebar-avatar.freebie { background: #9DA3AE; }
.klas-sidebar-avatar.pro     { background: #0057FF; }
.klas-sidebar-avatar.advance { background: #7C3AED; }
.klas-sidebar-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.klas-sidebar-tier { font-size: 11px; color: #9DA3AE; font-weight: 600; margin-top: 1px; }
.klas-sidebar-tier.freebie { color: #9DA3AE; }
.klas-sidebar-tier.pro     { color: #0057FF; }
.klas-sidebar-tier.advance { color: #7C3AED; }
.klas-sidebar-label { font-size: 10px; font-weight: 600; color: var(--text-3); letter-spacing: .7px; text-transform: uppercase; margin-bottom: 6px; padding: 0 6px; }
.klas-sidebar-section { margin-bottom: 18px; }
.klas-sidebar-btn { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; color: var(--text-1); cursor: pointer; border: none; background: transparent; width: 100%; text-align: left; transition: background .15s; }
.klas-sidebar-btn:hover { background: var(--bg); }
.klas-sidebar-btn.active { background: var(--blue-light); color: var(--blue); }
.klas-new-post-btn { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; padding: 10px; border-radius: var(--r-sm); background: var(--blue); color: #fff; font-size: 13px; font-weight: 600; border: none; cursor: pointer; margin-top: 4px; transition: background .15s; text-decoration: none; }
.klas-new-post-btn:hover { background: #0047D9; color: #fff; }

/* ── Sort bar ── */
.kf-sort-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.kf-sort-label {
  font-size: 12px; color: var(--text-3); white-space: nowrap;
}
.kf-sort-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.kf-sort-chip {
  font-size: 11px; font-weight: 500;
  padding: 4px 11px; border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg); color: var(--text-2);
  text-decoration: none; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.kf-sort-chip:hover { background: var(--blue-light); color: var(--blue); border-color: var(--blue); }
.kf-sort-chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Toolbar: sort icons + view toggle ── */
.kf-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.kf-sort-icons, .kf-view-toggle { display: inline-flex; gap: 2px; background: var(--bg); border: 0.5px solid var(--border); border-radius: 999px; padding: 3px; }
.kf-sort-ico, .kf-view-btn {
  width: 32px; height: 32px; border-radius: 999px; border: none; background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-3); cursor: pointer; text-decoration: none; transition: background .15s, color .15s;
}
.kf-sort-ico svg, .kf-view-btn svg { width: 16px; height: 16px; }
.kf-sort-ico:hover, .kf-view-btn:hover { color: var(--text-1); }
.kf-sort-ico.active, .kf-view-btn.active { background: var(--blue); color: #fff; }
[data-theme="dark"] .kf-sort-icons, [data-theme="dark"] .kf-view-toggle { background: var(--surface) !important; border-color: var(--border) !important; }
[data-theme="dark"] .kf-sort-ico.active, [data-theme="dark"] .kf-view-btn.active { background: var(--blue) !important; color: #fff !important; }

/* ── List view ── */
.klas-cards-grid.kf-list { grid-template-columns: 1fr; gap: 8px; }
.kf-list .klas-card {
  flex-direction: row; flex-wrap: wrap; align-items: center;
  height: auto; min-height: 0; padding: 14px 18px; gap: 4px 18px;
}
.kf-list .klas-card-top { width: auto; margin-bottom: 0; min-height: 0; order: 1; flex-shrink: 0; }
.kf-list .klas-card-title { flex: 1 1 260px; margin-bottom: 0; -webkit-line-clamp: 1; order: 2; }
.kf-list .klas-card-excerpt { display: none; }
.kf-list .klas-card-divider { display: none; }
.kf-list .klas-card-footer { width: auto; order: 3; flex-shrink: 0; }
@media (max-width: 600px){ .kf-list .klas-card-title { flex-basis: 100%; -webkit-line-clamp: 2; } }

/* ── Category filter chips (instant client-side filter) ── */
.kf-filter-bar {
  display: flex; gap: 7px; flex-wrap: wrap;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 0.5px solid var(--border);
}
.kf-filter-chip {
  font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s, transform .12s;
}
.kf-filter-chip:hover { border-color: var(--blue); color: var(--blue); }
.kf-filter-chip:active { transform: scale(.96); }
.kf-filter-chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }
[data-theme="dark"] .kf-filter-chip { background: var(--surface) !important; border-color: var(--border) !important; color: var(--text-3) !important; }
[data-theme="dark"] .kf-filter-chip.active { background: var(--blue) !important; color: #fff !important; }

/* ── Sidebar 熱門標籤 cloud ── */
.kf-tagcloud { display: flex; flex-wrap: wrap; gap: 6px; }
.kf-tagcloud-item {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500;
  padding: 4px 9px; border-radius: var(--r-sm);
  border: 0.5px solid var(--border); background: var(--bg); color: var(--text-2);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.kf-tagcloud-item:hover { border-color: var(--blue); color: var(--blue); }
.kf-tagcloud-n { font-size: 10px; color: var(--text-3); }
.kf-tagcloud-item:hover .kf-tagcloud-n { color: var(--blue); }
[data-theme="dark"] .kf-tagcloud-item { background: rgba(255,255,255,.04) !important; border-color: var(--border) !important; }

/* ── Topic cards — fixed 172px, 3-col ── */
.klas-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.klas-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  padding: 16px 16px 13px;
  height: auto; min-height: 196px;
  min-width: 0; /* 防止 nb（nowrap）長句撐大 grid track 令卡片溢出去側欄 */
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
  transition: box-shadow .2s, border-color .2s;
  will-change: box-shadow;
}
.klas-card:hover { border-color: rgba(0,87,255,.25); box-shadow: var(--shadow-hover); }
.klas-card-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px; min-height: 22px; overflow: hidden;
}
.klas-author-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.klas-avatar { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }
/* .av-* removed — replaced by .havatar.freebie/.pro/.advance (DS 1.0) */
.klas-author-name { font-size: 11px; font-weight: 500; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.klas-badge { font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: var(--r-pill); white-space: nowrap; flex-shrink: 0; line-height: 1.6; }
/* Tier colours — FREEBIE 灰 · PRO KLAS 藍 · ADVANCED KLAS 紫 */
.badge-pro  { color: #0057FF; border: 1px solid #0057FF; }
.badge-adv  { color: #7C3AED; border: 1px solid #7C3AED; }
.badge-free { color: #9DA3AE; border: 1px solid #9DA3AE; }
/* Title fills remaining space, 2-line clamp */
.klas-card-title {
  font-size: 13.5px; font-weight: 700; color: var(--text-1);
  line-height: 1.42; letter-spacing: -.1px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 6px; min-width: 0;
}
.klas-card:hover .klas-card-title { color: var(--blue); }
.klas-card-excerpt {
  font-size: 11.5px; line-height: 1.55; color: var(--text-3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; flex: 1; min-width: 0;
}
.klas-card-divider { height: 0.5px; background: var(--border); margin: 10px 0 8px; flex-shrink: 0; }
.klas-meta-group { display: flex; align-items: center; gap: 11px; }
/* Footer row: tag left · meta right */
.klas-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-shrink: 0;
}
.klas-tag { font-size: 10px; font-weight: 500; padding: 1px 7px; border-radius: var(--r-pill); background: var(--bg); color: var(--text-2); border: 0.5px solid var(--border); white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; text-transform: none; }
.klas-meta-item { font-size: 10px; color: var(--text-3); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.klas-meta-item svg { width: 13px; height: 13px; flex-shrink: 0; }
.klas-share-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--text-3); line-height: 1; transition: color .15s;
  margin-left: 2px;
}
.klas-share-btn:hover { color: var(--blue); }
.klas-share-btn svg { width: 13px; height: 13px; }

/* Pagination info — hidden */
.kf-pagi-info { display: none; }
.kf-pagi-btns { display: flex; gap: 4px; }

/* ── Pagination ── */
.klas-pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 0 0; }
.klas-page-btn { min-width: 26px; height: 26px; padding: 0 4px; border-radius: 6px; border: none; background: transparent; font-size: 12px; font-weight: 500; color: var(--text-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: color .15s, background .15s; text-decoration: none; }
.klas-page-btn:hover:not(.disabled) { color: var(--blue); }
.klas-page-btn.current { background: transparent; color: var(--text-1); font-weight: 800; }
.klas-page-btn.disabled { opacity: 0.3; cursor: default; pointer-events: none; }
.klas-page-btn i { font-size: 15px; color: inherit; }
[data-theme="dark"] .klas-page-btn.current { color: #F4F6FA; }

/* ── Freebie dialog ── */
.klas-dialog-overlay {
  display: flex;
  visibility: hidden;
  opacity: 0;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 9999;
  align-items: center; justify-content: center;
  transition: opacity .2s ease, visibility .2s ease;
}
.klas-dialog-overlay.open {
  visibility: visible;
  opacity: 1;
}
.klas-dialog-box {
  background: var(--surface); border-radius: 16px; padding: 32px 28px;
  max-width: 400px; width: 90%; text-align: center;
  transform: translateY(12px) scale(.97);
  transition: transform .22s cubic-bezier(.34,1.56,.64,1);
  will-change: transform;
}
.klas-dialog-overlay.open .klas-dialog-box {
  transform: translateY(0) scale(1);
}
.klas-dialog-icon { font-size: 36px; color: var(--blue); margin-bottom: 12px; }
.klas-dialog-title { font-size: 18px; font-weight: 700; color: var(--text-1); margin-bottom: 8px; }
.klas-dialog-desc { font-size: 14px; color: var(--text-2); line-height: 1.6; margin-bottom: 24px; }
.klas-dialog-upgrade { display: block; width: 100%; box-sizing: border-box; padding: 11px; background: var(--blue); color: #fff; border: none; border-radius: var(--r-sm); font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: 10px; text-decoration: none; text-align: center; }
.klas-dialog-upgrade:hover { background: #0047D9; }
.klas-dialog-cancel { display: block; width: 100%; padding: 10px; background: none; border: 0.5px solid var(--border); border-radius: var(--r-sm); font-size: 14px; color: var(--text-2); cursor: pointer; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .klas-page-shell { grid-template-columns: 1fr; padding: 16px 20px 32px; }
  .klas-sidebar { position: static; }
  .klas-bento { grid-template-columns: 1fr 1fr; }
  .klas-tile-announce { grid-column: 1/3; }
  .klas-tile-notice { grid-column: 1/2; }
  .klas-tile-news { grid-column: 2/3; }
  .klas-tile-online { grid-column: 1/3; min-height: auto; }
  .klas-cards-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .klas-bento { grid-template-columns: 1fr; }
  .klas-tile-announce, .klas-tile-notice, .klas-tile-news, .klas-tile-online { grid-column: 1/2; }
  .klas-cards-grid { grid-template-columns: 1fr; }
  .klas-card { height: auto; min-height: 148px; }
}
/* ── Dark mode forum overrides ── */
[data-theme="dark"] .klas-tile-news { background: #1E2028 !important; border-color: #2A2D35 !important; }
[data-theme="dark"] .klas-tile-online { background: #1E2028 !important; border: 0.5px solid #3A3F50 !important; }
[data-theme="dark"] .klas-sidebar-btn.active { background: rgba(96,179,255,0.12) !important; color: #60B3FF !important; }
[data-theme="dark"] .news-time { color: #9DA3AE !important; }
[data-theme="dark"] .klas-sidebar-label { color: #9DA3AE !important; }
[data-theme="dark"] .klas-sidebar { background: #1A1D24 !important; border-color: #2A2D35 !important; }
[data-theme="dark"] .klas-card { background: #1A1D24 !important; border-color: #2A2D35 !important; }
[data-theme="dark"] .klas-card:hover { border-color: rgba(96,179,255,0.25) !important; }
[data-theme="dark"] .kf-sort-chip { background: var(--surface) !important; border-color: var(--border) !important; color: var(--text-3) !important; }
[data-theme="dark"] .kf-sort-chip.active { background: var(--blue) !important; color: #fff !important; }
[data-theme="dark"] .klas-tag { background: rgba(255,255,255,.04) !important; border-color: var(--border) !important; }

/* ── Force white text on CTA (override style.css a { color: var(--klas-blue) !important }) ── */
html body .klas-sidebar a.klas-new-post-btn,
html body .klas-sidebar a.klas-new-post-btn:link,
html body .klas-sidebar a.klas-new-post-btn:visited,
html body .klas-sidebar a.klas-new-post-btn:hover,
html body .klas-sidebar a.klas-new-post-btn:focus,
html body button.klas-new-post-btn {
  color: #ffffff !important;
}
/* ════════════════════════════════════════════════════════════
   Community 2026-07 重設計（kf2-）· v1.7.0
   細 hero + 公告條 + 主內容行先 + 右側欄；零值隱藏
   ════════════════════════════════════════════════════════════ */
.kf2-wrap, .kf2-wrap * { box-sizing: border-box; } /* bbPress 頁無全域 reset，必須顯式 */
.kf2-wrap { max-width: 1160px; margin: 0 auto; padding: 56px 40px 0; }

/* 細 hero：影片 banner（同免費教學頁一致嘅視覺語言）*/
.kf2-hero-vid { position: relative; overflow: hidden; border-radius: 20px; margin-bottom: 24px; min-height: 280px; display: flex; align-items: center; background: #0A0B0F; }
.kf2-hero-vid-el { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.kf2-hero-vid-scrim { position: absolute; inset: 0; background: linear-gradient(115deg, rgba(8,10,14,.72) 0%, rgba(8,10,14,.48) 45%, rgba(8,10,14,.30) 100%); }
@media (max-width: 640px) { .kf2-hero-vid { min-height: 0; } }
.kf2-top { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 48px 44px; flex-wrap: wrap; width: 100%; }
.kf2-h1 { font-family: 'Montserrat','Noto Sans TC',sans-serif; font-weight: 900; font-size: clamp(26px, 3.5vw, 34px); letter-spacing: -.6px; color: #fff; margin: 0; }
.kf2-sub { font-size: 16px; line-height: 1.6; color: rgba(255,255,255,.86); margin: 8px 0 0; }
.kf2-cta {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--blue); color: #fff !important; border: 0; cursor: pointer;
  font-family: inherit; font-size: 16px; font-weight: 700;
  padding: 12px 24px; border-radius: 999px; text-decoration: none !important;
  transition: background .2s, transform .15s; white-space: nowrap;
}
.kf2-cta:hover { background: var(--klas-blue-700, #0046D6); }
.kf2-cta:active { transform: scale(.98); }
.kf2-cta svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* 公告條 */
.kf2-announce {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 24px;
}
.kf2-announce-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
  background: var(--klas-blue-50, #EEF3FF); color: var(--blue);
}
.kf2-announce-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kf2-announce-txt { margin: 0; font-size: 16px; line-height: 1.6; color: var(--text-1); min-width: 0; }
.kf2-announce-txt b { font-weight: 700; }
.kf2-announce-body { color: var(--text-3); margin-left: 10px; }
.kf2-announce-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin: -10px -8px -10px auto; flex: 0 0 auto;
  background: none; border: 0; cursor: pointer; color: var(--text-3); border-radius: 10px;
}
.kf2-announce-x:hover { color: var(--text-1); background: var(--bg); }
.kf2-announce-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* 主內容 + 側欄 */
.kf2-shell { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 28px; align-items: start; padding-bottom: 56px; }
.kf2-main { min-width: 0; }
.kf2-side { display: flex; flex-direction: column; gap: 16px; }

.kf2-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; }
.kf2-card-t { font-size: 15px; font-weight: 700; color: var(--text-1); margin-bottom: 12px; }

.kf2-user { display: flex; align-items: center; gap: 12px; }
.kf2-user-info { min-width: 0; }
.kf2-user-name { font-size: 15px; font-weight: 700; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kf2-user-link { margin-left: auto; font-size: 14px; font-weight: 600; color: var(--blue) !important; text-decoration: none !important; white-space: nowrap; }
.kf2-user-link:hover { color: var(--klas-blue-700, #0046D6) !important; }

.kf2-rules { list-style: none; margin: 0; padding: 0; }
.kf2-rules li { position: relative; padding-left: 16px; font-size: 14.5px; line-height: 1.65; color: var(--text-3); }
.kf2-rules li + li { margin-top: 10px; }
.kf2-rules li::before { content: ''; position: absolute; left: 0; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--klas-blue-300, #7EA8FF); }

.kf2-stats { display: flex; flex-direction: column; gap: 12px; }
.kf2-stat { display: flex; align-items: baseline; gap: 10px; }
.kf2-stat b { font-family: 'Montserrat','Noto Sans TC',sans-serif; font-weight: 800; font-size: 20px; color: var(--text-1); }
.kf2-stat span { font-size: 14px; color: var(--text-3); }

/* sort pill 加文字（覆蓋原 icon-only 32px 定闊） */
.kf-sort-ico { width: auto !important; height: 32px; padding: 0 14px !important; white-space: nowrap; }
.kf-sort-txt { font-size: 13.5px; font-weight: 600; margin-left: 6px; }

/* filter「更多標籤」 */
.kf-chip-toggle { border-style: dashed !important; color: var(--text-3) !important; }
.kf-chip-toggle:hover { color: var(--blue) !important; }

/* 卡片 footer chips + 官方 badge + 相關課節 */
.klas-card-chips { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.klas-badge.badge-official { background: var(--blue); color: #fff; }
.klas-tag.klas-tag-lesson {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  background: var(--klas-blue-50, #EEF3FF); color: var(--blue);
}
.klas-tag.klas-tag-lesson:hover { background: var(--klas-blue-100, #D4E2FF); }
.klas-tag.klas-tag-lesson svg { width: 11px; height: 11px; }

/* 響應式 */
@media (max-width: 960px) {
  .kf2-shell { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kf2-wrap { padding: 40px 20px 0; }
  .kf2-hero-vid { margin-bottom: 20px; }
  .kf2-top { padding: 32px 24px; flex-direction: column; align-items: stretch; }
  .kf2-cta { justify-content: center; }
  .kf2-announce-body { display: block; margin: 4px 0 0; }
  .kf2-shell { padding-bottom: 40px; }
}

/* dark mode */
[data-theme="dark"] .kf2-card,
[data-theme="dark"] .kf2-announce { background: var(--surface) !important; border-color: var(--border) !important; }
[data-theme="dark"] .kf2-announce-ic { background: rgba(106,168,255,.14); color: #6AA8FF; }
[data-theme="dark"] .kf2-rules li::before { background: #6AA8FF; }
[data-theme="dark"] .klas-tag.klas-tag-lesson { background: rgba(106,168,255,.14); color: #6AA8FF; }

/* ════════════════════════════════════════════════════════════
   帖文卡片 + 列表視圖修正 · v1.7.2
   字級跟無障礙規則（正文≥16 / 輔助≥14），標題 2 行、摘要 3 行 + …
   ════════════════════════════════════════════════════════════ */
/* ── 卡片 grid：2 欄大卡（標題永遠佔 2 行位、摘要永遠佔 3 行位，短內容留白 → 卡片視覺統一）── */
.klas-cards-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 16px; }
.klas-card { padding: 24px 26px 18px; border-radius: 16px; min-height: 0; }
.klas-card-top { gap: 12px; margin-bottom: 16px; }
.klas-author-row { gap: 10px; }
.klas-avatar { width: 28px; height: 28px; font-size: 12px; color: #fff; background: #9DA3AE; }
.klas-avatar.freebie { background: #9DA3AE; } /* FREEBIE 灰底白字 */
.klas-avatar.pro     { background: #0057FF; } /* PRO 藍底白字 */
.klas-avatar.advance { background: #7C3AED; } /* ADVANCED 紫底白字 */
.klas-author-name { font-size: 14px; }
.klas-card-title {
  font-size: 16px; line-height: 1.5; letter-spacing: -.15px;
  -webkit-line-clamp: 2; min-height: 3em; margin-bottom: 10px; /* 3em = 2 行固定預留 */
}
.klas-card-excerpt {
  font-size: 14px; line-height: 1.6;
  -webkit-line-clamp: 3; min-height: 4.8em; flex: none; /* 4.8em = 3 行固定預留 */
}
.klas-card-divider { margin: 18px 0 13px; }
.klas-badge { font-size: 11px; padding: 2px 9px; }
.klas-tag { font-size: 11px; padding: 2px 9px; max-width: 130px; }
.klas-meta-item { font-size: 13px; gap: 5px; }
.klas-meta-item svg { width: 14px; height: 14px; }
.klas-share-btn svg { width: 14px; height: 14px; }

/* ── 列表 row：作者欄定闊，標題全部對齊 ── */
.kf-list .klas-card { padding: 14px 20px; gap: 12px 16px; }
.kf-list .klas-card-top { width: 168px; flex: 0 0 168px; gap: 8px; justify-content: flex-start; }
.kf-list .klas-author-row { flex: 1 1 auto; min-width: 0; }
.kf-list .klas-card-title { font-size: 15px; min-height: 0; -webkit-line-clamp: 1; }
.kf-list .klas-card-excerpt { display: none; min-height: 0; }

/* ── 響應式 ── */
@media (max-width: 960px) {
  .klas-cards-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 640px) {
  .klas-cards-grid { grid-template-columns: 1fr !important; }
  /* 手機都保留 2 行／3 行預留，維持卡片視覺統一 */
  .klas-card { padding: 20px 20px 15px; }
}
/* dark mode：ADVANCED 紫加亮，確保同藍色明顯區分 */
[data-theme="dark"] .badge-adv { color: #B48CFF; border-color: #B48CFF; }
[data-theme="dark"] .klas-sidebar-tier.advance { color: #B48CFF; }

@media (max-width: 600px) {
  .kf-list .klas-card-top { width: auto; flex: 0 0 auto; }
  .kf-list .klas-card-top .klas-author-name { display: none; }
  .kf-list .klas-card-title { flex-basis: 100%; -webkit-line-clamp: 2; min-height: 0; }
}

/* ════════════════════════════════════════════════════════════
   單一主 CTA 規則 · v1.7.5
   每頁只有一個實心主藍 button（社群頁 = 發起討論 .kf2-cta）；
   其餘次要／active 一律淺藍底藍字
   ════════════════════════════════════════════════════════════ */
.kf-sort-ico.active, .kf-view-btn.active { background: #EEF3FF !important; color: #0057FF !important; }
.kf-filter-chip.active { background: #EEF3FF !important; color: #0057FF !important; border-color: #C7D7FF !important; }
.klas-badge.badge-official { background: #EEF3FF; color: #0057FF; border: 1px solid transparent; }
[data-theme="dark"] .kf-sort-ico.active, [data-theme="dark"] .kf-view-btn.active { background: rgba(106,168,255,.16) !important; color: #6AA8FF !important; }
[data-theme="dark"] .kf-filter-chip.active { background: rgba(106,168,255,.16) !important; color: #6AA8FF !important; border-color: rgba(106,168,255,.35) !important; }
[data-theme="dark"] .klas-badge.badge-official { background: rgba(106,168,255,.16); color: #6AA8FF; }

/* ════════════════════════════════════════════════════════════
   帖文頁（kt-）· v1.7.6 — KLAS 風格 single topic
   ════════════════════════════════════════════════════════════ */
.kt-wrap, .kt-wrap * { box-sizing: border-box; }
.kt-wrap { max-width: 860px; margin: 0 auto; padding: 56px 40px; }
.kt-wrap svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* breadcrumb */
.kt-bc { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--text-3); flex-wrap: wrap; margin-bottom: 22px; }
.kt-bc a { display: inline-flex; align-items: center; gap: 5px; color: var(--text-3) !important; text-decoration: none !important; }
.kt-bc a:hover { color: var(--blue) !important; }
.kt-bc svg { width: 14px; height: 14px; }
.kt-bc .sep { opacity: .6; }
.kt-bc .cur { color: var(--text-1); font-weight: 600; max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 主帖卡 */
.kt-topic { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px 32px; }
.kt-author { display: flex; align-items: center; gap: 12px; }
.kt-author .klas-avatar { width: 40px; height: 40px; font-size: 15px; }
.kt-author-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kt-author-name { font-size: 15px; font-weight: 700; color: var(--text-1); display: inline-flex; align-items: center; gap: 8px; }
.kt-author-time { font-size: 14px; color: var(--text-3); }
.kt-title { font-family: 'Montserrat','Noto Sans TC',sans-serif; font-weight: 800; font-size: clamp(22px,3vw,28px); line-height: 1.4; letter-spacing: -.4px; color: var(--text-1); margin: 18px 0 0; }
.kt-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.kt-content { font-size: 16px; line-height: 1.8; color: var(--text-2); margin-top: 18px; }
.kt-content p { margin: 0 0 14px; }
.kt-content p:last-child { margin-bottom: 0; }
.kt-content a { color: var(--blue); font-weight: 600; }
.kt-content img { max-width: 100%; height: auto; border-radius: 12px; }
.kt-content code { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 14px; }
.kt-content blockquote { border-left: 3px solid var(--klas-blue-200,#C7D7FF); margin: 0 0 14px; padding: 4px 0 4px 16px; color: var(--text-3); }
.kt-content ul, .kt-content ol { padding-left: 22px; margin: 0 0 14px; }

/* 回覆區 */
.kt-replies { margin-top: 40px; }
.kt-sec-t { font-family: inherit; font-weight: 400; font-size: 18px; letter-spacing: -.2px; color: var(--text-1); margin: 0 0 16px; }
.kt-reply-list { display: flex; flex-direction: column; gap: 12px; }
.kt-reply { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px 24px; }
.kt-reply .klas-avatar { width: 34px; height: 34px; font-size: 13px; }
.kt-reply-body { font-size: 16px; line-height: 1.75; color: var(--text-2); margin-top: 12px; }
.kt-reply-body p { margin: 0 0 12px; }
.kt-reply-body p:last-child { margin-bottom: 0; }
.kt-empty { background: var(--surface); border: 1px dashed var(--border); border-radius: 14px; padding: 36px 24px; text-align: center; color: var(--text-3); }
.kt-empty svg { width: 28px; height: 28px; margin-bottom: 10px; color: var(--klas-blue-300,#7EA8FF); }
.kt-empty p { margin: 0; font-size: 15px; }
.kt-pagi { margin-top: 16px; text-align: center; }

/* 回覆表單（reskin bbPress form-reply） */
.kt-form-sec { margin-top: 40px; }
.kt-form .bbp-form legend, .kt-form .bbp-template-notice.info { display: none; }
.kt-form fieldset.bbp-form { border: 0; padding: 0; margin: 0; }
.kt-form .bbp-the-content-wrapper { margin-bottom: 14px; }
.kt-form #qt_bbp_reply_content_toolbar { background: var(--bg); border: 1px solid var(--border); border-bottom: 0; border-radius: 12px 12px 0 0; padding: 6px 8px; }
.kt-form #qt_bbp_reply_content_toolbar .ed_button { background: transparent; border: 0; border-radius: 6px; color: var(--text-2); font-size: 12px; padding: 4px 8px; cursor: pointer; }
.kt-form #qt_bbp_reply_content_toolbar .ed_button:hover { background: var(--surface); color: var(--text-1); }
.kt-form textarea#bbp_reply_content { width: 100%; min-height: 160px; background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 12px 12px; padding: 14px 16px; font-family: inherit; font-size: 16px; line-height: 1.7; color: var(--text-1); resize: vertical; }
.kt-form textarea#bbp_reply_content:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,87,255,.12); }
.kt-form label[for="bbp_topic_tags"] { display: block; font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 6px; }
.kt-form #bbp_topic_tags { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 15px; color: var(--text-1); }
.kt-form #bbp_topic_tags:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,87,255,.12); }
.kt-form .bbp-form-subscription { margin-top: 12px; font-size: 14px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.kt-form .bbp-submit-wrapper { margin-top: 18px; }
.kt-form button#bbp_reply_submit {
  background: var(--blue); color: #fff !important; border: 0; cursor: pointer;
  font-family: inherit; font-size: 16px; font-weight: 700;
  padding: 12px 28px; border-radius: 999px; transition: background .2s, transform .15s;
}
.kt-form button#bbp_reply_submit:hover { background: var(--klas-blue-700,#0046D6); }
.kt-form button#bbp_reply_submit:active { transform: scale(.98); }

/* 權限/登入 gate */
.kt-gate { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 24px; text-align: center; }
.kt-gate svg { width: 24px; height: 24px; color: var(--text-3); margin-bottom: 8px; }
.kt-gate p { margin: 0 0 14px; font-size: 15px; line-height: 1.7; color: var(--text-2); }
.kt-gate p:last-child { margin-bottom: 0; }
.kt-gate-btn { display: inline-flex; align-items: center; background: var(--blue); color: #fff !important; text-decoration: none !important; font-size: 15px; font-weight: 700; padding: 10px 24px; border-radius: 999px; transition: background .2s; }
.kt-gate-btn:hover { background: var(--klas-blue-700,#0046D6); }

/* 返回社群 */
.kt-back { display: inline-flex; align-items: center; gap: 6px; margin-top: 32px; font-size: 15px; font-weight: 600; color: var(--text-2) !important; text-decoration: none !important; }
.kt-back:hover { color: var(--blue) !important; }
.kt-back svg { width: 15px; height: 15px; }

/* 隱藏 bbPress 原生雜項（admin links / favorite / subscribe / tag meta） */
body.bbp-is-single-topic .bbp-topic-tags,
body.bbp-is-single-topic #subscription-toggle,
body.bbp-is-single-topic #favorite-toggle,
body.bbp-is-single-topic .bbp-admin-links { display: none !important; }

/* 響應式 */
@media (max-width: 640px) {
  .kt-wrap { padding: 40px 20px; }
  .kt-topic { padding: 22px 20px; }
  .kt-reply { padding: 18px 16px; }
  .kt-bc .cur { max-width: 180px; }
}

/* dark mode */
[data-theme="dark"] .kt-topic, [data-theme="dark"] .kt-reply,
[data-theme="dark"] .kt-gate, [data-theme="dark"] .kt-empty,
[data-theme="dark"] .kt-form textarea#bbp_reply_content,
[data-theme="dark"] .kt-form #bbp_topic_tags { background: var(--surface) !important; border-color: var(--border) !important; }
