/* ═══════════════════════════════════════════════════════════════════════════
   Pro-Max Shared Stylesheet — aiknow.org.cn
   AIHOT-inspired Dark Theme · AI-curated content platform
   
   Layers: tokens → reset → base → layout → components → polish → compat
   Default: Dark (AIHOT style). Light: [data-theme="light"]
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═════════════════════════════════════════════════════════════════════════
   LAYER 1 — TOKENS (AIHOT Dark Palette)
   ═════════════════════════════════════════════════════════════════════════ */
@layer tokens {
  :root {
    color-scheme: dark;

    /* ── Surface (AIHOT dark) ── */
    --pm-surface-page:         #0a0a0f;
    --pm-surface-container:    #111118;
    --pm-surface-elevated:     #181825;
    --pm-surface-overlay:      rgba(255, 255, 255, 0.03);
    --pm-surface-glass:        rgba(17, 17, 24, 0.85);
    --pm-surface-glass-border: rgba(255, 255, 255, 0.06);

    /* ── Text ── */
    --pm-text-primary:         #e4e4ec;
    --pm-text-secondary:       #a0a0b8;
    --pm-text-muted:           #666680;
    --pm-text-inverse:         #0a0a0f;
    --pm-text-link:            #7b9fff;

    /* ── Accent (AIHOT blue-purple) ── */
    --pm-accent:               #6c8cff;
    --pm-accent-hover:         #8aa4ff;
    --pm-accent-active:        #5678ee;
    --pm-accent-subtle:        rgba(108, 140, 255, 0.10);
    --pm-accent-glow:          rgba(108, 140, 255, 0.25);

    /* ── Score colors (AIHOT 精选 badges) ── */
    --pm-score-high:           #22c55e;
    --pm-score-mid:            #eab308;
    --pm-score-low:            #94a3b8;

    /* ── Semantic ── */
    --pm-success:              #22c55e;
    --pm-warning:              #eab308;
    --pm-error:                #ef4444;
    --pm-info:                 #38bdf8;

    /* ── Borders ── */
    --pm-border-thin:          1px solid rgba(255, 255, 255, 0.06);
    --pm-border-medium:        1px solid rgba(255, 255, 255, 0.10);
    --pm-border-accent:        1px solid rgba(108, 140, 255, 0.30);
    --pm-border-focus:         2px solid #6c8cff;

    /* ── Shadows (dark) ── */
    --pm-shadow-sm:            0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --pm-shadow-md:            0 4px 12px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.25);
    --pm-shadow-lg:            0 12px 32px rgba(0,0,0,0.45), 0 4px 8px rgba(0,0,0,0.3);
    --pm-shadow-xl:            0 20px 48px rgba(0,0,0,0.55), 0 6px 12px rgba(0,0,0,0.35);
    --pm-shadow-glow:          0 0 0 3px var(--pm-accent-glow);

    /* ── Radii ── */
    --pm-radius-sm:            0.375rem;
    --pm-radius-md:            0.5rem;
    --pm-radius-lg:            0.75rem;
    --pm-radius-xl:            1rem;
    --pm-radius-full:          9999px;

    /* ── Spacing ── */
    --pm-space-1: 0.25rem; --pm-space-2: 0.5rem; --pm-space-3: 0.75rem;
    --pm-space-4: 1rem; --pm-space-5: 1.25rem; --pm-space-6: 1.5rem;
    --pm-space-8: 2rem; --pm-space-10: 2.5rem; --pm-space-12: 3rem;
    --pm-space-16: 4rem;

    /* ── Typography ── */
    --pm-font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
    --pm-font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Consolas', monospace;
    --pm-text-xs: 0.75rem; --pm-text-sm: 0.875rem; --pm-text-base: 1rem;
    --pm-text-lg: 1.125rem; --pm-text-xl: 1.25rem; --pm-text-2xl: 1.5rem;
    --pm-text-3xl: 1.875rem; --pm-text-4xl: 2.25rem;
    --pm-leading-tight: 1.25; --pm-leading-normal: 1.6; --pm-leading-relaxed: 1.75;
    --pm-font-weight-normal: 400; --pm-font-weight-medium: 500;
    --pm-font-weight-semibold: 600; --pm-font-weight-bold: 700;

    /* ── Transitions ── */
    --pm-transition-fast: 150ms ease;
    --pm-transition-base: 250ms ease;
    --pm-transition-slow: 400ms ease;

    /* ── Z-index ── */
    --pm-z-dropdown: 100; --pm-z-sticky: 200; --pm-z-overlay: 300;
    --pm-z-modal: 400; --pm-z-toast: 500;

    /* ── Layout ── */
    --pm-container-max: 1200px;
    --pm-container-padding: var(--pm-space-6);
    --pm-nav-height: 3.75rem;
  }

  /* Light theme override */
  [data-theme="light"] {
    color-scheme: light;

    --pm-surface-page:         #f8f9fa;
    --pm-surface-container:    #ffffff;
    --pm-surface-elevated:     #ffffff;
    --pm-surface-overlay:      rgba(0, 0, 0, 0.04);
    --pm-surface-glass:        rgba(255, 255, 255, 0.85);
    --pm-surface-glass-border: rgba(255, 255, 255, 0.55);

    --pm-text-primary:         #1a1a2e;
    --pm-text-secondary:       #4a4a6a;
    --pm-text-muted:           #7a7a9a;
    --pm-text-inverse:         #ffffff;
    --pm-text-link:            #2563eb;

    --pm-accent:               #2563eb;
    --pm-accent-hover:         #1d4ed8;
    --pm-accent-active:        #1e40af;
    --pm-accent-subtle:        rgba(37, 99, 235, 0.08);
    --pm-accent-glow:          rgba(37, 99, 235, 0.25);

    --pm-border-thin:          1px solid rgba(0, 0, 0, 0.08);
    --pm-border-medium:        1px solid rgba(0, 0, 0, 0.12);
    --pm-border-accent:        1px solid rgba(37, 99, 235, 0.30);
    --pm-border-focus:         2px solid #2563eb;

    --pm-shadow-sm:            0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --pm-shadow-md:            0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --pm-shadow-lg:            0 12px 32px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.05);
    --pm-shadow-xl:            0 20px 48px rgba(0,0,0,0.14), 0 6px 12px rgba(0,0,0,0.06);
    --pm-shadow-glow:          0 0 0 3px var(--pm-accent-glow);
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   LAYER 2 — RESET
   ═════════════════════════════════════════════════════════════════════════ */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }
  html:focus-within { scroll-behavior: smooth; }
  img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  ul, ol { list-style: none; }
  a { text-decoration: none; color: inherit; }
  button { background: none; border: none; cursor: pointer; padding: 0; }
  table { border-collapse: collapse; border-spacing: 0; }
  textarea { resize: vertical; }
  fieldset { border: none; }
  iframe { border: 0; display: block; }
  html { -webkit-text-size-adjust: 100%; -moz-text-size-adjust: 100%; text-size-adjust: 100%; }
  .sr-only, .pm-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
}

/* ═════════════════════════════════════════════════════════════════════════
   LAYER 3 — BASE
   ═════════════════════════════════════════════════════════════════════════ */
@layer base {
  html {
    font-family: var(--pm-font-sans);
    font-size: 100%;
    line-height: var(--pm-leading-normal);
    color: var(--pm-text-primary);
    background-color: var(--pm-surface-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
  body { min-height: 100vh; display: flex; flex-direction: column; background-color: var(--pm-surface-page); }
  main { flex: 1; }

  h1, h2, h3, h4, h5, h6 { font-weight: var(--pm-font-weight-bold); line-height: var(--pm-leading-tight); color: var(--pm-text-primary); text-wrap: balance; }
  h1 { font-size: var(--pm-text-4xl); letter-spacing: -0.02em; }
  h2 { font-size: var(--pm-text-3xl); letter-spacing: -0.015em; }
  h3 { font-size: var(--pm-text-2xl); }
  h4 { font-size: var(--pm-text-xl); }
  h5 { font-size: var(--pm-text-lg); }
  h6 { font-size: var(--pm-text-base); }

  p { margin-bottom: var(--pm-space-4); color: var(--pm-text-secondary); text-wrap: pretty; }
  p:last-child { margin-bottom: 0; }
  small { font-size: var(--pm-text-sm); color: var(--pm-text-muted); }
  strong, b { font-weight: var(--pm-font-weight-semibold); }

  code, kbd, samp, pre { font-family: var(--pm-font-mono); font-size: 0.9em; }
  code { padding: 0.15em 0.4em; background: var(--pm-surface-overlay); border-radius: var(--pm-radius-sm); color: var(--pm-accent); }
  pre { padding: var(--pm-space-4); background: var(--pm-surface-overlay); border-radius: var(--pm-radius-md); overflow-x: auto; }
  pre code { padding: 0; background: none; border-radius: 0; color: inherit; }

  a:not([class]) { color: var(--pm-text-link); text-decoration: underline; text-underline-offset: 0.15em; text-decoration-thickness: 1px; transition: color var(--pm-transition-fast); }
  a:not([class]):hover { color: var(--pm-accent-hover); }

  hr { border: none; height: 1px; background: var(--pm-border-thin); margin: var(--pm-space-8) 0; }
  ::selection { background: var(--pm-accent-subtle); color: var(--pm-text-primary); }
  :focus-visible { outline: var(--pm-border-focus); outline-offset: 2px; border-radius: var(--pm-radius-sm); }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   LAYER 4 — LAYOUT
   ═════════════════════════════════════════════════════════════════════════ */
@layer layout {
  .pm-container { width: 100%; max-width: var(--pm-container-max); margin-left: auto; margin-right: auto; padding-left: var(--pm-container-padding); padding-right: var(--pm-container-padding); }
  .pm-flex { display: flex; } .pm-inline-flex { display: inline-flex; }
  .pm-flex-col { flex-direction: column; } .pm-flex-wrap { flex-wrap: wrap; }
  .pm-items-center { align-items: center; } .pm-items-start { align-items: flex-start; } .pm-items-end { align-items: flex-end; }
  .pm-justify-center { justify-content: center; } .pm-justify-between { justify-content: space-between; } .pm-justify-end { justify-content: flex-end; }
  .pm-gap-2 { gap: var(--pm-space-2); } .pm-gap-4 { gap: var(--pm-space-4); } .pm-gap-6 { gap: var(--pm-space-6); } .pm-gap-8 { gap: var(--pm-space-8); }
  .pm-grid { display: grid; gap: var(--pm-space-6); grid-template-columns: repeat(12, 1fr); }
  .pm-grid-cards { display: grid; gap: var(--pm-space-6); grid-template-columns: repeat(3, 1fr); }
  .pm-grid-cards-2 { display: grid; gap: var(--pm-space-6); grid-template-columns: repeat(2, 1fr); }
  .pm-mt-4 { margin-top: var(--pm-space-4); } .pm-mt-6 { margin-top: var(--pm-space-6); } .pm-mt-8 { margin-top: var(--pm-space-8); }
  .pm-mb-4 { margin-bottom: var(--pm-space-4); } .pm-mb-6 { margin-bottom: var(--pm-space-6); } .pm-mb-8 { margin-bottom: var(--pm-space-8); }
  .pm-my-8 { margin-top: var(--pm-space-8); margin-bottom: var(--pm-space-8); }
  .pm-my-12 { margin-top: var(--pm-space-12); margin-bottom: var(--pm-space-12); }
  .pm-p-4 { padding: var(--pm-space-4); } .pm-p-6 { padding: var(--pm-space-6); } .pm-p-8 { padding: var(--pm-space-8); }
  .pm-px-6 { padding-left: var(--pm-space-6); padding-right: var(--pm-space-6); }
  .pm-py-4 { padding-top: var(--pm-space-4); padding-bottom: var(--pm-space-4); }
  .pm-py-6 { padding-top: var(--pm-space-6); padding-bottom: var(--pm-space-6); }
  .pm-py-8 { padding-top: var(--pm-space-8); padding-bottom: var(--pm-space-8); }
  .pm-section { padding-top: var(--pm-space-16); padding-bottom: var(--pm-space-16); }
  .pm-section-sm { padding-top: var(--pm-space-10); padding-bottom: var(--pm-space-10); }
  .pm-page-content { padding-top: calc(var(--pm-nav-height) + var(--pm-space-6)); }
  .pm-center { margin-left: auto; margin-right: auto; }
  .pm-max-w-sm { max-width: 480px; } .pm-max-w-md { max-width: 640px; } .pm-max-w-lg { max-width: 960px; }

  @media (max-width: 768px) {
    .pm-grid-cards { grid-template-columns: repeat(2, 1fr); }
    .pm-grid-cards-2 { grid-template-columns: 1fr; }
    .pm-grid { grid-template-columns: repeat(6, 1fr); }
    .pm-section { padding-top: var(--pm-space-10); padding-bottom: var(--pm-space-10); }
    .pm-hide-tablet { display: none !important; }
  }
  @media (max-width: 480px) {
    .pm-grid-cards, .pm-grid-cards-2 { grid-template-columns: 1fr; }
    .pm-grid { grid-template-columns: repeat(4, 1fr); gap: var(--pm-space-4); }
    .pm-section { padding-top: var(--pm-space-8); padding-bottom: var(--pm-space-8); }
    .pm-container { padding-left: var(--pm-space-4); padding-right: var(--pm-space-4); }
    .pm-hide-mobile { display: none !important; }
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   LAYER 5 — COMPONENTS (AIHOT-style)
   ═════════════════════════════════════════════════════════════════════════ */
@layer components {

  /* ── AIHOT Feed Layout ── */
  .aihot-feed {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px 60px;
  }

  /* ── AIHOT Hero ── */
  .aihot-hero {
    text-align: center;
    padding: 48px 20px 32px;
    max-width: 720px;
    margin: 0 auto;
  }
  .aihot-hero h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
    color: var(--pm-text-primary);
  }
  .aihot-hero .aihot-tagline {
    font-size: 0.9375rem;
    color: var(--pm-text-muted);
    font-weight: 400;
  }

  /* ── AIHOT Category Tabs ── */
  .aihot-tabs {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 0 20px 24px;
    max-width: 720px;
    margin: 0 auto;
    flex-wrap: wrap;
  }
  .aihot-tab {
    padding: 6px 16px;
    border-radius: var(--pm-radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--pm-text-muted);
    background: transparent;
    cursor: pointer;
    transition: all var(--pm-transition-fast);
    white-space: nowrap;
  }
  .aihot-tab:hover { color: var(--pm-text-secondary); background: var(--pm-surface-overlay); }
  .aihot-tab.active {
    color: var(--pm-text-primary);
    background: var(--pm-surface-container);
    border: var(--pm-border-thin);
    font-weight: 600;
  }
  .aihot-tab-count {
    font-size: 0.6875rem;
    color: var(--pm-text-muted);
    margin-left: 4px;
  }

  /* ── AIHOT Card ── */
  .aihot-card {
    background: var(--pm-surface-container);
    border: var(--pm-border-thin);
    border-radius: var(--pm-radius-lg);
    padding: 20px 24px;
    margin-bottom: 12px;
    transition: all var(--pm-transition-base);
    position: relative;
    overflow: hidden;
  }
  .aihot-card:hover {
    border-color: rgba(108, 140, 255, 0.2);
    box-shadow: var(--pm-shadow-md);
    transform: translateY(-1px);
  }
  .aihot-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(108,140,255,0.04), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
  }
  .aihot-card:hover::after { opacity: 1; }

  /* ── AIHOT Card Header (source + score) ── */
  .aihot-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }
  .aihot-source {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .aihot-avatar {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: linear-gradient(135deg, #6c8cff, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
  }
  .aihot-source-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--pm-text-secondary);
  }
  .aihot-source-name a { color: var(--pm-text-secondary); transition: color var(--pm-transition-fast); }
  .aihot-source-name a:hover { color: var(--pm-accent); }

  /* ── AIHOT Score Badge ── */
  .aihot-score {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 10px;
    border-radius: var(--pm-radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .aihot-score--high {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
  }
  .aihot-score--mid {
    background: rgba(234, 179, 8, 0.12);
    color: #eab308;
  }
  .aihot-score--low {
    background: rgba(148, 163, 184, 0.10);
    color: #94a3b8;
  }

  /* ── AIHOT Card Title ── */
  .aihot-card-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.45;
    color: var(--pm-text-primary);
    margin-bottom: 6px;
    display: block;
    text-decoration: none;
    transition: color var(--pm-transition-fast);
  }
  .aihot-card-title:hover { color: var(--pm-accent); }

  /* ── AIHOT Card Description ── */
  .aihot-card-desc {
    font-size: 0.875rem;
    line-height: 1.65;
    color: var(--pm-text-secondary);
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* ── AIHOT Tag Pills ── */
  .aihot-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
  }
  .aihot-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--pm-radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(108, 140, 255, 0.08);
    color: var(--pm-accent);
    transition: all var(--pm-transition-fast);
  }
  .aihot-tag:hover { background: rgba(108, 140, 255, 0.16); }

  /* Category-specific tag colors */
  .aihot-tag--green { background: rgba(34, 197, 94, 0.08); color: #22c55e; }
  .aihot-tag--amber { background: rgba(234, 179, 8, 0.08); color: #eab308; }
  .aihot-tag--purple { background: rgba(167, 139, 250, 0.08); color: #a78bfa; }
  .aihot-tag--red { background: rgba(239, 68, 68, 0.08); color: #ef4444; }
  .aihot-tag--cyan { background: rgba(56, 189, 248, 0.08); color: #38bdf8; }

  /* ── AIHOT Divider ── */
  .aihot-divider {
    height: 1px;
    background: var(--pm-border-thin);
    margin: 8px 0;
  }

  /* ── AIHOT Recommendation ── */
  .aihot-reco {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--pm-text-muted);
    padding-top: 4px;
  }
  .aihot-reco-label {
    font-weight: 600;
    color: var(--pm-accent);
    margin-right: 4px;
  }

  /* ── AIHOT Footer Meta ── */
  .aihot-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: var(--pm-border-thin);
  }
  .aihot-timestamp {
    font-size: 0.75rem;
    color: var(--pm-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .aihot-discussion {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--pm-text-muted);
    cursor: pointer;
    transition: color var(--pm-transition-fast);
  }
  .aihot-discussion:hover { color: var(--pm-accent); }

  /* ── PM Nav (glassmorphism, sticky) ── */
  .pm-nav {
    position: sticky;
    top: 0;
    z-index: var(--pm-z-sticky);
    height: var(--pm-nav-height);
    display: flex;
    align-items: center;
    background: var(--pm-surface-glass);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: var(--pm-border-thin);
    transition: background var(--pm-transition-base), box-shadow var(--pm-transition-base);
  }
  .pm-nav--scrolled {
    background: var(--pm-surface-glass);
    box-shadow: var(--pm-shadow-md);
  }
  .pm-nav__inner {
    width: 100%;
    max-width: var(--pm-container-max);
    margin: 0 auto;
    padding-left: var(--pm-container-padding);
    padding-right: var(--pm-container-padding);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
  }
  .pm-nav__brand {
    display: flex;
    align-items: center;
    gap: var(--pm-space-2);
    font-size: var(--pm-text-lg);
    font-weight: var(--pm-font-weight-bold);
    color: var(--pm-text-primary);
    white-space: nowrap;
  }
  .pm-nav__brand img { height: 2rem; width: auto; }
  .pm-nav__links { display: flex; align-items: center; gap: var(--pm-space-1); }
  .pm-nav__link {
    padding: 0.375rem 0.75rem;
    border-radius: var(--pm-radius-sm);
    font-size: var(--pm-text-sm);
    font-weight: var(--pm-font-weight-medium);
    color: var(--pm-text-muted);
    transition: color var(--pm-transition-fast), background var(--pm-transition-fast);
    white-space: nowrap;
  }
  .pm-nav__link:hover { color: var(--pm-text-primary); background: var(--pm-surface-overlay); }
  .pm-nav__link--active { color: var(--pm-accent); background: var(--pm-accent-subtle); font-weight: var(--pm-font-weight-semibold); }

  /* ── PM Card ── */
  .pm-card {
    background: var(--pm-surface-container);
    border: var(--pm-border-thin);
    border-radius: var(--pm-radius-lg);
    padding: var(--pm-space-6);
    transition: all var(--pm-transition-base);
    position: relative;
  }
  .pm-card:hover {
    border-color: rgba(108, 140, 255, 0.2);
    box-shadow: var(--pm-shadow-md);
    transform: translateY(-2px);
  }
  .pm-card:active { transform: scale(0.985); transition: transform 0.1s ease; }

  /* ── PM Button ── */
  .pm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--pm-space-2);
    padding: 0.5rem 1.25rem;
    border-radius: var(--pm-radius-sm);
    font-size: var(--pm-text-sm);
    font-weight: var(--pm-font-weight-semibold);
    line-height: 1.5;
    cursor: pointer;
    transition: all var(--pm-transition-fast);
    white-space: nowrap;
    border: 1px solid transparent;
  }
  .pm-btn--primary {
    background: var(--pm-accent);
    color: #fff;
    border-color: var(--pm-accent);
  }
  .pm-btn--primary:hover { background: var(--pm-accent-hover); box-shadow: var(--pm-shadow-glow); }
  .pm-btn--primary:active { background: var(--pm-accent-active); transform: scale(0.97); }
  .pm-btn--secondary {
    background: var(--pm-surface-container);
    color: var(--pm-text-primary);
    border: var(--pm-border-thin);
  }
  .pm-btn--secondary:hover { background: var(--pm-surface-overlay); border-color: var(--pm-border-medium); }
  .pm-btn--outline {
    background: transparent;
    color: var(--pm-accent);
    border: var(--pm-border-accent);
  }
  .pm-btn--outline:hover { background: var(--pm-accent-subtle); }
  .pm-btn--ghost { background: transparent; color: var(--pm-text-secondary); }
  .pm-btn--ghost:hover { background: var(--pm-surface-overlay); color: var(--pm-text-primary); }
  .pm-btn--sm { padding: 0.25rem 0.75rem; font-size: var(--pm-text-xs); }
  .pm-btn--lg { padding: 0.75rem 2rem; font-size: var(--pm-text-base); }
  .pm-btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

  /* ── PM Badge ── */
  .pm-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: var(--pm-radius-full);
    font-size: var(--pm-text-xs);
    font-weight: var(--pm-font-weight-semibold);
    line-height: 1.5;
  }
  .pm-badge--accent { background: var(--pm-accent-subtle); color: var(--pm-accent); }
  .pm-badge--success { background: rgba(34, 197, 94, 0.10); color: var(--pm-success); }
  .pm-badge--warning { background: rgba(234, 179, 8, 0.10); color: var(--pm-warning); }
  .pm-badge--error { background: rgba(239, 68, 68, 0.10); color: var(--pm-error); }
  .pm-badge--info { background: rgba(56, 189, 248, 0.10); color: var(--pm-info); }
}

/* ═════════════════════════════════════════════════════════════════════════
   LAYER 6 — UTILITIES
   ═════════════════════════════════════════════════════════════════════════ */
@layer utilities {
  .pm-text-center { text-align: center; }
  .pm-text-left { text-align: left; }
  .pm-text-right { text-align: right; }
  .pm-text-sm { font-size: var(--pm-text-sm); }
  .pm-text-base { font-size: var(--pm-text-base); }
  .pm-text-lg { font-size: var(--pm-text-lg); }
  .pm-text-muted { color: var(--pm-text-muted); }
  .pm-text-accent { color: var(--pm-accent); }
  .pm-font-bold { font-weight: var(--pm-font-weight-bold); }
  .pm-font-semibold { font-weight: var(--pm-font-weight-semibold); }
  .pm-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pm-hidden { display: none; }
  .pm-block { display: block; }
}

/* ═════════════════════════════════════════════════════════════════════════
   LAYER 7 — POLISH (animations, hover effects, scrollbar)
   ═════════════════════════════════════════════════════════════════════════ */
@layer polish {
  /* Staggered card entry */
  .aihot-feed > .aihot-card {
    animation: aihot-card-in 0.4s ease both;
  }
  .aihot-feed > .aihot-card:nth-child(1) { animation-delay: 0.03s; }
  .aihot-feed > .aihot-card:nth-child(2) { animation-delay: 0.08s; }
  .aihot-feed > .aihot-card:nth-child(3) { animation-delay: 0.13s; }
  .aihot-feed > .aihot-card:nth-child(4) { animation-delay: 0.18s; }
  .aihot-feed > .aihot-card:nth-child(5) { animation-delay: 0.23s; }
  .aihot-feed > .aihot-card:nth-child(6) { animation-delay: 0.28s; }
  @keyframes aihot-card-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Hero animation */
  .aihot-hero {
    animation: aihot-hero-in 0.5s ease both;
  }
  @keyframes aihot-hero-in {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.20); }

  /* Footer */
  footer {
    text-align: center;
    padding: 40px 24px 32px;
    border-top: var(--pm-border-thin);
    color: var(--pm-text-muted);
    font-size: 0.8125rem;
    margin-top: 32px;
  }
  footer p { margin: 4px 0; }
  footer a { color: var(--pm-accent); }
  .icp { font-size: 0.75rem; }
  .icp a { color: var(--pm-text-muted); }

  /* Reduced motion */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   LEGACY COMPATIBILITY — old variable names, card classes, nav classes
   ═════════════════════════════════════════════════════════════════════════ */
@layer compat {
  :root {
    --surface-1: var(--pm-surface-container);
    --surface-2: var(--pm-surface-page);
    --bg: var(--pm-surface-page);
    --bg-card: var(--pm-surface-container);
    --bg-elevated: var(--pm-surface-elevated);
    --bg-nav: var(--pm-surface-glass);
    --bg-soft: var(--pm-surface-overlay);
    --bg-subtle: var(--pm-surface-overlay);
    --bg-surface: var(--pm-surface-container);
    --bg-surface-hover: var(--pm-surface-overlay);
    --text: var(--pm-text-primary);
    --text-1: var(--pm-text-primary);
    --text-2: var(--pm-text-secondary);
    --text-3: var(--pm-text-muted);
    --text-4: var(--pm-text-muted);
    --text-primary: var(--pm-text-primary);
    --text-secondary: var(--pm-text-secondary);
    --text-muted: var(--pm-text-muted);
    --text-faint: var(--pm-text-muted);
    --text-color: var(--pm-text-primary);
    --text-dim: var(--pm-text-secondary);
    --text-soft: var(--pm-text-muted);
    --text2: var(--pm-text-secondary);
    --text3: var(--pm-text-muted);
    --accent: var(--pm-accent);
    --accent-hover: var(--pm-accent-hover);
    --accent-light: var(--pm-accent-subtle);
    --accent-glow: var(--pm-accent-glow);
    --primary: var(--pm-accent);
    --primary-light: var(--pm-accent-subtle);
    --link-blue: var(--pm-accent);
    --border: var(--pm-border-thin);
    --border-1: var(--pm-border-thin);
    --border-2: 1px solid rgba(255,255,255,0.04);
    --border-light: 1px solid rgba(255,255,255,0.04);
    --border-hover: 1px solid rgba(255,255,255,0.15);
    --border-card: var(--pm-border-thin);
    --border-card-hover: 1px solid rgba(108,140,255,0.22);
    --card-shadow: var(--pm-shadow-sm);
    --card-shadow-hover: var(--pm-shadow-md);
    --shadow-hard: var(--pm-shadow-md);
    --shadow-hard-lg: var(--pm-shadow-lg);
    --radius: 0.75rem;
    --radius-lg: 1rem;
  }

  [data-theme="light"] {
    --border-2: 1px solid rgba(0,0,0,0.04);
    --border-light: 1px solid rgba(0,0,0,0.04);
    --border-hover: 1px solid rgba(0,0,0,0.15);
    --border-card-hover: 1px solid rgba(37,99,235,0.22);
  }

  /* Legacy card styles */
  .card {
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
  }
  .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.15), 0 12px 24px rgba(108,140,255,0.15);
    border-color: rgba(108,140,255,0.25);
  }
  .card:active { transform: scale(0.985); transition: transform 0.1s ease; }

  /* Legacy nav */
  .nav-link {
    position: relative;
    transition: color 0.2s, background 0.2s;
  }
  .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 2px;
    background: var(--pm-accent);
    border-radius: 2px;
  }
  .nav-cta, .nav-actions {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, filter 0.2s ease;
  }
  .nav-cta:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 16px rgba(108,140,255,0.3);
    filter: brightness(1.1);
  }
  .nav-cta:active { transform: scale(0.96); }
  .nav-logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.125rem; color: var(--pm-text-primary); flex-shrink: 0; text-decoration: none; }
  .nav-logo img { height: 28px; width: 28px; border-radius: 6px; }
  .nav-cta {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 16px; border-radius: 99px;
    font-size: 0.8125rem; font-weight: 700;
    background: linear-gradient(135deg, #6c8cff, #a78bfa);
    color: #fff; text-decoration: none; flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .nav-cta:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(108,140,255,0.35); }
  .nav-cta:active { transform: scale(0.96); }

  /* Legacy section title */
  .section-title {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--pm-text-primary);
    margin-bottom: 20px;
  }
  .section-title::after {
    content: '';
    height: 1px;
    flex: 1;
    min-width: 40px;
    background: var(--pm-border-thin);
  }

  /* Legacy container */
  .container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
  .content-wrap { padding: 32px 0 48px; }

  /* Legacy analysis card */
  .analysis-card {
    background: var(--pm-surface-container);
    border: var(--pm-border-thin);
    border-radius: var(--pm-radius-lg);
    padding: 24px;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .analysis-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 12px 32px rgba(108,140,255,0.12);
    border-color: rgba(108,140,255,0.2);
  }
  .read-more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--pm-accent);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: gap 0.2s;
  }
  .read-more:hover { gap: 8px; }

  /* Legacy article section */
  .analysis-section {
    background: var(--pm-surface-container);
    border: var(--pm-border-thin);
    border-radius: var(--pm-radius-xl);
    padding: 24px 28px;
    margin-bottom: 36px;
  }
  .date-badge {
    display: inline-block;
    padding: 6px 24px;
    background: linear-gradient(135deg, #6c8cff, #a78bfa);
    border-radius: 20px;
    color: #fff;
    letter-spacing: 1px;
  }

  /* Legacy tags */
  .card-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 15px;
    background: var(--pm-surface-container);
    border: var(--pm-border-thin);
    border-radius: 99px;
    color: var(--pm-accent);
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    margin: 4px;
    transition: all var(--pm-transition-fast);
  }
  .card-link:hover { background: var(--pm-accent-subtle); border-color: rgba(108,140,255,0.25); }

  /* Legacy article card */
  .article-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--pm-surface-container);
    border: var(--pm-border-thin);
    border-radius: var(--pm-radius-md);
    padding: 16px 20px;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 8px 24px rgba(108,140,255,0.10);
    border-color: rgba(108,140,255,0.2);
  }

  /* Legacy news card */
  .news-card {
    background: var(--pm-surface-container);
    border: var(--pm-border-thin);
    border-radius: var(--pm-radius-md);
    padding: 20px 24px;
    margin-bottom: 12px;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .news-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 8px 24px rgba(108,140,255,0.10);
    border-color: rgba(108,140,255,0.18);
  }
  .news-card .category {
    display: inline-block;
    background: var(--pm-accent-subtle);
    color: var(--pm-accent);
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 8px;
  }

  /* Legacy comment */
  .comment-section {
    background: var(--pm-surface-container);
    border: var(--pm-border-thin);
    border-radius: var(--pm-radius-lg);
    padding: 28px 32px;
    margin-top: 24px;
    margin-bottom: 32px;
  }
  .comment-item {
    background: var(--pm-surface-page);
    border-radius: var(--pm-radius-md);
    padding: 16px 20px;
    margin-bottom: 10px;
  }

  /* Legacy mobile fixes */
  @media (max-width: 768px) {
    .container { padding: 0 16px; }
    .analysis-section { padding: 20px; }
    .comment-section { padding: 20px; }
    .news-card { padding: 16px 18px; }
    .article-card { padding: 14px 16px; gap: 12px; }
    .nav-cta { padding: 5px 12px; font-size: 0.75rem; }
  }
  @media (max-width: 480px) {
    .container { padding: 0 12px; }
    .analysis-section { padding: 16px; }
    .comment-section { padding: 16px; }
    .news-card { padding: 14px; }
    .nav-logo img { height: 22px; width: 22px; }
    .nav-logo span { font-size: 0.8125rem; }
    .nav-cta { padding: 4px 10px; font-size: 0.6875rem; }
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   MOBILE OVERFLOW FIX
   ═════════════════════════════════════════════════════════════════════════ */
html, body { overflow-x: hidden; max-width: 100vw; }
table { max-width: 100%; }
@media (max-width: 768px) {
  .stock-table, table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .stock-table th, .stock-table td, table th, table td { white-space: nowrap; min-width: 80px; }
}
pre, code { max-width: 100%; overflow-x: auto; word-wrap: break-word; white-space: pre-wrap; }
@media (max-width: 768px) { pre { font-size: 0.75rem; padding: 12px; } }
nav { flex-shrink: 0; max-width: 100vw; overflow-x: hidden; }
.nav-inner { max-width: 100%; flex-wrap: nowrap; }
img { max-width: 100%; height: auto; }
iframe { max-width: 100%; }
.container { max-width: 100%; overflow-x: hidden; }
.analysis, .deep-dive, .content-wrap { max-width: 100%; overflow-x: hidden; }
input, textarea, select { max-width: 100%; box-sizing: border-box; }
div, section, article, header, footer, main, aside, nav { max-width: 100%; }
.hot-title, .article-card .title, .news-card .title, .fc-title, .tc-title, .aihot-card-title { white-space: normal !important; word-break: break-word; }
@media (max-width: 480px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  .container { padding: 0 8px; }
  .stock-table th, .stock-table td { padding: 6px 8px; font-size: 0.75rem; min-width: 60px; }
}
/* Hamburger hidden by default */
.nav-toggle { display: none !important; }

/* ═════════════════════════════════════════════════════════════════════════
   PHONE PORTRAIT CONTENT GUARDRAILS
   Applies to generated articles, forum posts, courses, search, and lists.
   ═════════════════════════════════════════════════════════════════════════ */
img, svg, canvas, video, iframe, embed, object {
  max-width: 100%;
  box-sizing: border-box;
}
video, iframe, embed, object {
  display: block;
}
.article-content,
.post-content,
.content,
.content-wrap,
.article-body,
.analysis-content,
.rich-content,
.markdown-body {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.article-content table,
.post-content table,
.content table,
.content-wrap table,
.article-body table,
.markdown-body table,
.table-wrap table {
  max-width: 100%;
}
.table-wrap,
.chart,
.chart-box,
.chart-card,
.bar-chart,
.pie-chart,
.map-wrap,
.mermaid,
.video-wrapper,
.preview,
.c-video-frame {
  max-width: 100%;
  box-sizing: border-box;
}
.video-wrapper,
.c-video-frame {
  overflow: hidden;
}

@media (max-width: 600px) and (orientation: portrait) {
  body {
    min-width: 0;
    overflow-x: hidden;
  }
  main,
  article,
  section,
  .container,
  .wrap,
  .post-container,
  .article-container,
  .content-wrap,
  .article-body,
  .post-content {
    max-width: 100vw !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }
  .container,
  .wrap,
  .post-container,
  .article-container {
    padding-left: max(10px, env(safe-area-inset-left)) !important;
    padding-right: max(10px, env(safe-area-inset-right)) !important;
  }
  h1, h2, h3, h4, p, li, td, th, a, span {
    overflow-wrap: anywhere;
  }
  table,
  .article-content table,
  .post-content table,
  .content table,
  .article-body table,
  .markdown-body table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  th, td {
    white-space: normal;
    min-width: 72px;
  }
  pre, code {
    white-space: pre-wrap !important;
    word-break: break-word !important;
  }
  .bar-chart,
  .pie-chart,
  .chart,
  .chart-box,
  .chart-card,
  .map-wrap,
  .mermaid,
  .preview {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  iframe,
  embed,
  object {
    width: 100% !important;
  }
  audio,
  video {
    width: 100% !important;
  }
  input,
  textarea,
  select,
  button {
    max-width: 100%;
  }
}
