:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --panel: #fff;
  --soft: #eeeef1;
  --text: #27272d;
  --muted: #8b96ab;
  --line: #dddde2;
  --brand: #f24f6b;
}

.dark {
  color-scheme: dark;
  --bg: #1c1c1f;
  --panel: #27272a;
  --soft: #202023;
  --text: #d7d8df;
  --muted: #96a2b8;
  --line: #36363b;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "Noto Sans SC", system-ui, sans-serif;
  transition: color .2s, background-color .2s;
}
a { color: inherit; text-decoration: none; }
.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(16px);
}
.header-inner {
  display: flex;
  width: min(1280px, calc(100% - 32px));
  height: 100%;
  align-items: center;
  justify-content: space-between;
  margin: auto;
}
.brand, .top-nav { display: flex; align-items: center; }
.brand { gap: 10px; font-size: 16px; }
.brand img { width: 28px; height: 28px; }
.top-nav { gap: 14px; font-size: 14px; }
.about-link {
  padding: 4px 12px;
  border: 1px solid rgba(139, 92, 246, .38);
  border-radius: 999px;
  background: rgba(139, 92, 246, .08);
}
.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
}
.moon, .dark .sun { display: none; }
.dark .moon { display: inline; }
.portal-home {
  width: min(1240px, calc(100% - 32px));
  min-height: calc(100vh - 130px);
  margin: auto;
  padding: 10px 0 48px;
}
.category-nav {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow-x: auto;
}
.category-nav a {
  flex: 0 0 auto;
  padding: 5px 13px;
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  opacity: .66;
}
.category-nav a:hover, .category-nav a.active { color: var(--brand); opacity: 1; }
.category-nav a.active { font-weight: 650; }
.ai-banner {
  display: flex;
  width: min(620px, 100%);
  min-height: 78px;
  align-items: center;
  margin: 8px auto 30px;
  padding: 13px 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .08);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.ai-banner:hover { transform: translateY(-2px); border-color: rgba(130, 85, 237, .42); box-shadow: 0 22px 48px rgba(0, 0, 0, .12); }
.ai-banner:focus-visible { outline: 3px solid rgba(130, 85, 237, .25); outline-offset: 3px; }
.ai-avatar {
  position: relative;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
}
.ai-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.ai-avatar span {
  position: absolute;
  top: -5px;
  right: -6px;
  padding: 3px 5px;
  border-radius: 8px;
  color: white;
  background: #8255ed;
  font-size: 9px;
}
.ai-banner .ai-avatar {
  width: 58px;
  height: 58px;
  flex-basis: 58px;
}
.ai-copy { display: grid; gap: 4px; margin-left: 14px; }
.ai-copy strong { font-size: 16px; font-weight: 500; }
.ai-copy small { color: var(--muted); font-size: 14px; }
.ai-spark { margin-left: auto; color: var(--muted); font-size: 23px; }
.chat-open { overflow: hidden; }
.chat-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(12, 12, 16, .26);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .18s;
}
.chat-backdrop[hidden] { display: none; }
.chat-backdrop.visible { opacity: 1; }
.chat-dialog {
  display: grid;
  width: min(680px, 100%);
  height: min(720px, calc(100vh - 48px));
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .28);
  transform: translateY(10px) scale(.98);
  transition: transform .18s;
}
.chat-backdrop.visible .chat-dialog { transform: translateY(0) scale(1); }
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.chat-header .ai-avatar {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
}
.chat-header > div:nth-child(2) { display: grid; gap: 3px; }
.chat-header strong { font-size: 15px; }
.chat-header small { color: var(--muted); font-size: 12px; }
.chat-close {
  width: 34px;
  height: 34px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--soft);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
}
.chat-messages {
  overflow-y: auto;
  padding: 22px 20px;
  overscroll-behavior: contain;
}
.chat-message { display: flex; margin-bottom: 15px; }
.chat-message.user { justify-content: flex-end; }
.chat-bubble {
  max-width: min(82%, 520px);
  padding: 11px 14px;
  border-radius: 6px 18px 18px;
  background: var(--soft);
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.chat-message.user .chat-bubble {
  border-radius: 18px 6px 18px 18px;
  color: white;
  background: #7651dd;
}
.chat-bubble a { color: #7651dd; text-decoration: underline; text-underline-offset: 3px; }
.dark .chat-bubble a { color: #bca7ff; }
.chat-bubble.error { color: #d33f57; }
.chat-suggestions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 18px 12px;
}
.chat-suggestions button {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}
.chat-suggestions button:hover { color: #7651dd; border-color: #7651dd; }
.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 16px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--bg);
}
.chat-composer:focus-within { border-color: rgba(118, 81, 221, .65); box-shadow: 0 0 0 3px rgba(118, 81, 221, .1); }
.chat-composer textarea {
  width: 100%;
  min-height: 38px;
  max-height: 120px;
  resize: none;
  padding: 8px 9px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
}
.chat-composer button {
  height: 38px;
  flex: 0 0 auto;
  padding: 0 17px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: #7651dd;
  font-weight: 650;
  cursor: pointer;
}
.chat-composer button:disabled { cursor: wait; opacity: .6; }
.chat-disclaimer { margin: 8px 0 12px; color: var(--muted); font-size: 11px; text-align: center; }
.article-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  padding-top: 24px;
}
.visual-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .1);
  transition: transform .18s, box-shadow .18s;
}
.visual-card:hover { transform: translateY(-4px); box-shadow: 0 18px 34px rgba(0,0,0,.18); }
.cover-link { display: block; height: 160px; overflow: hidden; background: var(--soft); }
.cover-link img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.visual-card:hover img { transform: scale(1.05); }
.cover-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, #5961d9, #8e61b9);
  font-size: 64px;
  font-weight: 800;
}
.visual-card-body { display: flex; min-height: 174px; flex: 1; flex-direction: column; padding: 20px 24px; }
.card-title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.visual-card-meta { display: flex; justify-content: space-between; margin-top: auto; padding-top: 16px; color: var(--muted); font-size: 14px; }
.visual-card-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.meta-date { font-family: ui-monospace, monospace; }
.meta-date i { width: 12px; height: 12px; border: 1.5px solid currentColor; border-radius: 2px; }
.meta-views i { width: 14px; height: 9px; border: 1.5px solid currentColor; border-radius: 50%; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 34px; }
.pagination a, .pagination span { padding: 8px 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); font-size: 13px; }
.pagination .disabled { pointer-events: none; opacity: .38; }
.category-title { margin: 16px 0 0; font-size: 24px; }
.empty-posts { padding: 100px 0; color: var(--muted); text-align: center; }
.article-page {
  width: min(1240px, calc(100% - 32px));
  min-height: calc(100vh - 130px);
  margin: auto;
  padding: 34px 0 80px;
}
.back-link {
  display: inline-flex;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}
.back-link:hover { color: var(--text); }
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 48px;
  align-items: start;
}
.article-main { min-width: 0; }
.article-hero {
  position: relative;
  display: flex;
  min-height: 330px;
  align-items: flex-end;
  overflow: hidden;
  border-radius: 12px;
  background: #2d2d34;
  isolation: isolate;
}
.article-hero.no-cover {
  background:
    radial-gradient(circle at 78% 18%, rgba(153, 108, 255, .5), transparent 36%),
    linear-gradient(135deg, #30384d, #17181d 68%);
}
.article-hero-image {
  position: absolute;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.article-hero-shade {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 10, 14, .12) 12%, rgba(10, 10, 14, .78) 100%);
}
.article-hero-content { width: 100%; padding: 38px 42px; color: #fff; }
.article-hero h1 {
  max-width: 760px;
  margin: 10px 0 16px;
  font-size: clamp(30px, 4.2vw, 48px);
  line-height: 1.18;
  letter-spacing: -.035em;
  text-wrap: balance;
}
.article-categories { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.article-categories a {
  padding: 4px 9px;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  backdrop-filter: blur(8px);
}
.article-meta { display: flex; flex-wrap: wrap; gap: 10px 20px; color: rgba(255, 255, 255, .78); font-size: 14px; }
.article-tools { display: flex; gap: 10px; padding: 18px 0 2px; }
.article-tool-button {
  display: inline-flex;
  height: 42px;
  align-items: center;
  gap: 7px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.article-tool-button:hover { border-color: rgba(118, 81, 221, .55); color: #7651dd; }
.tool-chevron { color: var(--muted); transition: transform .18s; }
.article-tool-button[aria-expanded="true"] .tool-chevron { transform: rotate(180deg); }
.article-summary {
  margin-top: 14px;
  padding: 18px 20px;
  border: 1px solid rgba(118, 81, 221, .2);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 82%, #7651dd 4%);
}
.article-summary strong { font-size: 14px; }
.article-summary p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.75; }
.article-content {
  padding-top: 34px;
  font-size: 17px;
  line-height: 1.95;
  overflow-wrap: anywhere;
}
.article-content h1,
.article-content h2,
.article-content h3 {
  scroll-margin-top: 90px;
  line-height: 1.35;
  letter-spacing: -.02em;
}
.article-content h1,
.article-content h2 { margin: 2.2em 0 .8em; font-size: 32px; }
.article-content h3 { margin: 1.8em 0 .7em; font-size: 23px; }
.article-content p { margin: 1.15em 0; }
.article-content a { color: #3287d4; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.article-content img { display: block; max-width: 100%; height: auto; margin: 28px auto; border-radius: 12px; }
.article-content pre { overflow: auto; padding: 18px; border-radius: 10px; background: #151518; color: #e8e8eb; }
.article-content blockquote { margin: 1.5em 0; padding: 2px 0 2px 18px; border-left: 4px solid var(--brand); color: var(--muted); }
.article-comments {
  margin-top: 52px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.article-comments-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.article-comments-header span {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.article-comments-header small {
  color: var(--muted);
  font-size: 13px;
}
.article-comments halo-comment,
.article-comments .halo-comment,
.article-comments comment-widget {
  display: block;
}
.article-toc { position: sticky; top: 92px; max-height: calc(100vh - 120px); overflow: auto; }
.toc-panel { padding: 4px 0 4px 24px; border-left: 1px solid var(--line); }
.toc-panel > strong { display: block; margin-bottom: 14px; font-size: 16px; }
#article-toc-list { display: grid; gap: 2px; }
.toc-link {
  position: relative;
  display: block;
  padding: 7px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  transition: color .18s;
}
.toc-link.level-3 { padding-left: 14px; font-size: 13px; }
.toc-link::before {
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: -25px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  content: "";
}
.toc-link:hover, .toc-link.active { color: var(--text); }
.toc-link.active::before { background: #4ca5ff; }
.site-footer { display: flex; width: min(1240px, calc(100% - 32px)); justify-content: space-between; margin: auto; padding: 22px 0 30px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
@media (max-width: 959px) {
  .article-grid { grid-template-columns: repeat(2, 1fr); }
  .article-layout { grid-template-columns: 1fr; }
  .article-toc { display: none; }
}
@media (max-width: 640px) {
  .brand strong { display: none; }
  .top-nav { gap: 8px; }
  .category-nav { justify-content: flex-start; }
  .category-nav a { padding: 5px 10px; font-size: 14px; }
  .article-grid { grid-template-columns: 1fr; padding-top: 12px; }
  .cover-link { height: 240px; }
  .article-page { width: min(100% - 24px, 760px); padding-top: 18px; }
  .article-hero { min-height: 280px; border-radius: 10px; }
  .article-hero-content { padding: 26px 22px; }
  .article-hero h1 { font-size: 30px; }
  .article-meta { font-size: 12px; }
  .article-content { padding-top: 24px; font-size: 16px; line-height: 1.85; }
  .article-content h1,
  .article-content h2 { font-size: 27px; }
  .article-content h3 { font-size: 21px; }
  .ai-copy strong { font-size: 14px; }
  .chat-backdrop { padding: 0; }
  .chat-dialog {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .chat-messages { padding: 18px 14px; }
  .chat-bubble { max-width: 88%; }
  .chat-composer { margin: 0 10px; }
}
