/* Resource Hub — unified glass theme */
:root {
  --bg: #e8ecf4;
  --bg-base: #e8ecf4;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --white: #ffffff;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --accent-glow: rgba(99, 102, 241, 0.22);
  --nav-bg: rgba(15, 23, 42, 0.82);
  --card: rgba(255, 255, 255, 0.68);
  --card-strong: rgba(255, 255, 255, 0.82);
  --border: rgba(255, 255, 255, 0.55);
  --border-subtle: rgba(15, 23, 42, 0.07);
  --glass-blur: blur(18px) saturate(165%);
  --shadow-sm: 0 4px 20px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 56px rgba(15, 23, 42, 0.1);
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --topbar-h: 56px;
  --danger: #dc2626;
  --article-base: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg-base);
  background-image:
    radial-gradient(ellipse 80% 60% at 12% 8%, rgba(99, 102, 241, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 55% at 88% 12%, rgba(236, 72, 153, 0.1), transparent 50%),
    radial-gradient(ellipse 60% 50% at 72% 88%, rgba(16, 185, 129, 0.1), transparent 55%),
    radial-gradient(ellipse 50% 40% at 20% 75%, rgba(139, 92, 246, 0.08), transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* ===== Topbar (glass) ===== */
.topbar {
  min-height: var(--topbar-h);
  padding: 0 clamp(12px, 3vw, 28px);
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--nav-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 200;
  flex-wrap: nowrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(248, 250, 252, 0.92);
  text-decoration: none;
  transition: opacity 160ms ease;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 42%;
}

a.brand:hover {
  opacity: 0.88;
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a5b4fc, #f9fafb);
  box-shadow: 0 0 10px rgba(165, 180, 252, 0.6);
  flex-shrink: 0;
}

.brand strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  padding: 2px 0;
}

.nav-actions::-webkit-scrollbar {
  display: none;
}

.nav-link {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(248, 250, 252, 0.95);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
}

.nav-link--active {
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: currentColor;
}

.login-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

/* ===== Layout ===== */
.wrap {
  width: min(1160px, 92vw);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 36px) 0 clamp(48px, 6vw, 72px);
}

.header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-top: 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 960px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Typography ===== */
h1 {
  margin: 0;
  font-size: clamp(28px, 3.8vw, 44px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.025em;
  color: var(--text);
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
  max-width: 62ch;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.pill::before {
  content: "";
  width: 40px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-pink), var(--accent-2));
  flex-shrink: 0;
}

.pill-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--accent-2);
}

/* ===== Glass cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 2.5vw, 22px);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.75);
  transition: box-shadow 200ms ease, transform 200ms ease, border-color 200ms ease;
}

.card:hover {
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.72);
}

/* ===== Markdown / content blocks ===== */
.md h2 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

.md h2:first-child {
  margin-top: 0;
}

.md p,
.md li {
  color: var(--muted);
  line-height: 1.8;
  font-size: 14px;
}

.md p {
  margin: 0 0 10px;
}

.md ul,
.md ol {
  margin: 0 0 10px;
  padding-left: 20px;
  color: var(--text-secondary);
}

.md li {
  margin: 6px 0;
}

.md a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: rgba(99, 102, 241, 0.35);
  text-underline-offset: 3px;
  transition: color 160ms ease;
}

.md a:hover {
  color: var(--accent);
  text-decoration-color: rgba(99, 102, 241, 0.55);
}

.md code {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 6px;
  padding: 2px 7px;
  color: #4338ca;
  font-size: 12px;
  font-weight: 600;
}

.md small {
  color: var(--muted);
  font-size: 12px;
}

/* ===== Tags & pills row ===== */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

/* ===== Buttons ===== */
.btn {
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #f8fafc;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
  border-color: rgba(255, 255, 255, 0.08);
}

.btn-ghost {
  background: var(--card-strong);
  color: var(--text);
  border-color: var(--border);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-sm);
}

.small-btn {
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.65);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 140ms ease;
}

.small-btn:hover {
  background: rgba(255, 255, 255, 0.9);
}

/* ===== Topic / list items (glass) ===== */
.topic-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.topic-item {
  display: block;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.45);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.topic-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: rgba(255, 255, 255, 0.72);
}

.topic-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--text);
}

.topic-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.65;
}

.post-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.post-item {
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.42);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.post-item:hover {
  background: rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow-sm);
}

.post-item--active {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.95));
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
}

.post-title {
  margin: 0 0 5px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.post-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.post-item--active .post-title {
  color: #f8fafc;
}

.post-item--active .post-desc {
  color: rgba(248, 250, 252, 0.75);
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(8px);
  transition: background 160ms ease;
}

.back:hover {
  background: rgba(255, 255, 255, 0.85);
}

/* ===== Delta / section helpers ===== */
.section-lead {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid rgba(99, 102, 241, 0.14);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.75;
  backdrop-filter: blur(8px);
}

.nav-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

@media (max-width: 640px) {
  .nav-cards {
    grid-template-columns: 1fr;
  }
}

.nav-card {
  display: block;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.48);
  border-radius: var(--radius-md);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.nav-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: rgba(255, 255, 255, 0.72);
}

.nav-card-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.nav-card-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.compare-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0 16px;
  font-size: 13px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px);
}

.compare-table th,
.compare-table td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.compare-table tr:last-child td,
.compare-table tr:last-child th {
  border-bottom: none;
}

.compare-table th {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text);
  font-weight: 800;
}

.compare-table td {
  color: var(--muted);
}

/* ===== Search inputs (shared) ===== */
.search-input,
.gun-input {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  outline: none;
  backdrop-filter: blur(8px);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-input:focus,
.gun-input:focus {
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.search-input::placeholder,
.gun-input::placeholder {
  color: #94a3b8;
}

/* ===== Mobile & touch ===== */
body {
  overflow-x: hidden;
}

@media (max-width: 768px) {
  :root {
    --topbar-h: 52px;
  }

  .wrap {
    width: min(1160px, 94vw);
    padding: 20px 0 40px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  h1 {
    font-size: clamp(24px, 7vw, 36px);
  }

  .subtitle {
    font-size: 14px;
    max-width: none;
  }

  .pill {
    flex-wrap: wrap;
  }

  .pill::before {
    width: 28px;
  }

  .card {
    padding: 14px 16px;
  }

  .card:hover {
    transform: none;
  }

  .topic-item:hover,
  .nav-card:hover,
  .post-item:hover {
    transform: none;
  }

  .btn:hover {
    transform: none;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .actions .btn {
    width: 100%;
  }

  .compare-table {
    font-size: 12px;
    min-width: 100%;
  }

  .card.md,
  .note-main .card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 520px) {
  :root {
    --topbar-h: 48px;
  }

  .topbar {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    gap: 8px;
  }

  .brand {
    max-width: 36%;
    gap: 8px;
  }

  .brand strong {
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  .nav-actions {
    gap: 4px;
  }

  .nav-link {
    padding: 7px 10px;
    font-size: 11px;
    gap: 5px;
    min-height: 36px;
  }

  /* 有图标的导航：小屏仅显示图标，避免顶栏换行错位 */
  .nav-link:has(.nav-icon) {
    font-size: 0;
    padding: 8px;
    min-width: 38px;
    min-height: 38px;
    justify-content: center;
  }

  .nav-link:has(.nav-icon) .nav-icon {
    width: 18px;
    height: 18px;
  }

  .nav-link--active:has(.nav-icon) {
    color: #0f172a;
  }

  .tag-row {
    gap: 6px;
  }

  .tag {
    padding: 5px 10px;
    font-size: 10px;
  }

  .back {
    width: 100%;
    justify-content: center;
  }

  .article-nav,
  .font-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-row {
    grid-template-columns: 1fr !important;
  }

  .gun-toolbar {
    grid-template-columns: 1fr !important;
  }

  .gun-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (hover: none) and (pointer: coarse) {
  .card:hover,
  .topic-item:hover,
  .nav-card:hover,
  .post-item:hover,
  .btn:hover {
    transform: none;
  }
}
